| 1 |
/* $FreeWRT$ */ |
/* $MirOS: src/lib/libc/string/strlfun.c,v 1.14 2007/01/07 02:11:40 tg Exp $ */ |
|
/* $MirOS: src/lib/libc/string/strlfun.c,v 1.10 2006/11/08 23:18:04 tg Exp $ */ |
|
| 2 |
|
|
| 3 |
/*- |
/*- |
| 4 |
* Copyright (c) 2006 |
* Copyright (c) 2006 |
| 5 |
* Thorsten Glaser <tg@mirbsd.de> |
* Thorsten Glaser <tg@mirbsd.de> |
| 6 |
* |
* |
| 7 |
* Licensee is hereby permitted to deal in this work without restric- |
* Provided that these terms and disclaimer and all copyright notices |
| 8 |
* tion, including unlimited rights to use, publicly perform, modify, |
* are retained or reproduced in an accompanying document, permission |
| 9 |
* merge, distribute, sell, give away or sublicence, provided all co- |
* is granted to deal in this work without restriction, including un- |
| 10 |
* pyright notices above, these terms and the disclaimer are retained |
* limited rights to use, publicly perform, distribute, sell, modify, |
| 11 |
* in all redistributions or reproduced in accompanying documentation |
* merge, give away, or sublicence. |
|
* or other materials provided with binary redistributions. |
|
| 12 |
* |
* |
| 13 |
* Licensor offers the work "AS IS" and WITHOUT WARRANTY of any kind, |
* This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to |
| 14 |
* express, or implied, to the maximum extent permitted by applicable |
* the utmost extent permitted by applicable law, neither express nor |
| 15 |
* law, without malicious intent or gross negligence; in no event may |
* implied; without malicious intent or gross negligence. In no event |
| 16 |
* licensor, an author or contributor be held liable for any indirect |
* may a licensor, author or contributor be held liable for indirect, |
| 17 |
* or other damage, or direct damage except proven a consequence of a |
* direct, other damage, loss, or other issues arising in any way out |
| 18 |
* direct error of said person and intended use of this work, loss or |
* of dealing in the work, even if advised of the possibility of such |
| 19 |
* other issues arising in any way out of its use, even if advised of |
* damage or existence of a defect, except proven that it results out |
| 20 |
* the possibility of such damage or existence of a defect. |
* of said person's immediate fault when using the work as intended. |
| 21 |
*- |
*- |
| 22 |
* The strlcat() code below has been written by Thorsten Glaser. Bodo |
* The strlcat() code below has been written by Thorsten Glaser. Bodo |
| 23 |
* Eggert suggested optimising the strlcpy() code, originally written |
* Eggert suggested optimising the strlcpy() code, originally written |
| 24 |
* by Todd C. Miller (see below), which was carried out by Th. Glaser |
* by Todd C. Miller (see below), which was carried out by Th. Glaser |
| 25 |
* as well as writing wcslcat() and wcslcpy() equivalents. |
* as well as merging this code with strxfrm() for ISO-10646-only sy- |
| 26 |
|
* stems and writing wcslcat(), wcslcpy() and wcsxfrm() equivalents. |
| 27 |
*/ |
*/ |
| 28 |
|
|
| 29 |
|
#ifdef STRXFRM |
| 30 |
|
#undef HAVE_STRLCPY |
| 31 |
|
#undef HAVE_STRLCAT |
| 32 |
|
#define HAVE_STRLCPY 0 |
| 33 |
|
#define HAVE_STRLCAT 1 |
| 34 |
|
#define strlcpy strxfrm |
| 35 |
|
#endif |
| 36 |
|
|
| 37 |
#include <sys/types.h> |
#include <sys/types.h> |
| 38 |
#if defined(_KERNEL) || defined(_STANDALONE) |
#if defined(_KERNEL) || defined(_STANDALONE) |
| 39 |
#include <lib/libkern/libkern.h> |
#include <lib/libkern/libkern.h> |
| 78 |
#define __predict_false(exp) ((exp) != 0) |
#define __predict_false(exp) ((exp) != 0) |
| 79 |
#endif |
#endif |
| 80 |
|
|
| 81 |
__RCSID("$MirOS: src/lib/libc/string/strlfun.c,v 1.10 2006/11/08 23:18:04 tg Exp $"); |
#if !defined(_KERNEL) && !defined(_STANDALONE) |
| 82 |
|
__RCSID("$MirOS: src/lib/libc/string/strlfun.c,v 1.14 2007/01/07 02:11:40 tg Exp $"); |
| 83 |
|
#endif |
| 84 |
|
|
| 85 |
|
#ifndef _STRLCPY_DEFNS |
| 86 |
size_t strlcat(char *, const char *, size_t); |
size_t strlcat(char *, const char *, size_t); |
| 87 |
size_t strlcpy(char *, const char *, size_t); |
size_t strlcpy(char *, const char *, size_t); |
| 88 |
|
#endif |
| 89 |
|
|
| 90 |
#if !defined(HAVE_STRLCAT) || (HAVE_STRLCAT == 0) |
#if !defined(HAVE_STRLCAT) || (HAVE_STRLCAT == 0) |
| 91 |
/* |
/* |