diff options
author | Christian Grothoff <christian@grothoff.org> | 2008-09-11 02:56:50 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2008-09-11 02:56:50 +0000 |
commit | d6ca58fa60e8008c927bae149e5a7c043364cd66 (patch) | |
tree | 0bc4864226748a9c2793477ec9e5a0681d0ca19e | |
parent | fac89fd011aadc1a45212361f49aef96c474e37b (diff) | |
download | libmicrohttpd-d6ca58fa60e8008c927bae149e5a7c043364cd66.tar.gz libmicrohttpd-d6ca58fa60e8008c927bae149e5a7c043364cd66.zip |
dead
-rw-r--r-- | src/daemon/https/lgl/Makefile.am | 19 | ||||
-rw-r--r-- | src/daemon/https/lgl/printf-args.h | 152 | ||||
-rw-r--r-- | src/daemon/https/lgl/printf-parse.c | 599 | ||||
-rw-r--r-- | src/daemon/https/lgl/printf-parse.h | 176 | ||||
-rw-r--r-- | src/daemon/https/lgl/realloc.c | 87 |
5 files changed, 9 insertions, 1024 deletions
diff --git a/src/daemon/https/lgl/Makefile.am b/src/daemon/https/lgl/Makefile.am index 654a774f..62c2643d 100644 --- a/src/daemon/https/lgl/Makefile.am +++ b/src/daemon/https/lgl/Makefile.am | |||
@@ -12,19 +12,18 @@ liblgl_la_LDFLAGS = -lgcrypt | |||
12 | # liblgl_la_LIBADD = ./gc-libgcrypt.lo | 12 | # liblgl_la_LIBADD = ./gc-libgcrypt.lo |
13 | 13 | ||
14 | liblgl_la_SOURCES = \ | 14 | liblgl_la_SOURCES = \ |
15 | sha1.c \ | 15 | sha1.c sha1.h \ |
16 | gc-libgcrypt.c \ | 16 | gc-libgcrypt.c \ |
17 | time_r.c \ | 17 | time_r.c \ |
18 | rijndael-api-fst.c \ | 18 | rijndael-api-fst.c \ |
19 | gc-pbkdf2-sha1.c \ | 19 | gc-pbkdf2-sha1.c gc.h \ |
20 | read-file.c \ | 20 | read-file.c read-file.h \ |
21 | rijndael-alg-fst.c \ | 21 | rijndael-alg-fst.c rijndael-alg-fst.h \ |
22 | hmac-md5.c \ | 22 | hmac-md5.c hmac.h \ |
23 | hmac-sha1.c \ | 23 | hmac-sha1.c \ |
24 | realloc.c \ | 24 | memxor.c memxor.h\ |
25 | memxor.c \ | ||
26 | memmem.c \ | 25 | memmem.c \ |
27 | strverscmp.c \ | 26 | strverscmp.c strverscmp.h \ |
28 | md5.c \ | 27 | md5.c md5.h \ |
29 | des.c | 28 | des.c des.h |
30 | 29 | ||
diff --git a/src/daemon/https/lgl/printf-args.h b/src/daemon/https/lgl/printf-args.h deleted file mode 100644 index 5edbdf40..00000000 --- a/src/daemon/https/lgl/printf-args.h +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | /* Decomposed printf argument list. | ||
2 | Copyright (C) 1999, 2002-2003, 2006-2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU Lesser General Public License as published by | ||
6 | the Free Software Foundation; either version 2.1, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
17 | |||
18 | #ifndef _PRINTF_ARGS_H | ||
19 | #define _PRINTF_ARGS_H | ||
20 | |||
21 | /* This file can be parametrized with the following macros: | ||
22 | ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. | ||
23 | PRINTF_FETCHARGS Name of the function to be declared. | ||
24 | STATIC Set to 'static' to declare the function static. */ | ||
25 | |||
26 | /* Default parameters. */ | ||
27 | #ifndef PRINTF_FETCHARGS | ||
28 | # define PRINTF_FETCHARGS printf_fetchargs | ||
29 | #endif | ||
30 | |||
31 | /* Get size_t. */ | ||
32 | #include <stddef.h> | ||
33 | |||
34 | /* Get wchar_t. */ | ||
35 | #if HAVE_WCHAR_T | ||
36 | # include <stddef.h> | ||
37 | #endif | ||
38 | |||
39 | /* Get wint_t. */ | ||
40 | #if HAVE_WINT_T | ||
41 | # include <wchar.h> | ||
42 | #endif | ||
43 | |||
44 | /* Get va_list. */ | ||
45 | #include <stdarg.h> | ||
46 | |||
47 | |||
48 | /* Argument types */ | ||
49 | typedef enum | ||
50 | { | ||
51 | TYPE_NONE, | ||
52 | TYPE_SCHAR, | ||
53 | TYPE_UCHAR, | ||
54 | TYPE_SHORT, | ||
55 | TYPE_USHORT, | ||
56 | TYPE_INT, | ||
57 | TYPE_UINT, | ||
58 | TYPE_LONGINT, | ||
59 | TYPE_ULONGINT, | ||
60 | #if HAVE_LONG_LONG_INT | ||
61 | TYPE_LONGLONGINT, | ||
62 | TYPE_ULONGLONGINT, | ||
63 | #endif | ||
64 | TYPE_DOUBLE, | ||
65 | TYPE_LONGDOUBLE, | ||
66 | TYPE_CHAR, | ||
67 | #if HAVE_WINT_T | ||
68 | TYPE_WIDE_CHAR, | ||
69 | #endif | ||
70 | TYPE_STRING, | ||
71 | #if HAVE_WCHAR_T | ||
72 | TYPE_WIDE_STRING, | ||
73 | #endif | ||
74 | TYPE_POINTER, | ||
75 | TYPE_COUNT_SCHAR_POINTER, | ||
76 | TYPE_COUNT_SHORT_POINTER, | ||
77 | TYPE_COUNT_INT_POINTER, | ||
78 | TYPE_COUNT_LONGINT_POINTER | ||
79 | #if HAVE_LONG_LONG_INT | ||
80 | , TYPE_COUNT_LONGLONGINT_POINTER | ||
81 | #endif | ||
82 | #if ENABLE_UNISTDIO | ||
83 | /* The unistdio extensions. */ | ||
84 | , TYPE_U8_STRING, TYPE_U16_STRING, TYPE_U32_STRING | ||
85 | #endif | ||
86 | } arg_type; | ||
87 | |||
88 | /* Polymorphic argument */ | ||
89 | typedef struct | ||
90 | { | ||
91 | arg_type type; | ||
92 | union | ||
93 | { | ||
94 | signed char a_schar; | ||
95 | unsigned char a_uchar; | ||
96 | short a_short; | ||
97 | unsigned short a_ushort; | ||
98 | int a_int; | ||
99 | unsigned int a_uint; | ||
100 | long int a_longint; | ||
101 | unsigned long int a_ulongint; | ||
102 | #if HAVE_LONG_LONG_INT | ||
103 | long long int a_longlongint; | ||
104 | unsigned long long int a_ulonglongint; | ||
105 | #endif | ||
106 | float a_float; | ||
107 | double a_double; | ||
108 | long double a_longdouble; | ||
109 | int a_char; | ||
110 | #if HAVE_WINT_T | ||
111 | wint_t a_wide_char; | ||
112 | #endif | ||
113 | const char *a_string; | ||
114 | #if HAVE_WCHAR_T | ||
115 | const wchar_t *a_wide_string; | ||
116 | #endif | ||
117 | void *a_pointer; | ||
118 | signed char *a_count_schar_pointer; | ||
119 | short *a_count_short_pointer; | ||
120 | int *a_count_int_pointer; | ||
121 | long int *a_count_longint_pointer; | ||
122 | #if HAVE_LONG_LONG_INT | ||
123 | long long int *a_count_longlongint_pointer; | ||
124 | #endif | ||
125 | #if ENABLE_UNISTDIO | ||
126 | /* The unistdio extensions. */ | ||
127 | const uint8_t *a_u8_string; | ||
128 | const uint16_t *a_u16_string; | ||
129 | const uint32_t *a_u32_string; | ||
130 | #endif | ||
131 | } | ||
132 | a; | ||
133 | } | ||
134 | argument; | ||
135 | |||
136 | typedef struct | ||
137 | { | ||
138 | size_t count; | ||
139 | argument *arg; | ||
140 | } | ||
141 | arguments; | ||
142 | |||
143 | |||
144 | /* Fetch the arguments, putting them into a. */ | ||
145 | #ifdef STATIC | ||
146 | STATIC | ||
147 | #else | ||
148 | extern | ||
149 | #endif | ||
150 | int PRINTF_FETCHARGS (va_list args, arguments * a); | ||
151 | |||
152 | #endif /* _PRINTF_ARGS_H */ | ||
diff --git a/src/daemon/https/lgl/printf-parse.c b/src/daemon/https/lgl/printf-parse.c deleted file mode 100644 index 7eadfbd6..00000000 --- a/src/daemon/https/lgl/printf-parse.c +++ /dev/null | |||
@@ -1,599 +0,0 @@ | |||
1 | /* Formatted output to strings. | ||
2 | Copyright (C) 1999-2000, 2002-2003, 2006-2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU Lesser General Public License as published by | ||
6 | the Free Software Foundation; either version 2.1, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
17 | |||
18 | /* This file can be parametrized with the following macros: | ||
19 | CHAR_T The element type of the format string. | ||
20 | CHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters | ||
21 | in the format string are ASCII. | ||
22 | DIRECTIVE Structure denoting a format directive. | ||
23 | Depends on CHAR_T. | ||
24 | DIRECTIVES Structure denoting the set of format directives of a | ||
25 | format string. Depends on CHAR_T. | ||
26 | PRINTF_PARSE Function that parses a format string. | ||
27 | Depends on CHAR_T. | ||
28 | STATIC Set to 'static' to declare the function static. | ||
29 | ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. */ | ||
30 | |||
31 | #ifndef PRINTF_PARSE | ||
32 | #include "MHD_config.h" | ||
33 | #endif | ||
34 | |||
35 | /* Specification. */ | ||
36 | #ifndef PRINTF_PARSE | ||
37 | # include "printf-parse.h" | ||
38 | #endif | ||
39 | |||
40 | /* Default parameters. */ | ||
41 | #ifndef PRINTF_PARSE | ||
42 | # define PRINTF_PARSE printf_parse | ||
43 | # define CHAR_T char | ||
44 | # define DIRECTIVE char_directive | ||
45 | # define DIRECTIVES char_directives | ||
46 | #endif | ||
47 | |||
48 | /* Get size_t, NULL. */ | ||
49 | #include <stddef.h> | ||
50 | |||
51 | /* Get intmax_t. */ | ||
52 | #if defined IN_LIBINTL || defined IN_LIBASPRINTF | ||
53 | # if HAVE_STDINT_H_WITH_UINTMAX | ||
54 | # include <stdint.h> | ||
55 | # endif | ||
56 | # if HAVE_INTTYPES_H_WITH_UINTMAX | ||
57 | # include <inttypes.h> | ||
58 | # endif | ||
59 | #else | ||
60 | # include <stdint.h> | ||
61 | #endif | ||
62 | |||
63 | /* malloc(), realloc(), free(). */ | ||
64 | #include <stdlib.h> | ||
65 | |||
66 | /* errno. */ | ||
67 | #include <errno.h> | ||
68 | |||
69 | /* Checked size_t computations. */ | ||
70 | #include "xsize.h" | ||
71 | |||
72 | #if CHAR_T_ONLY_ASCII | ||
73 | /* c_isascii(). */ | ||
74 | # include "c-ctype.h" | ||
75 | #endif | ||
76 | |||
77 | #ifdef STATIC | ||
78 | STATIC | ||
79 | #endif | ||
80 | int | ||
81 | PRINTF_PARSE (const CHAR_T * format, DIRECTIVES * d, arguments * a) | ||
82 | { | ||
83 | const CHAR_T *cp = format; /* pointer into format */ | ||
84 | size_t arg_posn = 0; /* number of regular arguments consumed */ | ||
85 | size_t d_allocated; /* allocated elements of d->dir */ | ||
86 | size_t a_allocated; /* allocated elements of a->arg */ | ||
87 | size_t max_width_length = 0; | ||
88 | size_t max_precision_length = 0; | ||
89 | |||
90 | d->count = 0; | ||
91 | d_allocated = 1; | ||
92 | d->dir = (DIRECTIVE *) malloc (d_allocated * sizeof (DIRECTIVE)); | ||
93 | if (d->dir == NULL) | ||
94 | /* Out of memory. */ | ||
95 | goto out_of_memory_1; | ||
96 | |||
97 | a->count = 0; | ||
98 | a_allocated = 0; | ||
99 | a->arg = NULL; | ||
100 | |||
101 | #define REGISTER_ARG(_index_,_type_) \ | ||
102 | { \ | ||
103 | size_t n = (_index_); \ | ||
104 | if (n >= a_allocated) \ | ||
105 | { \ | ||
106 | size_t memory_size; \ | ||
107 | argument *memory; \ | ||
108 | \ | ||
109 | a_allocated = xtimes (a_allocated, 2); \ | ||
110 | if (a_allocated <= n) \ | ||
111 | a_allocated = xsum (n, 1); \ | ||
112 | memory_size = xtimes (a_allocated, sizeof (argument)); \ | ||
113 | if (size_overflow_p (memory_size)) \ | ||
114 | /* Overflow, would lead to out of memory. */ \ | ||
115 | goto out_of_memory; \ | ||
116 | memory = (argument *) (a->arg \ | ||
117 | ? realloc (a->arg, memory_size) \ | ||
118 | : malloc (memory_size)); \ | ||
119 | if (memory == NULL) \ | ||
120 | /* Out of memory. */ \ | ||
121 | goto out_of_memory; \ | ||
122 | a->arg = memory; \ | ||
123 | } \ | ||
124 | while (a->count <= n) \ | ||
125 | a->arg[a->count++].type = TYPE_NONE; \ | ||
126 | if (a->arg[n].type == TYPE_NONE) \ | ||
127 | a->arg[n].type = (_type_); \ | ||
128 | else if (a->arg[n].type != (_type_)) \ | ||
129 | /* Ambiguous type for positional argument. */ \ | ||
130 | goto error; \ | ||
131 | } | ||
132 | |||
133 | while (*cp != '\0') | ||
134 | { | ||
135 | CHAR_T c = *cp++; | ||
136 | if (c == '%') | ||
137 | { | ||
138 | size_t arg_index = ARG_NONE; | ||
139 | DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */ | ||
140 | |||
141 | /* Initialize the next directive. */ | ||
142 | dp->dir_start = cp - 1; | ||
143 | dp->flags = 0; | ||
144 | dp->width_start = NULL; | ||
145 | dp->width_end = NULL; | ||
146 | dp->width_arg_index = ARG_NONE; | ||
147 | dp->precision_start = NULL; | ||
148 | dp->precision_end = NULL; | ||
149 | dp->precision_arg_index = ARG_NONE; | ||
150 | dp->arg_index = ARG_NONE; | ||
151 | |||
152 | /* Test for positional argument. */ | ||
153 | if (*cp >= '0' && *cp <= '9') | ||
154 | { | ||
155 | const CHAR_T *np; | ||
156 | |||
157 | for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
158 | ; | ||
159 | if (*np == '$') | ||
160 | { | ||
161 | size_t n = 0; | ||
162 | |||
163 | for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
164 | n = xsum (xtimes (n, 10), *np - '0'); | ||
165 | if (n == 0) | ||
166 | /* Positional argument 0. */ | ||
167 | goto error; | ||
168 | if (size_overflow_p (n)) | ||
169 | /* n too large, would lead to out of memory later. */ | ||
170 | goto error; | ||
171 | arg_index = n - 1; | ||
172 | cp = np + 1; | ||
173 | } | ||
174 | } | ||
175 | |||
176 | /* Read the flags. */ | ||
177 | for (;;) | ||
178 | { | ||
179 | if (*cp == '\'') | ||
180 | { | ||
181 | dp->flags |= FLAG_GROUP; | ||
182 | cp++; | ||
183 | } | ||
184 | else if (*cp == '-') | ||
185 | { | ||
186 | dp->flags |= FLAG_LEFT; | ||
187 | cp++; | ||
188 | } | ||
189 | else if (*cp == '+') | ||
190 | { | ||
191 | dp->flags |= FLAG_SHOWSIGN; | ||
192 | cp++; | ||
193 | } | ||
194 | else if (*cp == ' ') | ||
195 | { | ||
196 | dp->flags |= FLAG_SPACE; | ||
197 | cp++; | ||
198 | } | ||
199 | else if (*cp == '#') | ||
200 | { | ||
201 | dp->flags |= FLAG_ALT; | ||
202 | cp++; | ||
203 | } | ||
204 | else if (*cp == '0') | ||
205 | { | ||
206 | dp->flags |= FLAG_ZERO; | ||
207 | cp++; | ||
208 | } | ||
209 | else | ||
210 | break; | ||
211 | } | ||
212 | |||
213 | /* Parse the field width. */ | ||
214 | if (*cp == '*') | ||
215 | { | ||
216 | dp->width_start = cp; | ||
217 | cp++; | ||
218 | dp->width_end = cp; | ||
219 | if (max_width_length < 1) | ||
220 | max_width_length = 1; | ||
221 | |||
222 | /* Test for positional argument. */ | ||
223 | if (*cp >= '0' && *cp <= '9') | ||
224 | { | ||
225 | const CHAR_T *np; | ||
226 | |||
227 | for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
228 | ; | ||
229 | if (*np == '$') | ||
230 | { | ||
231 | size_t n = 0; | ||
232 | |||
233 | for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
234 | n = xsum (xtimes (n, 10), *np - '0'); | ||
235 | if (n == 0) | ||
236 | /* Positional argument 0. */ | ||
237 | goto error; | ||
238 | if (size_overflow_p (n)) | ||
239 | /* n too large, would lead to out of memory later. */ | ||
240 | goto error; | ||
241 | dp->width_arg_index = n - 1; | ||
242 | cp = np + 1; | ||
243 | } | ||
244 | } | ||
245 | if (dp->width_arg_index == ARG_NONE) | ||
246 | { | ||
247 | dp->width_arg_index = arg_posn++; | ||
248 | if (dp->width_arg_index == ARG_NONE) | ||
249 | /* arg_posn wrapped around. */ | ||
250 | goto error; | ||
251 | } | ||
252 | REGISTER_ARG (dp->width_arg_index, TYPE_INT); | ||
253 | } | ||
254 | else if (*cp >= '0' && *cp <= '9') | ||
255 | { | ||
256 | size_t width_length; | ||
257 | |||
258 | dp->width_start = cp; | ||
259 | for (; *cp >= '0' && *cp <= '9'; cp++) | ||
260 | ; | ||
261 | dp->width_end = cp; | ||
262 | width_length = dp->width_end - dp->width_start; | ||
263 | if (max_width_length < width_length) | ||
264 | max_width_length = width_length; | ||
265 | } | ||
266 | |||
267 | /* Parse the precision. */ | ||
268 | if (*cp == '.') | ||
269 | { | ||
270 | cp++; | ||
271 | if (*cp == '*') | ||
272 | { | ||
273 | dp->precision_start = cp - 1; | ||
274 | cp++; | ||
275 | dp->precision_end = cp; | ||
276 | if (max_precision_length < 2) | ||
277 | max_precision_length = 2; | ||
278 | |||
279 | /* Test for positional argument. */ | ||
280 | if (*cp >= '0' && *cp <= '9') | ||
281 | { | ||
282 | const CHAR_T *np; | ||
283 | |||
284 | for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
285 | ; | ||
286 | if (*np == '$') | ||
287 | { | ||
288 | size_t n = 0; | ||
289 | |||
290 | for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
291 | n = xsum (xtimes (n, 10), *np - '0'); | ||
292 | if (n == 0) | ||
293 | /* Positional argument 0. */ | ||
294 | goto error; | ||
295 | if (size_overflow_p (n)) | ||
296 | /* n too large, would lead to out of memory | ||
297 | later. */ | ||
298 | goto error; | ||
299 | dp->precision_arg_index = n - 1; | ||
300 | cp = np + 1; | ||
301 | } | ||
302 | } | ||
303 | if (dp->precision_arg_index == ARG_NONE) | ||
304 | { | ||
305 | dp->precision_arg_index = arg_posn++; | ||
306 | if (dp->precision_arg_index == ARG_NONE) | ||
307 | /* arg_posn wrapped around. */ | ||
308 | goto error; | ||
309 | } | ||
310 | REGISTER_ARG (dp->precision_arg_index, TYPE_INT); | ||
311 | } | ||
312 | else | ||
313 | { | ||
314 | size_t precision_length; | ||
315 | |||
316 | dp->precision_start = cp - 1; | ||
317 | for (; *cp >= '0' && *cp <= '9'; cp++) | ||
318 | ; | ||
319 | dp->precision_end = cp; | ||
320 | precision_length = dp->precision_end - dp->precision_start; | ||
321 | if (max_precision_length < precision_length) | ||
322 | max_precision_length = precision_length; | ||
323 | } | ||
324 | } | ||
325 | |||
326 | { | ||
327 | arg_type type; | ||
328 | |||
329 | /* Parse argument type/size specifiers. */ | ||
330 | { | ||
331 | int flags = 0; | ||
332 | |||
333 | for (;;) | ||
334 | { | ||
335 | if (*cp == 'h') | ||
336 | { | ||
337 | flags |= (1 << (flags & 1)); | ||
338 | cp++; | ||
339 | } | ||
340 | else if (*cp == 'L') | ||
341 | { | ||
342 | flags |= 4; | ||
343 | cp++; | ||
344 | } | ||
345 | else if (*cp == 'l') | ||
346 | { | ||
347 | flags += 8; | ||
348 | cp++; | ||
349 | } | ||
350 | else if (*cp == 'j') | ||
351 | { | ||
352 | if (sizeof (intmax_t) > sizeof (long)) | ||
353 | { | ||
354 | /* intmax_t = long long */ | ||
355 | flags += 16; | ||
356 | } | ||
357 | else if (sizeof (intmax_t) > sizeof (int)) | ||
358 | { | ||
359 | /* intmax_t = long */ | ||
360 | flags += 8; | ||
361 | } | ||
362 | cp++; | ||
363 | } | ||
364 | else if (*cp == 'z' || *cp == 'Z') | ||
365 | { | ||
366 | /* 'z' is standardized in ISO C 99, but glibc uses 'Z' | ||
367 | because the warning facility in gcc-2.95.2 understands | ||
368 | only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ | ||
369 | if (sizeof (size_t) > sizeof (long)) | ||
370 | { | ||
371 | /* size_t = long long */ | ||
372 | flags += 16; | ||
373 | } | ||
374 | else if (sizeof (size_t) > sizeof (int)) | ||
375 | { | ||
376 | /* size_t = long */ | ||
377 | flags += 8; | ||
378 | } | ||
379 | cp++; | ||
380 | } | ||
381 | else if (*cp == 't') | ||
382 | { | ||
383 | if (sizeof (ptrdiff_t) > sizeof (long)) | ||
384 | { | ||
385 | /* ptrdiff_t = long long */ | ||
386 | flags += 16; | ||
387 | } | ||
388 | else if (sizeof (ptrdiff_t) > sizeof (int)) | ||
389 | { | ||
390 | /* ptrdiff_t = long */ | ||
391 | flags += 8; | ||
392 | } | ||
393 | cp++; | ||
394 | } | ||
395 | else | ||
396 | break; | ||
397 | } | ||
398 | |||
399 | /* Read the conversion character. */ | ||
400 | c = *cp++; | ||
401 | switch (c) | ||
402 | { | ||
403 | case 'd': | ||
404 | case 'i': | ||
405 | #if HAVE_LONG_LONG_INT | ||
406 | /* If 'long long' exists and is larger than 'long': */ | ||
407 | if (flags >= 16 || (flags & 4)) | ||
408 | type = TYPE_LONGLONGINT; | ||
409 | else | ||
410 | #endif | ||
411 | /* If 'long long' exists and is the same as 'long', we parse | ||
412 | "lld" into TYPE_LONGINT. */ | ||
413 | if (flags >= 8) | ||
414 | type = TYPE_LONGINT; | ||
415 | else if (flags & 2) | ||
416 | type = TYPE_SCHAR; | ||
417 | else if (flags & 1) | ||
418 | type = TYPE_SHORT; | ||
419 | else | ||
420 | type = TYPE_INT; | ||
421 | break; | ||
422 | case 'o': | ||
423 | case 'u': | ||
424 | case 'x': | ||
425 | case 'X': | ||
426 | #if HAVE_LONG_LONG_INT | ||
427 | /* If 'long long' exists and is larger than 'long': */ | ||
428 | if (flags >= 16 || (flags & 4)) | ||
429 | type = TYPE_ULONGLONGINT; | ||
430 | else | ||
431 | #endif | ||
432 | /* If 'unsigned long long' exists and is the same as | ||
433 | 'unsigned long', we parse "llu" into TYPE_ULONGINT. */ | ||
434 | if (flags >= 8) | ||
435 | type = TYPE_ULONGINT; | ||
436 | else if (flags & 2) | ||
437 | type = TYPE_UCHAR; | ||
438 | else if (flags & 1) | ||
439 | type = TYPE_USHORT; | ||
440 | else | ||
441 | type = TYPE_UINT; | ||
442 | break; | ||
443 | case 'f': | ||
444 | case 'F': | ||
445 | case 'e': | ||
446 | case 'E': | ||
447 | case 'g': | ||
448 | case 'G': | ||
449 | case 'a': | ||
450 | case 'A': | ||
451 | if (flags >= 16 || (flags & 4)) | ||
452 | type = TYPE_LONGDOUBLE; | ||
453 | else | ||
454 | type = TYPE_DOUBLE; | ||
455 | break; | ||
456 | case 'c': | ||
457 | if (flags >= 8) | ||
458 | #if HAVE_WINT_T | ||
459 | type = TYPE_WIDE_CHAR; | ||
460 | #else | ||
461 | goto error; | ||
462 | #endif | ||
463 | else | ||
464 | type = TYPE_CHAR; | ||
465 | break; | ||
466 | #if HAVE_WINT_T | ||
467 | case 'C': | ||
468 | type = TYPE_WIDE_CHAR; | ||
469 | c = 'c'; | ||
470 | break; | ||
471 | #endif | ||
472 | case 's': | ||
473 | if (flags >= 8) | ||
474 | #if HAVE_WCHAR_T | ||
475 | type = TYPE_WIDE_STRING; | ||
476 | #else | ||
477 | goto error; | ||
478 | #endif | ||
479 | else | ||
480 | type = TYPE_STRING; | ||
481 | break; | ||
482 | #if HAVE_WCHAR_T | ||
483 | case 'S': | ||
484 | type = TYPE_WIDE_STRING; | ||
485 | c = 's'; | ||
486 | break; | ||
487 | #endif | ||
488 | case 'p': | ||
489 | type = TYPE_POINTER; | ||
490 | break; | ||
491 | case 'n': | ||
492 | #if HAVE_LONG_LONG_INT | ||
493 | /* If 'long long' exists and is larger than 'long': */ | ||
494 | if (flags >= 16 || (flags & 4)) | ||
495 | type = TYPE_COUNT_LONGLONGINT_POINTER; | ||
496 | else | ||
497 | #endif | ||
498 | /* If 'long long' exists and is the same as 'long', we parse | ||
499 | "lln" into TYPE_COUNT_LONGINT_POINTER. */ | ||
500 | if (flags >= 8) | ||
501 | type = TYPE_COUNT_LONGINT_POINTER; | ||
502 | else if (flags & 2) | ||
503 | type = TYPE_COUNT_SCHAR_POINTER; | ||
504 | else if (flags & 1) | ||
505 | type = TYPE_COUNT_SHORT_POINTER; | ||
506 | else | ||
507 | type = TYPE_COUNT_INT_POINTER; | ||
508 | break; | ||
509 | #if ENABLE_UNISTDIO | ||
510 | /* The unistdio extensions. */ | ||
511 | case 'U': | ||
512 | if (flags >= 16) | ||
513 | type = TYPE_U32_STRING; | ||
514 | else if (flags >= 8) | ||
515 | type = TYPE_U16_STRING; | ||
516 | else | ||
517 | type = TYPE_U8_STRING; | ||
518 | break; | ||
519 | #endif | ||
520 | case '%': | ||
521 | type = TYPE_NONE; | ||
522 | break; | ||
523 | default: | ||
524 | /* Unknown conversion character. */ | ||
525 | goto error; | ||
526 | } | ||
527 | } | ||
528 | |||
529 | if (type != TYPE_NONE) | ||
530 | { | ||
531 | dp->arg_index = arg_index; | ||
532 | if (dp->arg_index == ARG_NONE) | ||
533 | { | ||
534 | dp->arg_index = arg_posn++; | ||
535 | if (dp->arg_index == ARG_NONE) | ||
536 | /* arg_posn wrapped around. */ | ||
537 | goto error; | ||
538 | } | ||
539 | REGISTER_ARG (dp->arg_index, type); | ||
540 | } | ||
541 | dp->conversion = c; | ||
542 | dp->dir_end = cp; | ||
543 | } | ||
544 | |||
545 | d->count++; | ||
546 | if (d->count >= d_allocated) | ||
547 | { | ||
548 | size_t memory_size; | ||
549 | DIRECTIVE *memory; | ||
550 | |||
551 | d_allocated = xtimes (d_allocated, 2); | ||
552 | memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); | ||
553 | if (size_overflow_p (memory_size)) | ||
554 | /* Overflow, would lead to out of memory. */ | ||
555 | goto out_of_memory; | ||
556 | memory = (DIRECTIVE *) realloc (d->dir, memory_size); | ||
557 | if (memory == NULL) | ||
558 | /* Out of memory. */ | ||
559 | goto out_of_memory; | ||
560 | d->dir = memory; | ||
561 | } | ||
562 | } | ||
563 | #if CHAR_T_ONLY_ASCII | ||
564 | else if (!c_isascii (c)) | ||
565 | { | ||
566 | /* Non-ASCII character. Not supported. */ | ||
567 | goto error; | ||
568 | } | ||
569 | #endif | ||
570 | } | ||
571 | d->dir[d->count].dir_start = cp; | ||
572 | |||
573 | d->max_width_length = max_width_length; | ||
574 | d->max_precision_length = max_precision_length; | ||
575 | return 0; | ||
576 | |||
577 | error: | ||
578 | if (a->arg) | ||
579 | free (a->arg); | ||
580 | if (d->dir) | ||
581 | free (d->dir); | ||
582 | errno = EINVAL; | ||
583 | return -1; | ||
584 | |||
585 | out_of_memory: | ||
586 | if (a->arg) | ||
587 | free (a->arg); | ||
588 | if (d->dir) | ||
589 | free (d->dir); | ||
590 | out_of_memory_1: | ||
591 | errno = ENOMEM; | ||
592 | return -1; | ||
593 | } | ||
594 | |||
595 | #undef PRINTF_PARSE | ||
596 | #undef DIRECTIVES | ||
597 | #undef DIRECTIVE | ||
598 | #undef CHAR_T_ONLY_ASCII | ||
599 | #undef CHAR_T | ||
diff --git a/src/daemon/https/lgl/printf-parse.h b/src/daemon/https/lgl/printf-parse.h deleted file mode 100644 index 2493d481..00000000 --- a/src/daemon/https/lgl/printf-parse.h +++ /dev/null | |||
@@ -1,176 +0,0 @@ | |||
1 | /* Parse printf format string. | ||
2 | Copyright (C) 1999, 2002-2003, 2005, 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU Lesser General Public License as published by | ||
6 | the Free Software Foundation; either version 2.1, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
17 | |||
18 | #ifndef _PRINTF_PARSE_H | ||
19 | #define _PRINTF_PARSE_H | ||
20 | |||
21 | /* This file can be parametrized with the following macros: | ||
22 | ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. | ||
23 | STATIC Set to 'static' to declare the function static. */ | ||
24 | |||
25 | #include "printf-args.h" | ||
26 | |||
27 | /* Flags */ | ||
28 | #define FLAG_GROUP 1 /* ' flag */ | ||
29 | #define FLAG_LEFT 2 /* - flag */ | ||
30 | #define FLAG_SHOWSIGN 4 /* + flag */ | ||
31 | #define FLAG_SPACE 8 /* space flag */ | ||
32 | #define FLAG_ALT 16 /* # flag */ | ||
33 | #define FLAG_ZERO 32 | ||
34 | |||
35 | /* arg_index value indicating that no argument is consumed. */ | ||
36 | #define ARG_NONE (~(size_t)0) | ||
37 | |||
38 | /* xxx_directive: A parsed directive. | ||
39 | xxx_directives: A parsed format string. */ | ||
40 | |||
41 | /* A parsed directive. */ | ||
42 | typedef struct | ||
43 | { | ||
44 | const char *dir_start; | ||
45 | const char *dir_end; | ||
46 | int flags; | ||
47 | const char *width_start; | ||
48 | const char *width_end; | ||
49 | size_t width_arg_index; | ||
50 | const char *precision_start; | ||
51 | const char *precision_end; | ||
52 | size_t precision_arg_index; | ||
53 | char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ | ||
54 | size_t arg_index; | ||
55 | } | ||
56 | char_directive; | ||
57 | |||
58 | /* A parsed format string. */ | ||
59 | typedef struct | ||
60 | { | ||
61 | size_t count; | ||
62 | char_directive *dir; | ||
63 | size_t max_width_length; | ||
64 | size_t max_precision_length; | ||
65 | } | ||
66 | char_directives; | ||
67 | |||
68 | #if ENABLE_UNISTDIO | ||
69 | |||
70 | /* A parsed directive. */ | ||
71 | typedef struct | ||
72 | { | ||
73 | const uint8_t *dir_start; | ||
74 | const uint8_t *dir_end; | ||
75 | int flags; | ||
76 | const uint8_t *width_start; | ||
77 | const uint8_t *width_end; | ||
78 | size_t width_arg_index; | ||
79 | const uint8_t *precision_start; | ||
80 | const uint8_t *precision_end; | ||
81 | size_t precision_arg_index; | ||
82 | uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ | ||
83 | size_t arg_index; | ||
84 | } | ||
85 | u8_directive; | ||
86 | |||
87 | /* A parsed format string. */ | ||
88 | typedef struct | ||
89 | { | ||
90 | size_t count; | ||
91 | u8_directive *dir; | ||
92 | size_t max_width_length; | ||
93 | size_t max_precision_length; | ||
94 | } | ||
95 | u8_directives; | ||
96 | |||
97 | /* A parsed directive. */ | ||
98 | typedef struct | ||
99 | { | ||
100 | const uint16_t *dir_start; | ||
101 | const uint16_t *dir_end; | ||
102 | int flags; | ||
103 | const uint16_t *width_start; | ||
104 | const uint16_t *width_end; | ||
105 | size_t width_arg_index; | ||
106 | const uint16_t *precision_start; | ||
107 | const uint16_t *precision_end; | ||
108 | size_t precision_arg_index; | ||
109 | uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ | ||
110 | size_t arg_index; | ||
111 | } | ||
112 | u16_directive; | ||
113 | |||
114 | /* A parsed format string. */ | ||
115 | typedef struct | ||
116 | { | ||
117 | size_t count; | ||
118 | u16_directive *dir; | ||
119 | size_t max_width_length; | ||
120 | size_t max_precision_length; | ||
121 | } | ||
122 | u16_directives; | ||
123 | |||
124 | /* A parsed directive. */ | ||
125 | typedef struct | ||
126 | { | ||
127 | const uint32_t *dir_start; | ||
128 | const uint32_t *dir_end; | ||
129 | int flags; | ||
130 | const uint32_t *width_start; | ||
131 | const uint32_t *width_end; | ||
132 | size_t width_arg_index; | ||
133 | const uint32_t *precision_start; | ||
134 | const uint32_t *precision_end; | ||
135 | size_t precision_arg_index; | ||
136 | uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ | ||
137 | size_t arg_index; | ||
138 | } | ||
139 | u32_directive; | ||
140 | |||
141 | /* A parsed format string. */ | ||
142 | typedef struct | ||
143 | { | ||
144 | size_t count; | ||
145 | u32_directive *dir; | ||
146 | size_t max_width_length; | ||
147 | size_t max_precision_length; | ||
148 | } | ||
149 | u32_directives; | ||
150 | |||
151 | #endif | ||
152 | |||
153 | |||
154 | /* Parses the format string. Fills in the number N of directives, and fills | ||
155 | in directives[0], ..., directives[N-1], and sets directives[N].dir_start | ||
156 | to the end of the format string. Also fills in the arg_type fields of the | ||
157 | arguments and the needed count of arguments. */ | ||
158 | #if ENABLE_UNISTDIO | ||
159 | extern int | ||
160 | ulc_printf_parse (const char *format, char_directives * d, arguments * a); | ||
161 | extern int | ||
162 | u8_printf_parse (const uint8_t * format, u8_directives * d, arguments * a); | ||
163 | extern int | ||
164 | u16_printf_parse (const uint16_t * format, u16_directives * d, arguments * a); | ||
165 | extern int | ||
166 | u32_printf_parse (const uint32_t * format, u32_directives * d, arguments * a); | ||
167 | #else | ||
168 | # ifdef STATIC | ||
169 | STATIC | ||
170 | # else | ||
171 | extern | ||
172 | # endif | ||
173 | int printf_parse (const char *format, char_directives * d, arguments * a); | ||
174 | #endif | ||
175 | |||
176 | #endif /* _PRINTF_PARSE_H */ | ||
diff --git a/src/daemon/https/lgl/realloc.c b/src/daemon/https/lgl/realloc.c deleted file mode 100644 index c4103a8d..00000000 --- a/src/daemon/https/lgl/realloc.c +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | /* realloc() function that is glibc compatible. | ||
2 | |||
3 | Copyright (C) 1997, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU Lesser General Public License as published by | ||
7 | the Free Software Foundation; either version 2.1 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program 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 | ||
13 | GNU Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | /* written by Jim Meyering and Bruno Haible */ | ||
19 | |||
20 | #include "MHD_config.h" | ||
21 | |||
22 | /* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */ | ||
23 | #ifdef realloc | ||
24 | # define NEED_REALLOC_GNU 1 | ||
25 | #endif | ||
26 | |||
27 | /* Infer the properties of the system's malloc function. | ||
28 | Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */ | ||
29 | #if GNULIB_MALLOC_GNU && !defined malloc | ||
30 | # define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1 | ||
31 | #endif | ||
32 | |||
33 | /* Below we want to call the system's malloc and realloc. | ||
34 | Undefine the symbols here so that including <stdlib.h> provides a | ||
35 | declaration of malloc(), not of rpl_malloc(), and likewise for realloc. */ | ||
36 | #undef malloc | ||
37 | #undef realloc | ||
38 | |||
39 | /* Specification. */ | ||
40 | #include <stdlib.h> | ||
41 | |||
42 | #include <errno.h> | ||
43 | |||
44 | /* Below we want to call the system's malloc and realloc. | ||
45 | Undefine the symbols, if they were defined by gnulib's <stdlib.h> | ||
46 | replacement. */ | ||
47 | #undef malloc | ||
48 | #undef realloc | ||
49 | |||
50 | /* Change the size of an allocated block of memory P to N bytes, | ||
51 | with error checking. If N is zero, change it to 1. If P is NULL, | ||
52 | use malloc. */ | ||
53 | |||
54 | void * | ||
55 | rpl_realloc (void *p, size_t n) | ||
56 | { | ||
57 | void *result; | ||
58 | |||
59 | #if NEED_REALLOC_GNU | ||
60 | if (n == 0) | ||
61 | { | ||
62 | n = 1; | ||
63 | |||
64 | /* In theory realloc might fail, so don't rely on it to free. */ | ||
65 | free (p); | ||
66 | p = NULL; | ||
67 | } | ||
68 | #endif | ||
69 | |||
70 | if (p == NULL) | ||
71 | { | ||
72 | #if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE | ||
73 | if (n == 0) | ||
74 | n = 1; | ||
75 | #endif | ||
76 | result = malloc (n); | ||
77 | } | ||
78 | else | ||
79 | result = realloc (p, n); | ||
80 | |||
81 | #if !HAVE_REALLOC_POSIX | ||
82 | if (result == NULL) | ||
83 | errno = ENOMEM; | ||
84 | #endif | ||
85 | |||
86 | return result; | ||
87 | } | ||