X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibrewrite%2Frewrite-int.h;h=ca8873b06af622c219e893e0d8774ea8fc74773f;hb=1f635b8bcfaaac666005a88a5620e9798c9565e1;hp=85358b72fc6fde99f50f8a6d747448b1d3519e6e;hpb=cddeab8513e951f21b5fe845df1cbac3730d023d;p=openldap diff --git a/libraries/librewrite/rewrite-int.h b/libraries/librewrite/rewrite-int.h index 85358b72fc..ca8873b06a 100644 --- a/libraries/librewrite/rewrite-int.h +++ b/libraries/librewrite/rewrite-int.h @@ -1,26 +1,21 @@ -/****************************************************************************** +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . * - * Copyright (C) 2000 Pierangelo Masarati, + * Copyright 2000-2007 The OpenLDAP Foundation. * All rights reserved. * - * Permission is granted to anyone to use this software for any purpose - * on any computer system, and to alter it and redistribute it, subject - * to the following restrictions: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. * - * 1. The author is not responsible for the consequences of use of this - * software, no matter how awful, even if they arise from flaws in it. - * - * 2. The origin of this software must not be misrepresented, either by - * explicit claim or by omission. Since few users ever read sources, - * credits should appear in the documentation. - * - * 3. Altered versions must be plainly marked as such, and must not be - * misrepresented as being the original software. Since few users - * ever read sources, credits should appear in the documentation. - * - * 4. This notice may not be removed or altered. - * - ******************************************************************************/ + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ +/* ACKNOWLEDGEMENT: + * This work was initially developed by Pierangelo Masarati for + * inclusion in OpenLDAP Software. + */ #ifndef REWRITE_INT_H #define REWRITE_INT_H @@ -39,7 +34,7 @@ #include #include #include "../libldap/ldap-int.h" - +#include #include #include @@ -60,7 +55,10 @@ */ /* the '\' conflicts with slapd.conf parsing */ /* #define REWRITE_SUBMATCH_ESCAPE '\\' */ -#define REWRITE_SUBMATCH_ESCAPE '%' +#define REWRITE_SUBMATCH_ESCAPE_ORIG '%' +#define REWRITE_SUBMATCH_ESCAPE '$' +#define IS_REWRITE_SUBMATCH_ESCAPE(c) \ + ((c) == REWRITE_SUBMATCH_ESCAPE || (c) == REWRITE_SUBMATCH_ESCAPE_ORIG) /* * REGEX flags @@ -76,6 +74,8 @@ #define REWRITE_FLAG_STOP '@' #define REWRITE_FLAG_UNWILLING '#' #define REWRITE_FLAG_GOTO 'G' /* requires an arg */ +#define REWRITE_FLAG_USER 'U' /* requires an arg */ +#define REWRITE_FLAG_MAX_PASSES 'M' /* requires an arg */ #define REWRITE_FLAG_IGNORE_ERR 'I' /* @@ -102,6 +102,7 @@ struct rewrite_action { #define REWRITE_ACTION_UNWILLING 0x0002 #define REWRITE_ACTION_GOTO 0x0003 #define REWRITE_ACTION_IGNORE_ERR 0x0004 +#define REWRITE_ACTION_USER 0x0005 int la_type; void *la_args; }; @@ -156,10 +157,11 @@ struct rewrite_map { * Builtin maps */ struct rewrite_builtin_map { -#define REWRITE_BUILTIN_MAP_LDAP 0x0201 +#define REWRITE_BUILTIN_MAP 0x0200 int lb_type; char *lb_name; void *lb_private; + const rewrite_mapper *lb_mapper; #ifdef USE_REWRITE_LDAP_PVT_THREADS ldap_pvt_thread_mutex_t lb_mutex; @@ -205,7 +207,7 @@ struct rewrite_rule { char *lr_pattern; char *lr_subststring; char *lr_flagstring; - regex_t lr_regex; + regex_t lr_regex; /* * I was thinking about some kind of per-rule mutex, but there's @@ -222,6 +224,7 @@ struct rewrite_rule { #define REWRITE_RECURSE 0x0001 #define REWRITE_EXEC_ONCE 0x0002 int lr_mode; + int lr_max_passes; struct rewrite_action *lr_action; }; @@ -253,6 +256,7 @@ struct rewrite_session { */ struct rewrite_var { char *lv_name; + int lv_flags; struct berval lv_value; }; @@ -306,6 +310,7 @@ struct rewrite_info { */ #define REWRITE_MAXPASSES 100 int li_max_passes; + int li_max_passes_per_rule; /* * Behavior in case a NULL or non-existent context is required @@ -464,11 +469,12 @@ rewrite_session_find( * Defines and inits a variable with session scope */ LDAP_REWRITE_F (int) -rewrite_session_var_set( +rewrite_session_var_set_f( struct rewrite_info *info, const void *cookie, const char *name, - const char *value + const char *value, + int flags ); /* @@ -513,27 +519,46 @@ rewrite_var_find( const char *name ); +/* + * Replaces the value of a variable + */ +LDAP_REWRITE_F (int) +rewrite_var_replace( + struct rewrite_var *var, + const char *value, + int flags +); + /* * Inserts a newly created var */ LDAP_REWRITE_F (struct rewrite_var *) -rewrite_var_insert( +rewrite_var_insert_f( Avlnode **tree, const char *name, - const char *value + const char *value, + int flags ); +#define rewrite_var_insert(tree, name, value) \ + rewrite_var_insert_f((tree), (name), (value), \ + REWRITE_VAR_UPDATE|REWRITE_VAR_COPY_NAME|REWRITE_VAR_COPY_VALUE) + /* * Sets/inserts a var */ LDAP_REWRITE_F (struct rewrite_var *) -rewrite_var_set( +rewrite_var_set_f( Avlnode **tree, const char *name, const char *value, - int insert + int flags ); +#define rewrite_var_set(tree, name, value, insert) \ + rewrite_var_set_f((tree), (name), (value), \ + REWRITE_VAR_UPDATE|REWRITE_VAR_COPY_NAME|REWRITE_VAR_COPY_VALUE|((insert)? REWRITE_VAR_INSERT : 0)) + /* * Deletes a var tree */