[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: error text in search results



 
> By examining the provided text to see if it starts with "Referral:".
> 
> See http://www.umich.edu/~dirsvcs/ldap/doc/other/ldap-ref.html

Try this one...
--- result.c    1999/10/21 15:53:57     1.63
+++ result.c    1999/10/25 00:59:45
@@ -18,15 +18,25 @@
 /* we need LBER internals */
 #include "../../libraries/liblber/lber-int.h"

-static char *v2ref( struct berval **ref )
+static char *v2ref( struct berval **ref, const char *text )
 {
-       size_t len, i;
+       size_t len = 0, i = 0;
        char *v2;

-       if(ref == NULL) return NULL;
+       if(ref == NULL) return text;

-       len = sizeof("Referral:");
-       v2 = ch_strdup("Referral:");
+       if (text) {
+               len = strlen( text );
+               if (text[len-1] != '\n')
+                   i = 1;
+       }
+       v2 = ch_malloc( len+i+sizeof("Referral:") );
+       if (text) {
+               strcpy(v2, text);
+               if (i)
+                       v2[len++] = '\n';
+       }
+       strcpy( v2+len, "Referral:" );

        for( i=0; ref[i] != NULL; i++ ) {
                v2 = ch_realloc( v2, len + ref[i]->bv_len + 1 );
@@ -384,7 +394,7 @@
                        err = LDAP_NO_SUCH_OBJECT;
                } else if ( op->o_protocol < LDAP_VERSION3 ) {
                        err = LDAP_PARTIAL_RESULTS;
-                       tmp = v2ref( ref );
+                       tmp = v2ref( ref, text );
                        text = tmp;
                        ref = NULL;
                }
@@ -449,10 +459,9 @@
                        err = LDAP_PARTIAL_RESULTS;
                }

-               tmp = v2ref( refs );
+               tmp = v2ref( refs, text );
                text = tmp;
                refs = NULL;
-
        } else {
                /* don't send references in search results */
                assert( refs == NULL );