blob: 27b2beb9ddb0e5ce9f5164807b11b6b3f64f1cfa [file] [log] [blame]
wdenk60b1bd02001-10-17 20:21:50 +00001#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
8extern "C" {
9#endif
10
11extern char * ___strtok;
12extern char * strpbrk(const char *,const char *);
13extern char * strtok(char *,const char *);
14extern char * strsep(char **,const char *);
15extern __kernel_size_t strspn(const char *,const char *);
16
wdenk60b1bd02001-10-17 20:21:50 +000017/*
18 * Include machine specific inline routines
19 */
20#include <asm/string.h>
21
22#ifndef __HAVE_ARCH_STRCPY
23extern char * strcpy(char *,const char *);
24#endif
25#ifndef __HAVE_ARCH_STRNCPY
26extern char * strncpy(char *,const char *, __kernel_size_t);
27#endif
Masahiro Yamada0588ce12014-11-20 21:20:32 +090028#ifndef __HAVE_ARCH_STRLCPY
29size_t strlcpy(char *, const char *, size_t);
30#endif
wdenk60b1bd02001-10-17 20:21:50 +000031#ifndef __HAVE_ARCH_STRCAT
32extern char * strcat(char *, const char *);
33#endif
34#ifndef __HAVE_ARCH_STRNCAT
35extern char * strncat(char *, const char *, __kernel_size_t);
36#endif
Sean Anderson9297a7f2021-03-11 00:15:42 -050037#ifndef __HAVE_ARCH_STRLCAT
38size_t strlcat(char *, const char *, size_t);
39#endif
wdenk60b1bd02001-10-17 20:21:50 +000040#ifndef __HAVE_ARCH_STRCMP
41extern int strcmp(const char *,const char *);
42#endif
43#ifndef __HAVE_ARCH_STRNCMP
44extern int strncmp(const char *,const char *,__kernel_size_t);
45#endif
Simon Glass459af692012-12-05 14:46:35 +000046#ifndef __HAVE_ARCH_STRCASECMP
47int strcasecmp(const char *s1, const char *s2);
48#endif
49#ifndef __HAVE_ARCH_STRNCASECMP
50extern int strncasecmp(const char *s1, const char *s2, __kernel_size_t len);
wdenk60b1bd02001-10-17 20:21:50 +000051#endif
52#ifndef __HAVE_ARCH_STRCHR
53extern char * strchr(const char *,int);
54#endif
Simon Glass4355d422017-05-18 20:09:28 -060055
56/**
57 * strchrnul() - return position of a character in the string, or end of string
58 *
59 * The strchrnul() function is like strchr() except that if c is not found
60 * in s, then it returns a pointer to the nul byte at the end of s, rather than
61 * NULL
62 * @s: string to search
63 * @c: character to search for
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010064 * Return: position of @c in @s, or end of @s if not found
Simon Glass4355d422017-05-18 20:09:28 -060065 */
66const char *strchrnul(const char *s, int c);
67
wdenk60b1bd02001-10-17 20:21:50 +000068#ifndef __HAVE_ARCH_STRRCHR
69extern char * strrchr(const char *,int);
70#endif
Joe Hershberger32ec63c2012-12-11 22:16:18 -060071#include <linux/linux_string.h>
wdenk60b1bd02001-10-17 20:21:50 +000072#ifndef __HAVE_ARCH_STRSTR
73extern char * strstr(const char *,const char *);
74#endif
75#ifndef __HAVE_ARCH_STRLEN
76extern __kernel_size_t strlen(const char *);
77#endif
78#ifndef __HAVE_ARCH_STRNLEN
79extern __kernel_size_t strnlen(const char *,__kernel_size_t);
80#endif
Simon Glass0d0e3c92017-05-18 20:09:29 -060081
82#ifndef __HAVE_ARCH_STRCSPN
83/**
84 * strcspn() - find span of string without given characters
85 *
86 * Calculates the length of the initial segment of @s which consists entirely
87 * of bsytes not in reject.
88 *
89 * @s: string to search
90 * @reject: strings which cause the search to halt
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010091 * Return: number of characters at the start of @s which are not in @reject
Simon Glass0d0e3c92017-05-18 20:09:29 -060092 */
93size_t strcspn(const char *s, const char *reject);
94#endif
95
Simon Glass07650362020-02-03 07:36:01 -070096#ifdef CONFIG_SANDBOX
97# define strdup sandbox_strdup
98# define strndup sandbox_strndup
99#endif
100
wdenk60b1bd02001-10-17 20:21:50 +0000101#ifndef __HAVE_ARCH_STRDUP
102extern char * strdup(const char *);
Thierry Redingf0561822019-04-15 11:32:14 +0200103extern char * strndup(const char *, size_t);
Simon Glass9e8f6d62020-02-03 07:36:00 -0700104#endif
wdenk8d4d1f62004-03-23 22:37:33 +0000105#ifndef __HAVE_ARCH_STRSWAB
wdenkacd9b102004-03-14 00:59:59 +0000106extern char * strswab(const char *);
107#endif
wdenk60b1bd02001-10-17 20:21:50 +0000108
109#ifndef __HAVE_ARCH_MEMSET
110extern void * memset(void *,int,__kernel_size_t);
111#endif
112#ifndef __HAVE_ARCH_MEMCPY
113extern void * memcpy(void *,const void *,__kernel_size_t);
114#endif
115#ifndef __HAVE_ARCH_MEMMOVE
116extern void * memmove(void *,const void *,__kernel_size_t);
117#endif
118#ifndef __HAVE_ARCH_MEMSCAN
119extern void * memscan(void *,int,__kernel_size_t);
120#endif
121#ifndef __HAVE_ARCH_MEMCMP
122extern int memcmp(const void *,const void *,__kernel_size_t);
123#endif
124#ifndef __HAVE_ARCH_MEMCHR
125extern void * memchr(const void *,int,__kernel_size_t);
126#endif
Sergey Lapin3a38a552013-01-14 03:46:50 +0000127#ifndef __HAVE_ARCH_MEMCHR_INV
128void *memchr_inv(const void *, int, size_t);
129#endif
wdenk60b1bd02001-10-17 20:21:50 +0000130
Simon Glass4b2a18b2021-09-25 07:03:06 -0600131/**
132 * memdup() - allocate a buffer and copy in the contents
133 *
134 * Note that this returns a valid pointer even if @len is 0
135 *
136 * @src: data to copy in
137 * @len: number of bytes to copy
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100138 * Return: allocated buffer with the copied contents, or NULL if not enough
Simon Glass4b2a18b2021-09-25 07:03:06 -0600139 * memory is available
140 *
141 */
142char *memdup(const void *src, size_t len);
143
Jeroen Hofstee937824b2014-10-08 22:57:49 +0200144unsigned long ustrtoul(const char *cp, char **endp, unsigned int base);
145unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base);
146
wdenk60b1bd02001-10-17 20:21:50 +0000147#ifdef __cplusplus
148}
149#endif
150
151#endif /* _LINUX_STRING_H_ */