]> mj.ucw.cz Git - libucw.git/blob - lib/url.h
Removed few by now obsolete assertions.
[libucw.git] / lib / url.h
1 /*
2  *      Sherlock Library -- URL Functions
3  *
4  *      (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
5  */
6
7 #define MAX_URL_SIZE 1024
8
9 /* Non-control meanings of control characters */
10
11 #define NCC_SEMICOLON 1
12 #define NCC_SLASH 2
13 #define NCC_QUEST 3
14 #define NCC_COLON 4
15 #define NCC_AT 5
16 #define NCC_EQUAL 6
17 #define NCC_AND 7
18 #define NCC_HASH 8
19 #define NCC_MAX 9
20
21 #define NCC_CHARS " ;/?:@=&#"
22
23 /* Remove/Introduce '%' escapes */
24
25 int url_deescape(byte *, byte *);
26 int url_enescape(byte *, byte *);
27
28 /* URL splitting and normalization */
29
30 struct url {
31   byte *protocol;
32   uns protoid;
33   byte *user;
34   byte *host;
35   uns port;                             /* ~0 if unspec */
36   byte *rest;
37   byte *buf, *bufend;
38 };
39
40 int url_split(byte *, struct url *, byte *);
41 int url_normalize(struct url *, struct url *);
42 int url_canonicalize(struct url *);
43 int url_pack(struct url *, byte *);
44 int url_canon_split(byte *, byte *, byte *, struct url *);
45 uns identify_protocol(byte *);
46
47 /* Error codes */
48
49 char *url_error(uns);
50
51 #define URL_ERR_TOO_LONG 1
52 #define URL_ERR_INVALID_CHAR 2
53 #define URL_ERR_INVALID_ESCAPE 3
54 #define URL_ERR_INVALID_ESCAPED_CHAR 4
55 #define URL_ERR_INVALID_PORT 5
56 #define URL_ERR_REL_NOTHING 6
57 #define URL_ERR_UNKNOWN_PROTOCOL 7
58 #define URL_SYNTAX_ERROR 8
59 #define URL_PATH_UNDERFLOW 9
60
61 #define URL_PROTO_UNKNOWN 0
62 #define URL_PROTO_HTTP 1
63 #define URL_PROTO_FTP 2
64 #define URL_PROTO_FILE 3
65 #define URL_PROTO_MAX 4
66
67 #define URL_PNAMES { "unknown", "http", "ftp", "file" }
68 #define URL_DEFPORTS { ~0, 80, 21, 0 }
69 #define URL_PATH_FLAGS { 0, 1, 1, 1 }
70
71 extern byte *url_proto_names[];