1
/* HTParse: URL parsing in the WWW Library
4
** This module of the WWW library contains code to parse URLs and various
6
** Implemented by HTParse.c .
16
** The following are flag bits which may be ORed together to form
17
** a number to give the 'wanted' argument to HTParse.
19
#define PARSE_ACCESS 16
22
#define PARSE_ANCHOR 2
23
#define PARSE_PUNCTUATION 1
26
#define PARSE_ALL_WITHOUT_ANCHOR (PARSE_ALL ^ PARSE_ANCHOR)
29
** Additional flag bits for more details on components already
30
** covered by the above. The PARSE_PATH above doesn't really
31
** strictly refer to the path component in the sense of the URI
32
** specs only, but rather to that combined with a possible query
35
#define PARSE_STRICTPATH 32
36
#define PARSE_QUERY 64
39
** The following are valid mask values. The terms are the BNF names
40
** in the URL document.
42
#define URL_XALPHAS UCH(1)
43
#define URL_XPALPHAS UCH(2)
44
#define URL_PATH UCH(4)
47
/* Strip white space off a string. HTStrip()
48
** -------------------------------
51
** Return value points to first non-white character, or to 0 if none.
52
** All trailing white space is OVERWRITTEN with zero.
54
extern char * HTStrip PARAMS((
57
/* Parse a Name relative to another name. HTParse()
58
** --------------------------------------
60
** This returns those parts of a name which are given (and requested)
61
** substituting bits from the related name where necessary.
64
** aName A filename given
65
** relatedName A name relative to which aName is to be parsed
66
** wanted A mask for the bits which are wanted.
69
** returns A pointer to a malloc'd string which MUST BE FREED
71
extern char * HTParse PARAMS((
73
CONST char * relatedName,
76
/* HTParseAnchor(), fast HTParse() specialization
77
** ----------------------------------------------
80
** returns A pointer within input string (probably to its end '\0')
82
extern CONST char * HTParseAnchor PARAMS((
85
/* Simplify a filename. HTSimplify()
86
** --------------------
88
** A unix-style file is allowed to contain the seqeunce xxx/../ which may
89
** be replaced by "" , and the seqeunce "/./" which may be replaced by "/".
90
** Simplification helps us recognize duplicate filenames.
92
** Thus, /etc/junk/../fred becomes /etc/fred
93
** /etc/junk/./fred becomes /etc/junk/fred
95
** but we should NOT change
96
** http://fred.xxx.edu/../..
98
** or ../../albert.html
100
extern void HTSimplify PARAMS((
103
/* Make Relative Name. HTRelative()
104
** -------------------
106
** This function creates and returns a string which gives an expression of
107
** one address as related to another. Where there is no relation, an absolute
108
** address is retured.
111
** Both names must be absolute, fully qualified names of nodes
115
** The return result points to a newly allocated name which, if
116
** parsed by HTParse relative to relatedName, will yield aName.
117
** The caller is responsible for freeing the resulting name later.
120
extern char * HTRelative PARAMS((
122
CONST char * relatedName));
124
/* Escape undesirable characters using % HTEscape()
125
** -------------------------------------
127
** This function takes a pointer to a string in which
128
** some characters may be unacceptable are unescaped.
129
** It returns a string which has these characters
130
** represented by a '%' character followed by two hex digits.
132
** Unlike HTUnEscape(), this routine returns a malloc'd string.
134
extern char * HTEscape PARAMS((
136
unsigned char mask));
138
/* Escape unsafe characters using % HTEscapeUnsafe()
139
** --------------------------------
141
** This function takes a pointer to a string in which
142
** some characters may be that may be unsafe are unescaped.
143
** It returns a string which has these characters
144
** represented by a '%' character followed by two hex digits.
146
** Unlike HTUnEscape(), this routine returns a malloc'd string.
148
extern char * HTEscapeUnsafe PARAMS((
151
/* Escape undesirable characters using % but space to +. HTEscapeSP()
152
** -----------------------------------------------------
154
** This function takes a pointer to a string in which
155
** some characters may be unacceptable are unescaped.
156
** It returns a string which has these characters
157
** represented by a '%' character followed by two hex digits,
158
** except that spaces are converted to '+' instead of %2B.
160
** Unlike HTUnEscape(), this routine returns a malloc'd string.
162
extern char * HTEscapeSP PARAMS((
164
unsigned char mask));
166
/* Decode %xx escaped characters. HTUnEscape()
167
** ------------------------------
169
** This function takes a pointer to a string in which some
170
** characters may have been encoded in %xy form, where xy is
171
** the acsii hex code for character 16x+y.
172
** The string is converted in place, as it will never grow.
174
extern char * HTUnEscape PARAMS((
177
/* Decode some %xx escaped characters. HTUnEscapeSome()
178
** ----------------------------------- Klaus Weide
179
** (kweide@tezcat.com)
180
** This function takes a pointer to a string in which some
181
** characters may have been encoded in %xy form, where xy is
182
** the acsii hex code for character 16x+y, and a pointer to
183
** a second string containing one or more characters which
184
** should be unescaped if escaped in the first string.
185
** The first string is converted in place, as it will never grow.
187
extern char * HTUnEscapeSome PARAMS((
189
CONST char * do_trans));
192
** Turn a string which is not a RFC 822 token into a quoted-string. - KW
194
extern void HTMake822Word PARAMS((
198
#endif /* HTPARSE_H */