1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * 3*0Sstevel@tonic-gate * Portions Copyright %G% Sun Microsystems, Inc. 4*0Sstevel@tonic-gate * All Rights Reserved 5*0Sstevel@tonic-gate * 6*0Sstevel@tonic-gate */ 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gate /* 11*0Sstevel@tonic-gate * Copyright (c) 1990 Regents of the University of Michigan. 12*0Sstevel@tonic-gate * All rights reserved. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * getentry.c 15*0Sstevel@tonic-gate */ 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gate #ifndef lint 18*0Sstevel@tonic-gate static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; 19*0Sstevel@tonic-gate #endif 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gate #include <stdio.h> 22*0Sstevel@tonic-gate #include <ctype.h> 23*0Sstevel@tonic-gate #include <string.h> 24*0Sstevel@tonic-gate #ifdef MACOS 25*0Sstevel@tonic-gate #include <stdlib.h> 26*0Sstevel@tonic-gate #include "macos.h" 27*0Sstevel@tonic-gate #else /* MACOS */ 28*0Sstevel@tonic-gate #if defined( DOS ) || defined( _WIN32 ) 29*0Sstevel@tonic-gate #include <malloc.h> 30*0Sstevel@tonic-gate #include "msdos.h" 31*0Sstevel@tonic-gate #else /* DOS */ 32*0Sstevel@tonic-gate #include <sys/types.h> 33*0Sstevel@tonic-gate #include <sys/socket.h> 34*0Sstevel@tonic-gate #endif /* DOS */ 35*0Sstevel@tonic-gate #endif /* MACOS */ 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #include "lber.h" 38*0Sstevel@tonic-gate #include "ldap.h" 39*0Sstevel@tonic-gate #include "ldap-private.h" 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate /* ARGSUSED */ 42*0Sstevel@tonic-gate LDAPMessage * 43*0Sstevel@tonic-gate ldap_first_entry( LDAP *ld, LDAPMessage *res ) 44*0Sstevel@tonic-gate { 45*0Sstevel@tonic-gate LDAPMessage *msg = res; 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate while ( msg != NULLMSG) { 48*0Sstevel@tonic-gate if (msg->lm_msgtype == LDAP_RES_SEARCH_ENTRY) 49*0Sstevel@tonic-gate break; 50*0Sstevel@tonic-gate msg = msg->lm_chain; 51*0Sstevel@tonic-gate } 52*0Sstevel@tonic-gate return (msg); 53*0Sstevel@tonic-gate } 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate /* ARGSUSED */ 56*0Sstevel@tonic-gate LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry ) 57*0Sstevel@tonic-gate { 58*0Sstevel@tonic-gate LDAPMessage *msg; 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate if ( entry == NULLMSG) 61*0Sstevel@tonic-gate return( NULLMSG ); 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate msg = entry->lm_chain; 64*0Sstevel@tonic-gate while(msg != NULLMSG){ 65*0Sstevel@tonic-gate if (msg->lm_msgtype == LDAP_RES_SEARCH_ENTRY) 66*0Sstevel@tonic-gate break; 67*0Sstevel@tonic-gate msg = msg->lm_chain; 68*0Sstevel@tonic-gate } 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate return( msg ); 71*0Sstevel@tonic-gate } 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gate /* ARGSUSED */ 74*0Sstevel@tonic-gate int 75*0Sstevel@tonic-gate ldap_count_entries( LDAP *ld, LDAPMessage *res ) 76*0Sstevel@tonic-gate { 77*0Sstevel@tonic-gate int i; 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate for ( i = 0; res != NULL; res = res->lm_chain ) 80*0Sstevel@tonic-gate if (res->lm_msgtype == LDAP_RES_SEARCH_ENTRY) 81*0Sstevel@tonic-gate i++; 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate return( i ); 84*0Sstevel@tonic-gate } 85