diff options
Diffstat (limited to 'usr/src/lib/libldap4/common/getentry.c')
-rw-r--r-- | usr/src/lib/libldap4/common/getentry.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/usr/src/lib/libldap4/common/getentry.c b/usr/src/lib/libldap4/common/getentry.c new file mode 100644 index 0000000000..078e8aaa80 --- /dev/null +++ b/usr/src/lib/libldap4/common/getentry.c @@ -0,0 +1,84 @@ +/* + * + * Portions Copyright %G% Sun Microsystems, Inc. + * All Rights Reserved + * + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * Copyright (c) 1990 Regents of the University of Michigan. + * All rights reserved. + * + * getentry.c + */ + +#ifndef lint +static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; +#endif + +#include <stdio.h> +#include <ctype.h> +#include <string.h> +#ifdef MACOS +#include <stdlib.h> +#include "macos.h" +#else /* MACOS */ +#if defined( DOS ) || defined( _WIN32 ) +#include <malloc.h> +#include "msdos.h" +#else /* DOS */ +#include <sys/types.h> +#include <sys/socket.h> +#endif /* DOS */ +#endif /* MACOS */ + +#include "lber.h" +#include "ldap.h" +#include "ldap-private.h" + +/* ARGSUSED */ +LDAPMessage * +ldap_first_entry( LDAP *ld, LDAPMessage *res ) +{ + LDAPMessage *msg = res; + + while ( msg != NULLMSG) { + if (msg->lm_msgtype == LDAP_RES_SEARCH_ENTRY) + break; + msg = msg->lm_chain; + } + return (msg); +} + +/* ARGSUSED */ +LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry ) +{ + LDAPMessage *msg; + + if ( entry == NULLMSG) + return( NULLMSG ); + + msg = entry->lm_chain; + while(msg != NULLMSG){ + if (msg->lm_msgtype == LDAP_RES_SEARCH_ENTRY) + break; + msg = msg->lm_chain; + } + + return( msg ); +} + +/* ARGSUSED */ +int +ldap_count_entries( LDAP *ld, LDAPMessage *res ) +{ + int i; + + for ( i = 0; res != NULL; res = res->lm_chain ) + if (res->lm_msgtype == LDAP_RES_SEARCH_ENTRY) + i++; + + return( i ); +} |