1 : /* Copyright (c) 2007 James Antill -- See LICENSE file for terms. */
2 : #ifndef USTR_CMP_H
3 : #define USTR_CMP_H 1
4 :
5 : #ifndef USTR_MAIN_H
6 : #error " You should have already included ustr-main.h, or just include ustr.h."
7 : #endif
8 :
9 : /* normal strcmp() like, deals with embeded NILs */
10 : USTR_CONF_E_PROTO int ustr_cmp_buf(const struct Ustr *, const void *, size_t)
11 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
12 : USTR__COMPILE_ATTR_NONNULL_A();
13 :
14 : USTR_CONF_EI_PROTO int ustr_cmp(const struct Ustr *, const struct Ustr *)
15 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
16 : USTR__COMPILE_ATTR_NONNULL_A();
17 : USTR_CONF_E_PROTO int ustr_cmp_subustr(const struct Ustr *,
18 : const struct Ustr *, size_t, size_t)
19 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
20 : USTR__COMPILE_ATTR_NONNULL_A();
21 : USTR_CONF_EI_PROTO int ustr_cmp_cstr(const struct Ustr *, const char *)
22 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
23 : USTR__COMPILE_ATTR_NONNULL_A();
24 :
25 : /* faster compare, sorts in a very non-human way */
26 : USTR_CONF_EI_PROTO int ustr_cmp_fast_buf(const struct Ustr*, const void*,size_t)
27 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
28 : USTR__COMPILE_ATTR_NONNULL_A();
29 :
30 : USTR_CONF_EI_PROTO int ustr_cmp_fast(const struct Ustr *, const struct Ustr *)
31 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
32 : USTR__COMPILE_ATTR_NONNULL_A();
33 : USTR_CONF_E_PROTO int ustr_cmp_fast_subustr(const struct Ustr *,
34 : const struct Ustr *, size_t, size_t)
35 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
36 : USTR__COMPILE_ATTR_NONNULL_A();
37 : USTR_CONF_EI_PROTO int ustr_cmp_fast_cstr(const struct Ustr *, const char *)
38 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
39 : USTR__COMPILE_ATTR_NONNULL_A();
40 :
41 : /* normal ASCII strcasecmp() like, deals with embeded NILs */
42 : USTR_CONF_E_PROTO int ustr_cmp_case_buf(const struct Ustr *,const void *,size_t)
43 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
44 : USTR__COMPILE_ATTR_NONNULL_A();
45 :
46 : USTR_CONF_EI_PROTO int ustr_cmp_case(const struct Ustr *, const struct Ustr *)
47 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
48 : USTR__COMPILE_ATTR_NONNULL_A();
49 : USTR_CONF_E_PROTO int ustr_cmp_case_subustr(const struct Ustr *,
50 : const struct Ustr *, size_t, size_t)
51 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
52 : USTR__COMPILE_ATTR_NONNULL_A();
53 : USTR_CONF_EI_PROTO int ustr_cmp_case_cstr(const struct Ustr *, const char *)
54 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
55 : USTR__COMPILE_ATTR_NONNULL_A();
56 :
57 : /* EQ functions to make code readable ... also faster due to ustr_cmp_fast() */
58 : USTR_CONF_EI_PROTO int ustr_cmp_eq(const struct Ustr *, const struct Ustr *)
59 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
60 : USTR__COMPILE_ATTR_NONNULL_A();
61 : USTR_CONF_EI_PROTO int ustr_cmp_buf_eq(const struct Ustr *, const void *,size_t)
62 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
63 : USTR__COMPILE_ATTR_NONNULL_A();
64 : USTR_CONF_EI_PROTO
65 : int ustr_cmp_subustr_eq(const struct Ustr *, const struct Ustr *, size_t,size_t)
66 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
67 : USTR__COMPILE_ATTR_NONNULL_A();
68 : USTR_CONF_EI_PROTO int ustr_cmp_cstr_eq(const struct Ustr *, const char *)
69 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
70 : USTR__COMPILE_ATTR_NONNULL_A();
71 :
72 : USTR_CONF_EI_PROTO int ustr_cmp_case_eq(const struct Ustr *,const struct Ustr *)
73 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
74 : USTR__COMPILE_ATTR_NONNULL_A();
75 : USTR_CONF_EI_PROTO
76 : int ustr_cmp_case_buf_eq(const struct Ustr *, const void *, size_t)
77 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
78 : USTR__COMPILE_ATTR_NONNULL_A();
79 : USTR_CONF_EI_PROTO
80 : int ustr_cmp_case_subustr_eq(const struct Ustr *,
81 : const struct Ustr *, size_t, size_t)
82 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
83 : USTR__COMPILE_ATTR_NONNULL_A();
84 : USTR_CONF_EI_PROTO int ustr_cmp_case_cstr_eq(const struct Ustr *, const char *)
85 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
86 : USTR__COMPILE_ATTR_NONNULL_A();
87 :
88 : USTR_CONF_EI_PROTO
89 : int ustr_cmp_prefix_eq(const struct Ustr *, const struct Ustr *)
90 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
91 : USTR__COMPILE_ATTR_NONNULL_A();
92 : USTR_CONF_EI_PROTO int ustr_cmp_prefix_buf_eq(const struct Ustr *,
93 : const void *, size_t)
94 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
95 : USTR__COMPILE_ATTR_NONNULL_A();
96 : USTR_CONF_EI_PROTO int ustr_cmp_prefix_cstr_eq(const struct Ustr *,const char *)
97 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
98 : USTR__COMPILE_ATTR_NONNULL_A();
99 : USTR_CONF_E_PROTO
100 : int ustr_cmp_prefix_subustr_eq(const struct Ustr *,
101 : const struct Ustr *, size_t, size_t)
102 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
103 : USTR__COMPILE_ATTR_NONNULL_A();
104 :
105 : USTR_CONF_EI_PROTO
106 : int ustr_cmp_case_prefix_eq(const struct Ustr *, const struct Ustr *)
107 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
108 : USTR__COMPILE_ATTR_NONNULL_A();
109 : USTR_CONF_E_PROTO int ustr_cmp_case_prefix_buf_eq(const struct Ustr *,
110 : const void *, size_t)
111 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
112 : USTR__COMPILE_ATTR_NONNULL_A();
113 : USTR_CONF_EI_PROTO
114 : int ustr_cmp_case_prefix_cstr_eq(const struct Ustr *, const char *)
115 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
116 : USTR__COMPILE_ATTR_NONNULL_A();
117 : USTR_CONF_E_PROTO
118 : int ustr_cmp_case_prefix_subustr_eq(const struct Ustr *,
119 : const struct Ustr *, size_t, size_t)
120 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
121 : USTR__COMPILE_ATTR_NONNULL_A();
122 :
123 : USTR_CONF_EI_PROTO
124 : int ustr_cmp_suffix_eq(const struct Ustr *, const struct Ustr *)
125 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
126 : USTR__COMPILE_ATTR_NONNULL_A();
127 : USTR_CONF_EI_PROTO int ustr_cmp_suffix_buf_eq(const struct Ustr *,
128 : const void *, size_t)
129 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
130 : USTR__COMPILE_ATTR_NONNULL_A();
131 : USTR_CONF_EI_PROTO int ustr_cmp_suffix_cstr_eq(const struct Ustr *,const char *)
132 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
133 : USTR__COMPILE_ATTR_NONNULL_A();
134 : USTR_CONF_E_PROTO
135 : int ustr_cmp_suffix_subustr_eq(const struct Ustr *,
136 : const struct Ustr *, size_t, size_t)
137 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
138 : USTR__COMPILE_ATTR_NONNULL_A();
139 :
140 : USTR_CONF_EI_PROTO
141 : int ustr_cmp_case_suffix_eq(const struct Ustr *, const struct Ustr *)
142 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
143 : USTR__COMPILE_ATTR_NONNULL_A();
144 : USTR_CONF_EI_PROTO int ustr_cmp_case_suffix_buf_eq(const struct Ustr *,
145 : const void *, size_t)
146 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
147 : USTR__COMPILE_ATTR_NONNULL_A();
148 : USTR_CONF_EI_PROTO
149 : int ustr_cmp_case_suffix_cstr_eq(const struct Ustr *, const char *)
150 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
151 : USTR__COMPILE_ATTR_NONNULL_A();
152 : USTR_CONF_E_PROTO
153 : int ustr_cmp_case_suffix_subustr_eq(const struct Ustr *,
154 : const struct Ustr *, size_t, size_t)
155 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
156 : USTR__COMPILE_ATTR_NONNULL_A();
157 :
158 : #if USTR_CONF_COMPILE_USE_INLINE
159 : USTR_CONF_II_PROTO
160 : int ustr_cmp_fast_buf(const struct Ustr *s1, const void *buf, size_t len2)
161 1892 : {
162 2473 : size_t len1 = 0;
163 :
164 1234 : USTR_ASSERT(ustr_assert_valid(s1) && buf);
165 :
166 1873 : len1 = ustr_len(s1);
167 2473 : if (len1 == len2)
168 2387 : return (memcmp(ustr_cstr(s1), buf, len1));
169 86 : else if (len1 > len2)
170 32 : return (1);
171 : else
172 54 : return (-1);
173 : }
174 : USTR_CONF_II_PROTO int ustr_cmp_prefix_buf_eq(const struct Ustr *s1,
175 : const void *buf, size_t len2)
176 298 : {
177 386 : size_t len1 = 0;
178 :
179 192 : USTR_ASSERT(ustr_assert_valid(s1) && buf);
180 :
181 290 : len1 = ustr_len(s1);
182 386 : if (len1 < len2)
183 24 : return (USTR_FALSE);
184 :
185 362 : return (!memcmp(ustr_cstr(s1), buf, len2));
186 : }
187 : USTR_CONF_II_PROTO int ustr_cmp_suffix_buf_eq(const struct Ustr *s1,
188 : const void *buf, size_t len2)
189 277 : {
190 358 : size_t len1 = 0;
191 :
192 178 : USTR_ASSERT(ustr_assert_valid(s1) && buf);
193 :
194 269 : len1 = ustr_len(s1);
195 358 : if (len1 < len2)
196 8 : return (USTR_FALSE);
197 :
198 350 : return (!memcmp(ustr_cstr(s1) + (len1 - len2), buf, len2));
199 : }
200 : #endif
201 :
202 : #if USTR_CONF_INCLUDE_INTERNAL_HEADERS
203 : # include "ustr-cmp-internal.h"
204 : #endif
205 :
206 : #if USTR_CONF_INCLUDE_CODEONLY_HEADERS
207 : # include "ustr-cmp-code.h"
208 : #endif
209 :
210 :
211 : #if USTR_CONF_COMPILE_USE_INLINE
212 : USTR_CONF_II_PROTO int ustr_cmp(const struct Ustr *s1, const struct Ustr *s2)
213 51 : {
214 29 : USTR_ASSERT(ustr_assert_valid(s1) && ustr_assert_valid(s2));
215 :
216 58 : if (s1 == s2)
217 20 : return (0);
218 :
219 38 : return (ustr_cmp_buf(s1, ustr_cstr(s2), ustr_len(s2)));
220 : }
221 :
222 : USTR_CONF_II_PROTO int ustr_cmp_fast(const struct Ustr *s1,const struct Ustr*s2)
223 1122 : {
224 743 : USTR_ASSERT(ustr_assert_valid(s1) && ustr_assert_valid(s2));
225 :
226 1486 : if (s1 == s2)
227 189 : return (0);
228 :
229 977 : return (ustr_cmp_fast_buf(s1, ustr_cstr(s2), ustr_len(s2)));
230 : }
231 :
232 : USTR_CONF_II_PROTO int ustr_cmp_case(const struct Ustr *s1,const struct Ustr*s2)
233 33 : {
234 22 : USTR_ASSERT(ustr_assert_valid(s1) && ustr_assert_valid(s2));
235 :
236 44 : if (s1 == s2)
237 12 : return (0);
238 :
239 32 : return (ustr_cmp_case_buf(s1, ustr_cstr(s2), ustr_len(s2)));
240 : }
241 :
242 : USTR_CONF_II_PROTO int ustr_cmp_cstr(const struct Ustr *s1, const char *s2)
243 10 : { return (ustr_cmp_buf(s1, s2, strlen(s2))); }
244 : USTR_CONF_II_PROTO int ustr_cmp_fast_cstr(const struct Ustr *s1, const char *s2)
245 4 : { return (ustr_cmp_fast_buf(s1, s2, strlen(s2))); }
246 :
247 : USTR_CONF_II_PROTO int ustr_cmp_case_cstr(const struct Ustr *s1, const char *s2)
248 48 : { return (ustr_cmp_case_buf(s1, s2, strlen(s2))); }
249 :
250 : USTR_CONF_II_PROTO int ustr_cmp_eq(const struct Ustr *s1, const struct Ustr *s2)
251 986 : { return (!ustr_cmp_fast(s1, s2)); }
252 : USTR_CONF_II_PROTO
253 : int ustr_cmp_buf_eq(const struct Ustr *s1, const void *buf, size_t len)
254 42 : { return (!ustr_cmp_fast_buf(s1, buf, len)); }
255 : USTR_CONF_II_PROTO int ustr_cmp_subustr_eq(const struct Ustr *s1,
256 : const struct Ustr *s2,
257 : size_t pos, size_t len)
258 60 : { return (!ustr_cmp_fast_subustr(s1, s2, pos, len)); }
259 : USTR_CONF_II_PROTO int ustr_cmp_cstr_eq(const struct Ustr *s1, const char *cstr)
260 1166 : { return (!ustr_cmp_fast_buf(s1, cstr, strlen(cstr))); }
261 :
262 : USTR_CONF_II_PROTO
263 : int ustr_cmp_case_eq(const struct Ustr *s1, const struct Ustr *s2)
264 27 : {
265 18 : USTR_ASSERT(ustr_assert_valid(s1) && ustr_assert_valid(s2));
266 :
267 36 : if (s1 == s2)
268 12 : return (USTR_TRUE);
269 :
270 30 : return ((ustr_len(s1) == ustr_len(s2)) && !ustr_cmp_case(s1, s2));
271 : }
272 : USTR_CONF_II_PROTO
273 : int ustr_cmp_case_buf_eq(const struct Ustr *s1, const void *buf, size_t len)
274 27 : {
275 18 : USTR_ASSERT(ustr_assert_valid(s1));
276 36 : return ((ustr_len(s1) == len) && !ustr_cmp_case_buf(s1, buf, len));
277 : }
278 : USTR_CONF_II_PROTO int ustr_cmp_case_subustr_eq(const struct Ustr *s1,
279 : const struct Ustr *s2,
280 : size_t pos, size_t len)
281 3 : {
282 2 : USTR_ASSERT(ustr_assert_valid(s1));
283 4 : return ((ustr_len(s1) == len) && !ustr_cmp_case_subustr(s1, s2, pos, len));
284 : }
285 : USTR_CONF_II_PROTO
286 : int ustr_cmp_case_cstr_eq(const struct Ustr *s1, const char *cstr)
287 9 : {
288 12 : size_t len = strlen(cstr);
289 6 : USTR_ASSERT(ustr_assert_valid(s1));
290 12 : return ((ustr_len(s1) == len) && !ustr_cmp_case_buf(s1, cstr, len));
291 : }
292 :
293 : USTR_CONF_II_PROTO int ustr_cmp_prefix_eq(const struct Ustr *s1,
294 : const struct Ustr *s2)
295 12 : {
296 8 : USTR_ASSERT(ustr_assert_valid(s1) && ustr_assert_valid(s2));
297 :
298 16 : if (s1 == s2)
299 4 : return (USTR_TRUE);
300 :
301 9 : return (ustr_cmp_prefix_buf_eq(s1, ustr_cstr(s2), ustr_len(s2)));
302 : }
303 : USTR_CONF_II_PROTO int ustr_cmp_prefix_cstr_eq(const struct Ustr *s1,
304 : const char *cstr)
305 120 : { return (ustr_cmp_prefix_buf_eq(s1, cstr, strlen(cstr))); }
306 :
307 : USTR_CONF_II_PROTO int ustr_cmp_case_prefix_eq(const struct Ustr *s1,
308 : const struct Ustr *s2)
309 12 : {
310 8 : USTR_ASSERT(ustr_assert_valid(s1) && ustr_assert_valid(s2));
311 :
312 16 : if (s1 == s2)
313 4 : return (USTR_TRUE);
314 :
315 12 : return (ustr_cmp_case_prefix_buf_eq(s1, ustr_cstr(s2), ustr_len(s2)));
316 : }
317 : USTR_CONF_II_PROTO int ustr_cmp_case_prefix_cstr_eq(const struct Ustr *s1,
318 : const char *cstr)
319 32 : { return (ustr_cmp_case_prefix_buf_eq(s1, cstr, strlen(cstr))); }
320 :
321 : USTR_CONF_II_PROTO int ustr_cmp_suffix_eq(const struct Ustr *s1,
322 : const struct Ustr *s2)
323 12 : {
324 8 : USTR_ASSERT(ustr_assert_valid(s1) && ustr_assert_valid(s2));
325 :
326 16 : if (s1 == s2)
327 4 : return (USTR_TRUE);
328 :
329 9 : return (ustr_cmp_suffix_buf_eq(s1, ustr_cstr(s2), ustr_len(s2)));
330 : }
331 : USTR_CONF_II_PROTO int ustr_cmp_suffix_cstr_eq(const struct Ustr *s1,
332 : const char *cstr)
333 108 : { return (ustr_cmp_suffix_buf_eq(s1, cstr, strlen(cstr))); }
334 :
335 : USTR_CONF_II_PROTO int ustr_cmp_case_suffix_eq(const struct Ustr *s1,
336 : const struct Ustr *s2)
337 12 : {
338 8 : USTR_ASSERT(ustr_assert_valid(s1) && ustr_assert_valid(s2));
339 :
340 16 : if (s1 == s2)
341 4 : return (USTR_TRUE);
342 :
343 12 : return (ustr_cmp_case_suffix_buf_eq(s1, ustr_cstr(s2), ustr_len(s2)));
344 : }
345 : USTR_CONF_II_PROTO int ustr_cmp_case_suffix_cstr_eq(const struct Ustr *s1,
346 : const char *cstr)
347 24 : { return (ustr_cmp_case_suffix_buf_eq(s1, cstr, strlen(cstr))); }
348 : #endif
349 :
350 : /* ---------------- pool wrapper APIs ---------------- */
351 :
352 : /* normal strcmp() like, deals with embeded NILs */
353 : USTR_CONF_EI_PROTO
354 : int ustrp_cmp_buf(const struct Ustrp *, const void *, size_t)
355 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
356 : USTR__COMPILE_ATTR_NONNULL_A();
357 : USTR_CONF_EI_PROTO int ustrp_cmp(const struct Ustrp *, const struct Ustrp *)
358 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
359 : USTR__COMPILE_ATTR_NONNULL_A();
360 : USTR_CONF_EI_PROTO int ustrp_cmp_subustrp(const struct Ustrp *,
361 : const struct Ustrp *, size_t, size_t)
362 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
363 : USTR__COMPILE_ATTR_NONNULL_A();
364 : USTR_CONF_EI_PROTO int ustrp_cmp_cstr(const struct Ustrp *, const char *)
365 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
366 : USTR__COMPILE_ATTR_NONNULL_A();
367 :
368 : /* faster compare, sorts in a very non-human way */
369 : USTR_CONF_EI_PROTO
370 : int ustrp_cmp_fast_buf(const struct Ustrp *, const void *, size_t)
371 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
372 : USTR__COMPILE_ATTR_NONNULL_A();
373 : USTR_CONF_EI_PROTO int ustrp_cmp_fast(const struct Ustrp *, const struct Ustrp*)
374 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
375 : USTR__COMPILE_ATTR_NONNULL_A();
376 : USTR_CONF_EI_PROTO
377 : int ustrp_cmp_fast_subustrp(const struct Ustrp *,
378 : const struct Ustrp *, size_t, size_t)
379 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
380 : USTR__COMPILE_ATTR_NONNULL_A();
381 : USTR_CONF_EI_PROTO int ustrp_cmp_fast_cstr(const struct Ustrp *, const char *)
382 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
383 : USTR__COMPILE_ATTR_NONNULL_A();
384 :
385 : /* normal ASCII strcasecmp() like, deals with embeded NILs */
386 : USTR_CONF_EI_PROTO
387 : int ustrp_cmp_case_buf(const struct Ustrp *, const void *, size_t)
388 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
389 : USTR__COMPILE_ATTR_NONNULL_A();
390 : USTR_CONF_EI_PROTO int ustrp_cmp_case(const struct Ustrp *,const struct Ustrp *)
391 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
392 : USTR__COMPILE_ATTR_NONNULL_A();
393 : USTR_CONF_EI_PROTO int ustrp_cmp_case_subustrp(const struct Ustrp *,
394 : const struct Ustrp *, size_t, size_t)
395 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
396 : USTR__COMPILE_ATTR_NONNULL_A();
397 : USTR_CONF_EI_PROTO int ustrp_cmp_case_cstr(const struct Ustrp *, const char *)
398 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
399 : USTR__COMPILE_ATTR_NONNULL_A();
400 :
401 : /* EQ functions to make code readable ... also faster due to ustr_cmp_fast() */
402 : USTR_CONF_EI_PROTO int ustrp_cmp_eq(const struct Ustrp *, const struct Ustrp *)
403 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
404 : USTR__COMPILE_ATTR_NONNULL_A();
405 : USTR_CONF_EI_PROTO int ustrp_cmp_buf_eq(const struct Ustrp *,const void*,size_t)
406 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
407 : USTR__COMPILE_ATTR_NONNULL_A();
408 : USTR_CONF_EI_PROTO int ustrp_cmp_subustrp_eq(const struct Ustrp *,
409 : const struct Ustrp *, size_t, size_t)
410 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
411 : USTR__COMPILE_ATTR_NONNULL_A();
412 : USTR_CONF_EI_PROTO int ustrp_cmp_cstr_eq(const struct Ustrp *, const char *)
413 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
414 : USTR__COMPILE_ATTR_NONNULL_A();
415 :
416 : USTR_CONF_EI_PROTO
417 : int ustrp_cmp_case_eq(const struct Ustrp *, const struct Ustrp *)
418 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
419 : USTR__COMPILE_ATTR_NONNULL_A();
420 : USTR_CONF_EI_PROTO
421 : int ustrp_cmp_case_buf_eq(const struct Ustrp *, const void *, size_t)
422 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
423 : USTR__COMPILE_ATTR_NONNULL_A();
424 : USTR_CONF_EI_PROTO
425 : int ustrp_cmp_case_subustrp_eq(const struct Ustrp *,
426 : const struct Ustrp *, size_t, size_t)
427 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
428 : USTR__COMPILE_ATTR_NONNULL_A();
429 : USTR_CONF_EI_PROTO int ustrp_cmp_case_cstr_eq(const struct Ustrp *,const char *)
430 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
431 : USTR__COMPILE_ATTR_NONNULL_A();
432 :
433 : USTR_CONF_EI_PROTO
434 : int ustrp_cmp_prefix_eq(const struct Ustrp *, const struct Ustrp *)
435 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
436 : USTR__COMPILE_ATTR_NONNULL_A();
437 : USTR_CONF_EI_PROTO int ustrp_cmp_prefix_buf_eq(const struct Ustrp *,
438 : const void *, size_t)
439 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
440 : USTR__COMPILE_ATTR_NONNULL_A();
441 : USTR_CONF_EI_PROTO
442 : int ustrp_cmp_prefix_cstr_eq(const struct Ustrp *, const char *)
443 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
444 : USTR__COMPILE_ATTR_NONNULL_A();
445 : USTR_CONF_EI_PROTO
446 : int ustrp_cmp_prefix_subustrp_eq(const struct Ustrp *,
447 : const struct Ustrp *, size_t, size_t)
448 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
449 : USTR__COMPILE_ATTR_NONNULL_A();
450 :
451 : USTR_CONF_EI_PROTO
452 : int ustrp_cmp_case_prefix_eq(const struct Ustrp *, const struct Ustrp *)
453 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
454 : USTR__COMPILE_ATTR_NONNULL_A();
455 : USTR_CONF_EI_PROTO int ustrp_cmp_case_prefix_buf_eq(const struct Ustrp *,
456 : const void *, size_t)
457 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
458 : USTR__COMPILE_ATTR_NONNULL_A();
459 : USTR_CONF_EI_PROTO
460 : int ustrp_cmp_case_prefix_cstr_eq(const struct Ustrp *, const char *)
461 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
462 : USTR__COMPILE_ATTR_NONNULL_A();
463 : USTR_CONF_EI_PROTO
464 : int ustrp_cmp_case_prefix_subustrp_eq(const struct Ustrp *,
465 : const struct Ustrp *, size_t, size_t)
466 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
467 : USTR__COMPILE_ATTR_NONNULL_A();
468 :
469 : USTR_CONF_EI_PROTO
470 : int ustrp_cmp_suffix_eq(const struct Ustrp *, const struct Ustrp *)
471 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
472 : USTR__COMPILE_ATTR_NONNULL_A();
473 : USTR_CONF_EI_PROTO int ustrp_cmp_suffix_buf_eq(const struct Ustrp *,
474 : const void *, size_t)
475 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
476 : USTR__COMPILE_ATTR_NONNULL_A();
477 : USTR_CONF_EI_PROTO
478 : int ustrp_cmp_suffix_cstr_eq(const struct Ustrp *, const char *)
479 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
480 : USTR__COMPILE_ATTR_NONNULL_A();
481 : USTR_CONF_EI_PROTO
482 : int ustrp_cmp_suffix_subustrp_eq(const struct Ustrp *,
483 : const struct Ustrp *, size_t, size_t)
484 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
485 : USTR__COMPILE_ATTR_NONNULL_A();
486 :
487 : USTR_CONF_EI_PROTO
488 : int ustrp_cmp_case_suffix_eq(const struct Ustrp *, const struct Ustrp *)
489 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
490 : USTR__COMPILE_ATTR_NONNULL_A();
491 : USTR_CONF_EI_PROTO int ustrp_cmp_case_suffix_buf_eq(const struct Ustrp *,
492 : const void *, size_t)
493 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
494 : USTR__COMPILE_ATTR_NONNULL_A();
495 : USTR_CONF_EI_PROTO
496 : int ustrp_cmp_case_suffix_cstr_eq(const struct Ustrp *, const char *)
497 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
498 : USTR__COMPILE_ATTR_NONNULL_A();
499 : USTR_CONF_EI_PROTO
500 : int ustrp_cmp_case_suffix_subustrp_eq(const struct Ustrp *,
501 : const struct Ustrp *, size_t, size_t)
502 : USTR__COMPILE_ATTR_PURE() USTR__COMPILE_ATTR_WARN_UNUSED_RET()
503 : USTR__COMPILE_ATTR_NONNULL_A();
504 :
505 : #if USTR_CONF_COMPILE_USE_INLINE
506 : USTR_CONF_II_PROTO
507 : int ustrp_cmp_buf(const struct Ustrp *s1, const void *s2, size_t len)
508 36 : { return (ustr_cmp_buf(&s1->s, s2, len)); }
509 : USTR_CONF_II_PROTO int ustrp_cmp(const struct Ustrp *s1, const struct Ustrp *s2)
510 8 : { return (ustr_cmp(&s1->s, &s2->s)); }
511 : USTR_CONF_II_PROTO
512 : int ustrp_cmp_subustrp(const struct Ustrp *s1,
513 : const struct Ustrp *s2, size_t pos, size_t len)
514 2 : { return (ustr_cmp_subustr(&s1->s, &s2->s, pos, len)); }
515 : USTR_CONF_II_PROTO int ustrp_cmp_cstr(const struct Ustrp *s1, const char *s2)
516 36 : { return (ustrp_cmp_buf(s1, s2, strlen(s2))); }
517 :
518 : USTR_CONF_II_PROTO
519 : int ustrp_cmp_fast_buf(const struct Ustrp *s1, const void *s2, size_t len)
520 112 : { return (ustr_cmp_fast_buf(&s1->s, s2, len)); }
521 : USTR_CONF_II_PROTO
522 : int ustrp_cmp_fast(const struct Ustrp *s1, const struct Ustrp *s2)
523 480 : { return (ustr_cmp_fast(&s1->s, &s2->s)); }
524 : USTR_CONF_II_PROTO
525 : int ustrp_cmp_fast_subustrp(const struct Ustrp *s1,
526 : const struct Ustrp *s2, size_t pos, size_t len)
527 18 : { return (ustr_cmp_fast_subustr(&s1->s, &s2->s, pos, len)); }
528 : USTR_CONF_II_PROTO
529 : int ustrp_cmp_fast_cstr(const struct Ustrp *s1, const char *s2)
530 12 : { return (ustrp_cmp_fast_buf(s1, s2, strlen(s2))); }
531 :
532 : USTR_CONF_II_PROTO
533 : int ustrp_cmp_case_buf(const struct Ustrp *s1, const void *s2, size_t len)
534 48 : { return (ustr_cmp_case_buf(&s1->s, s2, len)); }
535 : USTR_CONF_II_PROTO
536 : int ustrp_cmp_case(const struct Ustrp *s1, const struct Ustrp *s2)
537 20 : { return (ustr_cmp_case(&s1->s, &s2->s)); }
538 : USTR_CONF_II_PROTO
539 : int ustrp_cmp_case_subustrp(const struct Ustrp *s1,
540 : const struct Ustrp *s2, size_t pos, size_t len)
541 2 : { return (ustr_cmp_case_subustr(&s1->s, &s2->s, pos, len)); }
542 : USTR_CONF_II_PROTO int ustrp_cmp_case_cstr(const struct Ustrp *s1,const char*s2)
543 48 : { return (ustrp_cmp_case_buf(s1, s2, strlen(s2))); }
544 :
545 : USTR_CONF_II_PROTO
546 : int ustrp_cmp_eq(const struct Ustrp *s1, const struct Ustrp *s2)
547 598 : { return (!ustrp_cmp_fast(s1, s2)); }
548 : USTR_CONF_II_PROTO
549 : int ustrp_cmp_buf_eq(const struct Ustrp *s1, const void *buf, size_t len)
550 5 : { return (!ustrp_cmp_fast_buf(s1, buf, len)); }
551 : USTR_CONF_II_PROTO int ustrp_cmp_subustrp_eq(const struct Ustrp *s1,
552 : const struct Ustrp *s2,
553 : size_t pos, size_t len)
554 20 : { return (!ustrp_cmp_fast_subustrp(s1, s2, pos, len)); }
555 : USTR_CONF_II_PROTO
556 : int ustrp_cmp_cstr_eq(const struct Ustrp *s1, const char *cstr)
557 144 : { return (!ustrp_cmp_fast_buf(s1, cstr, strlen(cstr))); }
558 :
559 : USTR_CONF_II_PROTO
560 : int ustrp_cmp_case_eq(const struct Ustrp *s1, const struct Ustrp *s2)
561 24 : { return (ustr_cmp_case_eq(&s1->s, &s2->s)); }
562 : USTR_CONF_II_PROTO
563 : int ustrp_cmp_case_buf_eq(const struct Ustrp *s1, const void *buf, size_t len)
564 4 : { return (ustr_cmp_case_buf_eq(&s1->s, buf, len)); }
565 : USTR_CONF_II_PROTO
566 : int ustrp_cmp_case_subustrp_eq(const struct Ustrp *s1,
567 : const struct Ustrp *s2, size_t pos, size_t len)
568 4 : { return (ustr_cmp_case_subustr_eq(&s1->s, &s2->s, pos, len)); }
569 : USTR_CONF_II_PROTO
570 : int ustrp_cmp_case_cstr_eq(const struct Ustrp *s1, const char *cstr)
571 32 : { return (ustr_cmp_case_buf_eq(&s1->s, cstr, strlen(cstr))); }
572 :
573 : USTR_CONF_II_PROTO
574 : int ustrp_cmp_prefix_eq(const struct Ustrp *s1, const struct Ustrp *s2)
575 8 : { return (ustr_cmp_prefix_eq(&s1->s, &s2->s)); }
576 : USTR_CONF_II_PROTO
577 : int ustrp_cmp_prefix_buf_eq(const struct Ustrp *s1, const void *buf, size_t len)
578 220 : { return (ustr_cmp_prefix_buf_eq(&s1->s, buf, len)); }
579 : USTR_CONF_II_PROTO
580 : int ustrp_cmp_prefix_subustrp_eq(const struct Ustrp *s1,
581 : const struct Ustrp *s2, size_t p,size_t l)
582 34 : { return (ustr_cmp_prefix_subustr_eq(&s1->s, &s2->s, p, l)); }
583 : USTR_CONF_II_PROTO
584 : int ustrp_cmp_prefix_cstr_eq(const struct Ustrp *s1, const char *cstr)
585 212 : { return (ustrp_cmp_prefix_buf_eq(s1, cstr, strlen(cstr))); }
586 :
587 : USTR_CONF_II_PROTO
588 : int ustrp_cmp_case_prefix_eq(const struct Ustrp *s1, const struct Ustrp *s2)
589 8 : { return (ustr_cmp_case_prefix_eq(&s1->s, &s2->s)); }
590 : USTR_CONF_II_PROTO int ustrp_cmp_case_prefix_buf_eq(const struct Ustrp *s1,
591 : const void *buf, size_t len)
592 44 : { return (ustr_cmp_case_prefix_buf_eq(&s1->s, buf, len)); }
593 : USTR_CONF_II_PROTO
594 : int ustrp_cmp_case_prefix_subustrp_eq(const struct Ustrp *s1,
595 : const struct Ustrp *s2, size_t p,size_t l)
596 10 : { return (ustr_cmp_case_prefix_subustr_eq(&s1->s, &s2->s, p, l)); }
597 : USTR_CONF_II_PROTO
598 : int ustrp_cmp_case_prefix_cstr_eq(const struct Ustrp *s1, const char *cstr)
599 44 : { return (ustrp_cmp_case_prefix_buf_eq(s1, cstr, strlen(cstr))); }
600 :
601 : USTR_CONF_II_PROTO
602 : int ustrp_cmp_suffix_eq(const struct Ustrp *s1, const struct Ustrp *s2)
603 8 : { return (ustr_cmp_suffix_eq(&s1->s, &s2->s)); }
604 : USTR_CONF_II_PROTO
605 : int ustrp_cmp_suffix_buf_eq(const struct Ustrp *s1, const void *buf, size_t len)
606 204 : { return (ustr_cmp_suffix_buf_eq(&s1->s, buf, len)); }
607 : USTR_CONF_II_PROTO
608 : int ustrp_cmp_suffix_subustrp_eq(const struct Ustrp *s1,
609 : const struct Ustrp *s2, size_t p,size_t l)
610 34 : { return (ustr_cmp_suffix_subustr_eq(&s1->s, &s2->s, p, l)); }
611 : USTR_CONF_II_PROTO
612 : int ustrp_cmp_suffix_cstr_eq(const struct Ustrp *s1, const char *cstr)
613 196 : { return (ustrp_cmp_suffix_buf_eq(s1, cstr, strlen(cstr))); }
614 :
615 : USTR_CONF_II_PROTO
616 : int ustrp_cmp_case_suffix_eq(const struct Ustrp *s1, const struct Ustrp *s2)
617 8 : { return (ustr_cmp_case_suffix_eq(&s1->s, &s2->s)); }
618 : USTR_CONF_II_PROTO int ustrp_cmp_case_suffix_buf_eq(const struct Ustrp *s1,
619 : const void *buf, size_t len)
620 36 : { return (ustr_cmp_case_suffix_buf_eq(&s1->s, buf, len)); }
621 : USTR_CONF_II_PROTO
622 : int ustrp_cmp_case_suffix_subustrp_eq(const struct Ustrp *s1,
623 : const struct Ustrp *s2, size_t p,size_t l)
624 14 : { return (ustr_cmp_case_suffix_subustr_eq(&s1->s, &s2->s, p, l)); }
625 : USTR_CONF_II_PROTO
626 : int ustrp_cmp_case_suffix_cstr_eq(const struct Ustrp *s1, const char *cstr)
627 36 : { return (ustrp_cmp_case_suffix_buf_eq(s1, cstr, strlen(cstr))); }
628 :
629 : #endif
630 :
631 :
632 : #endif
|