3 * Miscellaneous string functions.
5 * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
6 * For copying and distribution information, please see the file
10 #include <mit-copyright.h>
18 * Trim whitespace off both ends of a string.
20 char *strtrim(char *save)
27 /* skip to end of string */
52 /* Modify a string for all of the letters to be uppercase. */
54 char *uppercase(char *s)
67 char *lowercase(char *s)
80 /* Copy as much of SRC will fit into a DST of size SIZE, always
81 * NUL-terminating. (Originally from OpenBSD.)
83 size_t strlcpy(char *dst, const char *src, size_t size)
85 size_t len = strlen(src);
88 memcpy(dst, src, len + 1);
91 memcpy(dst, src, size - 1);
99 /* Catenate as must of SRC will fit onto the end of DST, which is
100 * in a buffer of size SIZE, always NUL-terminating. (Originally
103 size_t strlcat(char *dst, const char *src, size_t size)
105 size_t dlen = strlen(dst);
106 size_t slen = strlen(src);
108 if (dlen + slen < size)
109 memcpy(dst + dlen, src, slen + 1);
112 memcpy(dst + dlen, src, size - dlen - 1);
113 dst[size - 1] = '\0';