2 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * (C) Copyright IBM Corp. 1997,2002
7 * Redistribution and use in source and binary forms are permitted
8 * provided that this notice is preserved and that due credit is
9 * given to IBM Corporation. This software is provided ``as is''
10 * without express or implied warranty.
14 #include "slapi_common.h"
19 isOkNetscapeParam( int param )
23 case SLAPI_CONNECTION:
25 case SLAPI_OPERATION_PARAMETERS:
26 case SLAPI_OPERATION_TYPE:
27 case SLAPI_OPERATION_ID:
28 case SLAPI_OPERATION_AUTHTYPE:
29 case SLAPI_REQUESTOR_ISROOT:
30 case SLAPI_BE_MONITORDN:
32 case SLAPI_BE_READONLY:
33 case SLAPI_BE_LASTMOD:
35 case SLAPI_OPINITIATED_TIME:
36 case SLAPI_REQUESTOR_DN:
37 case SLAPI_REQUESTOR_ISUPDATEDN:
39 case SLAPI_CONN_CLIENTIP:
40 case SLAPI_CONN_SERVERIP:
41 case SLAPI_CONN_AUTHTYPE:
42 case SLAPI_CONN_AUTHMETHOD:
44 case SLAPI_IBM_CONN_DN_ALT:
45 case SLAPI_IBM_CONN_DN_ORIG:
46 case SLAPI_IBM_GSSAPI_CONTEXT:
48 case SLAPI_PLUGIN_PRIVATE:
49 case SLAPI_PLUGIN_TYPE:
50 case SLAPI_PLUGIN_ARGV:
51 case SLAPI_PLUGIN_ARGC:
52 case SLAPI_PLUGIN_VERSION:
53 case SLAPI_PLUGIN_OPRETURN:
54 case SLAPI_PLUGIN_OBJECT:
55 case SLAPI_PLUGIN_DESTROY_FN:
56 case SLAPI_PLUGIN_DESCRIPTION:
57 case SLAPI_PLUGIN_INTOP_RESULT:
58 case SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES:
59 case SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS:
60 case SLAPI_PLUGIN_DB_BIND_FN:
61 case SLAPI_PLUGIN_DB_UNBIND_FN:
62 case SLAPI_PLUGIN_DB_SEARCH_FN:
63 case SLAPI_PLUGIN_DB_COMPARE_FN:
64 case SLAPI_PLUGIN_DB_MODIFY_FN:
65 case SLAPI_PLUGIN_DB_MODRDN_FN:
66 case SLAPI_PLUGIN_DB_ADD_FN:
67 case SLAPI_PLUGIN_DB_DELETE_FN:
68 case SLAPI_PLUGIN_DB_ABANDON_FN:
69 case SLAPI_PLUGIN_DB_CONFIG_FN:
70 case SLAPI_PLUGIN_CLOSE_FN:
71 case SLAPI_PLUGIN_DB_FLUSH_FN:
72 case SLAPI_PLUGIN_START_FN:
73 case SLAPI_PLUGIN_DB_SEQ_FN:
74 case SLAPI_PLUGIN_DB_ENTRY_FN:
75 case SLAPI_PLUGIN_DB_REFERRAL_FN:
76 case SLAPI_PLUGIN_DB_RESULT_FN:
77 case SLAPI_PLUGIN_DB_LDIF2DB_FN:
78 case SLAPI_PLUGIN_DB_DB2LDIF_FN:
79 case SLAPI_PLUGIN_DB_BEGIN_FN:
80 case SLAPI_PLUGIN_DB_COMMIT_FN:
81 case SLAPI_PLUGIN_DB_ABORT_FN:
82 case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN:
83 case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN:
84 case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN:
85 case SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN:
86 case SLAPI_PLUGIN_DB_SIZE_FN:
87 case SLAPI_PLUGIN_DB_TEST_FN:
88 case SLAPI_PLUGIN_DB_NO_ACL:
89 case SLAPI_PLUGIN_EXT_OP_FN:
90 case SLAPI_PLUGIN_EXT_OP_OIDLIST:
91 case SLAPI_PLUGIN_PRE_BIND_FN:
92 case SLAPI_PLUGIN_PRE_UNBIND_FN:
93 case SLAPI_PLUGIN_PRE_SEARCH_FN:
94 case SLAPI_PLUGIN_PRE_COMPARE_FN:
95 case SLAPI_PLUGIN_PRE_MODIFY_FN:
96 case SLAPI_PLUGIN_PRE_MODRDN_FN:
97 case SLAPI_PLUGIN_PRE_ADD_FN:
98 case SLAPI_PLUGIN_PRE_DELETE_FN:
99 case SLAPI_PLUGIN_PRE_ABANDON_FN:
100 case SLAPI_PLUGIN_PRE_ENTRY_FN:
101 case SLAPI_PLUGIN_PRE_REFERRAL_FN:
102 case SLAPI_PLUGIN_PRE_RESULT_FN:
103 case SLAPI_PLUGIN_POST_BIND_FN:
104 case SLAPI_PLUGIN_POST_UNBIND_FN:
105 case SLAPI_PLUGIN_POST_SEARCH_FN:
106 case SLAPI_PLUGIN_POST_COMPARE_FN:
107 case SLAPI_PLUGIN_POST_MODIFY_FN:
108 case SLAPI_PLUGIN_POST_MODRDN_FN:
109 case SLAPI_PLUGIN_POST_ADD_FN:
110 case SLAPI_PLUGIN_POST_DELETE_FN:
111 case SLAPI_PLUGIN_POST_ABANDON_FN:
112 case SLAPI_PLUGIN_POST_ENTRY_FN:
113 case SLAPI_PLUGIN_POST_REFERRAL_FN:
114 case SLAPI_PLUGIN_POST_RESULT_FN:
115 case SLAPI_PLUGIN_MR_FILTER_CREATE_FN:
116 case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN:
117 case SLAPI_PLUGIN_MR_FILTER_MATCH_FN:
118 case SLAPI_PLUGIN_MR_FILTER_INDEX_FN:
119 case SLAPI_PLUGIN_MR_FILTER_RESET_FN:
120 case SLAPI_PLUGIN_MR_INDEX_FN:
121 case SLAPI_PLUGIN_MR_OID:
122 case SLAPI_PLUGIN_MR_TYPE:
123 case SLAPI_PLUGIN_MR_VALUE:
124 case SLAPI_PLUGIN_MR_VALUES:
125 case SLAPI_PLUGIN_MR_KEYS:
126 case SLAPI_PLUGIN_MR_FILTER_REUSABLE:
127 case SLAPI_PLUGIN_MR_QUERY_OPERATOR:
128 case SLAPI_PLUGIN_MR_USAGE:
130 case SLAPI_OP_LESS_OR_EQUAL:
131 case SLAPI_PLUGIN_MR_USAGE_INDEX:
132 case SLAPI_PLUGIN_SYNTAX_FILTER_AVA:
133 case SLAPI_PLUGIN_SYNTAX_FILTER_SUB:
134 case SLAPI_PLUGIN_SYNTAX_VALUES2KEYS:
135 case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA:
136 case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB:
137 case SLAPI_PLUGIN_SYNTAX_NAMES:
138 case SLAPI_PLUGIN_SYNTAX_OID:
139 case SLAPI_PLUGIN_SYNTAX_FLAGS:
140 case SLAPI_PLUGIN_SYNTAX_COMPARE:
141 case SLAPI_MANAGEDSAIT:
142 case SLAPI_CONFIG_FILENAME:
143 case SLAPI_CONFIG_LINENO:
144 case SLAPI_CONFIG_ARGC:
145 case SLAPI_CONFIG_ARGV:
146 case SLAPI_TARGET_DN:
147 case SLAPI_REQCONTROLS:
148 case SLAPI_ENTRY_PRE_OP:
149 case SLAPI_ENTRY_POST_OP:
150 case SLAPI_RESCONTROLS:
151 case SLAPI_ADD_RESCONTROL:
152 case SLAPI_ADD_ENTRY:
153 case SLAPI_BIND_METHOD:
154 case SLAPI_BIND_CREDENTIALS:
155 case SLAPI_BIND_SASLMECHANISM:
156 case SLAPI_BIND_RET_SASLCREDS:
157 case SLAPI_COMPARE_TYPE:
158 case SLAPI_COMPARE_VALUE:
159 case SLAPI_MODIFY_MODS:
160 case SLAPI_MODRDN_NEWRDN:
161 case SLAPI_MODRDN_DELOLDRDN:
162 case SLAPI_MODRDN_NEWSUPERIOR:
163 case SLAPI_SEARCH_SCOPE:
164 case SLAPI_SEARCH_DEREF:
165 case SLAPI_SEARCH_SIZELIMIT:
166 case SLAPI_SEARCH_TIMELIMIT:
167 case SLAPI_SEARCH_FILTER:
168 case SLAPI_SEARCH_STRFILTER:
169 case SLAPI_SEARCH_ATTRS:
170 case SLAPI_SEARCH_ATTRSONLY:
171 case SLAPI_ABANDON_MSGID:
173 case SLAPI_SEQ_ATTRNAME:
175 case SLAPI_EXT_OP_REQ_OID:
176 case SLAPI_EXT_OP_REQ_VALUE:
177 case SLAPI_EXT_OP_RET_OID:
178 case SLAPI_EXT_OP_RET_VALUE:
179 case SLAPI_MR_FILTER_ENTRY:
180 case SLAPI_MR_FILTER_TYPE:
181 case SLAPI_MR_FILTER_VALUE:
182 case SLAPI_MR_FILTER_OID:
183 case SLAPI_MR_FILTER_DNATTRS:
184 case SLAPI_LDIF2DB_FILE:
185 case SLAPI_LDIF2DB_REMOVEDUPVALS:
186 case SLAPI_DB2LDIF_PRINTKEY:
187 case SLAPI_PARENT_TXN:
189 case SLAPI_SEARCH_RESULT_SET:
190 case SLAPI_SEARCH_RESULT_ENTRY:
192 case SLAPI_SEARCH_REFERRALS:
193 case SLAPI_CHANGENUMBER:
194 case SLAPI_LOG_OPERATION:
196 case SLAPI_RESULT_CODE:
197 case SLAPI_RESULT_TEXT:
198 case SLAPI_RESULT_MATCHED:
199 case SLAPI_PLUGIN_OPATTR_COALESCE_FN:
200 case SLAPI_PLUGIN_OPATTR_COALESCE_DATA:
203 return INVALID_PARAM;
208 isValidParam( Slapi_PBlock *pb, int param )
210 if ( pb->ckParams == TRUE ) {
211 if ( IBM_RESERVED( param ) ) return LDAP_SUCCESS;
212 if (param == SLAPI_PLUGIN_AUDIT_FN ||
213 param == SLAPI_PLUGIN_AUDIT_DATA )
215 if ( param < LAST_IBM_PARAM ) {
216 return INVALID_PARAM;
217 } else if ( NETSCAPE_RESERVED( param ) ) {
218 return INVALID_PARAM;
220 return isOkNetscapeParam(param);
228 Lock( Slapi_PBlock *pb )
230 ldap_pvt_thread_mutex_lock(&pb->pblockMutex);
234 unLock( Slapi_PBlock *pb )
236 ldap_pvt_thread_mutex_unlock(&pb->pblockMutex);
240 get( Slapi_PBlock *pb, int param, void **val )
244 if ( isValidParam( pb, param ) == INVALID_PARAM ) {
251 for ( i = 0; i < pb->numParams; i++ ) {
252 if ( pb->curParams[i] == param ) {
253 *val = pb->curVals[i];
262 set( Slapi_PBlock *pb, int param, void *val )
264 #if defined(LDAP_SLAPI)
267 if ( isValidParam( pb, param ) == INVALID_PARAM ) {
273 if ( pb->numParams == MAX_PARAMS ) {
278 for( i = 0; i < pb->numParams; i++ ) {
279 if ( pb->curParams[i] == param ) {
284 if ( i >= pb->numParams ) {
285 pb->curParams[i] = param;
288 pb->curVals[i] = val;
292 #endif /* LDAP_SLAPI */
297 clearPB( Slapi_PBlock *pb )
303 checkParams( Slapi_PBlock *pb, int flag )
309 deleteParam( Slapi_PBlock *p, int param )
314 for ( i = 0; i < p->numParams; i++ ) {
315 if ( p->curParams[i] == param ) {
320 if (i >= p->numParams ) {
324 if ( p->numParams > 1 ) {
325 p->curParams[i] = p->curParams[p->numParams];
326 p->curVals[i] = p->curVals[p->numParams];
336 #if defined(LDAP_SLAPI)
339 pb = (Slapi_PBlock *) ch_malloc(sizeof(Slapi_PBlock));
342 ldap_pvt_thread_mutex_init( &pb->pblockMutex );
343 memset( pb->curParams, 0, sizeof(pb->curParams) );
344 memset( pb->curVals, 0, sizeof(pb->curVals) );
345 pb->curParams[0] = SLAPI_IBM_PBLOCK;
346 pb->curVals[0] = NULL;
350 #endif /* LDAP_SLAPI */
355 slapi_pblock_destroy( Slapi_PBlock* pb )
357 #if defined(LDAP_SLAPI)
360 get( pb, SLAPI_CONN_DN,(void **)&str );
366 get( pb, SLAPI_CONN_AUTHMETHOD, (void **)&str );
372 get( pb, SLAPI_IBM_CONN_DN_ALT, (void **)&str );
378 get( pb, SLAPI_IBM_CONN_DN_ORIG, (void **)&str );
383 get( pb, SLAPI_RESULT_TEXT, (void **)&str );
389 get( pb, SLAPI_RESULT_MATCHED, (void **)&str );
395 ldap_pvt_thread_mutex_destroy( &pb->pblockMutex );
398 #endif /* LDAP_SLAPI */
402 slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value )
404 #if defined(LDAP_SLAPI)
405 return get( pb, arg, (void **)value );
406 #endif /* LDAP_SLAPI */
411 slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value )
413 #if defined(LDAP_SLAPI)
418 case SLAPI_CONN_AUTHMETHOD:
419 case SLAPI_IBM_CONN_DN_ALT:
420 case SLAPI_IBM_CONN_DN_ORIG:
421 case SLAPI_RESULT_TEXT:
422 case SLAPI_RESULT_MATCHED:
423 if ( value != NULL ) {
424 pTmp = (void *)slapi_ch_strdup((char *)value);
425 if ( pTmp == NULL ) {
426 return LDAP_NO_MEMORY;
434 return set( pb, arg, pTmp );
435 #endif /* LDAP_SLAPI */
436 return LDAP_NO_MEMORY;
440 slapi_pblock_clear( Slapi_PBlock *pb )
442 #if defined(LDAP_SLAPI)
444 #endif /* LDAP_SLAPI */
448 slapi_pblock_delete_param( Slapi_PBlock *p, int param )
450 #if defined(LDAP_SLAPI)
451 return deleteParam( p, param );
452 #endif /* LDAP_SLAPI */
457 slapi_pblock_check_params( Slapi_PBlock *pb, int flag )
459 #if defined(LDAP_SLAPI)
460 checkParams( pb, flag );
461 #endif /* LDAP_SLAPI */
468 slapi_x_pblock_get_first( Backend *be, Slapi_PBlock **pb )
470 #if defined(LDAP_SLAPI)
472 *pb = (Slapi_PBlock *)be->be_pb;
473 return (*pb == NULL ? LDAP_OTHER : LDAP_SUCCESS);
474 #else /* LDAP_SLAPI */
476 #endif /* LDAP_SLAPI */
483 slapi_x_pblock_get_next( Slapi_PBlock **pb )
485 #if defined(LDAP_SLAPI)
487 return slapi_pblock_get( *pb, SLAPI_IBM_PBLOCK, pb );
488 #else /* LDAP_SLAPI */
490 #endif /* LDAP_SLAPI */