[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gnulib] strlcpy & strlcat APIs
From: |
Mark D. Baushke |
Subject: |
[bug-gnulib] strlcpy & strlcat APIs |
Date: |
Wed, 02 Mar 2005 00:40:03 -0800 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Greetings,
I am curious to know if the GNULIB project would consider adopting
two more string manipulation functions: strlcpy() and strlcat().
For those who may not have heard of these functions previously,
here are some pointers to information concerning them:
http://www.openbsd.org/papers/strlcpy-paper.ps
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/strlcpy.c
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/strlcat.c
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/strlcpy.3
size_t
strlcpy(char *dst, const char *src, size_t size);
size_t
strlcat(char *dst, const char *src, size_t size);
The strlcpy function copies at most size-1 characters and
always NUL terminates (unless size == 0). The result is
strlen(src); if the returned value >= size), truncation
occured.
The strlcat function appends src to dst of size bytes. At
most size-1 characters will be copied. Always NUL terminates
(unless size <= strlen(dst)). The result is strlen(initial
dst) + strlen(src); if the returned value >= size,
truncation occured.
The license for these functions is not LGPL or GPL, but is
very open.
/*
* Copyright (c) 1998 Todd C. Miller <address@hidden>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
Thanks,
-- Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)
iD8DBQFCJXvi3x41pRYZE/gRAtTTAJ9EXaCPyQ+bHxd2evNPNszCyONQjwCbBS2K
0oBOtiOOZao77qUbT9nZPpk=
=FqRW
-----END PGP SIGNATURE-----
- [bug-gnulib] strlcpy & strlcat APIs,
Mark D. Baushke <=