1 /******************************************************************************
3 * Copyright (C) 2000 Pierangelo Masarati, <ando@sys-net.it>
6 * Permission is granted to anyone to use this software for any purpose
7 * on any computer system, and to alter it and redistribute it, subject
8 * to the following restrictions:
10 * 1. The author is not responsible for the consequences of use of this
11 * software, no matter how awful, even if they arise from flaws in it.
13 * 2. The origin of this software must not be misrepresented, either by
14 * explicit claim or by omission. Since few users ever read sources,
15 * credits should appear in the documentation.
17 * 3. Altered versions must be plainly marked as such, and must not be
18 * misrepresented as being the original software. Since few users
19 * ever read sources, credits should appear in the documentation.
21 * 4. This notice may not be removed or altered.
23 ******************************************************************************/
31 * Default rewrite context
33 #define REWRITE_DEFAULT_CONTEXT "default"
36 * Rewrite engine states
38 #define REWRITE_OFF 0x0000
39 #define REWRITE_ON 0x0001
40 #define REWRITE_DEFAULT REWRITE_OFF
43 * Rewrite internal status returns
45 #define REWRITE_SUCCESS LDAP_SUCCESS
46 #define REWRITE_ERR LDAP_OPERATIONS_ERROR
47 #define REWRITE_NO_SUCH_OBJECT LDAP_NO_SUCH_OBJECT
50 * Rewrite modes (input values for rewrite_info_init); determine the
51 * behavior in case a null or non existent context is required:
53 * REWRITE_MODE_ERR error
54 * REWRITE_MODE_OK no error but no rewrite
55 * REWRITE_MODE_COPY_INPUT a copy of the input is returned
56 * REWRITE_MODE_USE_DEFAULT the default context is used.
58 #define REWRITE_MODE_ERR 0x0010
59 #define REWRITE_MODE_OK 0x0011
60 #define REWRITE_MODE_COPY_INPUT 0x0012
61 #define REWRITE_MODE_USE_DEFAULT 0x0013
64 * Rewrite status returns
66 * REWRITE_REGEXEC_OK success (result may be empty in case
68 * REWRITE_REGEXEC_ERR error (internal error,
69 * misconfiguration, map not working ...)
70 * REWRITE_REGEXEC_STOP internal use; never returned
71 * REWRITE_REGEXEC_UNWILLING the server should issue an 'unwilling
74 #define REWRITE_REGEXEC_OK 0x0000
75 #define REWRITE_REGEXEC_ERR 0x0001
76 #define REWRITE_REGEXEC_STOP 0x0002
77 #define REWRITE_REGEXEC_UNWILLING 0x0004
84 struct berval; /* avoid include */
89 extern struct rewrite_info *
95 * Cleans up the info structure
99 struct rewrite_info *info
104 * Parses a config line and takes actions to fit content in rewrite structure;
105 * lines handled are of the form:
107 * rewriteEngine {on|off}
108 * rewriteMaxPasses numPasses
109 * rewriteContext contextName [alias aliasedRewriteContex]
110 * rewriteRule pattern substPattern [ruleFlags]
111 * rewriteMap mapType mapName [mapArgs]
112 * rewriteParam paramName paramValue
116 struct rewrite_info *info,
124 * Rewrites a string according to context.
125 * If the engine is off, OK is returned, but the return string will be NULL.
126 * In case of 'unwilling to perform', UNWILLING is returned, and the
127 * return string will also be null. The same in case of error.
128 * Otherwise, OK is returned, and result will hold a newly allocated string
129 * with the rewriting.
131 * What to do in case of non-existing rewrite context is still an issue.
132 * Four possibilities:
134 * - ok with NULL result,
135 * - ok with copy of string as result,
136 * - use the default rewrite context.
140 struct rewrite_info *info,
141 const char *rewriteContext,
147 * Same as above; the cookie relates the rewrite to a session
151 struct rewrite_info *info,
152 const char *rewriteContext,
161 extern struct rewrite_session *
162 rewrite_session_init(
163 struct rewrite_info *info,
168 * Defines and inits a variable with session scope
171 rewrite_session_var_set(
172 struct rewrite_info *info,
182 rewrite_session_delete(
183 struct rewrite_info *info,
193 * Defines and inits a variable with global scope
197 struct rewrite_info *info,
203 * Gets a var with global scope
207 struct rewrite_info *info,
213 * Destroys the parameter tree
216 rewrite_param_destroy(
217 struct rewrite_info *info
222 #endif /* REWRITE_H */