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
|
|
|
|
1998-10-26 09:18:41 +08:00
|
|
|
#include "ldap-int.h"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* ARGSUSED */
|
|
|
|
LDAPMessage *
|
|
|
|
ldap_first_entry( LDAP *ld, LDAPMessage *chain )
|
|
|
|
{
|
1998-12-24 14:00:53 +08:00
|
|
|
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 */
|
1998-12-24 14:00:53 +08:00
|
|
|
LDAPMessage *
|
|
|
|
ldap_next_entry( LDAP *ld, LDAPMessage *entry )
|
1998-08-09 08:43:13 +08:00
|
|
|
{
|
1998-12-24 14:00:53 +08:00
|
|
|
if ( ld == NULL || entry == NULLMSG ) {
|
|
|
|
return NULLMSG;
|
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-12-24 14:00:53 +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;
|
|
|
|
|
1998-12-24 14:00:53 +08:00
|
|
|
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 );
|
|
|
|
}
|