Rev 6934 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6934 | Rev 6936 | ||
---|---|---|---|
1 | #ifndef _LINUX_STRING_H_ |
1 | #ifndef _LINUX_STRING_H_ |
2 | #define _LINUX_STRING_H_ |
2 | #define _LINUX_STRING_H_ |
3 | 3 | ||
4 | 4 | ||
5 | #include |
5 | #include |
6 | #include |
6 | #include |
7 | #include |
7 | #include |
8 | #include |
8 | #include |
9 | #include |
9 | #include |
10 | 10 | ||
11 | extern char *strndup_user(const char __user *, long); |
11 | extern char *strndup_user(const char __user *, long); |
12 | extern void *memdup_user(const void __user *, size_t); |
12 | extern void *memdup_user(const void __user *, size_t); |
- | 13 | extern void *memdup_user_nul(const void __user *, size_t); |
|
13 | 14 | ||
14 | /* |
15 | /* |
15 | * Include machine specific inline routines |
16 | * Include machine specific inline routines |
16 | */ |
17 | */ |
17 | #include |
18 | #include |
18 | 19 | ||
19 | #ifndef __HAVE_ARCH_STRCPY |
20 | #ifndef __HAVE_ARCH_STRCPY |
20 | extern char * strcpy(char *,const char *); |
21 | extern char * strcpy(char *,const char *); |
21 | #endif |
22 | #endif |
22 | #ifndef __HAVE_ARCH_STRNCPY |
23 | #ifndef __HAVE_ARCH_STRNCPY |
23 | extern char * strncpy(char *,const char *, __kernel_size_t); |
24 | extern char * strncpy(char *,const char *, __kernel_size_t); |
24 | #endif |
25 | #endif |
25 | #ifndef __HAVE_ARCH_STRLCPY |
26 | #ifndef __HAVE_ARCH_STRLCPY |
26 | size_t strlcpy(char *, const char *, size_t); |
27 | size_t strlcpy(char *, const char *, size_t); |
27 | #endif |
28 | #endif |
28 | #ifndef __HAVE_ARCH_STRSCPY |
29 | #ifndef __HAVE_ARCH_STRSCPY |
29 | ssize_t __must_check strscpy(char *, const char *, size_t); |
30 | ssize_t __must_check strscpy(char *, const char *, size_t); |
30 | #endif |
31 | #endif |
31 | #ifndef __HAVE_ARCH_STRCAT |
32 | #ifndef __HAVE_ARCH_STRCAT |
32 | extern char * strcat(char *, const char *); |
33 | extern char * strcat(char *, const char *); |
33 | #endif |
34 | #endif |
34 | #ifndef __HAVE_ARCH_STRNCAT |
35 | #ifndef __HAVE_ARCH_STRNCAT |
35 | extern char * strncat(char *, const char *, __kernel_size_t); |
36 | extern char * strncat(char *, const char *, __kernel_size_t); |
36 | #endif |
37 | #endif |
37 | #ifndef __HAVE_ARCH_STRLCAT |
38 | #ifndef __HAVE_ARCH_STRLCAT |
38 | extern size_t strlcat(char *, const char *, __kernel_size_t); |
39 | extern size_t strlcat(char *, const char *, __kernel_size_t); |
39 | #endif |
40 | #endif |
40 | #ifndef __HAVE_ARCH_STRCMP |
41 | #ifndef __HAVE_ARCH_STRCMP |
41 | extern int strcmp(const char *,const char *); |
42 | extern int strcmp(const char *,const char *); |
42 | #endif |
43 | #endif |
43 | #ifndef __HAVE_ARCH_STRNCMP |
44 | #ifndef __HAVE_ARCH_STRNCMP |
44 | extern int strncmp(const char *,const char *,__kernel_size_t); |
45 | extern int strncmp(const char *,const char *,__kernel_size_t); |
45 | #endif |
46 | #endif |
46 | #ifndef __HAVE_ARCH_STRCASECMP |
47 | #ifndef __HAVE_ARCH_STRCASECMP |
47 | extern int strcasecmp(const char *s1, const char *s2); |
48 | extern int strcasecmp(const char *s1, const char *s2); |
48 | #endif |
49 | #endif |
49 | #ifndef __HAVE_ARCH_STRNCASECMP |
50 | #ifndef __HAVE_ARCH_STRNCASECMP |
50 | extern int strncasecmp(const char *s1, const char *s2, size_t n); |
51 | extern int strncasecmp(const char *s1, const char *s2, size_t n); |
51 | #endif |
52 | #endif |
52 | #ifndef __HAVE_ARCH_STRCHR |
53 | #ifndef __HAVE_ARCH_STRCHR |
53 | extern char * strchr(const char *,int); |
54 | extern char * strchr(const char *,int); |
54 | #endif |
55 | #endif |
55 | #ifndef __HAVE_ARCH_STRCHRNUL |
56 | #ifndef __HAVE_ARCH_STRCHRNUL |
56 | extern char * strchrnul(const char *,int); |
57 | extern char * strchrnul(const char *,int); |
57 | #endif |
58 | #endif |
58 | #ifndef __HAVE_ARCH_STRNCHR |
59 | #ifndef __HAVE_ARCH_STRNCHR |
59 | extern char * strnchr(const char *, size_t, int); |
60 | extern char * strnchr(const char *, size_t, int); |
60 | #endif |
61 | #endif |
61 | #ifndef __HAVE_ARCH_STRRCHR |
62 | #ifndef __HAVE_ARCH_STRRCHR |
62 | extern char * strrchr(const char *,int); |
63 | extern char * strrchr(const char *,int); |
63 | #endif |
64 | #endif |
64 | extern char * __must_check skip_spaces(const char *); |
65 | extern char * __must_check skip_spaces(const char *); |
65 | 66 | ||
66 | extern char *strim(char *); |
67 | extern char *strim(char *); |
67 | 68 | ||
68 | static inline __must_check char *strstrip(char *str) |
69 | static inline __must_check char *strstrip(char *str) |
69 | { |
70 | { |
70 | return strim(str); |
71 | return strim(str); |
71 | } |
72 | } |
72 | 73 | ||
73 | #ifndef __HAVE_ARCH_STRSTR |
74 | #ifndef __HAVE_ARCH_STRSTR |
74 | extern char * strstr(const char *, const char *); |
75 | extern char * strstr(const char *, const char *); |
75 | #endif |
76 | #endif |
76 | #ifndef __HAVE_ARCH_STRNSTR |
77 | #ifndef __HAVE_ARCH_STRNSTR |
77 | extern char * strnstr(const char *, const char *, size_t); |
78 | extern char * strnstr(const char *, const char *, size_t); |
78 | #endif |
79 | #endif |
79 | #ifndef __HAVE_ARCH_STRLEN |
80 | #ifndef __HAVE_ARCH_STRLEN |
80 | extern __kernel_size_t strlen(const char *); |
81 | extern __kernel_size_t strlen(const char *); |
81 | #endif |
82 | #endif |
82 | #ifndef __HAVE_ARCH_STRNLEN |
83 | #ifndef __HAVE_ARCH_STRNLEN |
83 | extern __kernel_size_t strnlen(const char *,__kernel_size_t); |
84 | extern __kernel_size_t strnlen(const char *,__kernel_size_t); |
84 | #endif |
85 | #endif |
85 | #ifndef __HAVE_ARCH_STRPBRK |
86 | #ifndef __HAVE_ARCH_STRPBRK |
86 | extern char * strpbrk(const char *,const char *); |
87 | extern char * strpbrk(const char *,const char *); |
87 | #endif |
88 | #endif |
88 | #ifndef __HAVE_ARCH_STRSEP |
89 | #ifndef __HAVE_ARCH_STRSEP |
89 | extern char * strsep(char **,const char *); |
90 | extern char * strsep(char **,const char *); |
90 | #endif |
91 | #endif |
91 | #ifndef __HAVE_ARCH_STRSPN |
92 | #ifndef __HAVE_ARCH_STRSPN |
92 | extern __kernel_size_t strspn(const char *,const char *); |
93 | extern __kernel_size_t strspn(const char *,const char *); |
93 | #endif |
94 | #endif |
94 | #ifndef __HAVE_ARCH_STRCSPN |
95 | #ifndef __HAVE_ARCH_STRCSPN |
95 | extern __kernel_size_t strcspn(const char *,const char *); |
96 | extern __kernel_size_t strcspn(const char *,const char *); |
96 | #endif |
97 | #endif |
97 | 98 | ||
98 | #ifndef __HAVE_ARCH_MEMSET |
99 | #ifndef __HAVE_ARCH_MEMSET |
99 | extern void * memset(void *,int,__kernel_size_t); |
100 | extern void * memset(void *,int,__kernel_size_t); |
100 | #endif |
101 | #endif |
101 | #ifndef __HAVE_ARCH_MEMCPY |
102 | #ifndef __HAVE_ARCH_MEMCPY |
102 | extern void * memcpy(void *,const void *,__kernel_size_t); |
103 | extern void * memcpy(void *,const void *,__kernel_size_t); |
103 | #endif |
104 | #endif |
104 | #ifndef __HAVE_ARCH_MEMMOVE |
105 | #ifndef __HAVE_ARCH_MEMMOVE |
105 | extern void * memmove(void *,const void *,__kernel_size_t); |
106 | extern void * memmove(void *,const void *,__kernel_size_t); |
106 | #endif |
107 | #endif |
107 | #ifndef __HAVE_ARCH_MEMSCAN |
108 | #ifndef __HAVE_ARCH_MEMSCAN |
108 | extern void * memscan(void *,int,__kernel_size_t); |
109 | extern void * memscan(void *,int,__kernel_size_t); |
109 | #endif |
110 | #endif |
110 | #ifndef __HAVE_ARCH_MEMCMP |
111 | #ifndef __HAVE_ARCH_MEMCMP |
111 | extern int memcmp(const void *,const void *,__kernel_size_t); |
112 | extern int memcmp(const void *,const void *,__kernel_size_t); |
112 | #endif |
113 | #endif |
113 | #ifndef __HAVE_ARCH_MEMCHR |
114 | #ifndef __HAVE_ARCH_MEMCHR |
114 | extern void * memchr(const void *,int,__kernel_size_t); |
115 | extern void * memchr(const void *,int,__kernel_size_t); |
115 | #endif |
116 | #endif |
116 | void *memchr_inv(const void *s, int c, size_t n); |
117 | void *memchr_inv(const void *s, int c, size_t n); |
117 | char *strreplace(char *s, char old, char new); |
118 | char *strreplace(char *s, char old, char new); |
118 | 119 | ||
119 | extern void kfree_const(const void *x); |
120 | extern void kfree_const(const void *x); |
120 | 121 | ||
121 | extern char *kstrdup(const char *s, gfp_t gfp); |
122 | extern char *kstrdup(const char *s, gfp_t gfp); |
122 | extern const char *kstrdup_const(const char *s, gfp_t gfp); |
123 | extern const char *kstrdup_const(const char *s, gfp_t gfp); |
123 | extern char *kstrndup(const char *s, size_t len, gfp_t gfp); |
124 | extern char *kstrndup(const char *s, size_t len, gfp_t gfp); |
124 | extern void *kmemdup(const void *src, size_t len, gfp_t gfp); |
125 | extern void *kmemdup(const void *src, size_t len, gfp_t gfp); |
125 | 126 | ||
126 | extern char **argv_split(gfp_t gfp, const char *str, int *argcp); |
127 | extern char **argv_split(gfp_t gfp, const char *str, int *argcp); |
127 | extern void argv_free(char **argv); |
128 | extern void argv_free(char **argv); |
128 | 129 | ||
129 | extern bool sysfs_streq(const char *s1, const char *s2); |
130 | extern bool sysfs_streq(const char *s1, const char *s2); |
130 | extern int kstrtobool(const char *s, bool *res); |
131 | extern int strtobool(const char *s, bool *res); |
131 | static inline int strtobool(const char *s, bool *res) |
- | |
132 | { |
- | |
133 | return kstrtobool(s, res); |
- | |
134 | } |
- | |
135 | 132 | ||
136 | #ifdef CONFIG_BINARY_PRINTF |
133 | #ifdef CONFIG_BINARY_PRINTF |
137 | int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); |
134 | int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); |
138 | int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf); |
135 | int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf); |
139 | int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4); |
136 | int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4); |
140 | #endif |
137 | #endif |
141 | 138 | ||
142 | extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, |
139 | extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, |
143 | const void *from, size_t available); |
140 | const void *from, size_t available); |
144 | 141 | ||
145 | /** |
142 | /** |
146 | * strstarts - does @str start with @prefix? |
143 | * strstarts - does @str start with @prefix? |
147 | * @str: string to examine |
144 | * @str: string to examine |
148 | * @prefix: prefix to look for. |
145 | * @prefix: prefix to look for. |
149 | */ |
146 | */ |
150 | static inline bool strstarts(const char *str, const char *prefix) |
147 | static inline bool strstarts(const char *str, const char *prefix) |
151 | { |
148 | { |
152 | return strncmp(str, prefix, strlen(prefix)) == 0; |
149 | return strncmp(str, prefix, strlen(prefix)) == 0; |
153 | } |
150 | } |
154 | 151 | ||
155 | size_t memweight(const void *ptr, size_t bytes); |
152 | size_t memweight(const void *ptr, size_t bytes); |
156 | void memzero_explicit(void *s, size_t count); |
153 | void memzero_explicit(void *s, size_t count); |
157 | 154 | ||
158 | /** |
155 | /** |
159 | * kbasename - return the last part of a pathname. |
156 | * kbasename - return the last part of a pathname. |
160 | * |
157 | * |
161 | * @path: path to extract the filename from. |
158 | * @path: path to extract the filename from. |
162 | */ |
159 | */ |
163 | static inline const char *kbasename(const char *path) |
160 | static inline const char *kbasename(const char *path) |
164 | { |
161 | { |
165 | const char *tail = strrchr(path, '/'); |
162 | const char *tail = strrchr(path, '/'); |
166 | return tail ? tail + 1 : path; |
163 | return tail ? tail + 1 : path; |
167 | } |
164 | } |
168 | 165 | ||
169 | #endif /* _LINUX_STRING_H_ */ |
166 | #endif /* _LINUX_STRING_H_ */ |