/src/util-linux/include/strutils.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * No copyright is claimed. This code is in the public domain; do with |
3 | | * it what you wish. |
4 | | */ |
5 | | #ifndef UTIL_LINUX_STRUTILS |
6 | | #define UTIL_LINUX_STRUTILS |
7 | | |
8 | | #include <stdlib.h> |
9 | | #include <inttypes.h> |
10 | | #include <string.h> |
11 | | #include <strings.h> |
12 | | #include <sys/types.h> |
13 | | #include <ctype.h> |
14 | | #include <stdio.h> |
15 | | #include <errno.h> |
16 | | #include <time.h> |
17 | | #include <stdbool.h> |
18 | | |
19 | | #include "c.h" |
20 | | |
21 | | /* initialize a custom exit code for all *_or_err functions */ |
22 | | extern void strutils_set_exitcode(int exit_code); |
23 | | |
24 | | extern int ul_parse_size(const char *str, uintmax_t *res, int *power); |
25 | | extern int strtosize(const char *str, uintmax_t *res); |
26 | | extern uintmax_t strtosize_or_err(const char *str, const char *errmesg); |
27 | | |
28 | | extern int ul_strtos64(const char *str, int64_t *num, int base); |
29 | | extern int ul_strtou64(const char *str, uint64_t *num, int base); |
30 | | extern int ul_strtos32(const char *str, int32_t *num, int base); |
31 | | extern int ul_strtou32(const char *str, uint32_t *num, int base); |
32 | | extern int ul_strtou16(const char *str, uint16_t *num, int base); |
33 | | |
34 | | extern int ul_strtold(const char *str, long double *num); |
35 | | |
36 | | extern int64_t str2num_or_err(const char *str, int base, const char *errmesg, int64_t low, int64_t up); |
37 | | extern uint64_t str2unum_or_err(const char *str, int base, const char *errmesg, uint64_t up); |
38 | | |
39 | 0 | #define strtos64_or_err(_s, _e) str2num_or_err(_s, 10, _e, 0, 0) |
40 | | #define strtou64_or_err(_s, _e) str2unum_or_err(_s, 10, _e, 0) |
41 | | #define strtox64_or_err(_s, _e) str2unum_or_err(_s, 16, _e, 0) |
42 | | |
43 | | #define strtos32_or_err(_s, _e) (int32_t) str2num_or_err(_s, 10, _e, INT32_MIN, INT32_MAX) |
44 | | #define strtou32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 10, _e, UINT32_MAX) |
45 | | #define strtox32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 16, _e, UINT32_MAX) |
46 | | |
47 | | #define strtos16_or_err(_s, _e) (int16_t) str2num_or_err(_s, 10, _e, INT16_MIN, INT16_MAX) |
48 | | #define strtou16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 10, _e, UINT16_MAX) |
49 | | #define strtox16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 16, _e, UINT16_MAX) |
50 | | |
51 | | extern double strtod_or_err(const char *str, const char *errmesg); |
52 | | extern long double strtold_or_err(const char *str, const char *errmesg); |
53 | | |
54 | | #define strtol_or_err(_s, _e) (long) str2num_or_err(_s, 10, _e, LONG_MIN, LONG_MAX) |
55 | | #define strtopid_or_err(_s, _e) (pid_t) str2num_or_err(_s, 10, _e, 1, SINT_MAX(pid_t)) |
56 | | #define strtoul_or_err(_s, _e) (unsigned long) str2unum_or_err(_s, 10, _e, ULONG_MAX) |
57 | | |
58 | | extern void strtotimeval_or_err(const char *str, struct timeval *tv, |
59 | | const char *errmesg); |
60 | | extern void strtotimespec_or_err(const char *str, struct timespec *ts, |
61 | | const char *errmesg); |
62 | | extern time_t strtotime_or_err(const char *str, const char *errmesg); |
63 | | |
64 | | extern bool hyperlinkwanted(const char *mode); |
65 | | |
66 | | extern int isdigit_strend(const char *str, const char **end); |
67 | | #define isdigit_string(_s) isdigit_strend(_s, NULL) |
68 | | |
69 | | extern int isxdigit_strend(const char *str, const char **end); |
70 | 41 | #define isxdigit_string(_s) isxdigit_strend(_s, NULL) |
71 | | |
72 | | |
73 | | extern int ul_parse_switch(const char *arg, ...); |
74 | | |
75 | | #ifndef HAVE_MEMPCPY |
76 | | extern void *mempcpy(void *restrict dest, const void *restrict src, size_t n); |
77 | | #endif |
78 | | #ifndef HAVE_STRNLEN |
79 | | extern size_t strnlen(const char *s, size_t maxlen); |
80 | | #endif |
81 | | #ifndef HAVE_STRNDUP |
82 | | extern char *strndup(const char *s, size_t n); |
83 | | #endif |
84 | | #ifndef HAVE_STRNCHR |
85 | | extern char *strnchr(const char *s, size_t maxlen, int c); |
86 | | #endif |
87 | | |
88 | | /* caller guarantees n > 0 */ |
89 | | static inline int xstrncpy(char *dest, const char *src, size_t n) |
90 | 0 | { |
91 | 0 | size_t len = src ? strlen(src) : 0; |
92 | |
|
93 | 0 | if (!len) |
94 | 0 | return 0; |
95 | 0 | len = min(len, n - 1); |
96 | 0 | memcpy(dest, src, len); |
97 | 0 | dest[len] = 0; |
98 | 0 | return len; |
99 | 0 | } Unexecuted instantiation: fuzz.c:xstrncpy Unexecuted instantiation: tab.c:xstrncpy Unexecuted instantiation: tab_parse.c:xstrncpy Unexecuted instantiation: utils.c:xstrncpy Unexecuted instantiation: canonicalize.c:xstrncpy Unexecuted instantiation: loopdev.c:xstrncpy Unexecuted instantiation: path.c:xstrncpy Unexecuted instantiation: strutils.c:xstrncpy Unexecuted instantiation: strv.c:xstrncpy Unexecuted instantiation: sysfs.c:xstrncpy Unexecuted instantiation: cache.c:xstrncpy Unexecuted instantiation: fs.c:xstrncpy Unexecuted instantiation: optmap.c:xstrncpy Unexecuted instantiation: optlist.c:xstrncpy Unexecuted instantiation: optstr.c:xstrncpy Unexecuted instantiation: buffer.c:xstrncpy Unexecuted instantiation: mbsalign.c:xstrncpy Unexecuted instantiation: evaluate.c:xstrncpy Unexecuted instantiation: probe.c:xstrncpy Unexecuted instantiation: partitions.c:xstrncpy Unexecuted instantiation: devname.c:xstrncpy Unexecuted instantiation: devno.c:xstrncpy Unexecuted instantiation: encode.c:xstrncpy |
100 | | |
101 | | /* This is like strncpy(), but based on memcpy(), so compilers and static |
102 | | * analyzers do not complain when sizeof(destination) is the same as 'n' and |
103 | | * result is not terminated by zero. |
104 | | * |
105 | | * Use this function to copy string to logs with fixed sizes (wtmp/utmp. ...) |
106 | | * where string terminator is optional. |
107 | | */ |
108 | | static inline void * __attribute__((nonnull (1))) |
109 | | str2memcpy(void *dest, const char *src, size_t n) |
110 | 0 | { |
111 | 0 | size_t bytes = strlen(src) + 1; |
112 | 0 |
|
113 | 0 | if (bytes > n) |
114 | 0 | bytes = n; |
115 | 0 |
|
116 | 0 | memcpy(dest, src, bytes); |
117 | 0 | return dest; |
118 | 0 | } Unexecuted instantiation: fuzz.c:str2memcpy Unexecuted instantiation: tab.c:str2memcpy Unexecuted instantiation: tab_parse.c:str2memcpy Unexecuted instantiation: utils.c:str2memcpy Unexecuted instantiation: canonicalize.c:str2memcpy Unexecuted instantiation: loopdev.c:str2memcpy Unexecuted instantiation: path.c:str2memcpy Unexecuted instantiation: strutils.c:str2memcpy Unexecuted instantiation: strv.c:str2memcpy Unexecuted instantiation: sysfs.c:str2memcpy Unexecuted instantiation: cache.c:str2memcpy Unexecuted instantiation: fs.c:str2memcpy Unexecuted instantiation: optmap.c:str2memcpy Unexecuted instantiation: optlist.c:str2memcpy Unexecuted instantiation: optstr.c:str2memcpy Unexecuted instantiation: buffer.c:str2memcpy Unexecuted instantiation: mbsalign.c:str2memcpy Unexecuted instantiation: evaluate.c:str2memcpy Unexecuted instantiation: probe.c:str2memcpy Unexecuted instantiation: partitions.c:str2memcpy Unexecuted instantiation: devname.c:str2memcpy Unexecuted instantiation: devno.c:str2memcpy Unexecuted instantiation: encode.c:str2memcpy |
119 | | |
120 | | static inline char * __attribute__((nonnull (1))) |
121 | | mem2strcpy(char *dest, const void *src, size_t n, size_t nmax) |
122 | 0 | { |
123 | 0 | if (n + 1 > nmax) |
124 | 0 | n = nmax - 1; |
125 | |
|
126 | 0 | memset(dest, '\0', nmax); |
127 | 0 | memcpy(dest, src, n); |
128 | 0 | return dest; |
129 | 0 | } Unexecuted instantiation: fuzz.c:mem2strcpy Unexecuted instantiation: tab.c:mem2strcpy Unexecuted instantiation: tab_parse.c:mem2strcpy Unexecuted instantiation: utils.c:mem2strcpy Unexecuted instantiation: canonicalize.c:mem2strcpy Unexecuted instantiation: loopdev.c:mem2strcpy Unexecuted instantiation: path.c:mem2strcpy Unexecuted instantiation: strutils.c:mem2strcpy Unexecuted instantiation: strv.c:mem2strcpy Unexecuted instantiation: sysfs.c:mem2strcpy Unexecuted instantiation: cache.c:mem2strcpy Unexecuted instantiation: fs.c:mem2strcpy Unexecuted instantiation: optmap.c:mem2strcpy Unexecuted instantiation: optlist.c:mem2strcpy Unexecuted instantiation: optstr.c:mem2strcpy Unexecuted instantiation: buffer.c:mem2strcpy Unexecuted instantiation: mbsalign.c:mem2strcpy Unexecuted instantiation: evaluate.c:mem2strcpy Unexecuted instantiation: probe.c:mem2strcpy Unexecuted instantiation: partitions.c:mem2strcpy Unexecuted instantiation: devname.c:mem2strcpy Unexecuted instantiation: devno.c:mem2strcpy Unexecuted instantiation: encode.c:mem2strcpy |
130 | | |
131 | | /* Reallocate @str according to @newstr and copy @newstr to @str; returns new @str. |
132 | | * The @str is not modified if reallocation failed (like classic realloc()). |
133 | | */ |
134 | | static inline char * __attribute__((warn_unused_result)) |
135 | | strrealloc(char *str, const char *newstr) |
136 | 0 | { |
137 | 0 | size_t nsz, osz; |
138 | 0 |
|
139 | 0 | if (!str) |
140 | 0 | return newstr ? strdup(newstr) : NULL; |
141 | 0 | if (!newstr) |
142 | 0 | return NULL; |
143 | 0 |
|
144 | 0 | osz = strlen(str); |
145 | 0 | nsz = strlen(newstr); |
146 | 0 |
|
147 | 0 | if (nsz > osz) |
148 | 0 | str = realloc(str, nsz + 1); |
149 | 0 | if (str) |
150 | 0 | memcpy(str, newstr, nsz + 1); |
151 | 0 | return str; |
152 | 0 | } Unexecuted instantiation: fuzz.c:strrealloc Unexecuted instantiation: tab.c:strrealloc Unexecuted instantiation: tab_parse.c:strrealloc Unexecuted instantiation: utils.c:strrealloc Unexecuted instantiation: canonicalize.c:strrealloc Unexecuted instantiation: loopdev.c:strrealloc Unexecuted instantiation: path.c:strrealloc Unexecuted instantiation: strutils.c:strrealloc Unexecuted instantiation: strv.c:strrealloc Unexecuted instantiation: sysfs.c:strrealloc Unexecuted instantiation: cache.c:strrealloc Unexecuted instantiation: fs.c:strrealloc Unexecuted instantiation: optmap.c:strrealloc Unexecuted instantiation: optlist.c:strrealloc Unexecuted instantiation: optstr.c:strrealloc Unexecuted instantiation: buffer.c:strrealloc Unexecuted instantiation: mbsalign.c:strrealloc Unexecuted instantiation: evaluate.c:strrealloc Unexecuted instantiation: probe.c:strrealloc Unexecuted instantiation: partitions.c:strrealloc Unexecuted instantiation: devname.c:strrealloc Unexecuted instantiation: devno.c:strrealloc Unexecuted instantiation: encode.c:strrealloc |
153 | | |
154 | | /* Copy string @str to struct @stru to member addressed by @offset */ |
155 | | static inline int strdup_to_offset(void *stru, size_t offset, const char *str) |
156 | 284 | { |
157 | 284 | char **o; |
158 | 284 | char *p = NULL; |
159 | | |
160 | 284 | if (!stru) |
161 | 0 | return -EINVAL; |
162 | | |
163 | 284 | o = (char **) ((char *) stru + offset); |
164 | 284 | if (str) { |
165 | 71 | p = strdup(str); |
166 | 71 | if (!p) |
167 | 0 | return -ENOMEM; |
168 | 71 | } |
169 | | |
170 | 284 | free(*o); |
171 | 284 | *o = p; |
172 | 284 | return 0; |
173 | 284 | } Unexecuted instantiation: fuzz.c:strdup_to_offset Line | Count | Source | 156 | 142 | { | 157 | 142 | char **o; | 158 | 142 | char *p = NULL; | 159 | | | 160 | 142 | if (!stru) | 161 | 0 | return -EINVAL; | 162 | | | 163 | 142 | o = (char **) ((char *) stru + offset); | 164 | 142 | if (str) { | 165 | 71 | p = strdup(str); | 166 | 71 | if (!p) | 167 | 0 | return -ENOMEM; | 168 | 71 | } | 169 | | | 170 | 142 | free(*o); | 171 | 142 | *o = p; | 172 | 142 | return 0; | 173 | 142 | } |
Unexecuted instantiation: tab_parse.c:strdup_to_offset Unexecuted instantiation: utils.c:strdup_to_offset Unexecuted instantiation: canonicalize.c:strdup_to_offset Unexecuted instantiation: loopdev.c:strdup_to_offset Unexecuted instantiation: path.c:strdup_to_offset Unexecuted instantiation: strutils.c:strdup_to_offset Unexecuted instantiation: strv.c:strdup_to_offset Unexecuted instantiation: sysfs.c:strdup_to_offset Unexecuted instantiation: cache.c:strdup_to_offset Line | Count | Source | 156 | 142 | { | 157 | 142 | char **o; | 158 | 142 | char *p = NULL; | 159 | | | 160 | 142 | if (!stru) | 161 | 0 | return -EINVAL; | 162 | | | 163 | 142 | o = (char **) ((char *) stru + offset); | 164 | 142 | if (str) { | 165 | 0 | p = strdup(str); | 166 | 0 | if (!p) | 167 | 0 | return -ENOMEM; | 168 | 0 | } | 169 | | | 170 | 142 | free(*o); | 171 | 142 | *o = p; | 172 | 142 | return 0; | 173 | 142 | } |
Unexecuted instantiation: optmap.c:strdup_to_offset Unexecuted instantiation: optlist.c:strdup_to_offset Unexecuted instantiation: optstr.c:strdup_to_offset Unexecuted instantiation: buffer.c:strdup_to_offset Unexecuted instantiation: mbsalign.c:strdup_to_offset Unexecuted instantiation: evaluate.c:strdup_to_offset Unexecuted instantiation: probe.c:strdup_to_offset Unexecuted instantiation: partitions.c:strdup_to_offset Unexecuted instantiation: devname.c:strdup_to_offset Unexecuted instantiation: devno.c:strdup_to_offset Unexecuted instantiation: encode.c:strdup_to_offset |
174 | | |
175 | | /* Copy string __str to struct member _m of the struct _s */ |
176 | | #define strdup_to_struct_member(_s, _m, _str) \ |
177 | 284 | strdup_to_offset((void *) _s, offsetof(__typeof__(*(_s)), _m), _str) |
178 | | |
179 | | /* Copy string addressed by @offset between two structs */ |
180 | | static inline int strdup_between_offsets(void *stru_dst, void *stru_src, size_t offset) |
181 | 0 | { |
182 | 0 | char **src; |
183 | 0 | char **dst; |
184 | 0 | char *p = NULL; |
185 | |
|
186 | 0 | if (!stru_src || !stru_dst) |
187 | 0 | return -EINVAL; |
188 | | |
189 | 0 | src = (char **) ((char *) stru_src + offset); |
190 | 0 | dst = (char **) ((char *) stru_dst + offset); |
191 | |
|
192 | 0 | if (*src) { |
193 | 0 | p = strdup(*src); |
194 | 0 | if (!p) |
195 | 0 | return -ENOMEM; |
196 | 0 | } |
197 | | |
198 | 0 | free(*dst); |
199 | 0 | *dst = p; |
200 | 0 | return 0; |
201 | 0 | } Unexecuted instantiation: fuzz.c:strdup_between_offsets Unexecuted instantiation: tab.c:strdup_between_offsets Unexecuted instantiation: tab_parse.c:strdup_between_offsets Unexecuted instantiation: utils.c:strdup_between_offsets Unexecuted instantiation: canonicalize.c:strdup_between_offsets Unexecuted instantiation: loopdev.c:strdup_between_offsets Unexecuted instantiation: path.c:strdup_between_offsets Unexecuted instantiation: strutils.c:strdup_between_offsets Unexecuted instantiation: strv.c:strdup_between_offsets Unexecuted instantiation: sysfs.c:strdup_between_offsets Unexecuted instantiation: cache.c:strdup_between_offsets Unexecuted instantiation: fs.c:strdup_between_offsets Unexecuted instantiation: optmap.c:strdup_between_offsets Unexecuted instantiation: optlist.c:strdup_between_offsets Unexecuted instantiation: optstr.c:strdup_between_offsets Unexecuted instantiation: buffer.c:strdup_between_offsets Unexecuted instantiation: mbsalign.c:strdup_between_offsets Unexecuted instantiation: evaluate.c:strdup_between_offsets Unexecuted instantiation: probe.c:strdup_between_offsets Unexecuted instantiation: partitions.c:strdup_between_offsets Unexecuted instantiation: devname.c:strdup_between_offsets Unexecuted instantiation: devno.c:strdup_between_offsets Unexecuted instantiation: encode.c:strdup_between_offsets |
202 | | |
203 | | /* Copy string addressed by struct member between two instances of the same |
204 | | * struct type */ |
205 | | #define strdup_between_structs(_dst, _src, _m) \ |
206 | 0 | strdup_between_offsets((void *)_dst, (void *)_src, offsetof(__typeof__(*(_src)), _m)) |
207 | | |
208 | | static inline int is_nonnull_offset(const void *stru, size_t offset) |
209 | 0 | { |
210 | 0 | const char **o; |
211 | 0 |
|
212 | 0 | if (!stru) |
213 | 0 | return -EINVAL; |
214 | 0 |
|
215 | 0 | o = (const char **) ((const char *) stru + offset); |
216 | 0 | return *o != NULL; |
217 | 0 | } Unexecuted instantiation: fuzz.c:is_nonnull_offset Unexecuted instantiation: tab.c:is_nonnull_offset Unexecuted instantiation: tab_parse.c:is_nonnull_offset Unexecuted instantiation: utils.c:is_nonnull_offset Unexecuted instantiation: canonicalize.c:is_nonnull_offset Unexecuted instantiation: loopdev.c:is_nonnull_offset Unexecuted instantiation: path.c:is_nonnull_offset Unexecuted instantiation: strutils.c:is_nonnull_offset Unexecuted instantiation: strv.c:is_nonnull_offset Unexecuted instantiation: sysfs.c:is_nonnull_offset Unexecuted instantiation: cache.c:is_nonnull_offset Unexecuted instantiation: fs.c:is_nonnull_offset Unexecuted instantiation: optmap.c:is_nonnull_offset Unexecuted instantiation: optlist.c:is_nonnull_offset Unexecuted instantiation: optstr.c:is_nonnull_offset Unexecuted instantiation: buffer.c:is_nonnull_offset Unexecuted instantiation: mbsalign.c:is_nonnull_offset Unexecuted instantiation: evaluate.c:is_nonnull_offset Unexecuted instantiation: probe.c:is_nonnull_offset Unexecuted instantiation: partitions.c:is_nonnull_offset Unexecuted instantiation: devname.c:is_nonnull_offset Unexecuted instantiation: devno.c:is_nonnull_offset Unexecuted instantiation: encode.c:is_nonnull_offset |
218 | | |
219 | | #define is_nonnull_member(_stru, _m) \ |
220 | | is_nonnull_offset((void *) _stru, offsetof(__typeof__(*(_stru)), _m)) |
221 | | |
222 | | static inline int strcmp_offsets(const void *sa, const void *sb, size_t offset) |
223 | 0 | { |
224 | 0 | const char **a = (const char **) ((const char *) sa + offset), |
225 | 0 | **b = (const char **) ((const char *) sb + offset); |
226 | 0 |
|
227 | 0 | if (!*a && !*b) |
228 | 0 | return 0; |
229 | 0 | if (!*a) |
230 | 0 | return -1; |
231 | 0 | if (!*b) |
232 | 0 | return 1; |
233 | 0 | return strcmp(*a, *b); |
234 | 0 | } Unexecuted instantiation: fuzz.c:strcmp_offsets Unexecuted instantiation: tab.c:strcmp_offsets Unexecuted instantiation: tab_parse.c:strcmp_offsets Unexecuted instantiation: utils.c:strcmp_offsets Unexecuted instantiation: canonicalize.c:strcmp_offsets Unexecuted instantiation: loopdev.c:strcmp_offsets Unexecuted instantiation: path.c:strcmp_offsets Unexecuted instantiation: strutils.c:strcmp_offsets Unexecuted instantiation: strv.c:strcmp_offsets Unexecuted instantiation: sysfs.c:strcmp_offsets Unexecuted instantiation: cache.c:strcmp_offsets Unexecuted instantiation: fs.c:strcmp_offsets Unexecuted instantiation: optmap.c:strcmp_offsets Unexecuted instantiation: optlist.c:strcmp_offsets Unexecuted instantiation: optstr.c:strcmp_offsets Unexecuted instantiation: buffer.c:strcmp_offsets Unexecuted instantiation: mbsalign.c:strcmp_offsets Unexecuted instantiation: evaluate.c:strcmp_offsets Unexecuted instantiation: probe.c:strcmp_offsets Unexecuted instantiation: partitions.c:strcmp_offsets Unexecuted instantiation: devname.c:strcmp_offsets Unexecuted instantiation: devno.c:strcmp_offsets Unexecuted instantiation: encode.c:strcmp_offsets |
235 | | |
236 | | #define strcmp_members(_a, _b, _m) \ |
237 | | strcmp_offsets((void *) _a, (void *) _b, offsetof(__typeof__(*(_a)), _m)) |
238 | | |
239 | | extern char *xstrmode(mode_t mode, char *str); |
240 | | |
241 | | /* Options for size_to_human_string() */ |
242 | | enum |
243 | | { |
244 | | SIZE_SUFFIX_1LETTER = 0, |
245 | | SIZE_SUFFIX_3LETTER = (1 << 0), |
246 | | SIZE_SUFFIX_SPACE = (1 << 1), |
247 | | SIZE_DECIMAL_2DIGITS = (1 << 2) |
248 | | }; |
249 | | |
250 | | extern char *size_to_human_string(int options, uint64_t bytes); |
251 | | |
252 | | extern int string_to_idarray(const char *list, int ary[], size_t arysz, |
253 | | int (name2id)(const char *, size_t)); |
254 | | extern int string_add_to_idarray(const char *list, int ary[], |
255 | | size_t arysz, size_t *ary_pos, |
256 | | int (name2id)(const char *, size_t)); |
257 | | |
258 | | extern int string_to_bitarray(const char *list, char *ary, |
259 | | int (*name2bit)(const char *, size_t), |
260 | | size_t allow_range); |
261 | | |
262 | | extern int string_to_bitmask(const char *list, |
263 | | unsigned long *mask, |
264 | | long (*name2flag)(const char *, size_t)); |
265 | | extern int ul_parse_range(const char *str, int *lower, int *upper, int def); |
266 | | |
267 | | extern int streq_paths(const char *a, const char *b); |
268 | | |
269 | | /* |
270 | | * Match string beginning. |
271 | | */ |
272 | | static inline const char *ul_startswith(const char *s, const char *prefix) |
273 | 33.4k | { |
274 | 33.4k | size_t sz = prefix ? strlen(prefix) : 0; |
275 | | |
276 | 33.4k | if (s && sz && strncmp(s, prefix, sz) == 0) |
277 | 493 | return s + sz; |
278 | 32.9k | return NULL; |
279 | 33.4k | } Unexecuted instantiation: fuzz.c:ul_startswith Unexecuted instantiation: tab.c:ul_startswith Unexecuted instantiation: tab_parse.c:ul_startswith Unexecuted instantiation: utils.c:ul_startswith Unexecuted instantiation: canonicalize.c:ul_startswith Unexecuted instantiation: loopdev.c:ul_startswith Unexecuted instantiation: path.c:ul_startswith Unexecuted instantiation: strutils.c:ul_startswith Unexecuted instantiation: strv.c:ul_startswith Unexecuted instantiation: sysfs.c:ul_startswith Unexecuted instantiation: cache.c:ul_startswith Unexecuted instantiation: fs.c:ul_startswith Line | Count | Source | 273 | 33.4k | { | 274 | 33.4k | size_t sz = prefix ? strlen(prefix) : 0; | 275 | | | 276 | 33.4k | if (s && sz && strncmp(s, prefix, sz) == 0) | 277 | 493 | return s + sz; | 278 | 32.9k | return NULL; | 279 | 33.4k | } |
Unexecuted instantiation: optlist.c:ul_startswith Unexecuted instantiation: optstr.c:ul_startswith Unexecuted instantiation: buffer.c:ul_startswith Unexecuted instantiation: mbsalign.c:ul_startswith Unexecuted instantiation: evaluate.c:ul_startswith Unexecuted instantiation: probe.c:ul_startswith Unexecuted instantiation: partitions.c:ul_startswith Unexecuted instantiation: devname.c:ul_startswith Unexecuted instantiation: devno.c:ul_startswith Unexecuted instantiation: encode.c:ul_startswith |
280 | | |
281 | | /* |
282 | | * Case insensitive match string beginning. |
283 | | */ |
284 | | static inline const char *startswith_no_case(const char *s, const char *prefix) |
285 | 0 | { |
286 | 0 | size_t sz = prefix ? strlen(prefix) : 0; |
287 | 0 |
|
288 | 0 | if (s && sz && strncasecmp(s, prefix, sz) == 0) |
289 | 0 | return s + sz; |
290 | 0 | return NULL; |
291 | 0 | } Unexecuted instantiation: fuzz.c:startswith_no_case Unexecuted instantiation: tab.c:startswith_no_case Unexecuted instantiation: tab_parse.c:startswith_no_case Unexecuted instantiation: utils.c:startswith_no_case Unexecuted instantiation: canonicalize.c:startswith_no_case Unexecuted instantiation: loopdev.c:startswith_no_case Unexecuted instantiation: path.c:startswith_no_case Unexecuted instantiation: strutils.c:startswith_no_case Unexecuted instantiation: strv.c:startswith_no_case Unexecuted instantiation: sysfs.c:startswith_no_case Unexecuted instantiation: cache.c:startswith_no_case Unexecuted instantiation: fs.c:startswith_no_case Unexecuted instantiation: optmap.c:startswith_no_case Unexecuted instantiation: optlist.c:startswith_no_case Unexecuted instantiation: optstr.c:startswith_no_case Unexecuted instantiation: buffer.c:startswith_no_case Unexecuted instantiation: mbsalign.c:startswith_no_case Unexecuted instantiation: evaluate.c:startswith_no_case Unexecuted instantiation: probe.c:startswith_no_case Unexecuted instantiation: partitions.c:startswith_no_case Unexecuted instantiation: devname.c:startswith_no_case Unexecuted instantiation: devno.c:startswith_no_case Unexecuted instantiation: encode.c:startswith_no_case |
292 | | |
293 | | /* |
294 | | * Match path beginning |
295 | | */ |
296 | | static inline const char *startswithpath(const char *s, const char *prefix) |
297 | 0 | { |
298 | 0 | const char *p = ul_startswith(s, prefix); |
299 | 0 |
|
300 | 0 | if (p && (*p == '/' || *p == '\0')) |
301 | 0 | return p; |
302 | 0 |
|
303 | 0 | return NULL; |
304 | 0 | } Unexecuted instantiation: fuzz.c:startswithpath Unexecuted instantiation: tab.c:startswithpath Unexecuted instantiation: tab_parse.c:startswithpath Unexecuted instantiation: utils.c:startswithpath Unexecuted instantiation: canonicalize.c:startswithpath Unexecuted instantiation: loopdev.c:startswithpath Unexecuted instantiation: path.c:startswithpath Unexecuted instantiation: strutils.c:startswithpath Unexecuted instantiation: strv.c:startswithpath Unexecuted instantiation: sysfs.c:startswithpath Unexecuted instantiation: cache.c:startswithpath Unexecuted instantiation: fs.c:startswithpath Unexecuted instantiation: optmap.c:startswithpath Unexecuted instantiation: optlist.c:startswithpath Unexecuted instantiation: optstr.c:startswithpath Unexecuted instantiation: buffer.c:startswithpath Unexecuted instantiation: mbsalign.c:startswithpath Unexecuted instantiation: evaluate.c:startswithpath Unexecuted instantiation: probe.c:startswithpath Unexecuted instantiation: partitions.c:startswithpath Unexecuted instantiation: devname.c:startswithpath Unexecuted instantiation: devno.c:startswithpath Unexecuted instantiation: encode.c:startswithpath |
305 | | |
306 | | /* |
307 | | * Match string ending. |
308 | | */ |
309 | | static inline const char *ul_endswith(const char *s, const char *postfix) |
310 | 25.8k | { |
311 | 25.8k | size_t sl = s ? strlen(s) : 0; |
312 | 25.8k | size_t pl = postfix ? strlen(postfix) : 0; |
313 | | |
314 | 25.8k | if (pl == 0) |
315 | 0 | return s + sl; |
316 | 25.8k | if (sl < pl) |
317 | 25.2k | return NULL; |
318 | 588 | if (memcmp(s + sl - pl, postfix, pl) != 0) |
319 | 388 | return NULL; |
320 | 200 | return s + sl - pl; |
321 | 588 | } Unexecuted instantiation: fuzz.c:ul_endswith Unexecuted instantiation: tab.c:ul_endswith Line | Count | Source | 310 | 25.8k | { | 311 | 25.8k | size_t sl = s ? strlen(s) : 0; | 312 | 25.8k | size_t pl = postfix ? strlen(postfix) : 0; | 313 | | | 314 | 25.8k | if (pl == 0) | 315 | 0 | return s + sl; | 316 | 25.8k | if (sl < pl) | 317 | 25.2k | return NULL; | 318 | 588 | if (memcmp(s + sl - pl, postfix, pl) != 0) | 319 | 388 | return NULL; | 320 | 200 | return s + sl - pl; | 321 | 588 | } |
Unexecuted instantiation: utils.c:ul_endswith Unexecuted instantiation: canonicalize.c:ul_endswith Unexecuted instantiation: loopdev.c:ul_endswith Unexecuted instantiation: path.c:ul_endswith Unexecuted instantiation: strutils.c:ul_endswith Unexecuted instantiation: strv.c:ul_endswith Unexecuted instantiation: sysfs.c:ul_endswith Unexecuted instantiation: cache.c:ul_endswith Unexecuted instantiation: fs.c:ul_endswith Unexecuted instantiation: optmap.c:ul_endswith Unexecuted instantiation: optlist.c:ul_endswith Unexecuted instantiation: optstr.c:ul_endswith Unexecuted instantiation: buffer.c:ul_endswith Unexecuted instantiation: mbsalign.c:ul_endswith Unexecuted instantiation: evaluate.c:ul_endswith Unexecuted instantiation: probe.c:ul_endswith Unexecuted instantiation: partitions.c:ul_endswith Unexecuted instantiation: devname.c:ul_endswith Unexecuted instantiation: devno.c:ul_endswith Unexecuted instantiation: encode.c:ul_endswith |
322 | | |
323 | | /* |
324 | | * Skip leading white space. |
325 | | */ |
326 | | static inline const char *skip_space(const char *p) |
327 | 0 | { |
328 | 0 | while (isspace(*p)) |
329 | 0 | ++p; |
330 | 0 | return p; |
331 | 0 | } Unexecuted instantiation: fuzz.c:skip_space Unexecuted instantiation: tab.c:skip_space Unexecuted instantiation: tab_parse.c:skip_space Unexecuted instantiation: utils.c:skip_space Unexecuted instantiation: canonicalize.c:skip_space Unexecuted instantiation: loopdev.c:skip_space Unexecuted instantiation: path.c:skip_space Unexecuted instantiation: strutils.c:skip_space Unexecuted instantiation: strv.c:skip_space Unexecuted instantiation: sysfs.c:skip_space Unexecuted instantiation: cache.c:skip_space Unexecuted instantiation: fs.c:skip_space Unexecuted instantiation: optmap.c:skip_space Unexecuted instantiation: optlist.c:skip_space Unexecuted instantiation: optstr.c:skip_space Unexecuted instantiation: buffer.c:skip_space Unexecuted instantiation: mbsalign.c:skip_space Unexecuted instantiation: evaluate.c:skip_space Unexecuted instantiation: probe.c:skip_space Unexecuted instantiation: partitions.c:skip_space Unexecuted instantiation: devname.c:skip_space Unexecuted instantiation: devno.c:skip_space Unexecuted instantiation: encode.c:skip_space |
332 | | |
333 | | static inline const char *skip_blank(const char *p) |
334 | 147k | { |
335 | 147k | while (isblank(*p)) |
336 | 23.9k | ++p; |
337 | 147k | return p; |
338 | 147k | } Unexecuted instantiation: fuzz.c:skip_blank Unexecuted instantiation: tab.c:skip_blank Line | Count | Source | 334 | 147k | { | 335 | 147k | while (isblank(*p)) | 336 | 23.9k | ++p; | 337 | 147k | return p; | 338 | 147k | } |
Unexecuted instantiation: utils.c:skip_blank Unexecuted instantiation: canonicalize.c:skip_blank Unexecuted instantiation: loopdev.c:skip_blank Unexecuted instantiation: path.c:skip_blank Unexecuted instantiation: strutils.c:skip_blank Unexecuted instantiation: strv.c:skip_blank Unexecuted instantiation: sysfs.c:skip_blank Unexecuted instantiation: cache.c:skip_blank Unexecuted instantiation: fs.c:skip_blank Unexecuted instantiation: optmap.c:skip_blank Unexecuted instantiation: optlist.c:skip_blank Unexecuted instantiation: optstr.c:skip_blank Unexecuted instantiation: buffer.c:skip_blank Unexecuted instantiation: mbsalign.c:skip_blank Unexecuted instantiation: evaluate.c:skip_blank Unexecuted instantiation: probe.c:skip_blank Unexecuted instantiation: partitions.c:skip_blank Unexecuted instantiation: devname.c:skip_blank Unexecuted instantiation: devno.c:skip_blank Unexecuted instantiation: encode.c:skip_blank |
339 | | |
340 | | |
341 | | /* Removes whitespace from the right-hand side of a string (trailing |
342 | | * whitespace). |
343 | | * |
344 | | * Returns size of the new string (without \0). |
345 | | */ |
346 | | static inline size_t rtrim_whitespace(unsigned char *str) |
347 | 9 | { |
348 | 9 | size_t i; |
349 | | |
350 | 9 | if (!str) |
351 | 0 | return 0; |
352 | 9 | i = strlen((char *) str); |
353 | 9 | while (i) { |
354 | 0 | i--; |
355 | 0 | if (!isspace(str[i])) { |
356 | 0 | i++; |
357 | 0 | break; |
358 | 0 | } |
359 | 0 | } |
360 | 9 | str[i] = '\0'; |
361 | 9 | return i; |
362 | 9 | } Unexecuted instantiation: fuzz.c:rtrim_whitespace Unexecuted instantiation: tab.c:rtrim_whitespace Unexecuted instantiation: tab_parse.c:rtrim_whitespace Unexecuted instantiation: utils.c:rtrim_whitespace Unexecuted instantiation: canonicalize.c:rtrim_whitespace Unexecuted instantiation: loopdev.c:rtrim_whitespace Unexecuted instantiation: path.c:rtrim_whitespace Unexecuted instantiation: strutils.c:rtrim_whitespace Unexecuted instantiation: strv.c:rtrim_whitespace Unexecuted instantiation: sysfs.c:rtrim_whitespace Unexecuted instantiation: cache.c:rtrim_whitespace Unexecuted instantiation: fs.c:rtrim_whitespace Unexecuted instantiation: optmap.c:rtrim_whitespace Unexecuted instantiation: optlist.c:rtrim_whitespace Unexecuted instantiation: optstr.c:rtrim_whitespace Unexecuted instantiation: buffer.c:rtrim_whitespace Unexecuted instantiation: mbsalign.c:rtrim_whitespace Unexecuted instantiation: evaluate.c:rtrim_whitespace Unexecuted instantiation: partitions.c:rtrim_whitespace Unexecuted instantiation: devname.c:rtrim_whitespace Unexecuted instantiation: devno.c:rtrim_whitespace Unexecuted instantiation: encode.c:rtrim_whitespace |
363 | | |
364 | | /* Removes whitespace from the left-hand side of a string. |
365 | | * |
366 | | * Returns size of the new string (without \0). |
367 | | */ |
368 | | static inline size_t ltrim_whitespace(unsigned char *str) |
369 | 0 | { |
370 | 0 | size_t len; |
371 | 0 | unsigned char *p; |
372 | |
|
373 | 0 | if (!str) |
374 | 0 | return 0; |
375 | 0 | for (p = str; *p && isspace(*p); p++); |
376 | |
|
377 | 0 | len = strlen((char *) p); |
378 | |
|
379 | 0 | if (p > str) |
380 | 0 | memmove(str, p, len + 1); |
381 | |
|
382 | 0 | return len; |
383 | 0 | } Unexecuted instantiation: fuzz.c:ltrim_whitespace Unexecuted instantiation: tab.c:ltrim_whitespace Unexecuted instantiation: tab_parse.c:ltrim_whitespace Unexecuted instantiation: utils.c:ltrim_whitespace Unexecuted instantiation: canonicalize.c:ltrim_whitespace Unexecuted instantiation: loopdev.c:ltrim_whitespace Unexecuted instantiation: path.c:ltrim_whitespace Unexecuted instantiation: strutils.c:ltrim_whitespace Unexecuted instantiation: strv.c:ltrim_whitespace Unexecuted instantiation: sysfs.c:ltrim_whitespace Unexecuted instantiation: cache.c:ltrim_whitespace Unexecuted instantiation: fs.c:ltrim_whitespace Unexecuted instantiation: optmap.c:ltrim_whitespace Unexecuted instantiation: optlist.c:ltrim_whitespace Unexecuted instantiation: optstr.c:ltrim_whitespace Unexecuted instantiation: buffer.c:ltrim_whitespace Unexecuted instantiation: mbsalign.c:ltrim_whitespace Unexecuted instantiation: evaluate.c:ltrim_whitespace Unexecuted instantiation: probe.c:ltrim_whitespace Unexecuted instantiation: partitions.c:ltrim_whitespace Unexecuted instantiation: devname.c:ltrim_whitespace Unexecuted instantiation: devno.c:ltrim_whitespace Unexecuted instantiation: encode.c:ltrim_whitespace |
384 | | |
385 | | /* Removes left-hand, right-hand and repeating whitespaces. |
386 | | */ |
387 | | static inline size_t __normalize_whitespace( |
388 | | const unsigned char *src, |
389 | | size_t sz, |
390 | | unsigned char *dst, |
391 | | size_t len) |
392 | 0 | { |
393 | 0 | size_t i, x = 0; |
394 | 0 | int nsp = 0, intext = 0; |
395 | |
|
396 | 0 | if (!sz) |
397 | 0 | goto done; |
398 | | |
399 | 0 | for (i = 0, x = 0; i < sz && x < len - 1; ) { |
400 | 0 | if (isspace(src[i])) |
401 | 0 | nsp++; |
402 | 0 | else |
403 | 0 | nsp = 0, intext = 1; |
404 | |
|
405 | 0 | if (nsp > 1 || (nsp && !intext)) |
406 | 0 | i++; |
407 | 0 | else |
408 | 0 | dst[x++] = src[i++]; |
409 | 0 | } |
410 | 0 | if (nsp && x > 0) /* trailing space */ |
411 | 0 | x--; |
412 | 0 | done: |
413 | 0 | dst[x] = '\0'; |
414 | 0 | return x; |
415 | 0 | } Unexecuted instantiation: fuzz.c:__normalize_whitespace Unexecuted instantiation: tab.c:__normalize_whitespace Unexecuted instantiation: tab_parse.c:__normalize_whitespace Unexecuted instantiation: utils.c:__normalize_whitespace Unexecuted instantiation: canonicalize.c:__normalize_whitespace Unexecuted instantiation: loopdev.c:__normalize_whitespace Unexecuted instantiation: path.c:__normalize_whitespace Unexecuted instantiation: strutils.c:__normalize_whitespace Unexecuted instantiation: strv.c:__normalize_whitespace Unexecuted instantiation: sysfs.c:__normalize_whitespace Unexecuted instantiation: cache.c:__normalize_whitespace Unexecuted instantiation: fs.c:__normalize_whitespace Unexecuted instantiation: optmap.c:__normalize_whitespace Unexecuted instantiation: optlist.c:__normalize_whitespace Unexecuted instantiation: optstr.c:__normalize_whitespace Unexecuted instantiation: buffer.c:__normalize_whitespace Unexecuted instantiation: mbsalign.c:__normalize_whitespace Unexecuted instantiation: evaluate.c:__normalize_whitespace Unexecuted instantiation: probe.c:__normalize_whitespace Unexecuted instantiation: partitions.c:__normalize_whitespace Unexecuted instantiation: devname.c:__normalize_whitespace Unexecuted instantiation: devno.c:__normalize_whitespace Unexecuted instantiation: encode.c:__normalize_whitespace |
416 | | |
417 | | static inline size_t normalize_whitespace(unsigned char *str) |
418 | 0 | { |
419 | 0 | size_t sz = strlen((char *) str); |
420 | 0 | return __normalize_whitespace(str, sz, str, sz + 1); |
421 | 0 | } Unexecuted instantiation: fuzz.c:normalize_whitespace Unexecuted instantiation: tab.c:normalize_whitespace Unexecuted instantiation: tab_parse.c:normalize_whitespace Unexecuted instantiation: utils.c:normalize_whitespace Unexecuted instantiation: canonicalize.c:normalize_whitespace Unexecuted instantiation: loopdev.c:normalize_whitespace Unexecuted instantiation: path.c:normalize_whitespace Unexecuted instantiation: strutils.c:normalize_whitespace Unexecuted instantiation: strv.c:normalize_whitespace Unexecuted instantiation: sysfs.c:normalize_whitespace Unexecuted instantiation: cache.c:normalize_whitespace Unexecuted instantiation: fs.c:normalize_whitespace Unexecuted instantiation: optmap.c:normalize_whitespace Unexecuted instantiation: optlist.c:normalize_whitespace Unexecuted instantiation: optstr.c:normalize_whitespace Unexecuted instantiation: buffer.c:normalize_whitespace Unexecuted instantiation: mbsalign.c:normalize_whitespace Unexecuted instantiation: evaluate.c:normalize_whitespace Unexecuted instantiation: probe.c:normalize_whitespace Unexecuted instantiation: partitions.c:normalize_whitespace Unexecuted instantiation: devname.c:normalize_whitespace Unexecuted instantiation: devno.c:normalize_whitespace Unexecuted instantiation: encode.c:normalize_whitespace |
422 | | |
423 | | static inline void ul_strrep(char *s, int find, int replace) |
424 | 0 | { |
425 | 0 | while (s && *s && (s = strchr(s, find)) != NULL) |
426 | 0 | *s++ = replace; |
427 | 0 | } Unexecuted instantiation: fuzz.c:ul_strrep Unexecuted instantiation: tab.c:ul_strrep Unexecuted instantiation: tab_parse.c:ul_strrep Unexecuted instantiation: utils.c:ul_strrep Unexecuted instantiation: canonicalize.c:ul_strrep Unexecuted instantiation: loopdev.c:ul_strrep Unexecuted instantiation: path.c:ul_strrep Unexecuted instantiation: strutils.c:ul_strrep Unexecuted instantiation: strv.c:ul_strrep Unexecuted instantiation: sysfs.c:ul_strrep Unexecuted instantiation: cache.c:ul_strrep Unexecuted instantiation: fs.c:ul_strrep Unexecuted instantiation: optmap.c:ul_strrep Unexecuted instantiation: optlist.c:ul_strrep Unexecuted instantiation: optstr.c:ul_strrep Unexecuted instantiation: buffer.c:ul_strrep Unexecuted instantiation: mbsalign.c:ul_strrep Unexecuted instantiation: evaluate.c:ul_strrep Unexecuted instantiation: probe.c:ul_strrep Unexecuted instantiation: partitions.c:ul_strrep Unexecuted instantiation: devname.c:ul_strrep Unexecuted instantiation: devno.c:ul_strrep Unexecuted instantiation: encode.c:ul_strrep |
428 | | |
429 | | static inline void ul_strrem(char *s, int rem) |
430 | 0 | { |
431 | 0 | char *p; |
432 | 0 |
|
433 | 0 | if (!s) |
434 | 0 | return; |
435 | 0 | for (p = s; *s; s++) { |
436 | 0 | if (*s != rem) |
437 | 0 | *p++ = *s; |
438 | 0 | } |
439 | 0 | *p = '\0'; |
440 | 0 | } Unexecuted instantiation: fuzz.c:ul_strrem Unexecuted instantiation: tab.c:ul_strrem Unexecuted instantiation: tab_parse.c:ul_strrem Unexecuted instantiation: utils.c:ul_strrem Unexecuted instantiation: canonicalize.c:ul_strrem Unexecuted instantiation: loopdev.c:ul_strrem Unexecuted instantiation: path.c:ul_strrem Unexecuted instantiation: strutils.c:ul_strrem Unexecuted instantiation: strv.c:ul_strrem Unexecuted instantiation: sysfs.c:ul_strrem Unexecuted instantiation: cache.c:ul_strrem Unexecuted instantiation: fs.c:ul_strrem Unexecuted instantiation: optmap.c:ul_strrem Unexecuted instantiation: optlist.c:ul_strrem Unexecuted instantiation: optstr.c:ul_strrem Unexecuted instantiation: buffer.c:ul_strrem Unexecuted instantiation: mbsalign.c:ul_strrem Unexecuted instantiation: evaluate.c:ul_strrem Unexecuted instantiation: probe.c:ul_strrem Unexecuted instantiation: partitions.c:ul_strrem Unexecuted instantiation: devname.c:ul_strrem Unexecuted instantiation: devno.c:ul_strrem Unexecuted instantiation: encode.c:ul_strrem |
441 | | |
442 | | /* returns next string after \0 if before @end */ |
443 | | static inline char *ul_next_string(char *p, char *end) |
444 | 0 | { |
445 | 0 | char *last; |
446 | 0 |
|
447 | 0 | if (!p || !end || p >= end) |
448 | 0 | return NULL; |
449 | 0 |
|
450 | 0 | for (last = p; p < end; p++) { |
451 | 0 | if (*last == '\0' && p != last) |
452 | 0 | return p; |
453 | 0 | last = p; |
454 | 0 | } |
455 | 0 |
|
456 | 0 | return NULL; |
457 | 0 | } Unexecuted instantiation: fuzz.c:ul_next_string Unexecuted instantiation: tab.c:ul_next_string Unexecuted instantiation: tab_parse.c:ul_next_string Unexecuted instantiation: utils.c:ul_next_string Unexecuted instantiation: canonicalize.c:ul_next_string Unexecuted instantiation: loopdev.c:ul_next_string Unexecuted instantiation: path.c:ul_next_string Unexecuted instantiation: strutils.c:ul_next_string Unexecuted instantiation: strv.c:ul_next_string Unexecuted instantiation: sysfs.c:ul_next_string Unexecuted instantiation: cache.c:ul_next_string Unexecuted instantiation: fs.c:ul_next_string Unexecuted instantiation: optmap.c:ul_next_string Unexecuted instantiation: optlist.c:ul_next_string Unexecuted instantiation: optstr.c:ul_next_string Unexecuted instantiation: buffer.c:ul_next_string Unexecuted instantiation: mbsalign.c:ul_next_string Unexecuted instantiation: evaluate.c:ul_next_string Unexecuted instantiation: probe.c:ul_next_string Unexecuted instantiation: partitions.c:ul_next_string Unexecuted instantiation: devname.c:ul_next_string Unexecuted instantiation: devno.c:ul_next_string Unexecuted instantiation: encode.c:ul_next_string |
458 | | |
459 | | extern char *ul_strnconcat(const char *s, const char *suffix, size_t b); |
460 | | extern char *ul_strconcat(const char *s, const char *suffix); |
461 | | extern char *ul_strfconcat(const char *s, const char *format, ...) |
462 | | __attribute__ ((__format__ (__printf__, 2, 3))); |
463 | | |
464 | | extern int ul_strappend(char **a, const char *b); |
465 | | extern int strfappend(char **a, const char *format, ...) |
466 | | __attribute__ ((__format__ (__printf__, 2, 3))); |
467 | | extern int ul_strvfappend(char **a, const char *format, va_list ap) |
468 | | __attribute__ ((__format__ (__printf__, 2, 0))); |
469 | | |
470 | | extern const char *ul_split(const char **state, size_t *l, const char *separator, int quoted); |
471 | | |
472 | | extern char *ul_strchr_escaped(const char *s, int c); |
473 | | |
474 | | extern int skip_fline(FILE *fp); |
475 | | extern int ul_stralnumcmp(const char *p1, const char *p2); |
476 | | |
477 | | extern int ul_optstr_next(char **optstr, char **name, size_t *namesz, char **value, size_t *valsz); |
478 | | extern int ul_optstr_is_valid(const char *optstr); |
479 | | |
480 | | #endif |