diff options
Diffstat (limited to 'tools/include/nolibc')
-rw-r--r-- | tools/include/nolibc/string.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/include/nolibc/string.h b/tools/include/nolibc/string.h index 7c274efcdfae..c550c9ba8f4c 100644 --- a/tools/include/nolibc/string.h +++ b/tools/include/nolibc/string.h @@ -122,6 +122,28 @@ size_t nolibc_strlen(const char *str) }) static __attribute__((unused)) +size_t strlcat(char *dst, const char *src, size_t size) +{ + size_t len; + char c; + + for (len = 0; dst[len]; len++) + ; + + for (;;) { + c = *src; + if (len < size) + dst[len] = c; + if (!c) + break; + len++; + src++; + } + + return len; +} + +static __attribute__((unused)) size_t strlcpy(char *dst, const char *src, size_t size) { size_t len; @@ -139,6 +161,25 @@ size_t strlcpy(char *dst, const char *src, size_t size) } static __attribute__((unused)) +char *strncat(char *dst, const char *src, size_t size) +{ + char *orig = dst; + + while (*dst) + dst++; + + while (size && (*dst = *src)) { + src++; + dst++; + size--; + } + + *dst = 0; + return orig; +} + + +static __attribute__((unused)) char *strncpy(char *dst, const char *src, size_t size) { size_t len; |