]> git.sur5r.net Git - openldap/blob - libraries/libldap/getentry.c
Initial revision
[openldap] / libraries / libldap / getentry.c
1 /*
2  *  Copyright (c) 1990 Regents of the University of Michigan.
3  *  All rights reserved.
4  *
5  *  getentry.c
6  */
7
8 #ifndef lint 
9 static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
10 #endif
11
12 #include <stdio.h>
13 #include <ctype.h>
14 #include <string.h>
15 #ifdef MACOS
16 #include <stdlib.h>
17 #include "macos.h"
18 #else /* MACOS */
19 #if defined( DOS ) || defined( _WIN32 )
20 #include <malloc.h>
21 #include "msdos.h"
22 #else /* DOS */
23 #include <sys/types.h>
24 #include <sys/socket.h>
25 #endif /* DOS */
26 #endif /* MACOS */
27
28 #include "lber.h"
29 #include "ldap.h"
30
31 /* ARGSUSED */
32 LDAPMessage *
33 ldap_first_entry( LDAP *ld, LDAPMessage *chain )
34 {
35         return( chain == NULLMSG || chain->lm_msgtype == LDAP_RES_SEARCH_RESULT
36             ? NULLMSG : chain );
37 }
38
39 /* ARGSUSED */
40 LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry )
41 {
42         if ( entry == NULLMSG || entry->lm_chain == NULLMSG
43             || entry->lm_chain->lm_msgtype == LDAP_RES_SEARCH_RESULT )
44                 return( NULLMSG );
45
46         return( entry->lm_chain );
47 }
48
49 /* ARGSUSED */
50 int
51 ldap_count_entries( LDAP *ld, LDAPMessage *chain )
52 {
53         int     i;
54
55         for ( i = 0; chain != NULL && chain->lm_msgtype
56             != LDAP_RES_SEARCH_RESULT; chain = chain->lm_chain )
57                 i++;
58
59         return( i );
60 }