]> git.ozlabs.org Git - petitboot/blob - lib/url/url.h
discover: Add reference to url in load_url_result
[petitboot] / lib / url / url.h
1 /*
2  *  Copyright (C) 2009 Sony Computer Entertainment Inc.
3  *  Copyright 2009 Sony Corp.
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; version 2 of the License.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #if !defined(_PB_URL_PARSER_H)
20 #define _PB_URL_PARSER_H
21
22 #include <stdbool.h>
23
24 /**
25  * enum pb_url_scheme - Enumeration of the URL schemes we can handle.
26  */
27
28 enum pb_url_scheme {
29         pb_url_unknown = 0,
30         pb_url_file,
31         pb_url_ftp,
32         pb_url_http,
33         pb_url_https,
34         pb_url_nfs,
35         pb_url_sftp,
36         pb_url_tftp,
37 };
38
39 /**
40  * struct pb_url - Parsed URL info.
41  * @scheme: The enum pb_url_scheme for this URL.
42  * @full: The full URL = scheme://host:port/path.
43  * @host: The host part of URL.
44  * @port: The port part of URL.
45  * @path: The path part of URL.
46  * @dir: The dir part of path.
47  * @file: The file part of path.
48  *
49  * For info on URL syntax see:
50  *  http://www.ietf.org/rfc/rfc3986.txt
51  */
52
53 struct pb_url {
54         enum pb_url_scheme scheme;
55         char *full;
56         char *host;
57         char *port;
58         char *path;
59         char *dir;
60         char *file;
61 };
62
63 bool is_url(const char *str);
64 struct pb_url *pb_url_parse(void *ctx, const char *url_str);
65 struct pb_url *pb_url_copy(void *ctx, const struct pb_url *url);
66 struct pb_url *pb_url_join(void *ctx, const struct pb_url *url, const char *s);
67 char *pb_url_to_string(struct pb_url *url);
68
69 const char *pb_url_scheme_name(enum pb_url_scheme scheme);
70
71 #endif