Initial versions of functions to step through messages and references.

Fixed entry step through functions to check specifically fore entries.
This commit is contained in:
Kurt Zeilenga 1998-12-24 04:45:54 +00:00
parent 2eb55b91ff
commit a4822cf328
4 changed files with 147 additions and 12 deletions

View 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 \

View 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 );
}

View File

@ -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 );
}

View File

@ -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 );
}