From fe8fb00dd57714528535de7e3a8d42f64e7a79aa Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Tue, 31 Oct 2006 12:17:39 +0000 Subject: clear up protocol macros while implementing getpwuid() and {set,get,end}pwent() functions (last not yet on NSS side) git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/libnss_ldapd@34 ef36b2f9-881f-0410-afb5-c4e39611909c --- nslcd-client.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'nslcd-client.h') diff --git a/nslcd-client.h b/nslcd-client.h index 1e5d46d..ca9273b 100644 --- a/nslcd-client.h +++ b/nslcd-client.h @@ -26,18 +26,32 @@ #include #include "nslcd.h" - -/* Extra request results. */ -#define NSLCD_RS_SMALLBUF 100 /* buffer too small */ +#include "nslcd-common.h" /* returns a socket to the server or NULL on error (see errno), socket should be closed with fclose() */ FILE *nslcd_client_open(void); -/* write a request message, returns <0 in case of errors */ -int nslcd_client_writerequest(FILE *fp,int type,const char *name,size_t count); - -/* read a response message, return a NSLCD_RS_* status */ -int nslcd_client_readresponse(FILE *fp,int type); +/* open a client socket */ +#define OPEN_SOCK(fp) \ + if ((fp=nslcd_client_open())==NULL) \ + { ERROR_OUT_OPENERROR } + +#define WRITE_REQUEST(fp,req) \ + WRITE_INT32(fp,NSLCD_VERSION) \ + WRITE_INT32(fp,req) + +#define READ_RESPONSEHEADER(fp,req) \ + READ_TYPE(fp,tmpint32,int32_t); \ + if (tmpint32!=NSLCD_VERSION) \ + { ERROR_OUT_READERROR(fp) } \ + READ_TYPE(fp,tmpint32,int32_t); \ + if (tmpint32!=(req)) \ + { ERROR_OUT_READERROR(fp) } + +#define READ_RESPONSE(fp) \ + READ_TYPE(fp,tmpint32,int32_t); \ + if (tmpint32!=NSLCD_RS_SUCCESS) \ + { ERROR_OUT_NOSUCCESS(fp,tmpint32) } #endif /* not _NSLCD_CLIENT_H */ -- cgit v1.2.3