From 937479fc3ba22595d354ec9fa54cdb525d1f4c41 Mon Sep 17 00:00:00 2001 From: kleink Date: Wed, 17 Apr 2002 16:23:08 +0000 Subject: [PATCH] Need internal names for strlcat() and strlcpy(). --- lib/libc/include/namespace.h | 4 ++- lib/libc/string/Makefile.inc | 5 +++- lib/libc/string/_strlcat.c | 49 ++++++++++++++++++++++++++++++++++++ lib/libc/string/_strlcpy.c | 49 ++++++++++++++++++++++++++++++++++++ lib/libc/string/strlcat.c | 14 +++++++++-- lib/libc/string/strlcpy.c | 14 +++++++++-- 6 files changed, 129 insertions(+), 6 deletions(-) create mode 100644 lib/libc/string/_strlcat.c create mode 100644 lib/libc/string/_strlcpy.c diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h index ffd510f36e7a..081eca149281 100644 --- a/lib/libc/include/namespace.h +++ b/lib/libc/include/namespace.h @@ -1,4 +1,4 @@ -/* $NetBSD: namespace.h,v 1.70 2002/01/24 02:46:34 lukem Exp $ */ +/* $NetBSD: namespace.h,v 1.71 2002/04/17 16:23:08 kleink Exp $ */ /*- * Copyright (c) 1997-2002 The NetBSD Foundation, Inc. @@ -52,6 +52,8 @@ #define inet_pton _inet_pton #define pipe _pipe #define sbrk _sbrk +#define strlcat _strlcat +#define strlcpy _strlcpy #define strtoimax _strtoimax #define strtoll _strtoll #define strtoull _strtoull diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc index 9e44348b3e25..4423021e489e 100644 --- a/lib/libc/string/Makefile.inc +++ b/lib/libc/string/Makefile.inc @@ -1,5 +1,5 @@ # from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $NetBSD: Makefile.inc,v 1.51 2000/12/24 03:45:04 itojun Exp $ +# $NetBSD: Makefile.inc,v 1.52 2002/04/17 16:23:09 kleink Exp $ # string sources .PATH: ${ARCHDIR}/string ${.CURDIR}/string @@ -14,6 +14,9 @@ SRCS+= wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslcat.c wcslcpy.c \ wcsncmp.c wcsncpy.c wcspbrk.c wcsrchr.c wcsspn.c wcsstr.c wcswidth.c \ wmemchr.c wmemcmp.c wmemcpy.c wmemmove.c wmemset.c +# namespace protection wrappers +SRCS+= _strlcat.c _strlcpy.c + # machine-dependent net sources # m-d Makefile.inc must include sources for: # bcmp() bcopy() bzero() ffs() index() memchr() memcmp() memset() diff --git a/lib/libc/string/_strlcat.c b/lib/libc/string/_strlcat.c new file mode 100644 index 000000000000..c71699d57497 --- /dev/null +++ b/lib/libc/string/_strlcat.c @@ -0,0 +1,49 @@ +/* $NetBSD: _strlcat.c,v 1.1 2002/04/17 16:23:09 kleink Exp $ */ + +/* + * Copyright (c) 1996 Christos Zoulas. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include + +#ifdef __indr_reference +__indr_reference(_strlcat, strlcat) +#else + +#include +size_t _strlcat __P((char *, const char *, size_t)); /* XXX */ + +size_t +strlcat(dst, src, siz) + char *dst; + const char *src; + size_t siz; +{ + + return _strlcat(dst, src, siz); +} +#endif diff --git a/lib/libc/string/_strlcpy.c b/lib/libc/string/_strlcpy.c new file mode 100644 index 000000000000..9773fe68aafb --- /dev/null +++ b/lib/libc/string/_strlcpy.c @@ -0,0 +1,49 @@ +/* $NetBSD: _strlcpy.c,v 1.1 2002/04/17 16:23:09 kleink Exp $ */ + +/* + * Copyright (c) 1996 Christos Zoulas. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include + +#ifdef __indr_reference +__indr_reference(_strlcpy, strlcpy) +#else + +#include +size_t _strlcpy __P((char *, const char *, size_t)); /* XXX */ + +size_t +strlcpy(dst, src, siz) + char *dst; + const char *src; + size_t siz; +{ + + return _strlcpy(dst, src, siz); +} +#endif diff --git a/lib/libc/string/strlcat.c b/lib/libc/string/strlcat.c index db46aca8e185..16192b039cbe 100644 --- a/lib/libc/string/strlcat.c +++ b/lib/libc/string/strlcat.c @@ -1,4 +1,4 @@ -/* $NetBSD: strlcat.c,v 1.11 2002/01/31 22:43:40 tv Exp $ */ +/* $NetBSD: strlcat.c,v 1.12 2002/04/17 16:23:09 kleink Exp $ */ /* $OpenBSD: strlcat.c,v 1.4 2001/01/12 22:55:23 millert Exp $ */ /* @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: strlcat.c,v 1.11 2002/01/31 22:43:40 tv Exp $"); +__RCSID("$NetBSD: strlcat.c,v 1.12 2002/04/17 16:23:09 kleink Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -38,6 +38,12 @@ __RCSID("$NetBSD: strlcat.c,v 1.11 2002/01/31 22:43:40 tv Exp $"); #include #include +#ifdef _LIBC +# ifdef __weak_alias +__weak_alias(strlcat, _strlcat) +# endif +#endif + #if !HAVE_STRLCAT /* * Appends src to string dst of size siz (unlike strncat, siz is the @@ -47,7 +53,11 @@ __RCSID("$NetBSD: strlcat.c,v 1.11 2002/01/31 22:43:40 tv Exp $"); * If retval >= siz, truncation occurred. */ size_t +#ifdef _LIBC +_strlcat(dst, src, siz) +#else strlcat(dst, src, siz) +#endif char *dst; const char *src; size_t siz; diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c index 7edff3e52d9b..680aba34d558 100644 --- a/lib/libc/string/strlcpy.c +++ b/lib/libc/string/strlcpy.c @@ -1,4 +1,4 @@ -/* $NetBSD: strlcpy.c,v 1.9 2002/01/31 22:43:41 tv Exp $ */ +/* $NetBSD: strlcpy.c,v 1.10 2002/04/17 16:23:09 kleink Exp $ */ /* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */ /* @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: strlcpy.c,v 1.9 2002/01/31 22:43:41 tv Exp $"); +__RCSID("$NetBSD: strlcpy.c,v 1.10 2002/04/17 16:23:09 kleink Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -38,6 +38,12 @@ __RCSID("$NetBSD: strlcpy.c,v 1.9 2002/01/31 22:43:41 tv Exp $"); #include #include +#ifdef _LIBC +# ifdef __weak_alias +__weak_alias(strlcpy, _strlcpy) +# endif +#endif + #if !HAVE_STRLCPY /* * Copy src to string dst of size siz. At most siz-1 characters @@ -45,7 +51,11 @@ __RCSID("$NetBSD: strlcpy.c,v 1.9 2002/01/31 22:43:41 tv Exp $"); * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t +#ifdef _LIBC +_strlcpy(dst, src, siz) +#else strlcpy(dst, src, siz) +#endif char *dst; const char *src; size_t siz;