/src/dovecot/src/lib/strfuncs.h
Line | Count | Source |
1 | | #ifndef STRFUNC_H |
2 | | #define STRFUNC_H |
3 | | |
4 | | /* Maximum number of bytes needed for the largest uintmax_t or the lowest |
5 | | intmax_t number in base 10. This value includes the trailing \0. */ |
6 | 0 | #define MAX_INT_STRLEN ((sizeof(uintmax_t) * CHAR_BIT + 2) / 3 + 1) |
7 | | |
8 | | extern const unsigned char uchar_nul; /* (const unsigned char *)"" */ |
9 | | extern const unsigned char *uchar_empty_ptr; /* non-NULL pointer that shouldn't be dereferenced. */ |
10 | | extern const char *const empty_str_array[]; |
11 | | |
12 | | /* Returns -1 if dest wasn't large enough, 0 if not. */ |
13 | | int i_snprintf(char *dest, size_t max_chars, const char *format, ...) |
14 | | ATTR_FORMAT(3, 4); |
15 | | |
16 | | /* The p_/t_/i_ strdup, strconcat and *printf helpers below preserve errno. |
17 | | So this pattern is safe - errno still refers to the failed syscall when |
18 | | "%m" is expanded: |
19 | | |
20 | | if (syscall(...) < 0) |
21 | | error = t_strdup_printf("syscall() failed: %m"); */ |
22 | | |
23 | | char *p_strdup(pool_t pool, const char *str) ATTR_MALLOC; |
24 | | void *p_memdup(pool_t pool, const void *data, size_t size) ATTR_MALLOC; |
25 | | /* return NULL if str = "" */ |
26 | | char *p_strdup_empty(pool_t pool, const char *str) ATTR_MALLOC; |
27 | | /* *end isn't included */ |
28 | | char *p_strdup_until(pool_t pool, const void *start, const void *end) |
29 | | ATTR_MALLOC ATTR_RETURNS_NONNULL; |
30 | | char *p_strndup(pool_t pool, const void *str, size_t max_chars) ATTR_MALLOC; |
31 | | char *p_strdup_printf(pool_t pool, const char *format, ...) |
32 | | ATTR_FORMAT(2, 3) ATTR_MALLOC ATTR_RETURNS_NONNULL; |
33 | | char *p_strdup_vprintf(pool_t pool, const char *format, va_list args) |
34 | | ATTR_FORMAT(2, 0) ATTR_MALLOC ATTR_RETURNS_NONNULL; |
35 | | char *p_strconcat(pool_t pool, const char *str1, ...) |
36 | | ATTR_SENTINEL ATTR_MALLOC; |
37 | | |
38 | | /* same with temporary memory allocations: */ |
39 | | const char *t_strdup(const char *str) ATTR_MALLOC; |
40 | | char *t_strdup_noconst(const char *str) ATTR_MALLOC; |
41 | | const void *t_memdup(const void *data, size_t size) ATTR_MALLOC; |
42 | | void *t_memdup_noconst(const void *data, size_t size) ATTR_MALLOC; |
43 | | /* return NULL if str = "" */ |
44 | | const char *t_strdup_empty(const char *str) ATTR_MALLOC; |
45 | | /* *end isn't included */ |
46 | | const char *t_strdup_until(const void *start, const void *end) |
47 | | ATTR_MALLOC ATTR_RETURNS_NONNULL; |
48 | | char *t_strdup_until_noconst(const void *start, const void *end) |
49 | | ATTR_MALLOC ATTR_RETURNS_NONNULL; |
50 | | const char *t_strndup(const void *str, size_t max_chars) ATTR_MALLOC; |
51 | | const char *t_strdup_printf(const char *format, ...) |
52 | | ATTR_FORMAT(1, 2) ATTR_MALLOC ATTR_RETURNS_NONNULL; |
53 | | const char *t_strdup_vprintf(const char *format, va_list args) |
54 | | ATTR_FORMAT(1, 0) ATTR_MALLOC ATTR_RETURNS_NONNULL; |
55 | | const char *t_strconcat(const char *str1, ...) |
56 | | ATTR_SENTINEL ATTR_MALLOC; |
57 | | |
58 | | /* Like t_strdup(), but stop at cutchar. */ |
59 | | const char *t_strcut(const char *str, char cutchar); |
60 | | /* Replace all from->to chars in the string. */ |
61 | | const char *t_str_replace(const char *str, char from, char to); |
62 | | /* Put the string on a single line by replacing all newlines with spaces and |
63 | | dropping any carriage returns. Sequences of several newlines are merged into |
64 | | one space and newlines at the beginning and end of the string are dropped. */ |
65 | | const char *t_str_oneline(const char *str); |
66 | | |
67 | | /* Like strlcpy(), but return -1 if buffer was overflown, 0 if not. */ |
68 | | int i_strocpy(char *dest, const char *src, size_t dstsize); |
69 | | |
70 | | char *str_ucase(char *str); |
71 | | char *str_lcase(char *str); |
72 | | const char *t_str_lcase(const char *str); |
73 | | const char *t_str_ucase(const char *str); |
74 | | |
75 | | /* Return pointer to first matching needle */ |
76 | | const char *i_strstr_arr(const char *haystack, const char *const *needles); |
77 | | |
78 | | /* Trim matching chars from either side of the string */ |
79 | | const char *t_str_trim(const char *str, const char *chars); |
80 | | const char *p_str_trim(pool_t pool, const char *str, const char *chars); |
81 | | const char *str_ltrim(const char *str, const char *chars); |
82 | | const char *t_str_ltrim(const char *str, const char *chars); |
83 | | const char *p_str_ltrim(pool_t pool, const char *str, const char *chars); |
84 | | const char *t_str_rtrim(const char *str, const char *chars); |
85 | | const char *p_str_rtrim(pool_t pool, const char *str, const char *chars); |
86 | | |
87 | | int null_strcmp(const char *s1, const char *s2) ATTR_PURE; |
88 | | int null_strcasecmp(const char *s1, const char *s2) ATTR_PURE; |
89 | | int i_memcasecmp(const void *p1, const void *p2, size_t size) ATTR_PURE; |
90 | | /* Like memrchr(): return a pointer to the last occurrence of c within the |
91 | | first size bytes of data, or NULL if not found. */ |
92 | | void *i_memrchr(const void *data, int c, size_t size) ATTR_PURE; |
93 | | int i_strcmp_p(const char *const *p1, const char *const *p2) ATTR_PURE; |
94 | | int i_strcasecmp_p(const char *const *p1, const char *const *p2) ATTR_PURE; |
95 | | /* Returns TRUE if the two memory areas are equal. This function is safe |
96 | | against timing attacks, so it compares all the bytes every time. */ |
97 | | bool mem_equals_timing_safe(const void *p1, const void *p2, size_t size); |
98 | | /* Returns TRUE if the two strings are equal. Similar to |
99 | | mem_equals_timing_safe() this function is safe against timing attacks when |
100 | | the string lengths are the same. If not, the length of the secret string may |
101 | | be leaked, but otherwise the contents won't be. */ |
102 | | bool str_equals_timing_almost_safe(const char *s1, const char *s2); |
103 | | /* Returns TRUE if the two strings are equal. Safe against timing attacks: |
104 | | neither the contents nor the length of either string is leaked. |
105 | | Implemented by HMAC-SHA256ing both inputs under a random per-process key |
106 | | and comparing the fixed-length digests. */ |
107 | | bool str_equals_hash_timing_safe(const char *s1, const char *s2); |
108 | | |
109 | | size_t str_match(const char *p1, const char *p2) ATTR_PURE; |
110 | | size_t str_match_icase(const char *p1, const char *p2) ATTR_PURE; |
111 | | bool str_begins(const char *haystack, const char *needle, |
112 | | const char **suffix_r); |
113 | | bool str_begins_icase(const char *haystack, const char *needle, |
114 | | const char **suffix_r); |
115 | | static inline ATTR_PURE bool |
116 | | str_begins_with(const char *haystack, const char *needle) |
117 | 0 | { |
118 | 0 | return needle[str_match(haystack, needle)] == '\0'; |
119 | 0 | } Unexecuted instantiation: fuzz-json-istream.c:str_begins_with Unexecuted instantiation: json-tree.c:str_begins_with Unexecuted instantiation: json-istream.c:str_begins_with Unexecuted instantiation: json-parser.c:str_begins_with Unexecuted instantiation: istream-json-string.c:str_begins_with Unexecuted instantiation: json-syntax.c:str_begins_with Unexecuted instantiation: fuzzer.c:str_begins_with Unexecuted instantiation: test-istream.c:str_begins_with Unexecuted instantiation: array.c:str_begins_with Unexecuted instantiation: buffer.c:str_begins_with Unexecuted instantiation: data-stack.c:str_begins_with Unexecuted instantiation: event-log.c:str_begins_with Unexecuted instantiation: failures.c:str_begins_with Unexecuted instantiation: fd-util.c:str_begins_with Unexecuted instantiation: hostpid.c:str_begins_with Unexecuted instantiation: imem.c:str_begins_with Unexecuted instantiation: iostream.c:str_begins_with Unexecuted instantiation: iostream-pump.c:str_begins_with Unexecuted instantiation: istream.c:str_begins_with Unexecuted instantiation: istream-data.c:str_begins_with Unexecuted instantiation: istream-file.c:str_begins_with Unexecuted instantiation: istream-limit.c:str_begins_with Unexecuted instantiation: istream-seekable.c:str_begins_with Unexecuted instantiation: ioloop.c:str_begins_with Unexecuted instantiation: ioloop-notify-inotify.c:str_begins_with Unexecuted instantiation: ioloop-epoll.c:str_begins_with Unexecuted instantiation: lib.c:str_begins_with Unexecuted instantiation: lib-event.c:str_begins_with Unexecuted instantiation: lib-signals.c:str_begins_with Unexecuted instantiation: memarea.c:str_begins_with Unexecuted instantiation: mempool.c:str_begins_with Unexecuted instantiation: mempool-alloconly.c:str_begins_with Unexecuted instantiation: mempool-datastack.c:str_begins_with Unexecuted instantiation: mempool-system.c:str_begins_with Unexecuted instantiation: mempool-unsafe-datastack.c:str_begins_with Unexecuted instantiation: net.c:str_begins_with Unexecuted instantiation: ostream.c:str_begins_with Unexecuted instantiation: ostream-file.c:str_begins_with Unexecuted instantiation: path-util.c:str_begins_with Unexecuted instantiation: printf-format-fix.c:str_begins_with Unexecuted instantiation: process-title.c:str_begins_with Unexecuted instantiation: priorityq.c:str_begins_with Unexecuted instantiation: randgen.c:str_begins_with Unexecuted instantiation: rand.c:str_begins_with Unexecuted instantiation: read-full.c:str_begins_with Unexecuted instantiation: restrict-access.c:str_begins_with Unexecuted instantiation: safe-memset.c:str_begins_with Unexecuted instantiation: safe-mkstemp.c:str_begins_with Unexecuted instantiation: sendfile-util.c:str_begins_with Unexecuted instantiation: sleep.c:str_begins_with Unexecuted instantiation: str.c:str_begins_with Unexecuted instantiation: strescape.c:str_begins_with Unexecuted instantiation: strfuncs.c:str_begins_with Unexecuted instantiation: strnum.c:str_begins_with Unexecuted instantiation: time-util.c:str_begins_with Unexecuted instantiation: unichar.c:str_begins_with Unexecuted instantiation: unicode-break.c:str_begins_with Unexecuted instantiation: unicode-data-tables.c:str_begins_with Unexecuted instantiation: unicode-transform.c:str_begins_with Unexecuted instantiation: write-full.c:str_begins_with Unexecuted instantiation: backtrace-string.c:str_begins_with Unexecuted instantiation: bits.c:str_begins_with Unexecuted instantiation: eacces-error.c:str_begins_with Unexecuted instantiation: env-util.c:str_begins_with Unexecuted instantiation: event-filter.c:str_begins_with Unexecuted instantiation: event-filter-lexer.c:str_begins_with Unexecuted instantiation: event-filter-parser.c:str_begins_with Unexecuted instantiation: hash.c:str_begins_with Unexecuted instantiation: hex-binary.c:str_begins_with Unexecuted instantiation: hmac.c:str_begins_with Unexecuted instantiation: ipwd.c:str_begins_with Unexecuted instantiation: istream-concat.c:str_begins_with Unexecuted instantiation: ioloop-iolist.c:str_begins_with Unexecuted instantiation: ioloop-notify-fd.c:str_begins_with Unexecuted instantiation: primes.c:str_begins_with Unexecuted instantiation: sha2.c:str_begins_with Unexecuted instantiation: xxh64.c:str_begins_with Unexecuted instantiation: str-parse.c:str_begins_with Unexecuted instantiation: wildcard-match.c:str_begins_with |
120 | | static inline ATTR_PURE bool |
121 | | str_begins_icase_with(const char *haystack, const char *needle) |
122 | 0 | { |
123 | 0 | return needle[str_match_icase(haystack, needle)] == '\0'; |
124 | 0 | } Unexecuted instantiation: fuzz-json-istream.c:str_begins_icase_with Unexecuted instantiation: json-tree.c:str_begins_icase_with Unexecuted instantiation: json-istream.c:str_begins_icase_with Unexecuted instantiation: json-parser.c:str_begins_icase_with Unexecuted instantiation: istream-json-string.c:str_begins_icase_with Unexecuted instantiation: json-syntax.c:str_begins_icase_with Unexecuted instantiation: fuzzer.c:str_begins_icase_with Unexecuted instantiation: test-istream.c:str_begins_icase_with Unexecuted instantiation: array.c:str_begins_icase_with Unexecuted instantiation: buffer.c:str_begins_icase_with Unexecuted instantiation: data-stack.c:str_begins_icase_with Unexecuted instantiation: event-log.c:str_begins_icase_with Unexecuted instantiation: failures.c:str_begins_icase_with Unexecuted instantiation: fd-util.c:str_begins_icase_with Unexecuted instantiation: hostpid.c:str_begins_icase_with Unexecuted instantiation: imem.c:str_begins_icase_with Unexecuted instantiation: iostream.c:str_begins_icase_with Unexecuted instantiation: iostream-pump.c:str_begins_icase_with Unexecuted instantiation: istream.c:str_begins_icase_with Unexecuted instantiation: istream-data.c:str_begins_icase_with Unexecuted instantiation: istream-file.c:str_begins_icase_with Unexecuted instantiation: istream-limit.c:str_begins_icase_with Unexecuted instantiation: istream-seekable.c:str_begins_icase_with Unexecuted instantiation: ioloop.c:str_begins_icase_with Unexecuted instantiation: ioloop-notify-inotify.c:str_begins_icase_with Unexecuted instantiation: ioloop-epoll.c:str_begins_icase_with Unexecuted instantiation: lib.c:str_begins_icase_with Unexecuted instantiation: lib-event.c:str_begins_icase_with Unexecuted instantiation: lib-signals.c:str_begins_icase_with Unexecuted instantiation: memarea.c:str_begins_icase_with Unexecuted instantiation: mempool.c:str_begins_icase_with Unexecuted instantiation: mempool-alloconly.c:str_begins_icase_with Unexecuted instantiation: mempool-datastack.c:str_begins_icase_with Unexecuted instantiation: mempool-system.c:str_begins_icase_with Unexecuted instantiation: mempool-unsafe-datastack.c:str_begins_icase_with Unexecuted instantiation: net.c:str_begins_icase_with Unexecuted instantiation: ostream.c:str_begins_icase_with Unexecuted instantiation: ostream-file.c:str_begins_icase_with Unexecuted instantiation: path-util.c:str_begins_icase_with Unexecuted instantiation: printf-format-fix.c:str_begins_icase_with Unexecuted instantiation: process-title.c:str_begins_icase_with Unexecuted instantiation: priorityq.c:str_begins_icase_with Unexecuted instantiation: randgen.c:str_begins_icase_with Unexecuted instantiation: rand.c:str_begins_icase_with Unexecuted instantiation: read-full.c:str_begins_icase_with Unexecuted instantiation: restrict-access.c:str_begins_icase_with Unexecuted instantiation: safe-memset.c:str_begins_icase_with Unexecuted instantiation: safe-mkstemp.c:str_begins_icase_with Unexecuted instantiation: sendfile-util.c:str_begins_icase_with Unexecuted instantiation: sleep.c:str_begins_icase_with Unexecuted instantiation: str.c:str_begins_icase_with Unexecuted instantiation: strescape.c:str_begins_icase_with Unexecuted instantiation: strfuncs.c:str_begins_icase_with Unexecuted instantiation: strnum.c:str_begins_icase_with Unexecuted instantiation: time-util.c:str_begins_icase_with Unexecuted instantiation: unichar.c:str_begins_icase_with Unexecuted instantiation: unicode-break.c:str_begins_icase_with Unexecuted instantiation: unicode-data-tables.c:str_begins_icase_with Unexecuted instantiation: unicode-transform.c:str_begins_icase_with Unexecuted instantiation: write-full.c:str_begins_icase_with Unexecuted instantiation: backtrace-string.c:str_begins_icase_with Unexecuted instantiation: bits.c:str_begins_icase_with Unexecuted instantiation: eacces-error.c:str_begins_icase_with Unexecuted instantiation: env-util.c:str_begins_icase_with Unexecuted instantiation: event-filter.c:str_begins_icase_with Unexecuted instantiation: event-filter-lexer.c:str_begins_icase_with Unexecuted instantiation: event-filter-parser.c:str_begins_icase_with Unexecuted instantiation: hash.c:str_begins_icase_with Unexecuted instantiation: hex-binary.c:str_begins_icase_with Unexecuted instantiation: hmac.c:str_begins_icase_with Unexecuted instantiation: ipwd.c:str_begins_icase_with Unexecuted instantiation: istream-concat.c:str_begins_icase_with Unexecuted instantiation: ioloop-iolist.c:str_begins_icase_with Unexecuted instantiation: ioloop-notify-fd.c:str_begins_icase_with Unexecuted instantiation: primes.c:str_begins_icase_with Unexecuted instantiation: sha2.c:str_begins_icase_with Unexecuted instantiation: xxh64.c:str_begins_icase_with Unexecuted instantiation: str-parse.c:str_begins_icase_with Unexecuted instantiation: wildcard-match.c:str_begins_icase_with |
125 | | #if defined(__GNUC__) && (__GNUC__ >= 2) && !defined(STATIC_CHECKER) |
126 | | /* GCC (and Clang) are known to have a compile-time strlen("literal") shortcut, and |
127 | | an optimised strncmp(), so use that by default. Macro is multi-evaluation safe. */ |
128 | | static inline bool |
129 | | str_begins_builtin_success(const char *haystack, size_t needle_len, |
130 | | const char **suffix_r) |
131 | 0 | { |
132 | 0 | *suffix_r = haystack + needle_len; |
133 | 0 | return TRUE; |
134 | 0 | } Unexecuted instantiation: fuzz-json-istream.c:str_begins_builtin_success Unexecuted instantiation: json-tree.c:str_begins_builtin_success Unexecuted instantiation: json-istream.c:str_begins_builtin_success Unexecuted instantiation: json-parser.c:str_begins_builtin_success Unexecuted instantiation: istream-json-string.c:str_begins_builtin_success Unexecuted instantiation: json-syntax.c:str_begins_builtin_success Unexecuted instantiation: fuzzer.c:str_begins_builtin_success Unexecuted instantiation: test-istream.c:str_begins_builtin_success Unexecuted instantiation: array.c:str_begins_builtin_success Unexecuted instantiation: buffer.c:str_begins_builtin_success Unexecuted instantiation: data-stack.c:str_begins_builtin_success Unexecuted instantiation: event-log.c:str_begins_builtin_success Unexecuted instantiation: failures.c:str_begins_builtin_success Unexecuted instantiation: fd-util.c:str_begins_builtin_success Unexecuted instantiation: hostpid.c:str_begins_builtin_success Unexecuted instantiation: imem.c:str_begins_builtin_success Unexecuted instantiation: iostream.c:str_begins_builtin_success Unexecuted instantiation: iostream-pump.c:str_begins_builtin_success Unexecuted instantiation: istream.c:str_begins_builtin_success Unexecuted instantiation: istream-data.c:str_begins_builtin_success Unexecuted instantiation: istream-file.c:str_begins_builtin_success Unexecuted instantiation: istream-limit.c:str_begins_builtin_success Unexecuted instantiation: istream-seekable.c:str_begins_builtin_success Unexecuted instantiation: ioloop.c:str_begins_builtin_success Unexecuted instantiation: ioloop-notify-inotify.c:str_begins_builtin_success Unexecuted instantiation: ioloop-epoll.c:str_begins_builtin_success Unexecuted instantiation: lib.c:str_begins_builtin_success Unexecuted instantiation: lib-event.c:str_begins_builtin_success Unexecuted instantiation: lib-signals.c:str_begins_builtin_success Unexecuted instantiation: memarea.c:str_begins_builtin_success Unexecuted instantiation: mempool.c:str_begins_builtin_success Unexecuted instantiation: mempool-alloconly.c:str_begins_builtin_success Unexecuted instantiation: mempool-datastack.c:str_begins_builtin_success Unexecuted instantiation: mempool-system.c:str_begins_builtin_success Unexecuted instantiation: mempool-unsafe-datastack.c:str_begins_builtin_success Unexecuted instantiation: net.c:str_begins_builtin_success Unexecuted instantiation: ostream.c:str_begins_builtin_success Unexecuted instantiation: ostream-file.c:str_begins_builtin_success Unexecuted instantiation: path-util.c:str_begins_builtin_success Unexecuted instantiation: printf-format-fix.c:str_begins_builtin_success Unexecuted instantiation: process-title.c:str_begins_builtin_success Unexecuted instantiation: priorityq.c:str_begins_builtin_success Unexecuted instantiation: randgen.c:str_begins_builtin_success Unexecuted instantiation: rand.c:str_begins_builtin_success Unexecuted instantiation: read-full.c:str_begins_builtin_success Unexecuted instantiation: restrict-access.c:str_begins_builtin_success Unexecuted instantiation: safe-memset.c:str_begins_builtin_success Unexecuted instantiation: safe-mkstemp.c:str_begins_builtin_success Unexecuted instantiation: sendfile-util.c:str_begins_builtin_success Unexecuted instantiation: sleep.c:str_begins_builtin_success Unexecuted instantiation: str.c:str_begins_builtin_success Unexecuted instantiation: strescape.c:str_begins_builtin_success Unexecuted instantiation: strfuncs.c:str_begins_builtin_success Unexecuted instantiation: strnum.c:str_begins_builtin_success Unexecuted instantiation: time-util.c:str_begins_builtin_success Unexecuted instantiation: unichar.c:str_begins_builtin_success Unexecuted instantiation: unicode-break.c:str_begins_builtin_success Unexecuted instantiation: unicode-data-tables.c:str_begins_builtin_success Unexecuted instantiation: unicode-transform.c:str_begins_builtin_success Unexecuted instantiation: write-full.c:str_begins_builtin_success Unexecuted instantiation: backtrace-string.c:str_begins_builtin_success Unexecuted instantiation: bits.c:str_begins_builtin_success Unexecuted instantiation: eacces-error.c:str_begins_builtin_success Unexecuted instantiation: env-util.c:str_begins_builtin_success Unexecuted instantiation: event-filter.c:str_begins_builtin_success Unexecuted instantiation: event-filter-lexer.c:str_begins_builtin_success Unexecuted instantiation: event-filter-parser.c:str_begins_builtin_success Unexecuted instantiation: hash.c:str_begins_builtin_success Unexecuted instantiation: hex-binary.c:str_begins_builtin_success Unexecuted instantiation: hmac.c:str_begins_builtin_success Unexecuted instantiation: ipwd.c:str_begins_builtin_success Unexecuted instantiation: istream-concat.c:str_begins_builtin_success Unexecuted instantiation: ioloop-iolist.c:str_begins_builtin_success Unexecuted instantiation: ioloop-notify-fd.c:str_begins_builtin_success Unexecuted instantiation: primes.c:str_begins_builtin_success Unexecuted instantiation: sha2.c:str_begins_builtin_success Unexecuted instantiation: xxh64.c:str_begins_builtin_success Unexecuted instantiation: str-parse.c:str_begins_builtin_success Unexecuted instantiation: wildcard-match.c:str_begins_builtin_success |
135 | | # define str_begins_with(h, n) \ |
136 | 0 | (__builtin_constant_p(n) ? strncmp((h), (n), strlen(n))==0 : \ |
137 | 0 | (str_begins_with)((h), (n))) |
138 | | # define str_begins(h, n, suffix_r) \ |
139 | | (!__builtin_constant_p(n) ? (str_begins)((h), (n), (suffix_r)) : \ |
140 | | (strncmp((h), (n), strlen(n)) != 0 ? FALSE : \ |
141 | | str_begins_builtin_success((h), strlen(n), suffix_r))) |
142 | | |
143 | | # define str_begins_icase_with(h, n) \ |
144 | 0 | (__builtin_constant_p(n) ? strncasecmp((h), (n), strlen(n))==0 : \ |
145 | 0 | (str_begins_icase_with)((h), (n))) |
146 | | # define str_begins_icase(h, n, suffix_r) \ |
147 | | (!__builtin_constant_p(n) ? (str_begins_icase)((h), (n), (suffix_r)) : \ |
148 | | (strncasecmp((h), (n), strlen(n)) != 0 ? FALSE : \ |
149 | | str_begins_builtin_success((h), strlen(n), suffix_r))) |
150 | | #endif |
151 | | |
152 | | static inline ATTR_PURE bool |
153 | | str_ends_with(const char *haystack, const char *suffix) |
154 | 0 | { |
155 | 0 | size_t haystack_len = strlen(haystack); |
156 | 0 | size_t suffix_len = strlen(suffix); |
157 | 0 | if (haystack_len < suffix_len) |
158 | 0 | return FALSE; |
159 | 0 | return strcmp(haystack + haystack_len - suffix_len, suffix) == 0; |
160 | 0 | } Unexecuted instantiation: fuzz-json-istream.c:str_ends_with Unexecuted instantiation: json-tree.c:str_ends_with Unexecuted instantiation: json-istream.c:str_ends_with Unexecuted instantiation: json-parser.c:str_ends_with Unexecuted instantiation: istream-json-string.c:str_ends_with Unexecuted instantiation: json-syntax.c:str_ends_with Unexecuted instantiation: fuzzer.c:str_ends_with Unexecuted instantiation: test-istream.c:str_ends_with Unexecuted instantiation: array.c:str_ends_with Unexecuted instantiation: buffer.c:str_ends_with Unexecuted instantiation: data-stack.c:str_ends_with Unexecuted instantiation: event-log.c:str_ends_with Unexecuted instantiation: failures.c:str_ends_with Unexecuted instantiation: fd-util.c:str_ends_with Unexecuted instantiation: hostpid.c:str_ends_with Unexecuted instantiation: imem.c:str_ends_with Unexecuted instantiation: iostream.c:str_ends_with Unexecuted instantiation: iostream-pump.c:str_ends_with Unexecuted instantiation: istream.c:str_ends_with Unexecuted instantiation: istream-data.c:str_ends_with Unexecuted instantiation: istream-file.c:str_ends_with Unexecuted instantiation: istream-limit.c:str_ends_with Unexecuted instantiation: istream-seekable.c:str_ends_with Unexecuted instantiation: ioloop.c:str_ends_with Unexecuted instantiation: ioloop-notify-inotify.c:str_ends_with Unexecuted instantiation: ioloop-epoll.c:str_ends_with Unexecuted instantiation: lib.c:str_ends_with Unexecuted instantiation: lib-event.c:str_ends_with Unexecuted instantiation: lib-signals.c:str_ends_with Unexecuted instantiation: memarea.c:str_ends_with Unexecuted instantiation: mempool.c:str_ends_with Unexecuted instantiation: mempool-alloconly.c:str_ends_with Unexecuted instantiation: mempool-datastack.c:str_ends_with Unexecuted instantiation: mempool-system.c:str_ends_with Unexecuted instantiation: mempool-unsafe-datastack.c:str_ends_with Unexecuted instantiation: net.c:str_ends_with Unexecuted instantiation: ostream.c:str_ends_with Unexecuted instantiation: ostream-file.c:str_ends_with Unexecuted instantiation: path-util.c:str_ends_with Unexecuted instantiation: printf-format-fix.c:str_ends_with Unexecuted instantiation: process-title.c:str_ends_with Unexecuted instantiation: priorityq.c:str_ends_with Unexecuted instantiation: randgen.c:str_ends_with Unexecuted instantiation: rand.c:str_ends_with Unexecuted instantiation: read-full.c:str_ends_with Unexecuted instantiation: restrict-access.c:str_ends_with Unexecuted instantiation: safe-memset.c:str_ends_with Unexecuted instantiation: safe-mkstemp.c:str_ends_with Unexecuted instantiation: sendfile-util.c:str_ends_with Unexecuted instantiation: sleep.c:str_ends_with Unexecuted instantiation: str.c:str_ends_with Unexecuted instantiation: strescape.c:str_ends_with Unexecuted instantiation: strfuncs.c:str_ends_with Unexecuted instantiation: strnum.c:str_ends_with Unexecuted instantiation: time-util.c:str_ends_with Unexecuted instantiation: unichar.c:str_ends_with Unexecuted instantiation: unicode-break.c:str_ends_with Unexecuted instantiation: unicode-data-tables.c:str_ends_with Unexecuted instantiation: unicode-transform.c:str_ends_with Unexecuted instantiation: write-full.c:str_ends_with Unexecuted instantiation: backtrace-string.c:str_ends_with Unexecuted instantiation: bits.c:str_ends_with Unexecuted instantiation: eacces-error.c:str_ends_with Unexecuted instantiation: env-util.c:str_ends_with Unexecuted instantiation: event-filter.c:str_ends_with Unexecuted instantiation: event-filter-lexer.c:str_ends_with Unexecuted instantiation: event-filter-parser.c:str_ends_with Unexecuted instantiation: hash.c:str_ends_with Unexecuted instantiation: hex-binary.c:str_ends_with Unexecuted instantiation: hmac.c:str_ends_with Unexecuted instantiation: ipwd.c:str_ends_with Unexecuted instantiation: istream-concat.c:str_ends_with Unexecuted instantiation: ioloop-iolist.c:str_ends_with Unexecuted instantiation: ioloop-notify-fd.c:str_ends_with Unexecuted instantiation: primes.c:str_ends_with Unexecuted instantiation: sha2.c:str_ends_with Unexecuted instantiation: xxh64.c:str_ends_with Unexecuted instantiation: str-parse.c:str_ends_with Unexecuted instantiation: wildcard-match.c:str_ends_with |
161 | | |
162 | | static inline ATTR_PURE bool |
163 | | str_ends_icase_with(const char *haystack, const char *suffix) |
164 | 0 | { |
165 | 0 | size_t haystack_len = strlen(haystack); |
166 | 0 | size_t suffix_len = strlen(suffix); |
167 | 0 | if (haystack_len < suffix_len) |
168 | 0 | return FALSE; |
169 | 0 | return strcasecmp(haystack + haystack_len - suffix_len, suffix) == 0; |
170 | 0 | } Unexecuted instantiation: fuzz-json-istream.c:str_ends_icase_with Unexecuted instantiation: json-tree.c:str_ends_icase_with Unexecuted instantiation: json-istream.c:str_ends_icase_with Unexecuted instantiation: json-parser.c:str_ends_icase_with Unexecuted instantiation: istream-json-string.c:str_ends_icase_with Unexecuted instantiation: json-syntax.c:str_ends_icase_with Unexecuted instantiation: fuzzer.c:str_ends_icase_with Unexecuted instantiation: test-istream.c:str_ends_icase_with Unexecuted instantiation: array.c:str_ends_icase_with Unexecuted instantiation: buffer.c:str_ends_icase_with Unexecuted instantiation: data-stack.c:str_ends_icase_with Unexecuted instantiation: event-log.c:str_ends_icase_with Unexecuted instantiation: failures.c:str_ends_icase_with Unexecuted instantiation: fd-util.c:str_ends_icase_with Unexecuted instantiation: hostpid.c:str_ends_icase_with Unexecuted instantiation: imem.c:str_ends_icase_with Unexecuted instantiation: iostream.c:str_ends_icase_with Unexecuted instantiation: iostream-pump.c:str_ends_icase_with Unexecuted instantiation: istream.c:str_ends_icase_with Unexecuted instantiation: istream-data.c:str_ends_icase_with Unexecuted instantiation: istream-file.c:str_ends_icase_with Unexecuted instantiation: istream-limit.c:str_ends_icase_with Unexecuted instantiation: istream-seekable.c:str_ends_icase_with Unexecuted instantiation: ioloop.c:str_ends_icase_with Unexecuted instantiation: ioloop-notify-inotify.c:str_ends_icase_with Unexecuted instantiation: ioloop-epoll.c:str_ends_icase_with Unexecuted instantiation: lib.c:str_ends_icase_with Unexecuted instantiation: lib-event.c:str_ends_icase_with Unexecuted instantiation: lib-signals.c:str_ends_icase_with Unexecuted instantiation: memarea.c:str_ends_icase_with Unexecuted instantiation: mempool.c:str_ends_icase_with Unexecuted instantiation: mempool-alloconly.c:str_ends_icase_with Unexecuted instantiation: mempool-datastack.c:str_ends_icase_with Unexecuted instantiation: mempool-system.c:str_ends_icase_with Unexecuted instantiation: mempool-unsafe-datastack.c:str_ends_icase_with Unexecuted instantiation: net.c:str_ends_icase_with Unexecuted instantiation: ostream.c:str_ends_icase_with Unexecuted instantiation: ostream-file.c:str_ends_icase_with Unexecuted instantiation: path-util.c:str_ends_icase_with Unexecuted instantiation: printf-format-fix.c:str_ends_icase_with Unexecuted instantiation: process-title.c:str_ends_icase_with Unexecuted instantiation: priorityq.c:str_ends_icase_with Unexecuted instantiation: randgen.c:str_ends_icase_with Unexecuted instantiation: rand.c:str_ends_icase_with Unexecuted instantiation: read-full.c:str_ends_icase_with Unexecuted instantiation: restrict-access.c:str_ends_icase_with Unexecuted instantiation: safe-memset.c:str_ends_icase_with Unexecuted instantiation: safe-mkstemp.c:str_ends_icase_with Unexecuted instantiation: sendfile-util.c:str_ends_icase_with Unexecuted instantiation: sleep.c:str_ends_icase_with Unexecuted instantiation: str.c:str_ends_icase_with Unexecuted instantiation: strescape.c:str_ends_icase_with Unexecuted instantiation: strfuncs.c:str_ends_icase_with Unexecuted instantiation: strnum.c:str_ends_icase_with Unexecuted instantiation: time-util.c:str_ends_icase_with Unexecuted instantiation: unichar.c:str_ends_icase_with Unexecuted instantiation: unicode-break.c:str_ends_icase_with Unexecuted instantiation: unicode-data-tables.c:str_ends_icase_with Unexecuted instantiation: unicode-transform.c:str_ends_icase_with Unexecuted instantiation: write-full.c:str_ends_icase_with Unexecuted instantiation: backtrace-string.c:str_ends_icase_with Unexecuted instantiation: bits.c:str_ends_icase_with Unexecuted instantiation: eacces-error.c:str_ends_icase_with Unexecuted instantiation: env-util.c:str_ends_icase_with Unexecuted instantiation: event-filter.c:str_ends_icase_with Unexecuted instantiation: event-filter-lexer.c:str_ends_icase_with Unexecuted instantiation: event-filter-parser.c:str_ends_icase_with Unexecuted instantiation: hash.c:str_ends_icase_with Unexecuted instantiation: hex-binary.c:str_ends_icase_with Unexecuted instantiation: hmac.c:str_ends_icase_with Unexecuted instantiation: ipwd.c:str_ends_icase_with Unexecuted instantiation: istream-concat.c:str_ends_icase_with Unexecuted instantiation: ioloop-iolist.c:str_ends_icase_with Unexecuted instantiation: ioloop-notify-fd.c:str_ends_icase_with Unexecuted instantiation: primes.c:str_ends_icase_with Unexecuted instantiation: sha2.c:str_ends_icase_with Unexecuted instantiation: xxh64.c:str_ends_icase_with Unexecuted instantiation: str-parse.c:str_ends_icase_with Unexecuted instantiation: wildcard-match.c:str_ends_icase_with |
171 | | |
172 | | /* Get length of a prefix segment. |
173 | | |
174 | | Calculates the length (in bytes) of the initial segment of s which consists |
175 | | entirely of bytes in accept. |
176 | | */ |
177 | | size_t i_memspn(const void *data, size_t data_len, |
178 | | const void *accept, size_t accept_len); |
179 | | /* Get length of a prefix segment. |
180 | | |
181 | | Calculates the length of the initial segment of s which consists entirely of |
182 | | bytes not in reject. |
183 | | */ |
184 | | size_t i_memcspn(const void *data, size_t data_len, |
185 | | const void *reject, size_t reject_len); |
186 | | |
187 | | static inline char *i_strchr_to_next(const char *str, char chr) |
188 | 0 | { |
189 | 0 | char *tmp = (char *)strchr(str, chr); |
190 | 0 | return tmp == NULL ? NULL : tmp+1; |
191 | 0 | } Unexecuted instantiation: fuzz-json-istream.c:i_strchr_to_next Unexecuted instantiation: json-tree.c:i_strchr_to_next Unexecuted instantiation: json-istream.c:i_strchr_to_next Unexecuted instantiation: json-parser.c:i_strchr_to_next Unexecuted instantiation: istream-json-string.c:i_strchr_to_next Unexecuted instantiation: json-syntax.c:i_strchr_to_next Unexecuted instantiation: fuzzer.c:i_strchr_to_next Unexecuted instantiation: test-istream.c:i_strchr_to_next Unexecuted instantiation: array.c:i_strchr_to_next Unexecuted instantiation: buffer.c:i_strchr_to_next Unexecuted instantiation: data-stack.c:i_strchr_to_next Unexecuted instantiation: event-log.c:i_strchr_to_next Unexecuted instantiation: failures.c:i_strchr_to_next Unexecuted instantiation: fd-util.c:i_strchr_to_next Unexecuted instantiation: hostpid.c:i_strchr_to_next Unexecuted instantiation: imem.c:i_strchr_to_next Unexecuted instantiation: iostream.c:i_strchr_to_next Unexecuted instantiation: iostream-pump.c:i_strchr_to_next Unexecuted instantiation: istream.c:i_strchr_to_next Unexecuted instantiation: istream-data.c:i_strchr_to_next Unexecuted instantiation: istream-file.c:i_strchr_to_next Unexecuted instantiation: istream-limit.c:i_strchr_to_next Unexecuted instantiation: istream-seekable.c:i_strchr_to_next Unexecuted instantiation: ioloop.c:i_strchr_to_next Unexecuted instantiation: ioloop-notify-inotify.c:i_strchr_to_next Unexecuted instantiation: ioloop-epoll.c:i_strchr_to_next Unexecuted instantiation: lib.c:i_strchr_to_next Unexecuted instantiation: lib-event.c:i_strchr_to_next Unexecuted instantiation: lib-signals.c:i_strchr_to_next Unexecuted instantiation: memarea.c:i_strchr_to_next Unexecuted instantiation: mempool.c:i_strchr_to_next Unexecuted instantiation: mempool-alloconly.c:i_strchr_to_next Unexecuted instantiation: mempool-datastack.c:i_strchr_to_next Unexecuted instantiation: mempool-system.c:i_strchr_to_next Unexecuted instantiation: mempool-unsafe-datastack.c:i_strchr_to_next Unexecuted instantiation: net.c:i_strchr_to_next Unexecuted instantiation: ostream.c:i_strchr_to_next Unexecuted instantiation: ostream-file.c:i_strchr_to_next Unexecuted instantiation: path-util.c:i_strchr_to_next Unexecuted instantiation: printf-format-fix.c:i_strchr_to_next Unexecuted instantiation: process-title.c:i_strchr_to_next Unexecuted instantiation: priorityq.c:i_strchr_to_next Unexecuted instantiation: randgen.c:i_strchr_to_next Unexecuted instantiation: rand.c:i_strchr_to_next Unexecuted instantiation: read-full.c:i_strchr_to_next Unexecuted instantiation: restrict-access.c:i_strchr_to_next Unexecuted instantiation: safe-memset.c:i_strchr_to_next Unexecuted instantiation: safe-mkstemp.c:i_strchr_to_next Unexecuted instantiation: sendfile-util.c:i_strchr_to_next Unexecuted instantiation: sleep.c:i_strchr_to_next Unexecuted instantiation: str.c:i_strchr_to_next Unexecuted instantiation: strescape.c:i_strchr_to_next Unexecuted instantiation: strfuncs.c:i_strchr_to_next Unexecuted instantiation: strnum.c:i_strchr_to_next Unexecuted instantiation: time-util.c:i_strchr_to_next Unexecuted instantiation: unichar.c:i_strchr_to_next Unexecuted instantiation: unicode-break.c:i_strchr_to_next Unexecuted instantiation: unicode-data-tables.c:i_strchr_to_next Unexecuted instantiation: unicode-transform.c:i_strchr_to_next Unexecuted instantiation: write-full.c:i_strchr_to_next Unexecuted instantiation: backtrace-string.c:i_strchr_to_next Unexecuted instantiation: bits.c:i_strchr_to_next Unexecuted instantiation: eacces-error.c:i_strchr_to_next Unexecuted instantiation: env-util.c:i_strchr_to_next Unexecuted instantiation: event-filter.c:i_strchr_to_next Unexecuted instantiation: event-filter-lexer.c:i_strchr_to_next Unexecuted instantiation: event-filter-parser.c:i_strchr_to_next Unexecuted instantiation: hash.c:i_strchr_to_next Unexecuted instantiation: hex-binary.c:i_strchr_to_next Unexecuted instantiation: hmac.c:i_strchr_to_next Unexecuted instantiation: ipwd.c:i_strchr_to_next Unexecuted instantiation: istream-concat.c:i_strchr_to_next Unexecuted instantiation: ioloop-iolist.c:i_strchr_to_next Unexecuted instantiation: ioloop-notify-fd.c:i_strchr_to_next Unexecuted instantiation: primes.c:i_strchr_to_next Unexecuted instantiation: sha2.c:i_strchr_to_next Unexecuted instantiation: xxh64.c:i_strchr_to_next Unexecuted instantiation: str-parse.c:i_strchr_to_next Unexecuted instantiation: wildcard-match.c:i_strchr_to_next |
192 | | |
193 | | /* Split only on the first separator encountered. |
194 | | Returns TRUE if the separator was found, FALSE and *value_r = "" otherwise. |
195 | | Normally it's fine (or even useful) to treat "key" and "key=" identically, |
196 | | so return value can just be ignored. */ |
197 | | bool t_split_key_value(const char *arg, char separator, |
198 | | const char **key_r, const char **value_r) |
199 | | ATTR_NOWARN_UNUSED_RESULT; |
200 | | static inline bool ATTR_NOWARN_UNUSED_RESULT |
201 | 0 | t_split_key_value_eq(const char *arg, const char **key_r, const char **value_r) { |
202 | 0 | return t_split_key_value(arg, '=', key_r, value_r); |
203 | 0 | } Unexecuted instantiation: fuzz-json-istream.c:t_split_key_value_eq Unexecuted instantiation: json-tree.c:t_split_key_value_eq Unexecuted instantiation: json-istream.c:t_split_key_value_eq Unexecuted instantiation: json-parser.c:t_split_key_value_eq Unexecuted instantiation: istream-json-string.c:t_split_key_value_eq Unexecuted instantiation: json-syntax.c:t_split_key_value_eq Unexecuted instantiation: fuzzer.c:t_split_key_value_eq Unexecuted instantiation: test-istream.c:t_split_key_value_eq Unexecuted instantiation: array.c:t_split_key_value_eq Unexecuted instantiation: buffer.c:t_split_key_value_eq Unexecuted instantiation: data-stack.c:t_split_key_value_eq Unexecuted instantiation: event-log.c:t_split_key_value_eq Unexecuted instantiation: failures.c:t_split_key_value_eq Unexecuted instantiation: fd-util.c:t_split_key_value_eq Unexecuted instantiation: hostpid.c:t_split_key_value_eq Unexecuted instantiation: imem.c:t_split_key_value_eq Unexecuted instantiation: iostream.c:t_split_key_value_eq Unexecuted instantiation: iostream-pump.c:t_split_key_value_eq Unexecuted instantiation: istream.c:t_split_key_value_eq Unexecuted instantiation: istream-data.c:t_split_key_value_eq Unexecuted instantiation: istream-file.c:t_split_key_value_eq Unexecuted instantiation: istream-limit.c:t_split_key_value_eq Unexecuted instantiation: istream-seekable.c:t_split_key_value_eq Unexecuted instantiation: ioloop.c:t_split_key_value_eq Unexecuted instantiation: ioloop-notify-inotify.c:t_split_key_value_eq Unexecuted instantiation: ioloop-epoll.c:t_split_key_value_eq Unexecuted instantiation: lib.c:t_split_key_value_eq Unexecuted instantiation: lib-event.c:t_split_key_value_eq Unexecuted instantiation: lib-signals.c:t_split_key_value_eq Unexecuted instantiation: memarea.c:t_split_key_value_eq Unexecuted instantiation: mempool.c:t_split_key_value_eq Unexecuted instantiation: mempool-alloconly.c:t_split_key_value_eq Unexecuted instantiation: mempool-datastack.c:t_split_key_value_eq Unexecuted instantiation: mempool-system.c:t_split_key_value_eq Unexecuted instantiation: mempool-unsafe-datastack.c:t_split_key_value_eq Unexecuted instantiation: net.c:t_split_key_value_eq Unexecuted instantiation: ostream.c:t_split_key_value_eq Unexecuted instantiation: ostream-file.c:t_split_key_value_eq Unexecuted instantiation: path-util.c:t_split_key_value_eq Unexecuted instantiation: printf-format-fix.c:t_split_key_value_eq Unexecuted instantiation: process-title.c:t_split_key_value_eq Unexecuted instantiation: priorityq.c:t_split_key_value_eq Unexecuted instantiation: randgen.c:t_split_key_value_eq Unexecuted instantiation: rand.c:t_split_key_value_eq Unexecuted instantiation: read-full.c:t_split_key_value_eq Unexecuted instantiation: restrict-access.c:t_split_key_value_eq Unexecuted instantiation: safe-memset.c:t_split_key_value_eq Unexecuted instantiation: safe-mkstemp.c:t_split_key_value_eq Unexecuted instantiation: sendfile-util.c:t_split_key_value_eq Unexecuted instantiation: sleep.c:t_split_key_value_eq Unexecuted instantiation: str.c:t_split_key_value_eq Unexecuted instantiation: strescape.c:t_split_key_value_eq Unexecuted instantiation: strfuncs.c:t_split_key_value_eq Unexecuted instantiation: strnum.c:t_split_key_value_eq Unexecuted instantiation: time-util.c:t_split_key_value_eq Unexecuted instantiation: unichar.c:t_split_key_value_eq Unexecuted instantiation: unicode-break.c:t_split_key_value_eq Unexecuted instantiation: unicode-data-tables.c:t_split_key_value_eq Unexecuted instantiation: unicode-transform.c:t_split_key_value_eq Unexecuted instantiation: write-full.c:t_split_key_value_eq Unexecuted instantiation: backtrace-string.c:t_split_key_value_eq Unexecuted instantiation: bits.c:t_split_key_value_eq Unexecuted instantiation: eacces-error.c:t_split_key_value_eq Unexecuted instantiation: env-util.c:t_split_key_value_eq Unexecuted instantiation: event-filter.c:t_split_key_value_eq Unexecuted instantiation: event-filter-lexer.c:t_split_key_value_eq Unexecuted instantiation: event-filter-parser.c:t_split_key_value_eq Unexecuted instantiation: hash.c:t_split_key_value_eq Unexecuted instantiation: hex-binary.c:t_split_key_value_eq Unexecuted instantiation: hmac.c:t_split_key_value_eq Unexecuted instantiation: ipwd.c:t_split_key_value_eq Unexecuted instantiation: istream-concat.c:t_split_key_value_eq Unexecuted instantiation: ioloop-iolist.c:t_split_key_value_eq Unexecuted instantiation: ioloop-notify-fd.c:t_split_key_value_eq Unexecuted instantiation: primes.c:t_split_key_value_eq Unexecuted instantiation: sha2.c:t_split_key_value_eq Unexecuted instantiation: xxh64.c:t_split_key_value_eq Unexecuted instantiation: str-parse.c:t_split_key_value_eq Unexecuted instantiation: wildcard-match.c:t_split_key_value_eq |
204 | | |
205 | | /* separators is an array of separator characters, not a separator string. |
206 | | an empty data string results in an array containing only NULL. */ |
207 | | char **p_strsplit(pool_t pool, const char *data, const char *separators) |
208 | | ATTR_MALLOC ATTR_RETURNS_NONNULL; |
209 | | const char **t_strsplit(const char *data, const char *separators) |
210 | | ATTR_MALLOC ATTR_RETURNS_NONNULL; |
211 | | /* like p_strsplit(), but treats multiple adjacent separators as a single |
212 | | separator. separators at the beginning or at the end of the string are also |
213 | | ignored, so it's not possible for the result to have any empty strings. */ |
214 | | char **p_strsplit_spaces(pool_t pool, const char *data, const char *separators) |
215 | | ATTR_MALLOC ATTR_RETURNS_NONNULL; |
216 | | const char **t_strsplit_spaces(const char *data, const char *separators) |
217 | | ATTR_MALLOC ATTR_RETURNS_NONNULL; |
218 | | void p_strsplit_free(pool_t pool, char **arr); |
219 | | |
220 | | const char *dec2str(uintmax_t number); |
221 | | /* Use the given buffer to write out the number. Returns pointer to the |
222 | | written number in the buffer. Note that this isn't the same as the beginning |
223 | | of the buffer. */ |
224 | | char *dec2str_buf(char buffer[STATIC_ARRAY MAX_INT_STRLEN], uintmax_t number); |
225 | | |
226 | | /* Return length of NULL-terminated list string array */ |
227 | | unsigned int str_array_length(const char *const *arr) ATTR_PURE; |
228 | | /* Return all strings from array joined into one string. */ |
229 | | const char *t_strarray_join(const char *const *arr, const char *separator) |
230 | | ATTR_MALLOC ATTR_RETURNS_NONNULL; |
231 | | /* Removes a value from NULL-terminated string array. Returns TRUE if found. */ |
232 | | bool str_array_remove(const char **arr, const char *value); |
233 | | /* Returns TRUE if value exists in NULL-terminated string array. */ |
234 | | bool str_array_find(const char *const *arr, const char *value); |
235 | | /* Like str_array_find(), but use strcasecmp(). */ |
236 | | bool str_array_icase_find(const char *const *arr, const char *value); |
237 | | /* Duplicate array of strings. The memory can be freed by freeing the |
238 | | return value. */ |
239 | | const char **p_strarray_dup(pool_t pool, const char *const *arr) |
240 | | ATTR_MALLOC ATTR_RETURNS_NONNULL; |
241 | | |
242 | | /* Join ARRAY_TYPE(const_string) to a string, similar to t_strarray_join() */ |
243 | | char *p_array_const_string_join(pool_t pool, const ARRAY_TYPE(const_string) *arr, |
244 | | const char *separator); |
245 | | #define t_array_const_string_join(arr, separator) \ |
246 | 0 | ((const char *)p_array_const_string_join(unsafe_data_stack_pool, arr, separator)) |
247 | | |
248 | | /* INTERNAL */ |
249 | | char *t_noalloc_strdup_vprintf(const char *format, va_list args, |
250 | | unsigned int *size_r) |
251 | | ATTR_FORMAT(1, 0) ATTR_RETURNS_NONNULL; |
252 | | char *vstrconcat(const char *str1, va_list args, size_t *ret_len) ATTR_MALLOC; |
253 | | |
254 | | #endif |