From 3cb98dee9067372756964f461eb2c931a1c75138 Mon Sep 17 00:00:00 2001 From: ajs Date: Sat, 2 Apr 2005 16:01:05 +0000 Subject: 2005-04-02 Andrew J. Schorr * configure.ac: Add strnlen to AC_CHECK_FUNCS. * zebra.h: Should include str.h to pick up missing functions. * str.h: Declare strnlen if needed. * str.c: Do not include str.h since zebra.h now includes it. (strnlen) New function. --- lib/str.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/str.c') diff --git a/lib/str.c b/lib/str.c index 797e9b87..18a5d8ed 100644 --- a/lib/str.c +++ b/lib/str.c @@ -8,8 +8,6 @@ #include -#include "str.h" - #ifndef HAVE_SNPRINTF /* * snprint() is a real basic wrapper around the standard sprintf() @@ -60,3 +58,12 @@ strlcat(char *dst, const char *src, size_t size) return (strlen(dst)); } #endif + +#ifndef HAVE_STRNLEN +size_t +strnlen(const char *s, size_t maxlen) +{ + const char *p; + return (p = (const char *)memchr(s, '\0', maxlen)) ? (size_t)(p-s) : maxlen; +} +#endif -- cgit v1.2.1