4 * Copyright (C) 1991, 1992 Linus Torvalds
8 * stupid library routines.. The optimized versions should generally be found
9 * as inline code in <asm-xx/string.h>
11 * These are buggy as well..
13 * * Fri Jun 25 1999, Ingo Oeser <ioe@informatik.tu-chemnitz.de>
14 * - Added strsep() which will replace strtok() soon (because strsep() is
15 * reentrant and should be faster). Use only strsep() in new code, please.
17 * * Sat Feb 09 2002, Jason Thomas <jason@topic.com.au>,
18 * Matthew Hawkins <matt@mh.dropbear.id.au>
19 * - Kissed strtok() goodbye
22 #include <linux/types.h>
23 #include <linux/string.h>
24 #include <linux/ctype.h>
25 #include <linux/kernel.h>
26 #include <linux/export.h>
27 #include <linux/bug.h>
28 #include <linux/errno.h>
33 * skip_spaces - Removes leading whitespace from @str.
34 * @str: The string to be stripped.
36 * Returns a pointer to the first non-whitespace character in @str.
38 char *skip_spaces(const char *str)
46 * strim - Removes leading and trailing whitespace from @s.
47 * @s: The string to be stripped.
49 * Note that the first trailing whitespace is replaced with a %NUL-terminator
50 * in the given string @s. Returns a pointer to the first non-whitespace
63 while (end >= s && isspace(*end))
67 return skip_spaces(s);
71 * strlcpy - Copy a C-string into a sized buffer
72 * @dest: Where to copy the string to
73 * @src: Where to copy the string from
74 * @size: size of destination buffer
76 * Compatible with *BSD: the result is always a valid
77 * NUL-terminated string that fits in the buffer (unless,
78 * of course, the buffer size is zero). It does not pad
79 * out the result like strncpy() does.
81 size_t strlcpy(char *dest, const char *src, size_t size)
83 size_t ret = strlen(src);
86 size_t len = (ret >= size) ? size - 1 : ret;
87 memcpy(dest, src, len);
93 void memzero_explicit(void *s, size_t count)