/* * Distributed under the terms of the GNU GPL version 2. */ #include #include #ifndef __HAVE_ARCH_STRCSPN /** * strcspn - Calculate the length of the initial substring of @s which does not contain letters in @reject * @s: The string to be searched * @reject: The string to avoid */ size_t strcspn(const char *s, const char *reject) { const char *p; const char *r; size_t count = 0; for (p = s; *p != '\0'; ++p) { for (r = reject; *r != '\0'; ++r) { if (*p == *r) return count; } ++count; } return count; } EXPORT_SYMBOL(strcspn); /** * strlcpy - Copy a %NUL terminated string into a sized buffer * @dest: Where to copy the string to * @src: Where to copy the string from * @size: size of destination buffer * * Compatible with *BSD: the result is always a valid * NUL-terminated string that fits in the buffer (unless, * of course, the buffer size is zero). It does not pad * out the result like strncpy() does. */ size_t strlcpy(char *dest, const char *src, size_t size) { size_t ret = strlen(src); if (size) { size_t len = (ret >= size) ? size - 1 : ret; memcpy(dest, src, len); dest[len] = '\0'; } return ret; } EXPORT_SYMBOL(strlcpy); #endif