[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 06/15: mhd_str: added macros for simple comparison again
From: |
gnunet |
Subject: |
[libmicrohttpd] 06/15: mhd_str: added macros for simple comparison against static strings |
Date: |
Tue, 19 Jul 2022 16:51:14 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit c80ceb0d0261f271c6b87d62aed433ae37e1f50f
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Jun 22 16:33:47 2022 +0300
mhd_str: added macros for simple comparison against static strings
---
src/microhttpd/mhd_str.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/src/microhttpd/mhd_str.h b/src/microhttpd/mhd_str.h
index 91219cba..dd74e602 100644
--- a/src/microhttpd/mhd_str.h
+++ b/src/microhttpd/mhd_str.h
@@ -143,6 +143,24 @@ MHD_str_equal_caseless_bin_n_ (const char *const str1,
size_t len);
+/**
+ * Check whether string is equal statically allocated another string,
+ * ignoring case of US-ASCII letters and checking not more than @a len bytes.
+ *
+ * If strings have different sizes (lengths) then macro returns boolean false
+ * without checking the content.
+ *
+ * Compares not more first than @a len bytes, including binary zero characters.
+ * Comparison stops at first unmatched byte.
+ * @param a the statically allocated string to compare
+ * @param s the string to compare
+ * @param len number of characters to compare
+ * @return non-zero if @a len bytes are equal, zero otherwise.
+ */
+#define MHD_str_equal_caseless_s_bin_n_(a,s,l) \
+ ((MHD_STATICSTR_LEN_(a) == (l)) \
+ && MHD_str_equal_caseless_bin_n_(a,s,l))
+
/**
* Check whether @a str has case-insensitive @a token.
* Token could be surrounded by spaces and tabs and delimited by comma.
@@ -484,7 +502,7 @@ MHD_uint8_to_str_pad (uint8_t val,
* hexadecimal digits, zero-terminate the result.
* @param bin the pointer to the binary data to convert
* @param size the size in bytes of the binary data to convert
- * @param hex the output buffer, should be at least 2 * @a size + 1
+ * @param[out] hex the output buffer, should be at least 2 * @a size + 1
* @return The number of characters written to the output buffer,
* not including terminating zero.
*/
@@ -630,6 +648,25 @@ MHD_str_equal_quoted_bin_n (const char *quoted,
const char *unquoted,
size_t unquoted_len);
+/**
+ * Check whether the string after "unquoting" equals static string.
+ *
+ * Null-termination for input string is not required, binary zeros compared
+ * like other characters.
+ *
+ * @param q the quoted string to compare, must NOT include leading and
+ * closing DQUOTE chars, does not need to be zero-terminated
+ * @param l the length in chars of the @a q string
+ * @param u the unquoted static string to compare
+ * @return zero if quoted form is broken (no character after the last escaping
+ * backslash), zero if strings are not equal after unquoting of the
+ * first string,
+ * non-zero if two strings are equal after unquoting of the
+ * first string.
+ */
+#define MHD_str_equal_quoted_s_bin_n(q,l,u) \
+ MHD_str_equal_quoted_bin_n(q,l,u,MHD_STATICSTR_LEN_(u))
+
/**
* Check two strings for equality, "unquoting" the first string from quoted
* form as specified by RFC7230#section-3.2.6 and RFC7694#quoted.strings and
@@ -656,6 +693,26 @@ MHD_str_equal_caseless_quoted_bin_n (const char *quoted,
const char *unquoted,
size_t unquoted_len);
+/**
+ * Check whether the string after "unquoting" equals static string, ignoring
+ * case of US-ASCII letters.
+ *
+ * Null-termination for input string is not required, binary zeros compared
+ * like other characters.
+ *
+ * @param q the quoted string to compare, must NOT include leading and
+ * closing DQUOTE chars, does not need to be zero-terminated
+ * @param l the length in chars of the @a q string
+ * @param u the unquoted static string to compare
+ * @return zero if quoted form is broken (no character after the last escaping
+ * backslash), zero if strings are not equal after unquoting of the
+ * first string,
+ * non-zero if two strings are caseless equal after unquoting of the
+ * first string.
+ */
+#define MHD_str_equal_caseless_quoted_s_bin_n(q,l,u) \
+ MHD_str_equal_caseless_quoted_bin_n(q,l,u,MHD_STATICSTR_LEN_(u))
+
/**
* Convert string from quoted to unquoted form as specified by
* RFC7230#section-3.2.6 and RFC7694#quoted.strings.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (d629ada1 -> 76b5b195), gnunet, 2022/07/19
- [libmicrohttpd] 03/15: Use new functions for decode request URLs, gnunet, 2022/07/19
- [libmicrohttpd] 01/15: mhd_str: added functions for percent-decoding, gnunet, 2022/07/19
- [libmicrohttpd] 02/15: Added tests for percent-decoding functions, gnunet, 2022/07/19
- [libmicrohttpd] 05/15: Added tests for hex <-> binary functions, gnunet, 2022/07/19
- [libmicrohttpd] 12/15: microhttpd.h: added special enum for hash types, gnunet, 2022/07/19
- [libmicrohttpd] 04/15: mhd_str: added MHD_hex_to_bin() internal function, gnunet, 2022/07/19
- [libmicrohttpd] 09/15: Digest: check whether all required parameters are present before doing heavy calculations, gnunet, 2022/07/19
- [libmicrohttpd] 06/15: mhd_str: added macros for simple comparison against static strings,
gnunet <=
- [libmicrohttpd] 08/15: Digest: use binary zero to separate get params in digest, gnunet, 2022/07/19
- [libmicrohttpd] 07/15: Added new functions MHD_digest_auth_get_request_info3() and MHD_digest_auth_get_username3(), gnunet, 2022/07/19
- [libmicrohttpd] 15/15: microhttpd.h: formatted some deprecation warnings, gnunet, 2022/07/19
- [libmicrohttpd] 10/15: Digest: moved URI match check to separate function, avoid one memcpy(), gnunet, 2022/07/19
- [libmicrohttpd] 11/15: digest_auth_check: mostly rewritten, simplified, optimised, gnunet, 2022/07/19
- [libmicrohttpd] 13/15: digest: small internal refactoring to clarify used hash type, gnunet, 2022/07/19
- [libmicrohttpd] 14/15: digest_auth_check(): check and report wrong algorithm, gnunet, 2022/07/19