2 * UCW Library -- URL Functions
4 * (c) 1997--2004 Martin Mares <mj@ucw.cz>
5 * (c) 2001 Robert Spalek <robert@ucw.cz>
7 * This software may be freely distributed and used according to the terms
8 * of the GNU Lesser General Public License.
14 #define MAX_URL_SIZE 1024
16 /* Non-control meanings of control characters */
27 // Avoid 9 (\t) and 10 (\n)
35 #define NCC_CHARS " ;/?:@=&#\t\n$+\r,"
37 /* Remove/Introduce '%' escapes */
39 int url_deescape(const char *s, char *d);
40 int url_enescape(const char *s, char *d);
41 int url_enescape_friendly(const char *src, char *dest);
43 /* URL splitting and normalization */
51 uns port; /* ~0 if unspec */
56 int url_split(char *s, struct url *u, char *d);
57 int url_normalize(struct url *u, struct url *b);
58 int url_canonicalize(struct url *u);
59 int url_pack(struct url *u, char *d);
60 int url_canon_split_rel(const char *url, char *buf1, char *buf2, struct url *u, struct url *base);
61 int url_auto_canonicalize_rel(const char *src, char *dst, struct url *base);
62 uns url_identify_protocol(const char *p);
63 int url_has_repeated_component(const char *url);
65 static inline int url_canon_split(const char *url, char *buf1, char *buf2, struct url *u)
66 { return url_canon_split_rel(url, buf1, buf2, u, NULL); }
68 static inline int url_auto_canonicalize(const char *src, char *dst)
69 { return url_auto_canonicalize_rel(src, dst, NULL); }
75 #define URL_ERR_TOO_LONG 1
76 #define URL_ERR_INVALID_CHAR 2
77 #define URL_ERR_INVALID_ESCAPE 3
78 #define URL_ERR_INVALID_ESCAPED_CHAR 4
79 #define URL_ERR_INVALID_PORT 5
80 #define URL_ERR_REL_NOTHING 6
81 #define URL_ERR_UNKNOWN_PROTOCOL 7
82 #define URL_SYNTAX_ERROR 8
83 #define URL_PATH_UNDERFLOW 9
85 #define URL_PROTO_UNKNOWN 0
86 #define URL_PROTO_HTTP 1
87 #define URL_PROTO_FTP 2
88 #define URL_PROTO_FILE 3
89 #define URL_PROTO_MAX 4
91 #define URL_PNAMES { "unknown", "http", "ftp", "file" }
92 #define URL_DEFPORTS { ~0, 80, 21, 0 }
93 #define URL_PATH_FLAGS { 0, 1, 1, 1 }
95 extern char *url_proto_names[];