diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-07 08:41:44 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-07 08:41:44 +0000 |
commit | f32b9a15950fd37aed5dae2ccf0a1e60a0fc78ee (patch) | |
tree | cb40f6f91b73ab642b4e3d649cbf9964cb32ba15 /nslcd/common.c | |
parent | c7f1fe832f3e46d7597da0a61f6fcb859b6c80df (diff) |
move some of the filter code to the database specific modules to be able to reduce complexity of ldap-nss.c later on
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@375 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nslcd/common.c')
-rw-r--r-- | nslcd/common.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/nslcd/common.c b/nslcd/common.c index d71b5b1..d2400a4 100644 --- a/nslcd/common.c +++ b/nslcd/common.c @@ -3,7 +3,7 @@ This file is part of the nss-ldapd library. Copyright (C) 2006 West Consulting - Copyright (C) 2006 Arthur de Jong + Copyright (C) 2006, 2007 Arthur de Jong This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,9 +23,27 @@ #include "config.h" +#include <stdio.h> +#include <stdarg.h> + #include "nslcd.h" #include "common.h" +/* simple wrapper around snptintf() to return non-0 in case + of any failure (but always keep string 0-terminated) */ +int mysnprintf(char *buffer,size_t buflen,const char *format, ...) +{ + int res; + va_list ap; + /* do snprintf */ + va_start(ap,format); + res=vsnprintf(buffer,buflen,format,ap); + /* NULL-terminate the string just to be on the safe side */ + buffer[buflen-1]='\0'; + /* check if the string was completely written */ + return ((res<0)||(((size_t)res)>=buflen)); +} + /* translates a nslcd return code (as defined in nslcd.h) to a nss code (as defined in nss.h) */ /* FIXME: this is a temporary hack, get rid of it */ |