]> git.sur5r.net Git - openldap/commitdiff
Initial versions of functions to step through messages and references.
authorKurt Zeilenga <kurt@openldap.org>
Thu, 24 Dec 1998 04:45:54 +0000 (04:45 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 24 Dec 1998 04:45:54 +0000 (04:45 +0000)
Fixed entry step through functions to check specifically fore entries.

libraries/libldap/Makefile.in
libraries/libldap/getentry.c
libraries/libldap/messages.c [new file with mode: 0644]
libraries/libldap/references.c [new file with mode: 0644]

index cb14f22a0c20e11c6b3afc10dc5f17555684a679..0e57ee5d956cab009c92cd69caa2c9a71d6bb115 100644 (file)
@@ -6,14 +6,16 @@ XLIBRARY = ../libldap.a
 
 PROGRAMS = apitest ltest ttest
 
-SRCS   = bind.c controls.c open.c result.c error.c compare.c search.c \
+SRCS   = bind.c open.c result.c error.c compare.c search.c \
+       controls.c messages.c references.c \
        modify.c add.c modrdn.c delete.c abandon.c ufn.c cache.c \
        getfilter.c sbind.c kbind.c unbind.c friendly.c cldap.c \
        free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \
        getdn.c getentry.c getattr.c getvalues.c addentry.c \
        request.c getdxbyname.c os-ip.c url.c charset.c \
        init.c options.c strdup.c util-int.c
-OBJS   = bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \
+OBJS   = bind.lo open.lo result.lo error.lo compare.lo search.lo \
+       controls.lo messages.lo references.lo \
        modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \
        getfilter.lo sbind.lo kbind.lo unbind.lo friendly.lo cldap.lo \
        free.lo disptmpl.lo srchpref.lo dsparse.lo tmplout.lo sort.lo \
index 01d8f2c1250791f1d84c10ebdebec0d5a8a2ef93..f3c0b8fa5e1e112d8be0cdfc9175d8da699e0e75 100644 (file)
@@ -25,18 +25,30 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of
 LDAPMessage *
 ldap_first_entry( LDAP *ld, LDAPMessage *chain )
 {
-       return( chain == NULLMSG || chain->lm_msgtype == LDAP_RES_SEARCH_RESULT
-           ? NULLMSG : chain );
+       if( ld == NULL || chain == NULLMSG ) {
+               return NULLMSG;
+       }
+
+       return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY
+               ? chain
+               : ldap_next_entry( ld, chain );
 }
 
 /* ARGSUSED */
-LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry )
+LDAPMessage *
+ldap_next_entry( LDAP *ld, LDAPMessage *entry )
 {
-       if ( entry == NULLMSG || entry->lm_chain == NULLMSG
-           || entry->lm_chain->lm_msgtype == LDAP_RES_SEARCH_RESULT )
-               return( NULLMSG );
+       if ( ld == NULL || entry == NULLMSG ) {
+               return NULLMSG;
+       }
 
-       return( entry->lm_chain );
+       for ( ; entry != NULLMSG; entry = entry->lm_chain ) {
+               if( entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
+                       return( entry );
+               }
+       }
+
+       return( NULLMSG );
 }
 
 /* ARGSUSED */
@@ -45,9 +57,15 @@ ldap_count_entries( LDAP *ld, LDAPMessage *chain )
 {
        int     i;
 
-       for ( i = 0; chain != NULL && chain->lm_msgtype
-           != LDAP_RES_SEARCH_RESULT; chain = chain->lm_chain )
-               i++;
+       if ( ld == NULL ) {
+               return -1;
+       }
+
+       for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
+               if( chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
+                       i++;
+               }
+       }
 
        return( i );
 }
diff --git a/libraries/libldap/messages.c b/libraries/libldap/messages.c
new file mode 100644 (file)
index 0000000..87aebdc
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  messages.c
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+/* ARGSUSED */
+LDAPMessage *
+ldap_first_message( LDAP *ld, LDAPMessage *chain )
+{
+       return( ld == NULL || chain == NULLMSG
+                       ? NULLMSG : chain );
+}
+
+/* ARGSUSED */
+LDAPMessage *
+ldap_next_message( LDAP *ld, LDAPMessage *msg )
+{
+       if ( ld == NULL || msg == NULLMSG || msg->lm_chain == NULL ) {
+               return NULLMSG;
+       }
+
+       return( msg->lm_chain );
+}
+
+/* ARGSUSED */
+int
+ldap_count_messages( LDAP *ld, LDAPMessage *chain )
+{
+       int     i;
+
+       if ( ld == NULL ) {
+               return -1;
+       }
+
+       for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
+               i++;
+       }
+
+       return( i );
+}
diff --git a/libraries/libldap/references.c b/libraries/libldap/references.c
new file mode 100644 (file)
index 0000000..569e209
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *  references.c
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+/* ARGSUSED */
+LDAPMessage *
+ldap_first_reference( LDAP *ld, LDAPMessage *chain )
+{
+       if ( ld == NULL || chain == NULLMSG ) {
+               return NULLMSG;
+       }
+
+       return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE
+               ? chain
+               : ldap_next_reference( ld, chain );
+}
+
+/* ARGSUSED */
+LDAPMessage *
+ldap_next_reference( LDAP *ld, LDAPMessage *ref )
+{
+       if ( ld == NULL || ref == NULLMSG ) {
+               return NULLMSG;
+       }
+
+       for ( ; ref != NULLMSG; ref = ref->lm_chain ) {
+               if( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
+                       return( ref );
+               }
+       }
+
+       return( NULLMSG );
+}
+
+/* ARGSUSED */
+int
+ldap_count_references( LDAP *ld, LDAPMessage *chain )
+{
+       int     i;
+
+       if ( ld == NULL ) {
+               return -1;
+       }
+
+       for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
+               if( chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
+                       i++;
+               }
+       }
+
+       return( i );
+}