~ubuntu-branches/ubuntu/edgy/lynx/edgy

« back to all changes in this revision

Viewing changes to WWW/Library/Implementation/HTParse.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-09-16 12:14:10 UTC
  • Revision ID: james.westby@ubuntu.com-20040916121410-cz1gu92c4nqfeyrg
Tags: upstream-2.8.5
ImportĀ upstreamĀ versionĀ 2.8.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*                                   HTParse:  URL parsing in the WWW Library
 
2
**                              HTPARSE
 
3
**
 
4
**  This module of the WWW library contains code to parse URLs and various
 
5
**  related things.
 
6
**  Implemented by HTParse.c .
 
7
*/
 
8
#ifndef HTPARSE_H
 
9
#define HTPARSE_H
 
10
 
 
11
#ifndef HTUTILS_H
 
12
#include <HTUtils.h>
 
13
#endif
 
14
 
 
15
/*
 
16
**  The following are flag bits which may be ORed together to form
 
17
**  a number to give the 'wanted' argument to HTParse.
 
18
*/
 
19
#define PARSE_ACCESS            16
 
20
#define PARSE_HOST               8
 
21
#define PARSE_PATH               4
 
22
#define PARSE_ANCHOR             2
 
23
#define PARSE_PUNCTUATION        1
 
24
 
 
25
#define PARSE_ALL               31
 
26
#define PARSE_ALL_WITHOUT_ANCHOR  (PARSE_ALL ^ PARSE_ANCHOR)
 
27
 
 
28
/*
 
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
 
33
**  component. - kw
 
34
*/
 
35
#define PARSE_STRICTPATH        32
 
36
#define PARSE_QUERY             64
 
37
 
 
38
/*
 
39
**  The following are valid mask values.  The terms are the BNF names
 
40
**  in the URL document.
 
41
*/
 
42
#define URL_XALPHAS     UCH(1)
 
43
#define URL_XPALPHAS    UCH(2)
 
44
#define URL_PATH        UCH(4)
 
45
 
 
46
 
 
47
/*      Strip white space off a string.                         HTStrip()
 
48
**      -------------------------------
 
49
**
 
50
** On exit,
 
51
**      Return value points to first non-white character, or to 0 if none.
 
52
**      All trailing white space is OVERWRITTEN with zero.
 
53
*/
 
54
extern char * HTStrip PARAMS((
 
55
        char *          s));
 
56
 
 
57
/*      Parse a Name relative to another name.                  HTParse()
 
58
**      --------------------------------------
 
59
**
 
60
**      This returns those parts of a name which are given (and requested)
 
61
**      substituting bits from the related name where necessary.
 
62
**
 
63
** On entry,
 
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.
 
67
**
 
68
** On exit,
 
69
**      returns         A pointer to a malloc'd string which MUST BE FREED
 
70
*/
 
71
extern char * HTParse PARAMS((
 
72
        CONST char *    aName,
 
73
        CONST char *    relatedName,
 
74
        int             wanted));
 
75
 
 
76
/*      HTParseAnchor(), fast HTParse() specialization
 
77
**      ----------------------------------------------
 
78
**
 
79
** On exit,
 
80
**      returns         A pointer within input string (probably to its end '\0')
 
81
*/
 
82
extern CONST char * HTParseAnchor PARAMS((
 
83
        CONST char *    aName));
 
84
 
 
85
/*      Simplify a filename.                            HTSimplify()
 
86
**      --------------------
 
87
**
 
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.
 
91
**
 
92
**      Thus,   /etc/junk/../fred       becomes /etc/fred
 
93
**              /etc/junk/./fred        becomes /etc/junk/fred
 
94
**
 
95
**      but we should NOT change
 
96
**              http://fred.xxx.edu/../..
 
97
**
 
98
**      or      ../../albert.html
 
99
*/
 
100
extern void HTSimplify PARAMS((
 
101
        char *          filename));
 
102
 
 
103
/*      Make Relative Name.                                     HTRelative()
 
104
**      -------------------
 
105
**
 
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.
 
109
**
 
110
**  On entry,
 
111
**      Both names must be absolute, fully qualified names of nodes
 
112
**      (no anchor bits)
 
113
**
 
114
**  On exit,
 
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.
 
118
**
 
119
*/
 
120
extern char * HTRelative PARAMS((
 
121
        CONST char *    aName,
 
122
        CONST char *    relatedName));
 
123
 
 
124
/*              Escape undesirable characters using %           HTEscape()
 
125
**              -------------------------------------
 
126
**
 
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.
 
131
**
 
132
**      Unlike HTUnEscape(), this routine returns a malloc'd string.
 
133
*/
 
134
extern char * HTEscape PARAMS((
 
135
        CONST char *    str,
 
136
        unsigned char   mask));
 
137
 
 
138
/*              Escape unsafe characters using %                HTEscapeUnsafe()
 
139
**              --------------------------------
 
140
**
 
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.
 
145
**
 
146
**      Unlike HTUnEscape(), this routine returns a malloc'd string.
 
147
*/
 
148
extern char * HTEscapeUnsafe PARAMS((
 
149
        CONST char *    str));
 
150
 
 
151
/*      Escape undesirable characters using % but space to +.   HTEscapeSP()
 
152
**      -----------------------------------------------------
 
153
**
 
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.
 
159
**
 
160
**      Unlike HTUnEscape(), this routine returns a malloc'd string.
 
161
*/
 
162
extern char * HTEscapeSP PARAMS((
 
163
        CONST char *    str,
 
164
        unsigned char   mask));
 
165
 
 
166
/*      Decode %xx escaped characters.                          HTUnEscape()
 
167
**      ------------------------------
 
168
**
 
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.
 
173
*/
 
174
extern char * HTUnEscape PARAMS((
 
175
        char *          str));
 
176
 
 
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.
 
186
*/
 
187
extern char * HTUnEscapeSome PARAMS((
 
188
        char *          str,
 
189
        CONST char *    do_trans));
 
190
 
 
191
/*
 
192
**  Turn a string which is not a RFC 822 token into a quoted-string. - KW
 
193
*/
 
194
extern void HTMake822Word PARAMS((
 
195
        char **         str,
 
196
        int             quoted));
 
197
 
 
198
#endif  /* HTPARSE_H */