| 1 |
/* Configuration Manager for libwww |
| 2 |
* CONFIGURATION MANAGER |
| 3 |
* |
| 4 |
* Author Tim Berners-Lee/CERN. Public domain. Please mail changes to |
| 5 |
* [email protected]. |
| 6 |
* |
| 7 |
* The configuration information loaded includes tables (file suffixes, |
| 8 |
* presentation methods) in other modules. The most likely routines needed by |
| 9 |
* developers will be: |
| 10 |
* |
| 11 |
* HTSetConfiguration to load configuration information. |
| 12 |
* |
| 13 |
* HTLoadRules to load a whole file of configuration information |
| 14 |
* |
| 15 |
* HTTranslate to translate a URL using the rule table. |
| 16 |
* |
| 17 |
*/ |
| 18 |
#ifndef HTRULE_H |
| 19 |
#define HTRULE_H |
| 20 |
|
| 21 |
#ifndef HTUTILS_H |
| 22 |
#include <HTUtils.h> |
| 23 |
#endif |
| 24 |
|
| 25 |
#ifdef __cplusplus |
| 26 |
extern "C" { |
| 27 |
#endif |
| 28 |
typedef enum { |
| 29 |
HT_Invalid, |
| 30 |
HT_Map, |
| 31 |
HT_Pass, |
| 32 |
HT_Fail, |
| 33 |
HT_DefProt, |
| 34 |
HT_Protect, |
| 35 |
HT_Progress, |
| 36 |
HT_InfoMsg, |
| 37 |
HT_UserMsg, |
| 38 |
HT_Alert, |
| 39 |
HT_AlwaysAlert, |
| 40 |
HT_Redirect, |
| 41 |
HT_RedirectPerm, |
| 42 |
HT_PermitRedir, |
| 43 |
HT_UseProxy |
| 44 |
} HTRuleOp; |
| 45 |
|
| 46 |
#ifndef NO_RULES |
| 47 |
|
| 48 |
/* |
| 49 |
|
| 50 |
Server Side Script Execution |
| 51 |
|
| 52 |
If a URL starts with /htbin/ it is understood to mean a script execution request on |
| 53 |
server. This feature needs to be turned on by setting HTBinDir by the htbin rule. |
| 54 |
Index searching is enabled by setting HTSearchScript into the name of script in BinDir |
| 55 |
doing the actual search by search rule (BinDir must also be set in this case, of |
| 56 |
course). |
| 57 |
|
| 58 |
*/ |
| 59 |
|
| 60 |
extern char *HTBinDir; /* Physical /htbin location */ |
| 61 |
extern char *HTSearchScript; /* Search script name */ |
| 62 |
|
| 63 |
/* |
| 64 |
|
| 65 |
HTAddRule: Add rule to the list |
| 66 |
|
| 67 |
ON ENTRY, |
| 68 |
|
| 69 |
pattern points to 0-terminated string containing a single "*" |
| 70 |
|
| 71 |
equiv points to the equivalent string with * for the place where the |
| 72 |
text matched by * goes; or to other 2nd parameter |
| 73 |
meaning depends on op). |
| 74 |
|
| 75 |
cond_op, additional condition for applying rule; cond_op should |
| 76 |
cond be either NULL (no additional condition), or one of |
| 77 |
the strings "if" or "unless"; if cond_op is not NULL, |
| 78 |
cond should point to a recognized condition keyword |
| 79 |
(as a string) such as "userspec", "redirected". |
| 80 |
|
| 81 |
ON EXIT, |
| 82 |
|
| 83 |
returns 0 if success, -1 if error. |
| 84 |
|
| 85 |
Note that if BYTE_ADDRESSING is set, the three blocks required are allocated and |
| 86 |
deallocated as one. This will save time and storage, when malloc's allocation units are |
| 87 |
large. |
| 88 |
|
| 89 |
*/ |
| 90 |
extern int HTAddRule(HTRuleOp op, const char *pattern, |
| 91 |
const char *equiv, |
| 92 |
const char *cond_op, |
| 93 |
const char *cond); |
| 94 |
|
| 95 |
/* |
| 96 |
|
| 97 |
HTClearRules: Clear all rules |
| 98 |
|
| 99 |
ON EXIT, |
| 100 |
|
| 101 |
Rule file There are no rules |
| 102 |
|
| 103 |
*/ |
| 104 |
|
| 105 |
extern void HTClearRules(void); |
| 106 |
|
| 107 |
/* |
| 108 |
|
| 109 |
HTTranslate: Translate by rules |
| 110 |
|
| 111 |
*/ |
| 112 |
|
| 113 |
/* |
| 114 |
|
| 115 |
ON ENTRY, |
| 116 |
|
| 117 |
required points to a string whose equivalent value is needed |
| 118 |
|
| 119 |
ON EXIT, |
| 120 |
|
| 121 |
returns the address of the equivalent string allocated from the heap |
| 122 |
which the CALLER MUST FREE. If no translation occurred, then it is |
| 123 |
a copy of the original. |
| 124 |
|
| 125 |
*/ |
| 126 |
extern char *HTTranslate(const char *required); |
| 127 |
|
| 128 |
/* |
| 129 |
|
| 130 |
HTSetConfiguration: Load one line of configuration information |
| 131 |
|
| 132 |
ON ENTRY, |
| 133 |
|
| 134 |
config is a string in the syntax of a rule file line. |
| 135 |
|
| 136 |
This routine may be used for loading configuration information from sources other than |
| 137 |
the rule file, for example INI files for X resources. |
| 138 |
|
| 139 |
*/ |
| 140 |
extern int HTSetConfiguration(char *config); |
| 141 |
|
| 142 |
/* |
| 143 |
|
| 144 |
HtLoadRules: Load the rules from a file |
| 145 |
|
| 146 |
ON ENTRY, |
| 147 |
|
| 148 |
Rule table Rules can be in any state |
| 149 |
|
| 150 |
ON EXIT, |
| 151 |
|
| 152 |
Rule table Any existing rules will have been kept. Any new rules will have |
| 153 |
been loaded on top, so as to be tried first. |
| 154 |
|
| 155 |
Returns 0 if no error. |
| 156 |
|
| 157 |
*/ |
| 158 |
|
| 159 |
extern int HTLoadRules(const char *filename); |
| 160 |
|
| 161 |
/* |
| 162 |
|
| 163 |
*/ |
| 164 |
|
| 165 |
#endif /* NO_RULES */ |
| 166 |
#ifdef __cplusplus |
| 167 |
} |
| 168 |
#endif |
| 169 |
#endif /* HTRULE_H */ |