/src/util-linux/include/strutils.h
Line | Count | Source |
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 | | extern bool annotationwanted(const char *mode); |
66 | | |
67 | | extern int isdigit_strend(const char *str, const char **end); |
68 | | #define isdigit_string(_s) isdigit_strend(_s, NULL) |
69 | | |
70 | | extern int isxdigit_strend(const char *str, const char **end); |
71 | | #define isxdigit_string(_s) isxdigit_strend(_s, NULL) |
72 | | |
73 | | |
74 | | extern int ul_strtobool(const char *str, bool *result); |
75 | | extern int ul_parse_switch(const char *arg, ...); |
76 | | |
77 | | #ifndef HAVE_MEMPCPY |
78 | | extern void *mempcpy(void *restrict dest, const void *restrict src, size_t n); |
79 | | #endif |
80 | | #ifndef HAVE_STRNLEN |
81 | | extern size_t strnlen(const char *s, size_t maxlen); |
82 | | #endif |
83 | | #ifndef HAVE_STRNDUP |
84 | | extern char *strndup(const char *s, size_t n); |
85 | | #endif |
86 | | #ifndef HAVE_STRNCHR |
87 | | extern char *strnchr(const char *s, size_t maxlen, int c); |
88 | | #endif |
89 | | |
90 | | /* caller guarantees n > 0 */ |
91 | | static inline int xstrncpy(char *dest, const char *src, size_t n) |
92 | 0 | { |
93 | 0 | size_t len = src ? strlen(src) : 0; |
94 | |
|
95 | 0 | if (!len) |
96 | 0 | return 0; |
97 | 0 | len = min(len, n - 1); |
98 | 0 | memcpy(dest, src, len); |
99 | 0 | dest[len] = 0; |
100 | 0 | return len; |
101 | 0 | } Unexecuted instantiation: script.c:xstrncpy Unexecuted instantiation: strutils.c:xstrncpy Unexecuted instantiation: ask.c:xstrncpy Unexecuted instantiation: utils.c:xstrncpy Unexecuted instantiation: context.c:xstrncpy Unexecuted instantiation: parttype.c:xstrncpy Unexecuted instantiation: partition.c:xstrncpy Unexecuted instantiation: wipe.c:xstrncpy Unexecuted instantiation: dos.c:xstrncpy Unexecuted instantiation: gpt.c:xstrncpy Unexecuted instantiation: canonicalize.c:xstrncpy Unexecuted instantiation: path.c:xstrncpy Unexecuted instantiation: sysfs.c:xstrncpy Unexecuted instantiation: buffer.c:xstrncpy Unexecuted instantiation: mbsalign.c:xstrncpy Unexecuted instantiation: gen_uuid.c:xstrncpy Unexecuted instantiation: probe.c:xstrncpy Unexecuted instantiation: partitions.c:xstrncpy Unexecuted instantiation: devname.c:xstrncpy Unexecuted instantiation: devno.c:xstrncpy Unexecuted instantiation: loopdev.c:xstrncpy Unexecuted instantiation: strv.c:xstrncpy |
102 | | |
103 | | /* This is like strncpy(), but based on memcpy(), so compilers and static |
104 | | * analyzers do not complain when sizeof(destination) is the same as 'n' and |
105 | | * result is not terminated by zero. |
106 | | * |
107 | | * Use this function to copy string to logs with fixed sizes (wtmp/utmp. ...) |
108 | | * where string terminator is optional. |
109 | | */ |
110 | | static inline void * __attribute__((nonnull (1))) |
111 | | str2memcpy(void *dest, const char *src, size_t n) |
112 | 0 | { |
113 | 0 | size_t bytes = strlen(src) + 1; |
114 | 0 |
|
115 | 0 | if (bytes > n) |
116 | 0 | bytes = n; |
117 | 0 |
|
118 | 0 | memcpy(dest, src, bytes); |
119 | 0 | return dest; |
120 | 0 | } Unexecuted instantiation: script.c:str2memcpy Unexecuted instantiation: strutils.c:str2memcpy Unexecuted instantiation: ask.c:str2memcpy Unexecuted instantiation: utils.c:str2memcpy Unexecuted instantiation: context.c:str2memcpy Unexecuted instantiation: parttype.c:str2memcpy Unexecuted instantiation: partition.c:str2memcpy Unexecuted instantiation: wipe.c:str2memcpy Unexecuted instantiation: dos.c:str2memcpy Unexecuted instantiation: gpt.c:str2memcpy Unexecuted instantiation: canonicalize.c:str2memcpy Unexecuted instantiation: path.c:str2memcpy Unexecuted instantiation: sysfs.c:str2memcpy Unexecuted instantiation: buffer.c:str2memcpy Unexecuted instantiation: mbsalign.c:str2memcpy Unexecuted instantiation: gen_uuid.c:str2memcpy Unexecuted instantiation: probe.c:str2memcpy Unexecuted instantiation: partitions.c:str2memcpy Unexecuted instantiation: devname.c:str2memcpy Unexecuted instantiation: devno.c:str2memcpy Unexecuted instantiation: loopdev.c:str2memcpy Unexecuted instantiation: strv.c:str2memcpy |
121 | | |
122 | | static inline char * __attribute__((nonnull (1))) |
123 | | mem2strcpy(char *dest, const void *src, size_t n, size_t nmax) |
124 | 0 | { |
125 | 0 | if (n + 1 > nmax) |
126 | 0 | n = nmax - 1; |
127 | 0 |
|
128 | 0 | memset(dest, '\0', nmax); |
129 | 0 | memcpy(dest, src, n); |
130 | 0 | return dest; |
131 | 0 | } Unexecuted instantiation: script.c:mem2strcpy Unexecuted instantiation: strutils.c:mem2strcpy Unexecuted instantiation: ask.c:mem2strcpy Unexecuted instantiation: utils.c:mem2strcpy Unexecuted instantiation: context.c:mem2strcpy Unexecuted instantiation: parttype.c:mem2strcpy Unexecuted instantiation: partition.c:mem2strcpy Unexecuted instantiation: wipe.c:mem2strcpy Unexecuted instantiation: dos.c:mem2strcpy Unexecuted instantiation: gpt.c:mem2strcpy Unexecuted instantiation: canonicalize.c:mem2strcpy Unexecuted instantiation: path.c:mem2strcpy Unexecuted instantiation: sysfs.c:mem2strcpy Unexecuted instantiation: buffer.c:mem2strcpy Unexecuted instantiation: mbsalign.c:mem2strcpy Unexecuted instantiation: gen_uuid.c:mem2strcpy Unexecuted instantiation: probe.c:mem2strcpy Unexecuted instantiation: partitions.c:mem2strcpy Unexecuted instantiation: devname.c:mem2strcpy Unexecuted instantiation: devno.c:mem2strcpy Unexecuted instantiation: loopdev.c:mem2strcpy Unexecuted instantiation: strv.c:mem2strcpy |
132 | | |
133 | | /* Reallocate @str according to @newstr and copy @newstr to @str; returns new @str. |
134 | | * The @str is not modified if reallocation failed (like classic realloc()). |
135 | | */ |
136 | | static inline char * __attribute__((warn_unused_result)) |
137 | | strrealloc(char *str, const char *newstr) |
138 | 0 | { |
139 | 0 | size_t nsz, osz; |
140 | 0 |
|
141 | 0 | if (!str) |
142 | 0 | return newstr ? strdup(newstr) : NULL; |
143 | 0 | if (!newstr) |
144 | 0 | return NULL; |
145 | 0 |
|
146 | 0 | osz = strlen(str); |
147 | 0 | nsz = strlen(newstr); |
148 | 0 |
|
149 | 0 | if (nsz > osz) |
150 | 0 | str = realloc(str, nsz + 1); |
151 | 0 | if (str) |
152 | 0 | memcpy(str, newstr, nsz + 1); |
153 | 0 | return str; |
154 | 0 | } Unexecuted instantiation: script.c:strrealloc Unexecuted instantiation: strutils.c:strrealloc Unexecuted instantiation: ask.c:strrealloc Unexecuted instantiation: utils.c:strrealloc Unexecuted instantiation: context.c:strrealloc Unexecuted instantiation: parttype.c:strrealloc Unexecuted instantiation: partition.c:strrealloc Unexecuted instantiation: wipe.c:strrealloc Unexecuted instantiation: dos.c:strrealloc Unexecuted instantiation: gpt.c:strrealloc Unexecuted instantiation: canonicalize.c:strrealloc Unexecuted instantiation: path.c:strrealloc Unexecuted instantiation: sysfs.c:strrealloc Unexecuted instantiation: buffer.c:strrealloc Unexecuted instantiation: mbsalign.c:strrealloc Unexecuted instantiation: gen_uuid.c:strrealloc Unexecuted instantiation: probe.c:strrealloc Unexecuted instantiation: partitions.c:strrealloc Unexecuted instantiation: devname.c:strrealloc Unexecuted instantiation: devno.c:strrealloc Unexecuted instantiation: loopdev.c:strrealloc Unexecuted instantiation: strv.c:strrealloc |
155 | | |
156 | | /* Copy string @str to struct @stru to member addressed by @offset */ |
157 | | static inline int strdup_to_offset(void *stru, size_t offset, const char *str) |
158 | 7.76k | { |
159 | 7.76k | char **o; |
160 | 7.76k | char *p = NULL; |
161 | | |
162 | 7.76k | if (!stru) |
163 | 0 | return -EINVAL; |
164 | | |
165 | 7.76k | o = (char **) ((char *) stru + offset); |
166 | 7.76k | if (str) { |
167 | 6.54k | p = strdup(str); |
168 | 6.54k | if (!p) |
169 | 0 | return -ENOMEM; |
170 | 6.54k | } |
171 | | |
172 | 7.76k | free(*o); |
173 | 7.76k | *o = p; |
174 | 7.76k | return 0; |
175 | 7.76k | } script.c:strdup_to_offset Line | Count | Source | 158 | 2.62k | { | 159 | 2.62k | char **o; | 160 | 2.62k | char *p = NULL; | 161 | | | 162 | 2.62k | if (!stru) | 163 | 0 | return -EINVAL; | 164 | | | 165 | 2.62k | o = (char **) ((char *) stru + offset); | 166 | 2.62k | if (str) { | 167 | 2.62k | p = strdup(str); | 168 | 2.62k | if (!p) | 169 | 0 | return -ENOMEM; | 170 | 2.62k | } | 171 | | | 172 | 2.62k | free(*o); | 173 | 2.62k | *o = p; | 174 | 2.62k | return 0; | 175 | 2.62k | } |
Unexecuted instantiation: strutils.c:strdup_to_offset Unexecuted instantiation: ask.c:strdup_to_offset Unexecuted instantiation: utils.c:strdup_to_offset Unexecuted instantiation: context.c:strdup_to_offset parttype.c:strdup_to_offset Line | Count | Source | 158 | 5.13k | { | 159 | 5.13k | char **o; | 160 | 5.13k | char *p = NULL; | 161 | | | 162 | 5.13k | if (!stru) | 163 | 0 | return -EINVAL; | 164 | | | 165 | 5.13k | o = (char **) ((char *) stru + offset); | 166 | 5.13k | if (str) { | 167 | 3.91k | p = strdup(str); | 168 | 3.91k | if (!p) | 169 | 0 | return -ENOMEM; | 170 | 3.91k | } | 171 | | | 172 | 5.13k | free(*o); | 173 | 5.13k | *o = p; | 174 | 5.13k | return 0; | 175 | 5.13k | } |
Unexecuted instantiation: partition.c:strdup_to_offset Unexecuted instantiation: wipe.c:strdup_to_offset Unexecuted instantiation: dos.c:strdup_to_offset Unexecuted instantiation: gpt.c:strdup_to_offset Unexecuted instantiation: canonicalize.c:strdup_to_offset Unexecuted instantiation: path.c:strdup_to_offset Unexecuted instantiation: sysfs.c:strdup_to_offset Unexecuted instantiation: buffer.c:strdup_to_offset Unexecuted instantiation: mbsalign.c:strdup_to_offset Unexecuted instantiation: gen_uuid.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: loopdev.c:strdup_to_offset Unexecuted instantiation: strv.c:strdup_to_offset |
176 | | |
177 | | /* Copy string __str to struct member _m of the struct _s */ |
178 | | #define strdup_to_struct_member(_s, _m, _str) \ |
179 | 7.76k | strdup_to_offset((void *) _s, offsetof(__typeof__(*(_s)), _m), _str) |
180 | | |
181 | | /* Copy string addressed by @offset between two structs */ |
182 | | static inline int strdup_between_offsets(void *stru_dst, void *stru_src, size_t offset) |
183 | 0 | { |
184 | 0 | char **src; |
185 | 0 | char **dst; |
186 | 0 | char *p = NULL; |
187 | |
|
188 | 0 | if (!stru_src || !stru_dst) |
189 | 0 | return -EINVAL; |
190 | | |
191 | 0 | src = (char **) ((char *) stru_src + offset); |
192 | 0 | dst = (char **) ((char *) stru_dst + offset); |
193 | |
|
194 | 0 | if (*src) { |
195 | 0 | p = strdup(*src); |
196 | 0 | if (!p) |
197 | 0 | return -ENOMEM; |
198 | 0 | } |
199 | | |
200 | 0 | free(*dst); |
201 | 0 | *dst = p; |
202 | 0 | return 0; |
203 | 0 | } Unexecuted instantiation: script.c:strdup_between_offsets Unexecuted instantiation: strutils.c:strdup_between_offsets Unexecuted instantiation: ask.c:strdup_between_offsets Unexecuted instantiation: utils.c:strdup_between_offsets Unexecuted instantiation: context.c:strdup_between_offsets Unexecuted instantiation: parttype.c:strdup_between_offsets Unexecuted instantiation: partition.c:strdup_between_offsets Unexecuted instantiation: wipe.c:strdup_between_offsets Unexecuted instantiation: dos.c:strdup_between_offsets Unexecuted instantiation: gpt.c:strdup_between_offsets Unexecuted instantiation: canonicalize.c:strdup_between_offsets Unexecuted instantiation: path.c:strdup_between_offsets Unexecuted instantiation: sysfs.c:strdup_between_offsets Unexecuted instantiation: buffer.c:strdup_between_offsets Unexecuted instantiation: mbsalign.c:strdup_between_offsets Unexecuted instantiation: gen_uuid.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: loopdev.c:strdup_between_offsets Unexecuted instantiation: strv.c:strdup_between_offsets |
204 | | |
205 | | /* Copy string addressed by struct member between two instances of the same |
206 | | * struct type */ |
207 | | #define strdup_between_structs(_dst, _src, _m) \ |
208 | 0 | strdup_between_offsets((void *)_dst, (void *)_src, offsetof(__typeof__(*(_src)), _m)) |
209 | | |
210 | | static inline int is_nonnull_offset(const void *stru, size_t offset) |
211 | 0 | { |
212 | 0 | const char **o; |
213 | 0 |
|
214 | 0 | if (!stru) |
215 | 0 | return -EINVAL; |
216 | 0 |
|
217 | 0 | o = (const char **) ((const char *) stru + offset); |
218 | 0 | return *o != NULL; |
219 | 0 | } Unexecuted instantiation: script.c:is_nonnull_offset Unexecuted instantiation: strutils.c:is_nonnull_offset Unexecuted instantiation: ask.c:is_nonnull_offset Unexecuted instantiation: utils.c:is_nonnull_offset Unexecuted instantiation: context.c:is_nonnull_offset Unexecuted instantiation: parttype.c:is_nonnull_offset Unexecuted instantiation: partition.c:is_nonnull_offset Unexecuted instantiation: wipe.c:is_nonnull_offset Unexecuted instantiation: dos.c:is_nonnull_offset Unexecuted instantiation: gpt.c:is_nonnull_offset Unexecuted instantiation: canonicalize.c:is_nonnull_offset Unexecuted instantiation: path.c:is_nonnull_offset Unexecuted instantiation: sysfs.c:is_nonnull_offset Unexecuted instantiation: buffer.c:is_nonnull_offset Unexecuted instantiation: mbsalign.c:is_nonnull_offset Unexecuted instantiation: gen_uuid.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: loopdev.c:is_nonnull_offset Unexecuted instantiation: strv.c:is_nonnull_offset |
220 | | |
221 | | #define is_nonnull_member(_stru, _m) \ |
222 | | is_nonnull_offset((void *) _stru, offsetof(__typeof__(*(_stru)), _m)) |
223 | | |
224 | | static inline int strcmp_offsets(const void *sa, const void *sb, size_t offset) |
225 | 0 | { |
226 | 0 | const char **a = (const char **) ((const char *) sa + offset), |
227 | 0 | **b = (const char **) ((const char *) sb + offset); |
228 | 0 |
|
229 | 0 | if (!*a && !*b) |
230 | 0 | return 0; |
231 | 0 | if (!*a) |
232 | 0 | return -1; |
233 | 0 | if (!*b) |
234 | 0 | return 1; |
235 | 0 | return strcmp(*a, *b); |
236 | 0 | } Unexecuted instantiation: script.c:strcmp_offsets Unexecuted instantiation: strutils.c:strcmp_offsets Unexecuted instantiation: ask.c:strcmp_offsets Unexecuted instantiation: utils.c:strcmp_offsets Unexecuted instantiation: context.c:strcmp_offsets Unexecuted instantiation: parttype.c:strcmp_offsets Unexecuted instantiation: partition.c:strcmp_offsets Unexecuted instantiation: wipe.c:strcmp_offsets Unexecuted instantiation: dos.c:strcmp_offsets Unexecuted instantiation: gpt.c:strcmp_offsets Unexecuted instantiation: canonicalize.c:strcmp_offsets Unexecuted instantiation: path.c:strcmp_offsets Unexecuted instantiation: sysfs.c:strcmp_offsets Unexecuted instantiation: buffer.c:strcmp_offsets Unexecuted instantiation: mbsalign.c:strcmp_offsets Unexecuted instantiation: gen_uuid.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: loopdev.c:strcmp_offsets Unexecuted instantiation: strv.c:strcmp_offsets |
237 | | |
238 | | #define strcmp_members(_a, _b, _m) \ |
239 | | strcmp_offsets((void *) _a, (void *) _b, offsetof(__typeof__(*(_a)), _m)) |
240 | | |
241 | | extern char *xstrmode(mode_t mode, char *str); |
242 | | |
243 | | /* Options for size_to_human_string() */ |
244 | | enum |
245 | | { |
246 | | SIZE_SUFFIX_1LETTER = 0, |
247 | | SIZE_SUFFIX_3LETTER = (1 << 0), |
248 | | SIZE_SUFFIX_SPACE = (1 << 1), |
249 | | SIZE_DECIMAL_2DIGITS = (1 << 2) |
250 | | }; |
251 | | |
252 | | extern char *size_to_human_string(int options, uint64_t bytes); |
253 | | |
254 | | extern int string_to_idarray(const char *list, int ary[], size_t arysz, |
255 | | int (name2id)(const char *, size_t)); |
256 | | extern int string_add_to_idarray(const char *list, int ary[], |
257 | | size_t arysz, size_t *ary_pos, |
258 | | int (name2id)(const char *, size_t)); |
259 | | |
260 | | extern int string_to_bitarray(const char *list, char *ary, |
261 | | int (*name2bit)(const char *, size_t), |
262 | | size_t allow_range); |
263 | | |
264 | | extern int string_to_bitmask(const char *list, |
265 | | unsigned long *mask, |
266 | | long (*name2flag)(const char *, size_t)); |
267 | | extern int ul_parse_range(const char *str, int *lower, int *upper, int def); |
268 | | |
269 | | extern int streq_paths(const char *a, const char *b); |
270 | | |
271 | | /* |
272 | | * Match string beginning. |
273 | | */ |
274 | | static inline const char *ul_startswith(const char *s, const char *prefix) |
275 | 0 | { |
276 | 0 | size_t sz = prefix ? strlen(prefix) : 0; |
277 | |
|
278 | 0 | if (s && sz && strncmp(s, prefix, sz) == 0) |
279 | 0 | return s + sz; |
280 | 0 | return NULL; |
281 | 0 | } Unexecuted instantiation: script.c:ul_startswith Unexecuted instantiation: strutils.c:ul_startswith Unexecuted instantiation: ask.c:ul_startswith Unexecuted instantiation: utils.c:ul_startswith Unexecuted instantiation: context.c:ul_startswith Unexecuted instantiation: parttype.c:ul_startswith Unexecuted instantiation: partition.c:ul_startswith Unexecuted instantiation: wipe.c:ul_startswith Unexecuted instantiation: dos.c:ul_startswith Unexecuted instantiation: gpt.c:ul_startswith Unexecuted instantiation: canonicalize.c:ul_startswith Unexecuted instantiation: path.c:ul_startswith Unexecuted instantiation: sysfs.c:ul_startswith Unexecuted instantiation: buffer.c:ul_startswith Unexecuted instantiation: mbsalign.c:ul_startswith Unexecuted instantiation: gen_uuid.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: loopdev.c:ul_startswith Unexecuted instantiation: strv.c:ul_startswith |
282 | | |
283 | | /* |
284 | | * Case insensitive match string beginning. |
285 | | */ |
286 | | static inline const char *startswith_no_case(const char *s, const char *prefix) |
287 | 0 | { |
288 | 0 | size_t sz = prefix ? strlen(prefix) : 0; |
289 | 0 |
|
290 | 0 | if (s && sz && strncasecmp(s, prefix, sz) == 0) |
291 | 0 | return s + sz; |
292 | 0 | return NULL; |
293 | 0 | } Unexecuted instantiation: script.c:startswith_no_case Unexecuted instantiation: strutils.c:startswith_no_case Unexecuted instantiation: ask.c:startswith_no_case Unexecuted instantiation: utils.c:startswith_no_case Unexecuted instantiation: context.c:startswith_no_case Unexecuted instantiation: parttype.c:startswith_no_case Unexecuted instantiation: partition.c:startswith_no_case Unexecuted instantiation: wipe.c:startswith_no_case Unexecuted instantiation: dos.c:startswith_no_case Unexecuted instantiation: gpt.c:startswith_no_case Unexecuted instantiation: canonicalize.c:startswith_no_case Unexecuted instantiation: path.c:startswith_no_case Unexecuted instantiation: sysfs.c:startswith_no_case Unexecuted instantiation: buffer.c:startswith_no_case Unexecuted instantiation: mbsalign.c:startswith_no_case Unexecuted instantiation: gen_uuid.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: loopdev.c:startswith_no_case Unexecuted instantiation: strv.c:startswith_no_case |
294 | | |
295 | | /* |
296 | | * Match path beginning |
297 | | */ |
298 | | static inline const char *startswithpath(const char *s, const char *prefix) |
299 | 0 | { |
300 | 0 | const char *p = ul_startswith(s, prefix); |
301 | 0 |
|
302 | 0 | if (p && (*p == '/' || *p == '\0')) |
303 | 0 | return p; |
304 | 0 |
|
305 | 0 | return NULL; |
306 | 0 | } Unexecuted instantiation: script.c:startswithpath Unexecuted instantiation: strutils.c:startswithpath Unexecuted instantiation: ask.c:startswithpath Unexecuted instantiation: utils.c:startswithpath Unexecuted instantiation: context.c:startswithpath Unexecuted instantiation: parttype.c:startswithpath Unexecuted instantiation: partition.c:startswithpath Unexecuted instantiation: wipe.c:startswithpath Unexecuted instantiation: dos.c:startswithpath Unexecuted instantiation: gpt.c:startswithpath Unexecuted instantiation: canonicalize.c:startswithpath Unexecuted instantiation: path.c:startswithpath Unexecuted instantiation: sysfs.c:startswithpath Unexecuted instantiation: buffer.c:startswithpath Unexecuted instantiation: mbsalign.c:startswithpath Unexecuted instantiation: gen_uuid.c:startswithpath Unexecuted instantiation: probe.c:startswithpath Unexecuted instantiation: partitions.c:startswithpath Unexecuted instantiation: devname.c:startswithpath Unexecuted instantiation: devno.c:startswithpath Unexecuted instantiation: loopdev.c:startswithpath Unexecuted instantiation: strv.c:startswithpath |
307 | | |
308 | | /* |
309 | | * Match string ending. |
310 | | */ |
311 | | static inline const char *ul_endswith(const char *s, const char *postfix) |
312 | 2.47k | { |
313 | 2.47k | size_t sl = s ? strlen(s) : 0; |
314 | 2.47k | size_t pl = postfix ? strlen(postfix) : 0; |
315 | | |
316 | 2.47k | if (pl == 0) |
317 | 0 | return s + sl; |
318 | 2.47k | if (sl < pl) |
319 | 451 | return NULL; |
320 | 2.02k | if (memcmp(s + sl - pl, postfix, pl) != 0) |
321 | 1.82k | return NULL; |
322 | 195 | return s + sl - pl; |
323 | 2.02k | } Unexecuted instantiation: script.c:ul_endswith Unexecuted instantiation: strutils.c:ul_endswith Unexecuted instantiation: ask.c:ul_endswith Line | Count | Source | 312 | 2.47k | { | 313 | 2.47k | size_t sl = s ? strlen(s) : 0; | 314 | 2.47k | size_t pl = postfix ? strlen(postfix) : 0; | 315 | | | 316 | 2.47k | if (pl == 0) | 317 | 0 | return s + sl; | 318 | 2.47k | if (sl < pl) | 319 | 451 | return NULL; | 320 | 2.02k | if (memcmp(s + sl - pl, postfix, pl) != 0) | 321 | 1.82k | return NULL; | 322 | 195 | return s + sl - pl; | 323 | 2.02k | } |
Unexecuted instantiation: context.c:ul_endswith Unexecuted instantiation: parttype.c:ul_endswith Unexecuted instantiation: partition.c:ul_endswith Unexecuted instantiation: wipe.c:ul_endswith Unexecuted instantiation: dos.c:ul_endswith Unexecuted instantiation: gpt.c:ul_endswith Unexecuted instantiation: canonicalize.c:ul_endswith Unexecuted instantiation: path.c:ul_endswith Unexecuted instantiation: sysfs.c:ul_endswith Unexecuted instantiation: buffer.c:ul_endswith Unexecuted instantiation: mbsalign.c:ul_endswith Unexecuted instantiation: gen_uuid.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: loopdev.c:ul_endswith Unexecuted instantiation: strv.c:ul_endswith |
324 | | |
325 | | /* |
326 | | * Skip leading white space. |
327 | | */ |
328 | | static inline const char *skip_space(const char *p) |
329 | 0 | { |
330 | 0 | while (isspace(*p)) |
331 | 0 | ++p; |
332 | 0 | return p; |
333 | 0 | } Unexecuted instantiation: script.c:skip_space Unexecuted instantiation: strutils.c:skip_space Unexecuted instantiation: ask.c:skip_space Unexecuted instantiation: utils.c:skip_space Unexecuted instantiation: context.c:skip_space Unexecuted instantiation: parttype.c:skip_space Unexecuted instantiation: partition.c:skip_space Unexecuted instantiation: wipe.c:skip_space Unexecuted instantiation: dos.c:skip_space Unexecuted instantiation: gpt.c:skip_space Unexecuted instantiation: canonicalize.c:skip_space Unexecuted instantiation: path.c:skip_space Unexecuted instantiation: sysfs.c:skip_space Unexecuted instantiation: buffer.c:skip_space Unexecuted instantiation: mbsalign.c:skip_space Unexecuted instantiation: gen_uuid.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: loopdev.c:skip_space Unexecuted instantiation: strv.c:skip_space |
334 | | |
335 | | static inline const char *skip_blank(const char *p) |
336 | 189k | { |
337 | 189k | while (isblank(*p)) |
338 | 29.3k | ++p; |
339 | 189k | return p; |
340 | 189k | } Line | Count | Source | 336 | 189k | { | 337 | 189k | while (isblank(*p)) | 338 | 29.3k | ++p; | 339 | 189k | return p; | 340 | 189k | } |
Unexecuted instantiation: strutils.c:skip_blank Unexecuted instantiation: ask.c:skip_blank Unexecuted instantiation: utils.c:skip_blank Unexecuted instantiation: context.c:skip_blank Unexecuted instantiation: parttype.c:skip_blank Unexecuted instantiation: partition.c:skip_blank Unexecuted instantiation: wipe.c:skip_blank Unexecuted instantiation: dos.c:skip_blank Unexecuted instantiation: gpt.c:skip_blank Unexecuted instantiation: canonicalize.c:skip_blank Unexecuted instantiation: path.c:skip_blank Unexecuted instantiation: sysfs.c:skip_blank Unexecuted instantiation: buffer.c:skip_blank Unexecuted instantiation: mbsalign.c:skip_blank Unexecuted instantiation: gen_uuid.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: loopdev.c:skip_blank Unexecuted instantiation: strv.c:skip_blank |
341 | | |
342 | | |
343 | | /* Removes whitespace from the right-hand side of a string (trailing |
344 | | * whitespace). |
345 | | * |
346 | | * Returns size of the new string (without \0). |
347 | | */ |
348 | | static inline size_t rtrim_whitespace(unsigned char *str) |
349 | 9.75k | { |
350 | 9.75k | size_t i; |
351 | | |
352 | 9.75k | if (!str) |
353 | 0 | return 0; |
354 | 9.75k | i = strlen((char *) str); |
355 | 11.5k | while (i) { |
356 | 11.3k | i--; |
357 | 11.3k | if (!isspace(str[i])) { |
358 | 9.50k | i++; |
359 | 9.50k | break; |
360 | 9.50k | } |
361 | 11.3k | } |
362 | 9.75k | str[i] = '\0'; |
363 | 9.75k | return i; |
364 | 9.75k | } script.c:rtrim_whitespace Line | Count | Source | 349 | 9.75k | { | 350 | 9.75k | size_t i; | 351 | | | 352 | 9.75k | if (!str) | 353 | 0 | return 0; | 354 | 9.75k | i = strlen((char *) str); | 355 | 11.5k | while (i) { | 356 | 11.3k | i--; | 357 | 11.3k | if (!isspace(str[i])) { | 358 | 9.50k | i++; | 359 | 9.50k | break; | 360 | 9.50k | } | 361 | 11.3k | } | 362 | 9.75k | str[i] = '\0'; | 363 | 9.75k | return i; | 364 | 9.75k | } |
Unexecuted instantiation: strutils.c:rtrim_whitespace Unexecuted instantiation: ask.c:rtrim_whitespace Unexecuted instantiation: utils.c:rtrim_whitespace Unexecuted instantiation: context.c:rtrim_whitespace Unexecuted instantiation: parttype.c:rtrim_whitespace Unexecuted instantiation: partition.c:rtrim_whitespace Unexecuted instantiation: wipe.c:rtrim_whitespace Unexecuted instantiation: dos.c:rtrim_whitespace Unexecuted instantiation: gpt.c:rtrim_whitespace Unexecuted instantiation: canonicalize.c:rtrim_whitespace Unexecuted instantiation: path.c:rtrim_whitespace Unexecuted instantiation: sysfs.c:rtrim_whitespace Unexecuted instantiation: buffer.c:rtrim_whitespace Unexecuted instantiation: mbsalign.c:rtrim_whitespace Unexecuted instantiation: gen_uuid.c:rtrim_whitespace Unexecuted instantiation: probe.c:rtrim_whitespace Unexecuted instantiation: partitions.c:rtrim_whitespace Unexecuted instantiation: devname.c:rtrim_whitespace Unexecuted instantiation: devno.c:rtrim_whitespace Unexecuted instantiation: loopdev.c:rtrim_whitespace Unexecuted instantiation: strv.c:rtrim_whitespace |
365 | | |
366 | | /* Removes whitespace from the left-hand side of a string. |
367 | | * |
368 | | * Returns size of the new string (without \0). |
369 | | */ |
370 | | static inline size_t ltrim_whitespace(unsigned char *str) |
371 | 8.26k | { |
372 | 8.26k | size_t len; |
373 | 8.26k | unsigned char *p; |
374 | | |
375 | 8.26k | if (!str) |
376 | 0 | return 0; |
377 | 9.11k | for (p = str; *p && isspace(*p); p++); |
378 | | |
379 | 8.26k | len = strlen((char *) p); |
380 | | |
381 | 8.26k | if (p > str) |
382 | 455 | memmove(str, p, len + 1); |
383 | | |
384 | 8.26k | return len; |
385 | 8.26k | } script.c:ltrim_whitespace Line | Count | Source | 371 | 8.26k | { | 372 | 8.26k | size_t len; | 373 | 8.26k | unsigned char *p; | 374 | | | 375 | 8.26k | if (!str) | 376 | 0 | return 0; | 377 | 9.11k | for (p = str; *p && isspace(*p); p++); | 378 | | | 379 | 8.26k | len = strlen((char *) p); | 380 | | | 381 | 8.26k | if (p > str) | 382 | 455 | memmove(str, p, len + 1); | 383 | | | 384 | 8.26k | return len; | 385 | 8.26k | } |
Unexecuted instantiation: strutils.c:ltrim_whitespace Unexecuted instantiation: ask.c:ltrim_whitespace Unexecuted instantiation: utils.c:ltrim_whitespace Unexecuted instantiation: context.c:ltrim_whitespace Unexecuted instantiation: parttype.c:ltrim_whitespace Unexecuted instantiation: partition.c:ltrim_whitespace Unexecuted instantiation: wipe.c:ltrim_whitespace Unexecuted instantiation: dos.c:ltrim_whitespace Unexecuted instantiation: gpt.c:ltrim_whitespace Unexecuted instantiation: canonicalize.c:ltrim_whitespace Unexecuted instantiation: path.c:ltrim_whitespace Unexecuted instantiation: sysfs.c:ltrim_whitespace Unexecuted instantiation: buffer.c:ltrim_whitespace Unexecuted instantiation: mbsalign.c:ltrim_whitespace Unexecuted instantiation: gen_uuid.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: loopdev.c:ltrim_whitespace Unexecuted instantiation: strv.c:ltrim_whitespace |
386 | | |
387 | | /* Removes left-hand, right-hand and repeating whitespaces. |
388 | | */ |
389 | | static inline size_t __normalize_whitespace( |
390 | | const unsigned char *src, |
391 | | size_t sz, |
392 | | unsigned char *dst, |
393 | | size_t len) |
394 | 0 | { |
395 | 0 | size_t i, x = 0; |
396 | 0 | int nsp = 0, intext = 0; |
397 | 0 |
|
398 | 0 | if (!sz) |
399 | 0 | goto done; |
400 | 0 |
|
401 | 0 | for (i = 0, x = 0; i < sz && x < len - 1; ) { |
402 | 0 | if (isspace(src[i])) |
403 | 0 | nsp++; |
404 | 0 | else |
405 | 0 | nsp = 0, intext = 1; |
406 | 0 |
|
407 | 0 | if (nsp > 1 || (nsp && !intext)) |
408 | 0 | i++; |
409 | 0 | else |
410 | 0 | dst[x++] = src[i++]; |
411 | 0 | } |
412 | 0 | if (nsp && x > 0) /* trailing space */ |
413 | 0 | x--; |
414 | 0 | done: |
415 | 0 | dst[x] = '\0'; |
416 | 0 | return x; |
417 | 0 | } Unexecuted instantiation: script.c:__normalize_whitespace Unexecuted instantiation: strutils.c:__normalize_whitespace Unexecuted instantiation: ask.c:__normalize_whitespace Unexecuted instantiation: utils.c:__normalize_whitespace Unexecuted instantiation: context.c:__normalize_whitespace Unexecuted instantiation: parttype.c:__normalize_whitespace Unexecuted instantiation: partition.c:__normalize_whitespace Unexecuted instantiation: wipe.c:__normalize_whitespace Unexecuted instantiation: dos.c:__normalize_whitespace Unexecuted instantiation: gpt.c:__normalize_whitespace Unexecuted instantiation: canonicalize.c:__normalize_whitespace Unexecuted instantiation: path.c:__normalize_whitespace Unexecuted instantiation: sysfs.c:__normalize_whitespace Unexecuted instantiation: buffer.c:__normalize_whitespace Unexecuted instantiation: mbsalign.c:__normalize_whitespace Unexecuted instantiation: gen_uuid.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: loopdev.c:__normalize_whitespace Unexecuted instantiation: strv.c:__normalize_whitespace |
418 | | |
419 | | static inline size_t normalize_whitespace(unsigned char *str) |
420 | 0 | { |
421 | 0 | size_t sz = strlen((char *) str); |
422 | 0 | return __normalize_whitespace(str, sz, str, sz + 1); |
423 | 0 | } Unexecuted instantiation: script.c:normalize_whitespace Unexecuted instantiation: strutils.c:normalize_whitespace Unexecuted instantiation: ask.c:normalize_whitespace Unexecuted instantiation: utils.c:normalize_whitespace Unexecuted instantiation: context.c:normalize_whitespace Unexecuted instantiation: parttype.c:normalize_whitespace Unexecuted instantiation: partition.c:normalize_whitespace Unexecuted instantiation: wipe.c:normalize_whitespace Unexecuted instantiation: dos.c:normalize_whitespace Unexecuted instantiation: gpt.c:normalize_whitespace Unexecuted instantiation: canonicalize.c:normalize_whitespace Unexecuted instantiation: path.c:normalize_whitespace Unexecuted instantiation: sysfs.c:normalize_whitespace Unexecuted instantiation: buffer.c:normalize_whitespace Unexecuted instantiation: mbsalign.c:normalize_whitespace Unexecuted instantiation: gen_uuid.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: loopdev.c:normalize_whitespace Unexecuted instantiation: strv.c:normalize_whitespace |
424 | | |
425 | | static inline void ul_strrep(char *s, int find, int replace) |
426 | 0 | { |
427 | 0 | while (s && *s && (s = strchr(s, find)) != NULL) |
428 | 0 | *s++ = replace; |
429 | 0 | } Unexecuted instantiation: script.c:ul_strrep Unexecuted instantiation: strutils.c:ul_strrep Unexecuted instantiation: ask.c:ul_strrep Unexecuted instantiation: utils.c:ul_strrep Unexecuted instantiation: context.c:ul_strrep Unexecuted instantiation: parttype.c:ul_strrep Unexecuted instantiation: partition.c:ul_strrep Unexecuted instantiation: wipe.c:ul_strrep Unexecuted instantiation: dos.c:ul_strrep Unexecuted instantiation: gpt.c:ul_strrep Unexecuted instantiation: canonicalize.c:ul_strrep Unexecuted instantiation: path.c:ul_strrep Unexecuted instantiation: sysfs.c:ul_strrep Unexecuted instantiation: buffer.c:ul_strrep Unexecuted instantiation: mbsalign.c:ul_strrep Unexecuted instantiation: gen_uuid.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: loopdev.c:ul_strrep Unexecuted instantiation: strv.c:ul_strrep |
430 | | |
431 | | static inline void ul_strrem(char *s, int rem) |
432 | 0 | { |
433 | 0 | char *p; |
434 | 0 |
|
435 | 0 | if (!s) |
436 | 0 | return; |
437 | 0 | for (p = s; *s; s++) { |
438 | 0 | if (*s != rem) |
439 | 0 | *p++ = *s; |
440 | 0 | } |
441 | 0 | *p = '\0'; |
442 | 0 | } Unexecuted instantiation: script.c:ul_strrem Unexecuted instantiation: strutils.c:ul_strrem Unexecuted instantiation: ask.c:ul_strrem Unexecuted instantiation: utils.c:ul_strrem Unexecuted instantiation: context.c:ul_strrem Unexecuted instantiation: parttype.c:ul_strrem Unexecuted instantiation: partition.c:ul_strrem Unexecuted instantiation: wipe.c:ul_strrem Unexecuted instantiation: dos.c:ul_strrem Unexecuted instantiation: gpt.c:ul_strrem Unexecuted instantiation: canonicalize.c:ul_strrem Unexecuted instantiation: path.c:ul_strrem Unexecuted instantiation: sysfs.c:ul_strrem Unexecuted instantiation: buffer.c:ul_strrem Unexecuted instantiation: mbsalign.c:ul_strrem Unexecuted instantiation: gen_uuid.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: loopdev.c:ul_strrem Unexecuted instantiation: strv.c:ul_strrem |
443 | | |
444 | | /* returns next string after \0 if before @end */ |
445 | | static inline char *ul_next_string(char *p, char *end) |
446 | 0 | { |
447 | 0 | char *last; |
448 | 0 |
|
449 | 0 | if (!p || !end || p >= end) |
450 | 0 | return NULL; |
451 | 0 |
|
452 | 0 | for (last = p; p < end; p++) { |
453 | 0 | if (*last == '\0' && p != last) |
454 | 0 | return p; |
455 | 0 | last = p; |
456 | 0 | } |
457 | 0 |
|
458 | 0 | return NULL; |
459 | 0 | } Unexecuted instantiation: script.c:ul_next_string Unexecuted instantiation: strutils.c:ul_next_string Unexecuted instantiation: ask.c:ul_next_string Unexecuted instantiation: utils.c:ul_next_string Unexecuted instantiation: context.c:ul_next_string Unexecuted instantiation: parttype.c:ul_next_string Unexecuted instantiation: partition.c:ul_next_string Unexecuted instantiation: wipe.c:ul_next_string Unexecuted instantiation: dos.c:ul_next_string Unexecuted instantiation: gpt.c:ul_next_string Unexecuted instantiation: canonicalize.c:ul_next_string Unexecuted instantiation: path.c:ul_next_string Unexecuted instantiation: sysfs.c:ul_next_string Unexecuted instantiation: buffer.c:ul_next_string Unexecuted instantiation: mbsalign.c:ul_next_string Unexecuted instantiation: gen_uuid.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: loopdev.c:ul_next_string Unexecuted instantiation: strv.c:ul_next_string |
460 | | |
461 | | extern char *ul_strnconcat(const char *s, const char *suffix, size_t b); |
462 | | extern char *ul_strconcat(const char *s, const char *suffix); |
463 | | extern char *ul_strfconcat(const char *s, const char *format, ...) |
464 | | __attribute__ ((__format__ (__printf__, 2, 3))); |
465 | | |
466 | | extern int ul_strappend(char **a, const char *b); |
467 | | extern int strfappend(char **a, const char *format, ...) |
468 | | __attribute__ ((__format__ (__printf__, 2, 3))); |
469 | | extern int ul_strvfappend(char **a, const char *format, va_list ap) |
470 | | __attribute__ ((__format__ (__printf__, 2, 0))); |
471 | | |
472 | | extern const char *ul_split(const char **state, size_t *l, const char *separator, int quoted); |
473 | | |
474 | | extern char *ul_strchr_escaped(const char *s, int c); |
475 | | |
476 | | extern int skip_fline(FILE *fp); |
477 | | extern int ul_stralnumcmp(const char *p1, const char *p2); |
478 | | |
479 | | extern int ul_optstr_next(char **optstr, char **name, size_t *namesz, char **value, size_t *valsz); |
480 | | extern int ul_optstr_is_valid(const char *optstr); |
481 | | extern char *ul_optstr_get_value(const char *optstr, const char *key); |
482 | | |
483 | | #endif /* UTIL_LINUX_STRUTILS */ |