wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 1 | #ifndef _LINUX_STRING_H_ |
| 2 | #define _LINUX_STRING_H_ |
| 3 | |
| 4 | #include <linux/types.h> /* for size_t */ |
| 5 | #include <linux/stddef.h> /* for NULL */ |
| 6 | |
| 7 | #ifdef __cplusplus |
| 8 | extern "C" { |
| 9 | #endif |
| 10 | |
| 11 | extern char * ___strtok; |
| 12 | extern char * strpbrk(const char *,const char *); |
| 13 | extern char * strtok(char *,const char *); |
| 14 | extern char * strsep(char **,const char *); |
| 15 | extern __kernel_size_t strspn(const char *,const char *); |
| 16 | |
| 17 | |
| 18 | /* |
| 19 | * Include machine specific inline routines |
| 20 | */ |
| 21 | #include <asm/string.h> |
| 22 | |
| 23 | #ifndef __HAVE_ARCH_STRCPY |
| 24 | extern char * strcpy(char *,const char *); |
| 25 | #endif |
| 26 | #ifndef __HAVE_ARCH_STRNCPY |
| 27 | extern char * strncpy(char *,const char *, __kernel_size_t); |
| 28 | #endif |
Masahiro Yamada | 0588ce1 | 2014-11-20 21:20:32 +0900 | [diff] [blame] | 29 | #ifndef __HAVE_ARCH_STRLCPY |
| 30 | size_t strlcpy(char *, const char *, size_t); |
| 31 | #endif |
wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 32 | #ifndef __HAVE_ARCH_STRCAT |
| 33 | extern char * strcat(char *, const char *); |
| 34 | #endif |
| 35 | #ifndef __HAVE_ARCH_STRNCAT |
| 36 | extern char * strncat(char *, const char *, __kernel_size_t); |
| 37 | #endif |
Sean Anderson | 9297a7f | 2021-03-11 00:15:42 -0500 | [diff] [blame] | 38 | #ifndef __HAVE_ARCH_STRLCAT |
| 39 | size_t strlcat(char *, const char *, size_t); |
| 40 | #endif |
wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 41 | #ifndef __HAVE_ARCH_STRCMP |
| 42 | extern int strcmp(const char *,const char *); |
| 43 | #endif |
| 44 | #ifndef __HAVE_ARCH_STRNCMP |
| 45 | extern int strncmp(const char *,const char *,__kernel_size_t); |
| 46 | #endif |
Simon Glass | 459af69 | 2012-12-05 14:46:35 +0000 | [diff] [blame] | 47 | #ifndef __HAVE_ARCH_STRCASECMP |
| 48 | int strcasecmp(const char *s1, const char *s2); |
| 49 | #endif |
| 50 | #ifndef __HAVE_ARCH_STRNCASECMP |
| 51 | extern int strncasecmp(const char *s1, const char *s2, __kernel_size_t len); |
wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 52 | #endif |
| 53 | #ifndef __HAVE_ARCH_STRCHR |
| 54 | extern char * strchr(const char *,int); |
| 55 | #endif |
Simon Glass | 4355d42 | 2017-05-18 20:09:28 -0600 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * strchrnul() - return position of a character in the string, or end of string |
| 59 | * |
| 60 | * The strchrnul() function is like strchr() except that if c is not found |
| 61 | * in s, then it returns a pointer to the nul byte at the end of s, rather than |
| 62 | * NULL |
| 63 | * @s: string to search |
| 64 | * @c: character to search for |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 65 | * Return: position of @c in @s, or end of @s if not found |
Simon Glass | 4355d42 | 2017-05-18 20:09:28 -0600 | [diff] [blame] | 66 | */ |
| 67 | const char *strchrnul(const char *s, int c); |
| 68 | |
wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 69 | #ifndef __HAVE_ARCH_STRRCHR |
| 70 | extern char * strrchr(const char *,int); |
| 71 | #endif |
Joe Hershberger | 32ec63c | 2012-12-11 22:16:18 -0600 | [diff] [blame] | 72 | #include <linux/linux_string.h> |
wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 73 | #ifndef __HAVE_ARCH_STRSTR |
| 74 | extern char * strstr(const char *,const char *); |
| 75 | #endif |
| 76 | #ifndef __HAVE_ARCH_STRLEN |
| 77 | extern __kernel_size_t strlen(const char *); |
| 78 | #endif |
| 79 | #ifndef __HAVE_ARCH_STRNLEN |
| 80 | extern __kernel_size_t strnlen(const char *,__kernel_size_t); |
| 81 | #endif |
Simon Glass | 0d0e3c9 | 2017-05-18 20:09:29 -0600 | [diff] [blame] | 82 | |
| 83 | #ifndef __HAVE_ARCH_STRCSPN |
| 84 | /** |
| 85 | * strcspn() - find span of string without given characters |
| 86 | * |
| 87 | * Calculates the length of the initial segment of @s which consists entirely |
| 88 | * of bsytes not in reject. |
| 89 | * |
| 90 | * @s: string to search |
| 91 | * @reject: strings which cause the search to halt |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 92 | * Return: number of characters at the start of @s which are not in @reject |
Simon Glass | 0d0e3c9 | 2017-05-18 20:09:29 -0600 | [diff] [blame] | 93 | */ |
| 94 | size_t strcspn(const char *s, const char *reject); |
| 95 | #endif |
| 96 | |
Simon Glass | 0765036 | 2020-02-03 07:36:01 -0700 | [diff] [blame] | 97 | #ifdef CONFIG_SANDBOX |
| 98 | # define strdup sandbox_strdup |
| 99 | # define strndup sandbox_strndup |
| 100 | #endif |
| 101 | |
wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 102 | #ifndef __HAVE_ARCH_STRDUP |
| 103 | extern char * strdup(const char *); |
Thierry Reding | f056182 | 2019-04-15 11:32:14 +0200 | [diff] [blame] | 104 | extern char * strndup(const char *, size_t); |
Simon Glass | 9e8f6d6 | 2020-02-03 07:36:00 -0700 | [diff] [blame] | 105 | #endif |
wdenk | 8d4d1f6 | 2004-03-23 22:37:33 +0000 | [diff] [blame] | 106 | #ifndef __HAVE_ARCH_STRSWAB |
wdenk | acd9b10 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 107 | extern char * strswab(const char *); |
| 108 | #endif |
wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 109 | |
| 110 | #ifndef __HAVE_ARCH_MEMSET |
| 111 | extern void * memset(void *,int,__kernel_size_t); |
| 112 | #endif |
| 113 | #ifndef __HAVE_ARCH_MEMCPY |
| 114 | extern void * memcpy(void *,const void *,__kernel_size_t); |
| 115 | #endif |
| 116 | #ifndef __HAVE_ARCH_MEMMOVE |
| 117 | extern void * memmove(void *,const void *,__kernel_size_t); |
| 118 | #endif |
| 119 | #ifndef __HAVE_ARCH_MEMSCAN |
| 120 | extern void * memscan(void *,int,__kernel_size_t); |
| 121 | #endif |
| 122 | #ifndef __HAVE_ARCH_MEMCMP |
| 123 | extern int memcmp(const void *,const void *,__kernel_size_t); |
| 124 | #endif |
| 125 | #ifndef __HAVE_ARCH_MEMCHR |
| 126 | extern void * memchr(const void *,int,__kernel_size_t); |
| 127 | #endif |
Sergey Lapin | 3a38a55 | 2013-01-14 03:46:50 +0000 | [diff] [blame] | 128 | #ifndef __HAVE_ARCH_MEMCHR_INV |
| 129 | void *memchr_inv(const void *, int, size_t); |
| 130 | #endif |
wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 131 | |
Simon Glass | 4b2a18b | 2021-09-25 07:03:06 -0600 | [diff] [blame] | 132 | /** |
| 133 | * memdup() - allocate a buffer and copy in the contents |
| 134 | * |
| 135 | * Note that this returns a valid pointer even if @len is 0 |
| 136 | * |
| 137 | * @src: data to copy in |
| 138 | * @len: number of bytes to copy |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 139 | * Return: allocated buffer with the copied contents, or NULL if not enough |
Simon Glass | 4b2a18b | 2021-09-25 07:03:06 -0600 | [diff] [blame] | 140 | * memory is available |
| 141 | * |
| 142 | */ |
| 143 | char *memdup(const void *src, size_t len); |
| 144 | |
Jeroen Hofstee | 937824b | 2014-10-08 22:57:49 +0200 | [diff] [blame] | 145 | unsigned long ustrtoul(const char *cp, char **endp, unsigned int base); |
| 146 | unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base); |
| 147 | |
wdenk | 60b1bd0 | 2001-10-17 20:21:50 +0000 | [diff] [blame] | 148 | #ifdef __cplusplus |
| 149 | } |
| 150 | #endif |
| 151 | |
| 152 | #endif /* _LINUX_STRING_H_ */ |