GNU libmicrohttpd  0.9.29
mhd_str.h
Go to the documentation of this file.
1 /*
2  This file is part of libmicrohttpd
3  Copyright (C) 2015, 2016 Karlson2k (Evgeny Grin)
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
26 #ifndef MHD_STR_H
27 #define MHD_STR_H 1
28 
29 #include "mhd_options.h"
30 
31 #include <stdint.h>
32 #include <stdlib.h>
33 
34 #ifdef MHD_FAVOR_SMALL_CODE
35 #include "mhd_limits.h"
36 #endif /* MHD_FAVOR_SMALL_CODE */
37 
38 /*
39  * Block of functions/macros that use US-ASCII charset as required by HTTP
40  * standards. Not affected by current locale settings.
41  */
42 
43 #ifndef MHD_FAVOR_SMALL_CODE
44 
50 int
51 MHD_str_equal_caseless_ (const char * str1,
52  const char * str2);
53 #else /* MHD_FAVOR_SMALL_CODE */
54 /* Reuse MHD_str_equal_caseless_n_() to reduce size */
55 #define MHD_str_equal_caseless_(s1,s2) MHD_str_equal_caseless_n_((s1),(s2), SIZE_MAX)
56 #endif /* MHD_FAVOR_SMALL_CODE */
57 
58 
69 int
70 MHD_str_equal_caseless_n_ (const char * const str1,
71  const char * const str2,
72  size_t maxlen);
73 
74 #ifndef MHD_FAVOR_SMALL_CODE
75 /* Use individual function for each case to improve speed */
76 
86 size_t
87 MHD_str_to_uint64_ (const char * str,
88  uint64_t * out_val);
89 
102 size_t
103 MHD_str_to_uint64_n_ (const char * str,
104  size_t maxlen,
105  uint64_t * out_val);
106 
107 
117 size_t
118 MHD_strx_to_uint32_ (const char * str,
119  uint32_t * out_val);
120 
121 
134 size_t
135 MHD_strx_to_uint32_n_ (const char * str,
136  size_t maxlen,
137  uint32_t * out_val);
138 
139 
149 size_t
150 MHD_strx_to_uint64_ (const char * str,
151  uint64_t * out_val);
152 
153 
166 size_t
167 MHD_strx_to_uint64_n_ (const char * str,
168  size_t maxlen,
169  uint64_t * out_val);
170 
171 #else /* MHD_FAVOR_SMALL_CODE */
172 /* Use one universal function and macros to reduce size */
173 
190 size_t
191 MHD_str_to_uvalue_n_ (const char * str,
192  size_t maxlen,
193  void * out_val,
194  size_t val_size,
195  uint64_t max_val,
196  int base);
197 
198 #define MHD_str_to_uint64_(s,ov) MHD_str_to_uvalue_n_((s),SIZE_MAX,(ov),\
199  sizeof(uint64_t),UINT64_MAX,10)
200 
201 #define MHD_str_to_uint64_n_(s,ml,ov) MHD_str_to_uvalue_n_((s),(ml),(ov),\
202  sizeof(uint64_t),UINT64_MAX,10)
203 
204 #define MHD_strx_to_sizet_(s,ov) MHD_str_to_uvalue_n_((s),SIZE_MAX,(ov),\
205  sizeof(size_t),SIZE_MAX,16)
206 
207 #define MHD_strx_to_sizet_n_(s,ml,ov) MHD_str_to_uvalue_n_((s),(ml),(ov),\
208  sizeof(size_t),SIZE_MAX,16)
209 
210 #define MHD_strx_to_uint32_(s,ov) MHD_str_to_uvalue_n_((s),SIZE_MAX,(ov),\
211  sizeof(uint32_t),UINT32_MAX,16)
212 
213 #define MHD_strx_to_uint32_n_(s,ml,ov) MHD_str_to_uvalue_n_((s),(ml),(ov),\
214  sizeof(uint32_t),UINT32_MAX,16)
215 
216 #define MHD_strx_to_uint64_(s,ov) MHD_str_to_uvalue_n_((s),SIZE_MAX,(ov),\
217  sizeof(uint64_t),UINT64_MAX,16)
218 
219 #define MHD_strx_to_uint64_n_(s,ml,ov) MHD_str_to_uvalue_n_((s),(ml),(ov),\
220  sizeof(uint64_t),UINT64_MAX,16)
221 
222 #endif /* MHD_FAVOR_SMALL_CODE */
223 
224 #endif /* MHD_STR_H */
additional automatic macros for MHD_config.h
int MHD_str_equal_caseless_(const char *str1, const char *str2)
Definition: mhd_str.c:319
size_t MHD_strx_to_uint64_(const char *str, uint64_t *out_val)
Definition: mhd_str.c:553
int MHD_str_equal_caseless_n_(const char *const str1, const char *const str2, size_t maxlen)
Definition: mhd_str.c:349
size_t MHD_str_to_uint64_n_(const char *str, size_t maxlen, uint64_t *out_val)
Definition: mhd_str.c:424
limits values definitions
size_t MHD_strx_to_uint64_n_(const char *str, size_t maxlen, uint64_t *out_val)
Definition: mhd_str.c:598
size_t MHD_str_to_uint64_(const char *str, uint64_t *out_val)
Definition: mhd_str.c:382
size_t MHD_strx_to_uint32_n_(const char *str, size_t maxlen, uint32_t *out_val)
Definition: mhd_str.c:513
size_t MHD_strx_to_uint32_(const char *str, uint32_t *out_val)
Definition: mhd_str.c:467