summaryrefslogtreecommitdiff
path: root/usr/src/lib/libldap4/common/getentry.c
blob: 346f23e9a840ce21a736917ebc2467f3d83c3304 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Portions Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

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