aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_str.h
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-05-08 17:24:19 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-05-09 22:20:42 +0300
commite93439da71e027cafe5b2788a997cbfc85d193c8 (patch)
treea4004d13b98d12b1529eec696c9ef1d2401331c5 /src/microhttpd/mhd_str.h
parentb03ee4c52a6deebdcad3f12a18c4bd4f947f167b (diff)
downloadlibmicrohttpd-e93439da71e027cafe5b2788a997cbfc85d193c8.tar.gz
libmicrohttpd-e93439da71e027cafe5b2788a997cbfc85d193c8.zip
Added function for detection of token inside comma-separated string, added tests
Diffstat (limited to 'src/microhttpd/mhd_str.h')
-rw-r--r--src/microhttpd/mhd_str.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/microhttpd/mhd_str.h b/src/microhttpd/mhd_str.h
index 0ee41717..410cc36e 100644
--- a/src/microhttpd/mhd_str.h
+++ b/src/microhttpd/mhd_str.h
@@ -30,11 +30,21 @@
30 30
31#include <stdint.h> 31#include <stdint.h>
32#include <stdlib.h> 32#include <stdlib.h>
33#ifdef HAVE_STDBOOL_H
34#include <stdbool.h>
35#endif /* HAVE_STDBOOL_H */
33 36
34#ifdef MHD_FAVOR_SMALL_CODE 37#ifdef MHD_FAVOR_SMALL_CODE
35#include "mhd_limits.h" 38#include "mhd_limits.h"
36#endif /* MHD_FAVOR_SMALL_CODE */ 39#endif /* MHD_FAVOR_SMALL_CODE */
37 40
41#ifndef MHD_STATICSTR_LEN_
42/**
43 * Determine length of static string / macro strings at compile time.
44 */
45#define MHD_STATICSTR_LEN_(macro) (sizeof(macro)/sizeof(char) - 1)
46#endif /* ! MHD_STATICSTR_LEN_ */
47
38/* 48/*
39 * Block of functions/macros that use US-ASCII charset as required by HTTP 49 * Block of functions/macros that use US-ASCII charset as required by HTTP
40 * standards. Not affected by current locale settings. 50 * standards. Not affected by current locale settings.
@@ -71,6 +81,38 @@ MHD_str_equal_caseless_n_ (const char * const str1,
71 const char * const str2, 81 const char * const str2,
72 size_t maxlen); 82 size_t maxlen);
73 83
84
85/**
86 * Check whether @a str has case-insensitive @a token.
87 * Token could be surrounded by spaces and tabs and delimited by comma.
88 * Match succeed if substring between start, end of string or comma
89 * contains only case-insensitive token and optional spaces and tabs.
90 * @warning token must not contain null-charters except optional
91 * terminating null-character.
92 * @param str the string to check
93 * @param token the token to find
94 * @param token_len length of token, not including optional terminating
95 * null-character.
96 * @return non-zero if two strings are equal, zero otherwise.
97 */
98bool
99MHD_str_has_token_caseless_ (const char * str,
100 const char * const token,
101 size_t token_len);
102
103/**
104 * Check whether @a str has case-insensitive static @a tkn.
105 * Token could be surrounded by spaces and tabs and delimited by comma.
106 * Match succeed if substring between start, end of string or comma
107 * contains only case-insensitive token and optional spaces and tabs.
108 * @warning tkn must be static string
109 * @param str the string to check
110 * @param tkn the static string of token to find
111 * @return non-zero if two strings are equal, zero otherwise.
112 */
113#define MHD_str_has_s_token_caseless_(str,tkn) \
114 MHD_str_has_token_caseless_((str),(tkn),MHD_STATICSTR_LEN_(tkn))
115
74#ifndef MHD_FAVOR_SMALL_CODE 116#ifndef MHD_FAVOR_SMALL_CODE
75/* Use individual function for each case to improve speed */ 117/* Use individual function for each case to improve speed */
76 118