diff options
author | Gerald Carter <jerry@samba.org> | 2002-06-17 18:36:36 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2002-06-17 18:36:36 +0000 |
commit | 1e6e5b299c235b513095a76a4cd9fffc41e8fc9c (patch) | |
tree | 9f741529073ad411cc7328334e26d3e35b1d33f1 /source/lib/util_str.c | |
parent | a11c5d7ad07d259d764aede4745d13f8163a8212 (diff) | |
download | samba-1e6e5b299c235b513095a76a4cd9fffc41e8fc9c.tar.gz samba-1e6e5b299c235b513095a76a4cd9fffc41e8fc9c.tar.xz samba-1e6e5b299c235b513095a76a4cd9fffc41e8fc9c.zip |
beginning to sync up for 2.2.5 release....
Diffstat (limited to 'source/lib/util_str.c')
-rw-r--r-- | source/lib/util_str.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/lib/util_str.c b/source/lib/util_str.c index a2b01a0fc7e..f44341b8dd1 100644 --- a/source/lib/util_str.c +++ b/source/lib/util_str.c @@ -1332,3 +1332,37 @@ char *binary_string(char *buf, int len) s[j] = 0; return s; } + +#ifndef HAVE_STRNLEN +/******************************************************************* + Some platforms don't have strnlen +********************************************************************/ + + size_t strnlen(const char *s, size_t n) +{ + int i; + for (i=0; s[i] && i<n; i++) + /* noop */ ; + return i; +} +#endif + +#ifndef HAVE_STRNDUP +/******************************************************************* + Some platforms don't have strndup. +********************************************************************/ + + char *strndup(const char *s, size_t n) +{ + char *ret; + + n = strnlen(s, n); + ret = malloc(n+1); + if (!ret) + return NULL; + memcpy(ret, s, n); + ret[n] = 0; + + return ret; +} +#endif |