summaryrefslogtreecommitdiff
path: root/nslcd/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'nslcd/common.h')
-rw-r--r--nslcd/common.h41
1 files changed, 22 insertions, 19 deletions
diff --git a/nslcd/common.h b/nslcd/common.h
index 89022b8..7951588 100644
--- a/nslcd/common.h
+++ b/nslcd/common.h
@@ -26,6 +26,7 @@
#include <errno.h>
#include <limits.h>
+#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif /* HAVE_STDINT_H */
@@ -47,20 +48,26 @@
stream */
#define ERROR_OUT_WRITEERROR(fp) \
- if (errno == EPIPE) \
- log_log(LOG_DEBUG, "error writing to client: %s", strerror(errno)); \
- else \
- log_log(LOG_WARNING, "error writing to client: %s", strerror(errno)); \
- return -1;
+ do { \
+ if (errno == EPIPE) \
+ log_log(LOG_DEBUG, "error writing to client: %s", strerror(errno)); \
+ else \
+ log_log(LOG_WARNING, "error writing to client: %s", strerror(errno)); \
+ return -1; \
+ } while(0)
#define ERROR_OUT_READERROR(fp) \
- log_log(LOG_WARNING, "error reading from client: %s", strerror(errno)); \
- return -1;
+ do { \
+ log_log(LOG_WARNING, "error reading from client: %s", strerror(errno)); \
+ return -1; \
+ } while(0)
#define ERROR_OUT_BUFERROR(fp) \
- log_log(LOG_ERR, "client supplied argument %d bytes too large", \
- tmpint32); \
- return -1;
+ do { \
+ log_log(LOG_ERR, "client supplied argument %d bytes too large", \
+ tmpint32); \
+ return -1; \
+ } while(0)
/* a simple wrapper around snprintf,
returns 0 if ok, -1 on error */
@@ -70,11 +77,6 @@ int mysnprintf(char *buffer, size_t buflen, const char *format, ...)
/* get a name of a signal with a given signal number */
const char *signame(int signum);
-/* return the fully qualified domain name of the current host
- the returned value does not need to be freed but is re-used for every
- call */
-MUST_USE const char *getfqdn(void);
-
/* This tries to get the user password attribute from the entry.
It will try to return an encrypted password as it is used in /etc/passwd,
/etc/group or /etc/shadow depending upon what is in the directory.
@@ -213,11 +215,12 @@ void shadow_init(void);
#define NSLCD_HANDLE_BODY(db, fn, fndecls, fnread, fncheck, tentry, fnsearch, fnwrite, fnclean) \
{ \
/* define common variables */ \
- int32_t tmpint32; \
tentry *entry = NULL; \
int rc = 1; \
fndecls \
tentry *search(int *rcp) { fnsearch } \
+ int write(TFILE *fp, tentry *entry) { fnwrite } \
+ void clean() { fnclean } \
/* read request parameters */ \
fnread \
/* validate request parameters */ \
@@ -228,8 +231,8 @@ void shadow_init(void);
/* go over results */ \
while ((entry = search(&rc)) != NULL) \
{ \
- if ( ({ fnwrite }) ) { \
- fnclean \
+ if ( write(fp, entry) ) { \
+ clean(); \
return -1; \
} \
} \
@@ -238,7 +241,7 @@ void shadow_init(void);
{ \
WRITE_INT32(fp, NSLCD_RESULT_END); \
} \
- fnclean \
+ clean(); \
return 0; \
}