summaryrefslogtreecommitdiffstats
path: root/lib/url/url.h
blob: 25e1ad8175b9681935c5c53ee5a932638d1531d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 *  Copyright (C) 2009 Sony Computer Entertainment Inc.
 *  Copyright 2009 Sony Corp.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#if !defined(_PB_URL_PARSER_H)
#define _PB_URL_PARSER_H

#include <stdbool.h>

/**
 * enum pb_url_scheme - Enumeration of the URL schemes we can handle.
 */

enum pb_url_scheme {
	pb_url_unknown = 0,
	pb_url_file,
	pb_url_ftp,
	pb_url_http,
	pb_url_https,
	pb_url_nfs,
	pb_url_sftp,
	pb_url_tftp,
};

/**
 * struct pb_url - Parsed URL info.
 * @scheme: The enum pb_url_scheme for this URL.
 * @full: The full URL = scheme://host:port/path.
 * @host: The host part of URL.
 * @port: The port part of URL.
 * @path: The path part of URL.
 * @dir: The dir part of path.
 * @file: The file part of path.
 *
 * For info on URL syntax see:
 *  http://www.ietf.org/rfc/rfc3986.txt
 */

struct pb_url {
	enum pb_url_scheme scheme;
	char *full;
	char *host;
	char *port;
	char *path;
	char *dir;
	char *file;
};

bool is_url(const char *str);
struct pb_url *pb_url_parse(void *ctx, const char *url_str);
struct pb_url *pb_url_join(void *ctx, const struct pb_url *url, const char *s);
char *pb_url_to_string(struct pb_url *url);

const char *pb_url_scheme_name(enum pb_url_scheme scheme);

#endif
OpenPOWER on IntegriCloud