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