diff options
author | hpa <hpa> | 2004-12-21 04:57:40 +0000 |
---|---|---|
committer | hpa <hpa> | 2004-12-21 04:57:40 +0000 |
commit | abf1b805231a7cd01a249c67413e7c1e3152b72e (patch) | |
tree | b979617c1dc3b1bd0d49502b5890d0eb32635f52 | |
parent | d4318da1d4c6a337264b1c5248601f35e6e6eb9e (diff) | |
download | syslinux-abf1b805231a7cd01a249c67413e7c1e3152b72e.tar.gz |
Add strlcpy(), strlcat()
-rw-r--r-- | com32/lib/strlcat.c | 31 | ||||
-rw-r--r-- | com32/lib/strlcpy.c | 26 |
2 files changed, 57 insertions, 0 deletions
diff --git a/com32/lib/strlcat.c b/com32/lib/strlcat.c new file mode 100644 index 00000000..6111445f --- /dev/null +++ b/com32/lib/strlcat.c @@ -0,0 +1,31 @@ +/* + * strlcat.c + */ + +#include <string.h> +#include <klibc/compiler.h> + +size_t strlcat(char *dst, const char *src, size_t size) +{ + size_t bytes = 0; + char *q = dst; + const char *p = src; + char ch; + + while ( bytes < size && *q ) { + q++; + bytes++; + } + + while ( (ch = *p++) ) { + if ( bytes < size ) + *q++ = ch; + + bytes++; + } + + *q = '\0'; + return bytes; +} + + diff --git a/com32/lib/strlcpy.c b/com32/lib/strlcpy.c new file mode 100644 index 00000000..eb384c98 --- /dev/null +++ b/com32/lib/strlcpy.c @@ -0,0 +1,26 @@ +/* + * strlcpy.c + */ + +#include <string.h> +#include <klibc/compiler.h> + +size_t strlcpy(char *dst, const char *src, size_t size) +{ + size_t bytes = 0; + char *q = dst; + const char *p = src; + char ch; + + while ( (ch = *p++) ) { + if ( bytes < size ) + *q++ = ch; + + bytes++; + } + + *q = '\0'; + return bytes; +} + + |