openldap/libraries/libldap/getentry.c

76 lines
1.2 KiB
C
Raw Normal View History

1998-08-09 08:43:13 +08:00
/*
* Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
* getentry.c
*/
1998-10-25 09:41:42 +08:00
#include "portable.h"
1998-08-09 08:43:13 +08:00
#ifndef lint
static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
#endif
#include <stdio.h>
#include <stdlib.h>
1998-10-25 09:41:42 +08:00
#include <ac/ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
1998-08-09 08:43:13 +08:00
#include "ldap-int.h"
1998-08-09 08:43:13 +08:00
/* ARGSUSED */
LDAPMessage *
ldap_first_entry( LDAP *ld, LDAPMessage *chain )
{
if( ld == NULL || chain == NULLMSG ) {
return NULLMSG;
}
return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY
? chain
: ldap_next_entry( ld, chain );
1998-08-09 08:43:13 +08:00
}
/* ARGSUSED */
LDAPMessage *
ldap_next_entry( LDAP *ld, LDAPMessage *entry )
1998-08-09 08:43:13 +08:00
{
if ( ld == NULL || entry == NULLMSG ) {
return NULLMSG;
}
1998-08-09 08:43:13 +08:00
for (
entry = entry->lm_chain;
entry != NULLMSG;
entry = entry->lm_chain )
{
if( entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
return( entry );
}
}
return( NULLMSG );
1998-08-09 08:43:13 +08:00
}
/* ARGSUSED */
int
ldap_count_entries( 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_ENTRY ) {
i++;
}
}
1998-08-09 08:43:13 +08:00
return( i );
}