xref: /onnv-gate/usr/src/lib/libldap4/common/getentry.c (revision 3857:21b9b714e4ab)
10Sstevel@tonic-gate /*
2*3857Sstevel  * Portions Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
3*3857Sstevel  * Use is subject to license terms.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate 
60Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
70Sstevel@tonic-gate 
80Sstevel@tonic-gate /*
90Sstevel@tonic-gate  *  Copyright (c) 1990 Regents of the University of Michigan.
100Sstevel@tonic-gate  *  All rights reserved.
110Sstevel@tonic-gate  *
120Sstevel@tonic-gate  *  getentry.c
130Sstevel@tonic-gate  */
140Sstevel@tonic-gate 
150Sstevel@tonic-gate #ifndef lint
160Sstevel@tonic-gate static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
170Sstevel@tonic-gate #endif
180Sstevel@tonic-gate 
190Sstevel@tonic-gate #include <stdio.h>
200Sstevel@tonic-gate #include <ctype.h>
210Sstevel@tonic-gate #include <string.h>
220Sstevel@tonic-gate #ifdef MACOS
230Sstevel@tonic-gate #include <stdlib.h>
240Sstevel@tonic-gate #include "macos.h"
250Sstevel@tonic-gate #else /* MACOS */
260Sstevel@tonic-gate #if defined( DOS ) || defined( _WIN32 )
270Sstevel@tonic-gate #include <malloc.h>
280Sstevel@tonic-gate #include "msdos.h"
290Sstevel@tonic-gate #else /* DOS */
300Sstevel@tonic-gate #include <sys/types.h>
310Sstevel@tonic-gate #include <sys/socket.h>
320Sstevel@tonic-gate #endif /* DOS */
330Sstevel@tonic-gate #endif /* MACOS */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include "lber.h"
360Sstevel@tonic-gate #include "ldap.h"
370Sstevel@tonic-gate #include "ldap-private.h"
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /* ARGSUSED */
400Sstevel@tonic-gate LDAPMessage *
ldap_first_entry(LDAP * ld,LDAPMessage * res)410Sstevel@tonic-gate ldap_first_entry( LDAP *ld, LDAPMessage *res )
420Sstevel@tonic-gate {
430Sstevel@tonic-gate 	LDAPMessage *msg = res;
440Sstevel@tonic-gate 
450Sstevel@tonic-gate 	while ( msg != NULLMSG) {
460Sstevel@tonic-gate 		if (msg->lm_msgtype == LDAP_RES_SEARCH_ENTRY)
470Sstevel@tonic-gate 			break;
480Sstevel@tonic-gate 		msg = msg->lm_chain;
490Sstevel@tonic-gate 	}
500Sstevel@tonic-gate 	return (msg);
510Sstevel@tonic-gate }
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /* ARGSUSED */
ldap_next_entry(LDAP * ld,LDAPMessage * entry)540Sstevel@tonic-gate LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry )
550Sstevel@tonic-gate {
560Sstevel@tonic-gate 	LDAPMessage *msg;
570Sstevel@tonic-gate 
580Sstevel@tonic-gate 	if ( entry == NULLMSG)
590Sstevel@tonic-gate 		return( NULLMSG );
600Sstevel@tonic-gate 
610Sstevel@tonic-gate 	msg = entry->lm_chain;
620Sstevel@tonic-gate 	while(msg != NULLMSG){
630Sstevel@tonic-gate 		if (msg->lm_msgtype == LDAP_RES_SEARCH_ENTRY)
640Sstevel@tonic-gate 			break;
650Sstevel@tonic-gate 		msg = msg->lm_chain;
660Sstevel@tonic-gate 	}
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	return( msg );
690Sstevel@tonic-gate }
700Sstevel@tonic-gate 
710Sstevel@tonic-gate /* ARGSUSED */
720Sstevel@tonic-gate int
ldap_count_entries(LDAP * ld,LDAPMessage * res)730Sstevel@tonic-gate ldap_count_entries( LDAP *ld, LDAPMessage *res )
740Sstevel@tonic-gate {
750Sstevel@tonic-gate 	int	i;
760Sstevel@tonic-gate 
770Sstevel@tonic-gate 	for ( i = 0; res != NULL; res = res->lm_chain )
780Sstevel@tonic-gate 		if (res->lm_msgtype == LDAP_RES_SEARCH_ENTRY)
790Sstevel@tonic-gate 			i++;
800Sstevel@tonic-gate 
810Sstevel@tonic-gate 	return( i );
820Sstevel@tonic-gate }
83