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