3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2004 The OpenLDAP Foundation.
6 * Portions Copyright 2000-2003 Pierangelo Masarati.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Pierangelo Masarati for
19 * inclusion in OpenLDAP Software.
26 * Default rewrite context
28 #define REWRITE_DEFAULT_CONTEXT "default"
31 * Rewrite engine states
33 #define REWRITE_OFF 0x0000
34 #define REWRITE_ON 0x0001
35 #define REWRITE_DEFAULT REWRITE_OFF
38 * Rewrite internal status returns
40 #define REWRITE_SUCCESS LDAP_SUCCESS
41 #define REWRITE_ERR LDAP_OPERATIONS_ERROR
42 #define REWRITE_NO_SUCH_OBJECT LDAP_NO_SUCH_OBJECT
45 * Rewrite modes (input values for rewrite_info_init); determine the
46 * behavior in case a null or non existent context is required:
48 * REWRITE_MODE_ERR error
49 * REWRITE_MODE_OK no error but no rewrite
50 * REWRITE_MODE_COPY_INPUT a copy of the input is returned
51 * REWRITE_MODE_USE_DEFAULT the default context is used.
53 #define REWRITE_MODE_ERR 0x0010
54 #define REWRITE_MODE_OK 0x0011
55 #define REWRITE_MODE_COPY_INPUT 0x0012
56 #define REWRITE_MODE_USE_DEFAULT 0x0013
59 * Rewrite status returns
61 * REWRITE_REGEXEC_OK success (result may be empty in case
63 * REWRITE_REGEXEC_ERR error (internal error,
64 * misconfiguration, map not working ...)
65 * REWRITE_REGEXEC_STOP internal use; never returned
66 * REWRITE_REGEXEC_UNWILLING the server should issue an 'unwilling
69 #define REWRITE_REGEXEC_OK 0x0000
70 #define REWRITE_REGEXEC_ERR 0x0001
71 #define REWRITE_REGEXEC_STOP 0x0002
72 #define REWRITE_REGEXEC_UNWILLING 0x0003
73 #define REWRITE_REGEXEC_USER 0x0004 /* and above ... */
76 * Rewrite variable flags
77 * REWRITE_VAR_INSERT insert mode (default) when adding
78 * a variable; if not set during value
79 * update, the variable is not inserted
81 * REWRITE_VAR_UPDATE update mode (default) when updating
82 * a variable; if not set during insert,
83 * the value is not updated if the
84 * variable already exists
85 * REWRITE_VAR_COPY_NAME copy the variable name; if not set,
86 * the name is not copied; be sure the
87 * referenced string is available for
88 * the entire life scope of the variable.
89 * REWRITE_VAR_COPY_VALUE copy the variable value; if not set,
90 * the value is not copied; be sure the
91 * referenced string is available for
92 * the entire life scope of the variable.
94 #define REWRITE_VAR_NONE 0x0000
95 #define REWRITE_VAR_INSERT 0x0001
96 #define REWRITE_VAR_UPDATE 0x0002
97 #define REWRITE_VAR_COPY_NAME 0x0004
98 #define REWRITE_VAR_COPY_VALUE 0x0008
105 struct berval; /* avoid include */
112 LDAP_REWRITE_F (struct rewrite_info *)
118 * Cleans up the info structure
122 struct rewrite_info **info
127 * Parses a config line and takes actions to fit content in rewrite structure;
128 * lines handled are of the form:
130 * rewriteEngine {on|off}
131 * rewriteMaxPasses numPasses
132 * rewriteContext contextName [alias aliasedRewriteContex]
133 * rewriteRule pattern substPattern [ruleFlags]
134 * rewriteMap mapType mapName [mapArgs]
135 * rewriteParam paramName paramValue
139 struct rewrite_info *info,
147 * process a config file that was already opened. Uses rewrite_parse.
152 struct rewrite_info *info
156 * Rewrites a string according to context.
157 * If the engine is off, OK is returned, but the return string will be NULL.
158 * In case of 'unwilling to perform', UNWILLING is returned, and the
159 * return string will also be null. The same in case of error.
160 * Otherwise, OK is returned, and result will hold a newly allocated string
161 * with the rewriting.
163 * What to do in case of non-existing rewrite context is still an issue.
164 * Four possibilities:
166 * - ok with NULL result,
167 * - ok with copy of string as result,
168 * - use the default rewrite context.
172 struct rewrite_info *info,
173 const char *rewriteContext,
179 * Same as above; the cookie relates the rewrite to a session
183 struct rewrite_info *info,
184 const char *rewriteContext,
193 LDAP_REWRITE_F (struct rewrite_session *)
194 rewrite_session_init(
195 struct rewrite_info *info,
200 * Defines and inits a variable with session scope
203 rewrite_session_var_set_f(
204 struct rewrite_info *info,
211 #define rewrite_session_var_set(info, cookie, name, value) \
212 rewrite_session_var_set_f((info), (cookie), (name), (value), \
213 REWRITE_VAR_INSERT|REWRITE_VAR_UPDATE|REWRITE_VAR_COPY_NAME|REWRITE_VAR_COPY_VALUE)
219 rewrite_session_delete(
220 struct rewrite_info *info,
230 * Defines and inits a variable with global scope
234 struct rewrite_info *info,
240 * Gets a var with global scope
244 struct rewrite_info *info,
250 * Destroys the parameter tree
253 rewrite_param_destroy(
254 struct rewrite_info *info
259 #endif /* REWRITE_H */