-static void initSearchPlugin( Operation *op,
- char **attrs, int managedsait )
-{
- slapi_x_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 doPreSearchPluginFNs( Operation *op )
-{
- int rc;
-
- rc = doPluginFNs( 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, "doPreSearchPluginFNs: search preoperation plugin "
- "returned %d\n", rc, 0, 0 );
-#else
- Debug(LDAP_DEBUG_TRACE, "doPreSearchPluginFNs: 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_OTHER;
- } else {
- rc = LDAP_SUCCESS;
- }
-
- return rc;
-}
-
-static int doSearchRewriteFNs( Operation *op )
-{
- if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, op->o_pb ) == 0 ) {
- Filter *f;
-
- /*
- * The plugin can set the SLAPI_SEARCH_FILTER.
- * SLAPI_SEARCH_STRFILER is not normative.
- */
- slapi_pblock_get( op->o_pb, SLAPI_SEARCH_FILTER, (void *)&f );
- if ( f != op->ors_filter ) {
- /* Plugin modified filter. Is pointer comparison safe? */
- /*
- * This is inefficient but it is not possible to expose the
- * new memory allocation API through SLAPI.
- *
- * Further, the plugin should be responsible for freeing
- * the original filter, but there is no way to communicate
- * the memory context through the SLAPI filter free API.
- */
- op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
- filter2bv_x( op, f, &op->ors_filterstr );
- filter_free_x( op, op->ors_filter );
- op->ors_filter = str2filter_x( op, op->ors_filterstr.bv_val );
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ARGS,
- "doSearchRewriteFNs: 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