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