]> git.sur5r.net Git - openldap/commitdiff
Reworked callback layout, added send_search_entry callback
authorHoward Chu <hyc@openldap.org>
Sun, 13 Jan 2002 16:40:37 +0000 (16:40 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 13 Jan 2002 16:40:37 +0000 (16:40 +0000)
servers/slapd/backglue.c
servers/slapd/result.c
servers/slapd/slap.h

index 79f20b8f27ad67abdad5b15e51f0e241d9a6b0cb..2a5bef23b3719819fb5a334340a0991a587191eb 100644 (file)
@@ -170,6 +170,7 @@ typedef struct glue_state {
        char *matched;
        int nrefs;
        BVarray refs;
+       slap_callback *prevcb;
 } glue_state;
 
 static void
@@ -188,7 +189,7 @@ glue_back_response (
        LDAPControl **ctrls
 )
 {
-       glue_state *gs = op->o_glue;
+       glue_state *gs = op->o_callback->sc_private;
 
        if (err == LDAP_SUCCESS || gs->err != LDAP_SUCCESS)
                gs->err = err;
@@ -240,13 +241,38 @@ glue_back_sresult (
        int nentries
 )
 {
-       glue_state *gs = op->o_glue;
+       glue_state *gs = op->o_callback->sc_private;
 
        gs->nentries += nentries;
        glue_back_response (c, op, 0, 0, err, matched, text, refs,
                            NULL, NULL, NULL, ctrls);
 }
 
+static int
+glue_back_sendentry (
+       BackendDB *be,
+       Connection *c,
+       Operation *op,
+       Entry *e,
+       AttributeName *an,
+       int ao,
+       LDAPControl **ctrls
+)
+{
+       slap_callback *tmp = op->o_callback;
+       glue_state *gs = tmp->sc_private;
+       int rc;
+
+       op->o_callback = gs->prevcb;
+       if (op->o_callback && op->o_callback->sc_sendentry) {
+               rc = op->o_callback->sc_sendentry(be, c, op, e, an, ao, ctrls);
+       } else {
+               rc = send_search_entry(be, c, op, e, an, ao, ctrls);
+       }
+       op->o_callback = tmp;
+       return rc;
+}
+
 static int
 glue_back_search (
        BackendDB *b0,
@@ -268,9 +294,12 @@ glue_back_search (
        BackendDB *be;
        int i, rc, t2limit = 0, s2limit = 0;
        long stoptime = 0;
-       glue_state gs = {0};
        struct berval bv;
+       glue_state gs = {0};
+       slap_callback cb = {glue_back_response, glue_back_sresult, 
+               glue_back_sendentry, &gs};
 
+       gs.prevcb = op->o_callback;
 
        if (tlimit) {
                stoptime = slap_get_time () + tlimit;
@@ -293,9 +322,7 @@ glue_back_search (
 
        case LDAP_SCOPE_ONELEVEL:
        case LDAP_SCOPE_SUBTREE:
-               op->o_glue = &gs;
-               op->o_sresult = glue_back_sresult;
-               op->o_response = glue_back_response;
+               op->o_callback = &cb;
 
                /*
                 * Execute in reverse order, most general first 
@@ -349,9 +376,7 @@ glue_back_search (
                }
                break;
        }
-       op->o_sresult = NULL;
-       op->o_response = NULL;
-       op->o_glue = NULL;
+       op->o_callback = gs.prevcb;
 
        send_search_result (conn, op, gs.err, gs.matched, NULL,
                gs.refs, NULL, gs.nentries);
index c79f848d88c4e7278f887796cb93450c48182bc5..47699043490bf7d8b3c244dddb1e83ad6f27fea1 100644 (file)
@@ -187,8 +187,8 @@ send_ldap_response(
        int             rc;
        long    bytes;
 
-       if (op->o_response) {
-               op->o_response( conn, op, tag, msgid, err, matched,
+       if (op->o_callback && op->o_callback->sc_response) {
+               op->o_callback->sc_response( conn, op, tag, msgid, err, matched,
                        text, ref, resoid, resdata, sasldata, ctrls );
                return;
        }
@@ -548,8 +548,8 @@ send_search_result(
 
        assert( !LDAP_API_ERROR( err ) );
 
-       if (op->o_sresult) {
-               op->o_sresult(conn, op, err, matched, text, refs,
+       if (op->o_callback && op->o_callback->sc_sresult) {
+               op->o_callback->sc_sresult(conn, op, err, matched, text, refs,
                        ctrls, nentries);
                return;
        }
@@ -631,6 +631,11 @@ send_search_entry(
 
        AttributeDescription *ad_entry = slap_schema.si_ad_entry;
 
+       if (op->o_callback && op->o_callback->sc_sendentry) {
+               return op->o_callback->sc_sendentry( be, conn, op, e, attrs,
+                       attrsonly, ctrls );
+       }
+
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
                   "send_search_entry: conn %d  dn=\"%s\"%s\n",
index d41355a45ad5239d9d2ba34ee192f2a08a646985..98b2148be12b8d0d0c77bfcd5c91cbe1fd566e22 100644 (file)
@@ -1360,6 +1360,16 @@ typedef void (slap_sresult)( struct slap_conn *, struct slap_op *,
        ber_int_t, const char *, const char *, BVarray,
        LDAPControl **, int nentries);
 
+typedef int (slap_sendentry)( BackendDB *, struct slap_conn *,
+       struct slap_op *, Entry *, AttributeName *, int, LDAPControl **);
+
+typedef struct slap_callback {
+       slap_response *sc_response;
+       slap_sresult *sc_sresult;
+       slap_sendentry *sc_sendentry;
+       void *sc_private;
+} slap_callback;
+
 /*
  * represents an operation pending from an ldap client
  */
@@ -1388,11 +1398,9 @@ typedef struct slap_op {
        AuthorizationInformation o_authz;
 
        BerElement      *o_ber;         /* ber of the request             */
-       slap_response   *o_response;    /* callback function */
-       slap_sresult    *o_sresult;     /* search result callback */
+       slap_callback   *o_callback;    /* callback pointers */
        LDAPControl     **o_ctrls;       /* controls */
 
-       void    *o_glue;        /* for the glue backend */
        void    *o_private;     /* anything the backend needs */
 
        LDAP_STAILQ_ENTRY(slap_op)      o_next; /* next operation in list         */