]> git.sur5r.net Git - openldap/commitdiff
Added referrals to gluestate.
authorHoward Chu <hyc@openldap.org>
Sun, 9 Dec 2001 02:46:25 +0000 (02:46 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 9 Dec 2001 02:46:25 +0000 (02:46 +0000)
servers/slapd/backglue.c

index cd2363ee97221ccaeffe008d29a58461d284739a..1bf44af818379b4a3098a3cab0b0425a1610e4a3 100644 (file)
@@ -189,6 +189,8 @@ typedef struct glue_state {
        int nentries;
        int matchlen;
        char *matched;
+       int nrefs;
+       struct berval **refs;
 } glue_state;
 
 void
@@ -225,6 +227,27 @@ glue_back_response (
                        gs->matchlen = len;
                }
        }
+       if (ref) {
+               int i, j, k;
+               struct berval **new;
+
+               for (i=0; ref[i]; i++);
+
+               j = gs->nrefs;
+               if (!j) {
+                       new = ch_malloc ((i+1)*sizeof(struct berval *));
+                       gs->nrefs = i;
+               } else {
+                       new = ch_realloc(gs->refs,
+                               (j+i+1)*sizeof(struct berval *));
+               }
+               for (k=0; k<i; j++,k++) {
+                       new[j] = ber_bvdup(ref[k]);
+               }
+               new[j] = NULL;
+               gs->nrefs = j;
+               gs->refs = new;
+       }
 }
 
 void
@@ -267,8 +290,7 @@ glue_back_search (
        BackendDB *be;
        int i, rc, t2limit = 0, s2limit = 0;
        long stoptime = 0;
-       glue_state gs =
-       {0};
+       glue_state gs = {0};
 
 
        if (tlimit)
@@ -391,11 +413,13 @@ glue_back_search (
        op->o_response = NULL;
        op->o_glue = NULL;
 
-       send_search_result (conn, op, gs.err, gs.matched, NULL, NULL,
+       send_search_result (conn, op, gs.err, gs.matched, NULL, gs.refs,
                            NULL, gs.nentries);
-      done:
+done:
        if (gs.matched)
                free (gs.matched);
+       if (gs.refs)
+               ber_bvecfree(gs.refs);
        return rc;
 }