]> git.ozlabs.org Git - petitboot/blob - lib/url/url.h
lib/log: Switch to pb_log_fn
[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 <arpa/inet.h>
23 #include <stdbool.h>
24
25 /**
26  * enum pb_url_scheme - Enumeration of the URL schemes we can handle.
27  */
28
29 enum pb_url_scheme {
30         pb_url_unknown = 0,
31         pb_url_file,
32         pb_url_ftp,
33         pb_url_http,
34         pb_url_https,
35         pb_url_nfs,
36         pb_url_sftp,
37         pb_url_tftp,
38 };
39
40 /**
41  * struct pb_url - Parsed URL info.
42  * @scheme: The enum pb_url_scheme for this URL.
43  * @full: The full URL = scheme://host:port/path.
44  * @host: The host part of URL.
45  * @port: The port part of URL.
46  * @path: The path part of URL.
47  * @dir: The dir part of path.
48  * @file: The file part of path.
49  *
50  * For info on URL syntax see:
51  *  http://www.ietf.org/rfc/rfc3986.txt
52  */
53
54 struct pb_url {
55         enum pb_url_scheme scheme;
56         char *full;
57         char *host;
58         char *port;
59         char *path;
60         char *dir;
61         char *file;
62 };
63
64 bool is_url(const char *str);
65 int addr_scheme(const char *address);
66 struct pb_url *pb_url_parse(void *ctx, const char *url_str);
67 struct pb_url *pb_url_copy(void *ctx, const struct pb_url *url);
68 struct pb_url *pb_url_join(void *ctx, const struct pb_url *url, const char *s);
69 char *pb_url_to_string(struct pb_url *url);
70
71 const char *pb_url_scheme_name(enum pb_url_scheme scheme);
72
73 #endif