-#ifdef LDAP_SLAPI
-
-static char **anlist2charray( Operation *op, AttributeName *an )
-{
- char **attrs;
- int i;
-
- if ( an != NULL ) {
- for ( i = 0; an[i].an_name.bv_val != NULL; i++ )
- ;
- attrs = (char **)op->o_tmpalloc( (i + 1) * sizeof(char *), op->o_tmpmemctx );
- for ( i = 0; an[i].an_name.bv_val != NULL; i++ ) {
- attrs[i] = an[i].an_name.bv_val;
- }
- attrs[i] = NULL;
- } else {
- attrs = NULL;
- }
-
- return attrs;
-}
-
-static void init_search_pblock( Operation *op,
- char **attrs, int managedsait )
-{
- slapi_int_pblock_set_operation( op->o_pb, op );
- slapi_pblock_set( op->o_pb, SLAPI_SEARCH_TARGET, (void *)op->o_req_dn.bv_val );
- slapi_pblock_set( op->o_pb, SLAPI_SEARCH_SCOPE, (void *)op->ors_scope );
- slapi_pblock_set( op->o_pb, SLAPI_SEARCH_DEREF, (void *)op->ors_deref );
- slapi_pblock_set( op->o_pb, SLAPI_SEARCH_SIZELIMIT, (void *)op->ors_slimit );
- slapi_pblock_set( op->o_pb, SLAPI_SEARCH_TIMELIMIT, (void *)op->ors_tlimit );
- slapi_pblock_set( op->o_pb, SLAPI_SEARCH_FILTER, (void *)op->ors_filter );
- slapi_pblock_set( op->o_pb, SLAPI_SEARCH_STRFILTER, (void *)op->ors_filterstr.bv_val );
- slapi_pblock_set( op->o_pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
- slapi_pblock_set( op->o_pb, SLAPI_SEARCH_ATTRSONLY, (void *)op->ors_attrsonly );
- slapi_pblock_set( op->o_pb, SLAPI_MANAGEDSAIT, (void *)managedsait );
-}
-
-static int call_search_preop_plugins( Operation *op )
-{
- int rc;
-
- rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_SEARCH_FN, op->o_pb );
- if ( rc < 0 ) {
- /*
- * A preoperation plugin failure will abort the
- * entire operation.
- */
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO, "call_search_preop_plugins: search preoperation plugin "
- "returned %d\n", rc, 0, 0 );
-#else
- Debug(LDAP_DEBUG_TRACE, "call_search_preop_plugins: search preoperation plugin "
- "returned %d.\n", rc, 0, 0);
-#endif
- if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 ) ||
- rc == LDAP_SUCCESS ) {
- rc = LDAP_OTHER;
- }
- } else {
- rc = LDAP_SUCCESS;
- }
-
- return rc;
-}
-
-static int call_search_rewrite_plugins( Operation *op )
-{
- if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, op->o_pb ) == 0 ) {
- int rc;
-
- /*
- * The plugin can set the SLAPI_SEARCH_FILTER.
- * SLAPI_SEARCH_STRFILER is not normative.
- */
- slapi_pblock_get( op->o_pb, SLAPI_SEARCH_FILTER, (void *)&op->ors_filter );
- op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
- filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
-
- /*
- * Also permit other search parameters to be reset. One thing
- * this doesn't (yet) deal with is plugins that change a root
- * DSE search to a non-root DSE search...
- */
- slapi_pblock_get( op->o_pb, SLAPI_SEARCH_TARGET, (void **)&op->o_req_dn.bv_val );
- op->o_req_dn.bv_len = strlen( op->o_req_dn.bv_val );
-
- if( op->o_req_ndn.bv_val != NULL) {
- sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
- }
- rc = dnNormalize( 0, NULL, NULL, &op->o_req_dn, &op->o_req_ndn,
- op->o_tmpmemctx );
- if ( rc != LDAP_SUCCESS ) {
- return rc;
- }
-
- slapi_pblock_get( op->o_pb, SLAPI_SEARCH_SCOPE, (void **)&op->ors_scope );
- slapi_pblock_get( op->o_pb, SLAPI_SEARCH_DEREF, (void **)&op->ors_deref );
-
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ARGS,
- "call_search_rewrite_plugins: after compute_rewrite_search filter: %s\n",
- op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
-#else
- Debug( LDAP_DEBUG_ARGS, " after compute_rewrite_search filter: %s\n",
- op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
-#endif
- }
-
- return LDAP_SUCCESS;
-}
-
-static void call_search_postop_plugins( Operation *op )
-{
- if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_SEARCH_FN, op->o_pb ) < 0 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO, "call_search_postop_plugins: search postoperation plugins "
- "failed\n", 0, 0, 0 );
-#else
- Debug(LDAP_DEBUG_TRACE, "call_search_postop_plugins: search postoperation plugins "
- "failed.\n", 0, 0, 0);
-#endif
- }
-}
-
-void slapi_int_dummy(void)
-{
- /*
- * XXX slapi_search_internal() was no getting pulled
- * in; all manner of linker flags failed to link it.
- * FIXME
- */
- slapi_search_internal( NULL, 0, NULL, NULL, NULL, 0 );
-}
-#endif /* LDAP_SLAPI */
-