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_REQUESTOR_ISROOT:
26 case SLAPI_BE_MONITORDN:
28 case SLAPI_BE_READONLY:
29 case SLAPI_BE_LASTMOD:
31 case SLAPI_OPINITIATED_TIME:
32 case SLAPI_REQUESTOR_DN:
33 case SLAPI_REQUESTOR_ISUPDATEDN:
35 case SLAPI_CONN_AUTHTYPE:
36 case SLAPI_IBM_CONN_DN_ALT:
37 case SLAPI_IBM_CONN_DN_ORIG:
38 case SLAPI_IBM_GSSAPI_CONTEXT:
40 case SLAPI_PLUGIN_PRIVATE:
41 case SLAPI_PLUGIN_TYPE:
42 case SLAPI_PLUGIN_ARGV:
43 case SLAPI_PLUGIN_ARGC:
44 case SLAPI_PLUGIN_VERSION:
45 case SLAPI_PLUGIN_OPRETURN:
46 case SLAPI_PLUGIN_OBJECT:
47 case SLAPI_PLUGIN_DESTROY_FN:
48 case SLAPI_PLUGIN_DESCRIPTION:
49 case SLAPI_PLUGIN_INTOP_RESULT:
50 case SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES:
51 case SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS:
52 case SLAPI_PLUGIN_DB_BIND_FN:
53 case SLAPI_PLUGIN_DB_UNBIND_FN:
54 case SLAPI_PLUGIN_DB_SEARCH_FN:
55 case SLAPI_PLUGIN_DB_COMPARE_FN:
56 case SLAPI_PLUGIN_DB_MODIFY_FN:
57 case SLAPI_PLUGIN_DB_MODRDN_FN:
58 case SLAPI_PLUGIN_DB_ADD_FN:
59 case SLAPI_PLUGIN_DB_DELETE_FN:
60 case SLAPI_PLUGIN_DB_ABANDON_FN:
61 case SLAPI_PLUGIN_DB_CONFIG_FN:
62 case SLAPI_PLUGIN_CLOSE_FN:
63 case SLAPI_PLUGIN_DB_FLUSH_FN:
64 case SLAPI_PLUGIN_START_FN:
65 case SLAPI_PLUGIN_DB_SEQ_FN:
66 case SLAPI_PLUGIN_DB_ENTRY_FN:
67 case SLAPI_PLUGIN_DB_REFERRAL_FN:
68 case SLAPI_PLUGIN_DB_RESULT_FN:
69 case SLAPI_PLUGIN_DB_LDIF2DB_FN:
70 case SLAPI_PLUGIN_DB_DB2LDIF_FN:
71 case SLAPI_PLUGIN_DB_BEGIN_FN:
72 case SLAPI_PLUGIN_DB_COMMIT_FN:
73 case SLAPI_PLUGIN_DB_ABORT_FN:
74 case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN:
75 case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN:
76 case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN:
77 case SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN:
78 case SLAPI_PLUGIN_DB_SIZE_FN:
79 case SLAPI_PLUGIN_DB_TEST_FN:
80 case SLAPI_PLUGIN_DB_NO_ACL:
81 case SLAPI_PLUGIN_EXT_OP_FN:
82 case SLAPI_PLUGIN_EXT_OP_OIDLIST:
83 case SLAPI_PLUGIN_PRE_BIND_FN:
84 case SLAPI_PLUGIN_PRE_UNBIND_FN:
85 case SLAPI_PLUGIN_PRE_SEARCH_FN:
86 case SLAPI_PLUGIN_PRE_COMPARE_FN:
87 case SLAPI_PLUGIN_PRE_MODIFY_FN:
88 case SLAPI_PLUGIN_PRE_MODRDN_FN:
89 case SLAPI_PLUGIN_PRE_ADD_FN:
90 case SLAPI_PLUGIN_PRE_DELETE_FN:
91 case SLAPI_PLUGIN_PRE_ABANDON_FN:
92 case SLAPI_PLUGIN_PRE_ENTRY_FN:
93 case SLAPI_PLUGIN_PRE_REFERRAL_FN:
94 case SLAPI_PLUGIN_PRE_RESULT_FN:
95 case SLAPI_PLUGIN_POST_BIND_FN:
96 case SLAPI_PLUGIN_POST_UNBIND_FN:
97 case SLAPI_PLUGIN_POST_SEARCH_FN:
98 case SLAPI_PLUGIN_POST_COMPARE_FN:
99 case SLAPI_PLUGIN_POST_MODIFY_FN:
100 case SLAPI_PLUGIN_POST_MODRDN_FN:
101 case SLAPI_PLUGIN_POST_ADD_FN:
102 case SLAPI_PLUGIN_POST_DELETE_FN:
103 case SLAPI_PLUGIN_POST_ABANDON_FN:
104 case SLAPI_PLUGIN_POST_ENTRY_FN:
105 case SLAPI_PLUGIN_POST_REFERRAL_FN:
106 case SLAPI_PLUGIN_POST_RESULT_FN:
107 case SLAPI_PLUGIN_MR_FILTER_CREATE_FN:
108 case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN:
109 case SLAPI_PLUGIN_MR_FILTER_MATCH_FN:
110 case SLAPI_PLUGIN_MR_FILTER_INDEX_FN:
111 case SLAPI_PLUGIN_MR_FILTER_RESET_FN:
112 case SLAPI_PLUGIN_MR_INDEX_FN:
113 case SLAPI_PLUGIN_MR_OID:
114 case SLAPI_PLUGIN_MR_TYPE:
115 case SLAPI_PLUGIN_MR_VALUE:
116 case SLAPI_PLUGIN_MR_VALUES:
117 case SLAPI_PLUGIN_MR_KEYS:
118 case SLAPI_PLUGIN_MR_FILTER_REUSABLE:
119 case SLAPI_PLUGIN_MR_QUERY_OPERATOR:
120 case SLAPI_PLUGIN_MR_USAGE:
122 case SLAPI_OP_LESS_OR_EQUAL:
123 case SLAPI_PLUGIN_MR_USAGE_INDEX:
124 case SLAPI_PLUGIN_SYNTAX_FILTER_AVA:
125 case SLAPI_PLUGIN_SYNTAX_FILTER_SUB:
126 case SLAPI_PLUGIN_SYNTAX_VALUES2KEYS:
127 case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA:
128 case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB:
129 case SLAPI_PLUGIN_SYNTAX_NAMES:
130 case SLAPI_PLUGIN_SYNTAX_OID:
131 case SLAPI_PLUGIN_SYNTAX_FLAGS:
132 case SLAPI_PLUGIN_SYNTAX_COMPARE:
133 case SLAPI_MANAGEDSAIT:
134 case SLAPI_CONFIG_FILENAME:
135 case SLAPI_CONFIG_LINENO:
136 case SLAPI_CONFIG_ARGC:
137 case SLAPI_CONFIG_ARGV:
138 case SLAPI_TARGET_DN:
139 case SLAPI_REQCONTROLS:
140 case SLAPI_ENTRY_PRE_OP:
141 case SLAPI_ENTRY_POST_OP:
142 case SLAPI_RESCONTROLS:
143 case SLAPI_ADD_RESCONTROL:
144 case SLAPI_ADD_ENTRY:
145 case SLAPI_BIND_METHOD:
146 case SLAPI_BIND_CREDENTIALS:
147 case SLAPI_BIND_SASLMECHANISM:
148 case SLAPI_BIND_RET_SASLCREDS:
149 case SLAPI_COMPARE_TYPE:
150 case SLAPI_COMPARE_VALUE:
151 case SLAPI_MODIFY_MODS:
152 case SLAPI_MODRDN_NEWRDN:
153 case SLAPI_MODRDN_DELOLDRDN:
154 case SLAPI_MODRDN_NEWSUPERIOR:
155 case SLAPI_SEARCH_SCOPE:
156 case SLAPI_SEARCH_DEREF:
157 case SLAPI_SEARCH_SIZELIMIT:
158 case SLAPI_SEARCH_TIMELIMIT:
159 case SLAPI_SEARCH_FILTER:
160 case SLAPI_SEARCH_STRFILTER:
161 case SLAPI_SEARCH_ATTRS:
162 case SLAPI_SEARCH_ATTRSONLY:
163 case SLAPI_ABANDON_MSGID:
165 case SLAPI_SEQ_ATTRNAME:
167 case SLAPI_EXT_OP_REQ_OID:
168 case SLAPI_EXT_OP_REQ_VALUE:
169 case SLAPI_EXT_OP_RET_OID:
170 case SLAPI_EXT_OP_RET_VALUE:
171 case SLAPI_MR_FILTER_ENTRY:
172 case SLAPI_MR_FILTER_TYPE:
173 case SLAPI_MR_FILTER_VALUE:
174 case SLAPI_MR_FILTER_OID:
175 case SLAPI_MR_FILTER_DNATTRS:
176 case SLAPI_LDIF2DB_FILE:
177 case SLAPI_LDIF2DB_REMOVEDUPVALS:
178 case SLAPI_DB2LDIF_PRINTKEY:
179 case SLAPI_PARENT_TXN:
181 case SLAPI_SEARCH_RESULT_SET:
182 case SLAPI_SEARCH_RESULT_ENTRY:
184 case SLAPI_SEARCH_REFERRALS:
185 case SLAPI_CHANGENUMBER:
186 case SLAPI_LOG_OPERATION:
190 return INVALID_PARAM;
195 isValidParam( Slapi_PBlock *pb, int param )
197 if ( pb->ckParams == TRUE ) {
198 if ( IBM_RESERVED( param ) ) return LDAP_SUCCESS;
199 if (param == SLAPI_PLUGIN_AUDIT_FN ||
200 param == SLAPI_PLUGIN_AUDIT_DATA )
202 if ( param < LAST_IBM_PARAM ) {
203 return INVALID_PARAM;
204 } else if ( NETSCAPE_RESERVED( param ) ) {
205 return INVALID_PARAM;
207 return isOkNetscapeParam(param);
215 Lock( Slapi_PBlock *pb )
217 ldap_pvt_thread_mutex_lock(&pb->pblockMutex);
221 unLock( Slapi_PBlock *pb )
223 ldap_pvt_thread_mutex_unlock(&pb->pblockMutex);
227 get( Slapi_PBlock *pb, int param, void **val )
231 if ( isValidParam( pb, param ) == INVALID_PARAM ) {
238 for ( i = 0; i < pb->numParams; i++ ) {
239 if ( pb->curParams[i] == param ) {
240 *val = pb->curVals[i];
249 set( Slapi_PBlock *pb, int param, void *val )
251 #if defined(LDAP_SLAPI)
254 if ( isValidParam( pb, param ) == INVALID_PARAM ) {
260 if ( pb->numParams == MAX_PARAMS ) {
265 for( i = 0; i < pb->numParams; i++ ) {
266 if ( pb->curParams[i] == param ) {
271 if ( i >= pb->numParams ) {
272 pb->curParams[i] = param;
275 pb->curVals[i] = val;
279 #endif /* LDAP_SLAPI */
284 clearPB( Slapi_PBlock *pb )
290 checkParams( Slapi_PBlock *pb, int flag )
296 deleteParam( Slapi_PBlock *p, int param )
301 for ( i = 0; i < p->numParams; i++ ) {
302 if ( p->curParams[i] == param ) {
307 if (i >= p->numParams ) {
311 if ( p->numParams > 1 ) {
312 p->curParams[i] = p->curParams[p->numParams];
313 p->curVals[i] = p->curVals[p->numParams];
323 #if defined(LDAP_SLAPI)
326 pb = (Slapi_PBlock *) ch_malloc(sizeof(Slapi_PBlock));
329 ldap_pvt_thread_mutex_init( &pb->pblockMutex );
330 memset( pb->curParams, 0, sizeof(pb->curParams) );
331 memset( pb->curVals, 0, sizeof(pb->curVals) );
332 pb->curParams[0] = SLAPI_IBM_PBLOCK;
333 pb->curVals[0] = NULL;
337 #endif /* LDAP_SLAPI */
342 slapi_pblock_destroy( Slapi_PBlock* pb )
344 #if defined(LDAP_SLAPI)
347 get( pb, SLAPI_CONN_DN,(void **)&str );
353 get( pb, SLAPI_CONN_AUTHTYPE, (void **)&str );
359 get( pb, SLAPI_IBM_CONN_DN_ALT, (void **)&str );
365 get( pb, SLAPI_IBM_CONN_DN_ORIG, (void **)&str );
370 get( pb, SLAPI_RESULT_TEXT, (void **)&str );
376 get( pb, SLAPI_RESULT_MATCHED, (void **)&str );
382 ldap_pvt_thread_mutex_destroy( &pb->pblockMutex );
385 #endif /* LDAP_SLAPI */
389 slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value )
391 #if defined(LDAP_SLAPI)
392 return get( pb, arg, (void **)value );
393 #endif /* LDAP_SLAPI */
398 slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value )
400 #if defined(LDAP_SLAPI)
405 case SLAPI_CONN_AUTHTYPE:
406 case SLAPI_IBM_CONN_DN_ALT:
407 case SLAPI_IBM_CONN_DN_ORIG:
408 if ( value != NULL ) {
409 pTmp = (void *)slapi_ch_strdup((char *)value);
410 if ( pTmp == NULL ) {
411 return LDAP_NO_MEMORY;
419 return set( pb, arg, pTmp );
420 #endif /* LDAP_SLAPI */
421 return LDAP_NO_MEMORY;
425 slapi_pblock_clear( Slapi_PBlock *pb )
427 #if defined(LDAP_SLAPI)
429 #endif /* LDAP_SLAPI */
433 slapi_pblock_delete_param( Slapi_PBlock *p, int param )
435 #if defined(LDAP_SLAPI)
436 return deleteParam( p, param );
437 #endif /* LDAP_SLAPI */
442 slapi_pblock_check_params( Slapi_PBlock *pb, int flag )
444 #if defined(LDAP_SLAPI)
445 checkParams( pb, flag );
446 #endif /* LDAP_SLAPI */
453 slapi_x_pblock_get_first( Backend *be, Slapi_PBlock **pb )
455 #if defined(LDAP_SLAPI)
457 *pb = (Slapi_PBlock *)be->be_pb;
458 return (*pb == NULL ? LDAP_OTHER : LDAP_SUCCESS);
459 #else /* LDAP_SLAPI */
461 #endif /* LDAP_SLAPI */
468 slapi_x_pblock_get_next( Slapi_PBlock **pb )
470 #if defined(LDAP_SLAPI)
472 return slapi_pblock_get( *pb, SLAPI_IBM_PBLOCK, pb );
473 #else /* LDAP_SLAPI */
475 #endif /* LDAP_SLAPI */