From 5779d9e2ce26a8a9419ebf4fcf02f3571af34332 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Fri, 3 Nov 2006 10:06:54 +0000 Subject: make loop macros common, create macros for expanding {set,get,end}ent() functions and implement {set,get,end}aliasent git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/libnss_ldapd@62 ef36b2f9-881f-0410-afb5-c4e39611909c --- nss/passwd.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) (limited to 'nss/passwd.c') diff --git a/nss/passwd.c b/nss/passwd.c index 0557bc6..2ed200f 100644 --- a/nss/passwd.c +++ b/nss/passwd.c @@ -88,45 +88,17 @@ static __thread FILE *pwentfp; /* open a connection to the nslcd and write the request */ enum nss_status _nss_ldap_setpwent(void) { - int32_t tmpint32; - /* this is to satisfy our macros */ - int errnocp; - int *errnop; - errnop=&errnocp; - /* close the existing stream if it is still open */ - if (fp!=NULL) - _nss_ldap_endpwent(); - /* open a new stream and write the request */ - OPEN_SOCK(fp); - WRITE_REQUEST(fp,NSLCD_ACTION_PASSWD_ALL); - WRITE_FLUSH(fp); - /* read response header */ - READ_RESPONSEHEADER(fp,NSLCD_ACTION_PASSWD_ALL); - return NSS_STATUS_SUCCESS; + NSS_SETENT(NSLCD_ACTION_PASSWD_ALL); } /* read password data from an opened stream */ enum nss_status _nss_ldap_getpwent_r(struct passwd *result,char *buffer,size_t buflen,int *errnop) { - int32_t tmpint32; - size_t bufptr=0; - /* check that we have a valid file descriptor */ - if (fp==NULL) - { - *errnop=ENOENT; - return NSS_STATUS_UNAVAIL; - } - /* read a response */ - READ_RESPONSE_CODE(fp); - LDF_PASSWD; - return NSS_STATUS_SUCCESS; + NSS_GETENT(LDF_PASSWD); } /* close the stream opened with setpwent() above */ enum nss_status _nss_ldap_endpwent(void) { - if (fp==NULL) - return NSS_STATUS_SUCCESS; - fclose(fp); - return NSS_STATUS_SUCCESS; + NSS_ENDENT(); } -- cgit v1.2.3