summaryrefslogtreecommitdiffstats
path: root/WWW/Library/Implementation/HTRules.h
blob: 9bb859311c9f4686309a52d99e5c1e6dfba3e19d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*                                             Configuration Manager for libwww
 *                            CONFIGURATION MANAGER
 *
 * Author Tim Berners-Lee/CERN.  Public domain.  Please mail changes to
 * timbl@info.cern.ch.
 *
 * The configuration information loaded includes tables (file suffixes,
 * presentation methods) in other modules.  The most likely routines needed by
 * developers will be:
 *
 * HTSetConfiguration	to load configuration information.
 *
 * HTLoadRules		to load a whole file of configuration information
 *
 * HTTranslate		to translate a URL using the rule table.
 *
 */
#ifndef HTRULE_H
#define HTRULE_H

#ifndef HTUTILS_H
#include <HTUtils.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif
    typedef enum {
	HT_Invalid,
	HT_Map,
	HT_Pass,
	HT_Fail,
	HT_DefProt,
	HT_Protect,
	HT_Progress,
	HT_InfoMsg,
	HT_UserMsg,
	HT_Alert,
	HT_AlwaysAlert,
	HT_Redirect,
	HT_RedirectPerm,
	HT_PermitRedir,
	HT_UseProxy
    } HTRuleOp;

#ifndef NO_RULES

/*

Server Side Script Execution

   If a URL starts with /htbin/ it is understood to mean a script execution request on
   server.  This feature needs to be turned on by setting HTBinDir by the htbin rule.
   Index searching is enabled by setting HTSearchScript into the name of script in BinDir
   doing the actual search by search rule (BinDir must also be set in this case, of
   course).

 */

    extern char *HTBinDir;	/* Physical /htbin location */
    extern char *HTSearchScript;	/* Search script name */

/*

HTAddRule:  Add rule to the list

  ON ENTRY,

  pattern                points to 0-terminated string containing a single "*"

  equiv                  points to the equivalent string with * for the place where the
                         text matched by * goes; or to other 2nd parameter
                         meaning depends on op).			 

  cond_op,               additional condition for applying rule; cond_op should
  cond                   be either NULL (no additional condition), or one of
                         the strings "if" or "unless"; if cond_op is not NULL,
                         cond should point to a recognized condition keyword
                         (as a string) such as "userspec", "redirected".

  ON EXIT,

  returns                0 if success, -1 if error.

   Note that if BYTE_ADDRESSING is set, the three blocks required are allocated and
   deallocated as one.  This will save time and storage, when malloc's allocation units are
   large.

 */
    extern int HTAddRule(HTRuleOp op, const char *pattern,
			 const char *equiv,
			 const char *cond_op,
			 const char *cond);

/*

HTClearRules: Clear all rules

  ON EXIT,

  Rule file               There are no rules

 */

    extern void HTClearRules(void);

/*

HTTranslate: Translate by rules

 */

/*

  ON ENTRY,

  required                points to a string whose equivalent value is needed

  ON EXIT,

  returns                 the address of the equivalent string allocated from the heap
                         which the CALLER MUST FREE. If no translation occurred, then it is
                         a copy of the original.

 */
    extern char *HTTranslate(const char *required);

/*

HTSetConfiguration:  Load one line of configuration information

  ON ENTRY,

  config                  is a string in the syntax of a rule file line.

   This routine may be used for loading configuration information from sources other than
   the  rule file, for example INI files for X resources.

 */
    extern int HTSetConfiguration(char *config);

/*

HtLoadRules:  Load the rules from a file

  ON ENTRY,

  Rule table              Rules can be in any state

  ON EXIT,

  Rule table              Any existing rules will have been kept.  Any new rules will have
                         been loaded on top, so as to be tried first.

  Returns                 0 if no error.

 */

    extern int HTLoadRules(const char *filename);

/*

 */

#endif				/* NO_RULES */
#ifdef __cplusplus
}
#endif
#endif				/* HTRULE_H */