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 ******************************************************************************/
29 * Default rewrite context
31 #define REWRITE_DEFAULT_CONTEXT "default"
34 * Rewrite engine states
36 #define REWRITE_OFF 0x0000
37 #define REWRITE_ON 0x0001
38 #define REWRITE_DEFAULT REWRITE_OFF
41 * Rewrite internal status returns
43 #define REWRITE_SUCCESS LDAP_SUCCESS
44 #define REWRITE_ERR LDAP_OPERATIONS_ERROR
45 #define REWRITE_NO_SUCH_OBJECT LDAP_NO_SUCH_OBJECT
48 * Rewrite modes (input values for rewrite_info_init); determine the
49 * behavior in case a null or non existent context is required:
51 * REWRITE_MODE_ERR error
52 * REWRITE_MODE_OK no error but no rewrite
53 * REWRITE_MODE_COPY_INPUT a copy of the input is returned
54 * REWRITE_MODE_USE_DEFAULT the default context is used.
56 #define REWRITE_MODE_ERR 0x0010
57 #define REWRITE_MODE_OK 0x0011
58 #define REWRITE_MODE_COPY_INPUT 0x0012
59 #define REWRITE_MODE_USE_DEFAULT 0x0013
62 * Rewrite status returns
64 * REWRITE_REGEXEC_OK success (result may be empty in case
66 * REWRITE_REGEXEC_ERR error (internal error,
67 * misconfiguration, map not working ...)
68 * REWRITE_REGEXEC_STOP internal use; never returned
69 * REWRITE_REGEXEC_UNWILLING the server should issue an 'unwilling
72 #define REWRITE_REGEXEC_OK 0x0000
73 #define REWRITE_REGEXEC_ERR 0x0001
74 #define REWRITE_REGEXEC_STOP 0x0002
75 #define REWRITE_REGEXEC_UNWILLING 0x0003
76 #define REWRITE_REGEXEC_USER 0x0004 /* and above ... */
79 * Rewrite variable flags
80 * REWRITE_VAR_INSERT insert mode (default) when adding
81 * a variable; if not set during value
82 * update, the variable is not inserted
84 * REWRITE_VAR_UPDATE update mode (default) when updating
85 * a variable; if not set during insert,
86 * the value is not updated if the
87 * variable already exists
88 * REWRITE_VAR_COPY_NAME copy the variable name; if not set,
89 * the name is not copied; be sure the
90 * referenced string is available for
91 * the entire life scope of the variable.
92 * REWRITE_VAR_COPY_VALUE copy the variable value; if not set,
93 * the value is not copied; be sure the
94 * referenced string is available for
95 * the entire life scope of the variable.
97 #define REWRITE_VAR_NONE 0x0000
98 #define REWRITE_VAR_INSERT 0x0001
99 #define REWRITE_VAR_UPDATE 0x0002
100 #define REWRITE_VAR_COPY_NAME 0x0004
101 #define REWRITE_VAR_COPY_VALUE 0x0008
108 struct berval; /* avoid include */
115 LDAP_REWRITE_F (struct rewrite_info *)
121 * Cleans up the info structure
125 struct rewrite_info **info
130 * Parses a config line and takes actions to fit content in rewrite structure;
131 * lines handled are of the form:
133 * rewriteEngine {on|off}
134 * rewriteMaxPasses numPasses
135 * rewriteContext contextName [alias aliasedRewriteContex]
136 * rewriteRule pattern substPattern [ruleFlags]
137 * rewriteMap mapType mapName [mapArgs]
138 * rewriteParam paramName paramValue
142 struct rewrite_info *info,
150 * process a config file that was already opened. Uses rewrite_parse.
155 struct rewrite_info *info
159 * Rewrites a string according to context.
160 * If the engine is off, OK is returned, but the return string will be NULL.
161 * In case of 'unwilling to perform', UNWILLING is returned, and the
162 * return string will also be null. The same in case of error.
163 * Otherwise, OK is returned, and result will hold a newly allocated string
164 * with the rewriting.
166 * What to do in case of non-existing rewrite context is still an issue.
167 * Four possibilities:
169 * - ok with NULL result,
170 * - ok with copy of string as result,
171 * - use the default rewrite context.
175 struct rewrite_info *info,
176 const char *rewriteContext,
182 * Same as above; the cookie relates the rewrite to a session
186 struct rewrite_info *info,
187 const char *rewriteContext,
196 LDAP_REWRITE_F (struct rewrite_session *)
197 rewrite_session_init(
198 struct rewrite_info *info,
203 * Defines and inits a variable with session scope
206 rewrite_session_var_set_f(
207 struct rewrite_info *info,
214 #define rewrite_session_var_set(info, cookie, name, value) \
215 rewrite_session_var_set_f((info), (cookie), (name), (value), \
216 REWRITE_VAR_INSERT|REWRITE_VAR_UPDATE|REWRITE_VAR_COPY_NAME|REWRITE_VAR_COPY_VALUE)
222 rewrite_session_delete(
223 struct rewrite_info *info,
233 * Defines and inits a variable with global scope
237 struct rewrite_info *info,
243 * Gets a var with global scope
247 struct rewrite_info *info,
253 * Destroys the parameter tree
256 rewrite_param_destroy(
257 struct rewrite_info *info
262 #endif /* REWRITE_H */