diff options
-rw-r--r-- | lib/util/nstring.c | 13 | ||||
-rw-r--r-- | lib/util/nstring.h | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/util/nstring.c b/lib/util/nstring.c index 48984309..8cff4d56 100644 --- a/lib/util/nstring.c +++ b/lib/util/nstring.c @@ -195,6 +195,19 @@ static char credits[] = "\n\ @(#)snprintf.c, v2.2: http://www.ijs.si/software/snprintf/\n"; +/* MacOS X before 10.7, for one, does not have strnlen */ +size_t +pm_strnlen(const char * const s, + size_t const maxlen) { + + unsigned int i; + + for (i = 0; i < maxlen && s[i]; ++i) {} + + return i; +} + + void pm_vsnprintf(char * const str, diff --git a/lib/util/nstring.h b/lib/util/nstring.h index 257b04b0..bded8417 100644 --- a/lib/util/nstring.h +++ b/lib/util/nstring.h @@ -150,6 +150,10 @@ strncaseeq(const char * const comparand, extern const char * const pm_strsol; +size_t +pm_strnlen(const char * const s, + size_t const maxlen); + int pm_snprintf(char * const dest, size_t const str_m, |