diff options
author | Christian Grothoff <christian@grothoff.org> | 2008-08-29 20:03:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2008-08-29 20:03:02 +0000 |
commit | 596aff3843f074b0c7102dd7a52b4e6ffde3ed93 (patch) | |
tree | 5962cdbee49dcf09a6d6bf22ab253aa316e78f31 | |
parent | 2054f21370144b82b95c7efec026a0843fa5385f (diff) | |
download | libmicrohttpd-596aff3843f074b0c7102dd7a52b4e6ffde3ed93.tar.gz libmicrohttpd-596aff3843f074b0c7102dd7a52b4e6ffde3ed93.zip |
removing useless code
-rw-r--r-- | src/daemon/https/lgl/Makefile.am | 9 | ||||
-rw-r--r-- | src/daemon/https/lgl/asprintf.c | 39 | ||||
-rw-r--r-- | src/daemon/https/lgl/memmem.c | 61 | ||||
-rw-r--r-- | src/daemon/https/lgl/memmove.c | 26 | ||||
-rw-r--r-- | src/daemon/https/lgl/vasnprintf.h | 84 | ||||
-rw-r--r-- | src/daemon/https/lgl/vasprintf.c | 56 | ||||
-rw-r--r-- | src/daemon/https/tls/gnutls_str.c | 12 |
7 files changed, 10 insertions, 277 deletions
diff --git a/src/daemon/https/lgl/Makefile.am b/src/daemon/https/lgl/Makefile.am index ff8d1856..f14c7acc 100644 --- a/src/daemon/https/lgl/Makefile.am +++ b/src/daemon/https/lgl/Makefile.am | |||
@@ -12,7 +12,6 @@ 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 | asnprintf.c \ | ||
16 | sha1.c \ | 15 | sha1.c \ |
17 | gc-libgcrypt.c \ | 16 | gc-libgcrypt.c \ |
18 | time_r.c \ | 17 | time_r.c \ |
@@ -23,16 +22,10 @@ rijndael-alg-fst.c \ | |||
23 | hmac-md5.c \ | 22 | hmac-md5.c \ |
24 | hmac-sha1.c \ | 23 | hmac-sha1.c \ |
25 | realloc.c \ | 24 | realloc.c \ |
26 | memmem.c \ | ||
27 | memmove.c \ | ||
28 | memxor.c \ | 25 | memxor.c \ |
29 | printf-args.c \ | 26 | printf-args.c \ |
30 | strverscmp.c \ | 27 | strverscmp.c \ |
31 | snprintf.c \ | ||
32 | asprintf.c \ | ||
33 | vasprintf.c \ | ||
34 | vasnprintf.c \ | ||
35 | md5.c \ | 28 | md5.c \ |
36 | printf-parse.c \ | 29 | printf-parse.c \ |
37 | des.c | 30 | des.c |
38 | \ No newline at end of file | 31 | |
diff --git a/src/daemon/https/lgl/asprintf.c b/src/daemon/https/lgl/asprintf.c deleted file mode 100644 index 04e3c58c..00000000 --- a/src/daemon/https/lgl/asprintf.c +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | /* Formatted output to strings. | ||
2 | Copyright (C) 1999, 2002, 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 | #include "MHD_config.h" | ||
19 | |||
20 | /* Specification. */ | ||
21 | #ifdef IN_LIBASPRINTF | ||
22 | # include "vasprintf.h" | ||
23 | #else | ||
24 | # include <stdio.h> | ||
25 | #endif | ||
26 | |||
27 | #include <stdarg.h> | ||
28 | |||
29 | int | ||
30 | asprintf (char **resultp, const char *format, ...) | ||
31 | { | ||
32 | va_list args; | ||
33 | int result; | ||
34 | |||
35 | va_start (args, format); | ||
36 | result = vasprintf (resultp, format, args); | ||
37 | va_end (args); | ||
38 | return result; | ||
39 | } | ||
diff --git a/src/daemon/https/lgl/memmem.c b/src/daemon/https/lgl/memmem.c deleted file mode 100644 index 9a0e67d2..00000000 --- a/src/daemon/https/lgl/memmem.c +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | /* Copyright (C) 1991,92,93,94,96,97,98,2000,2004,2007 Free Software Foundation, Inc. | ||
2 | This file is part of the GNU C Library. | ||
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 _LIBC | ||
19 | #include "MHD_config.h" | ||
20 | #endif | ||
21 | |||
22 | #include <stddef.h> | ||
23 | #include <string.h> | ||
24 | |||
25 | #ifndef _LIBC | ||
26 | # define __builtin_expect(expr, val) (expr) | ||
27 | #endif | ||
28 | |||
29 | #undef memmem | ||
30 | |||
31 | /* Return the first occurrence of NEEDLE in HAYSTACK. */ | ||
32 | void * | ||
33 | memmem (haystack, haystack_len, needle, needle_len) | ||
34 | const void *haystack; | ||
35 | size_t haystack_len; | ||
36 | const void *needle; | ||
37 | size_t needle_len; | ||
38 | { | ||
39 | const char *begin; | ||
40 | const char *const last_possible = (const char *) haystack + haystack_len | ||
41 | - needle_len; | ||
42 | |||
43 | if (needle_len == 0) | ||
44 | /* The first occurrence of the empty string is deemed to occur at | ||
45 | the beginning of the string. */ | ||
46 | return (void *) haystack; | ||
47 | |||
48 | /* Sanity check, otherwise the loop might search through the whole | ||
49 | memory. */ | ||
50 | if (__builtin_expect (haystack_len < needle_len, 0)) | ||
51 | return NULL; | ||
52 | |||
53 | for (begin = (const char *) haystack; begin <= last_possible; ++begin) | ||
54 | if (begin[0] == ((const char *) needle)[0] | ||
55 | && !memcmp ((const void *) &begin[1], | ||
56 | (const void *) ((const char *) needle + 1), | ||
57 | needle_len - 1)) | ||
58 | return (void *) begin; | ||
59 | |||
60 | return NULL; | ||
61 | } | ||
diff --git a/src/daemon/https/lgl/memmove.c b/src/daemon/https/lgl/memmove.c deleted file mode 100644 index c37d6923..00000000 --- a/src/daemon/https/lgl/memmove.c +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | /* memmove.c -- copy memory. | ||
2 | Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate. | ||
3 | In the public domain. | ||
4 | By David MacKenzie <djm@gnu.ai.mit.edu>. */ | ||
5 | |||
6 | #include "MHD_config.h" | ||
7 | |||
8 | #include <stddef.h> | ||
9 | |||
10 | void * | ||
11 | memmove (void *dest0, void const *source0, size_t length) | ||
12 | { | ||
13 | char *dest = dest0; | ||
14 | char const *source = source0; | ||
15 | if (source < dest) | ||
16 | /* Moving from low mem to hi mem; start at end. */ | ||
17 | for (source += length, dest += length; length; --length) | ||
18 | *--dest = *--source; | ||
19 | else if (source != dest) | ||
20 | { | ||
21 | /* Moving from hi mem to low mem; start at beginning. */ | ||
22 | for (; length; --length) | ||
23 | *dest++ = *source++; | ||
24 | } | ||
25 | return dest0; | ||
26 | } | ||
diff --git a/src/daemon/https/lgl/vasnprintf.h b/src/daemon/https/lgl/vasnprintf.h deleted file mode 100644 index e4c57f5b..00000000 --- a/src/daemon/https/lgl/vasnprintf.h +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* vsprintf with automatic memory allocation. | ||
2 | Copyright (C) 2002-2004, 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 _VASNPRINTF_H | ||
19 | #define _VASNPRINTF_H | ||
20 | |||
21 | /* Get va_list. */ | ||
22 | #include <stdarg.h> | ||
23 | |||
24 | /* Get size_t. */ | ||
25 | #include <stddef.h> | ||
26 | |||
27 | #ifndef __attribute__ | ||
28 | /* This feature is available in gcc versions 2.5 and later. */ | ||
29 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ | ||
30 | # define __attribute__(Spec) /* empty */ | ||
31 | # endif | ||
32 | /* The __-protected variants of `format' and `printf' attributes | ||
33 | are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ | ||
34 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) | ||
35 | # define __format__ format | ||
36 | # define __printf__ printf | ||
37 | # endif | ||
38 | #endif | ||
39 | |||
40 | #ifdef __cplusplus | ||
41 | extern "C" | ||
42 | { | ||
43 | #endif | ||
44 | |||
45 | /* Write formatted output to a string dynamically allocated with malloc(). | ||
46 | You can pass a preallocated buffer for the result in RESULTBUF and its | ||
47 | size in *LENGTHP; otherwise you pass RESULTBUF = NULL. | ||
48 | If successful, return the address of the string (this may be = RESULTBUF | ||
49 | if no dynamic memory allocation was necessary) and set *LENGTHP to the | ||
50 | number of resulting bytes, excluding the trailing NUL. Upon error, set | ||
51 | errno and return NULL. | ||
52 | |||
53 | When dynamic memory allocation occurs, the preallocated buffer is left | ||
54 | alone (with possibly modified contents). This makes it possible to use | ||
55 | a statically allocated or stack-allocated buffer, like this: | ||
56 | |||
57 | char buf[100]; | ||
58 | size_t len = sizeof (buf); | ||
59 | char *output = vasnprintf (buf, &len, format, args); | ||
60 | if (output == NULL) | ||
61 | ... error handling ...; | ||
62 | else | ||
63 | { | ||
64 | ... use the output string ...; | ||
65 | if (output != buf) | ||
66 | free (output); | ||
67 | } | ||
68 | */ | ||
69 | #if REPLACE_VASNPRINTF | ||
70 | # define asnprintf rpl_asnprintf | ||
71 | # define vasnprintf rpl_vasnprintf | ||
72 | #endif | ||
73 | extern char *asnprintf (char *resultbuf, size_t * lengthp, | ||
74 | const char *format, ...) | ||
75 | __attribute__ ((__format__ (__printf__, 3, 4))); | ||
76 | extern char *vasnprintf (char *resultbuf, size_t * lengthp, | ||
77 | const char *format, va_list args) | ||
78 | __attribute__ ((__format__ (__printf__, 3, 0))); | ||
79 | |||
80 | #ifdef __cplusplus | ||
81 | } | ||
82 | #endif | ||
83 | |||
84 | #endif /* _VASNPRINTF_H */ | ||
diff --git a/src/daemon/https/lgl/vasprintf.c b/src/daemon/https/lgl/vasprintf.c deleted file mode 100644 index 9348b5bd..00000000 --- a/src/daemon/https/lgl/vasprintf.c +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /* Formatted output to strings. | ||
2 | Copyright (C) 1999, 2002, 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 | #include "MHD_config.h" | ||
19 | |||
20 | /* Specification. */ | ||
21 | #ifdef IN_LIBASPRINTF | ||
22 | # include "vasprintf.h" | ||
23 | #else | ||
24 | # include <stdio.h> | ||
25 | #endif | ||
26 | |||
27 | #include <errno.h> | ||
28 | #include <limits.h> | ||
29 | #include <stdlib.h> | ||
30 | |||
31 | #include "vasnprintf.h" | ||
32 | |||
33 | /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ | ||
34 | #ifndef EOVERFLOW | ||
35 | # define EOVERFLOW E2BIG | ||
36 | #endif | ||
37 | |||
38 | int | ||
39 | vasprintf (char **resultp, const char *format, va_list args) | ||
40 | { | ||
41 | size_t length; | ||
42 | char *result = vasnprintf (NULL, &length, format, args); | ||
43 | if (result == NULL) | ||
44 | return -1; | ||
45 | |||
46 | if (length > INT_MAX) | ||
47 | { | ||
48 | free (result); | ||
49 | errno = EOVERFLOW; | ||
50 | return -1; | ||
51 | } | ||
52 | |||
53 | *resultp = result; | ||
54 | /* Return the number of resulting bytes, excluding the trailing NUL. */ | ||
55 | return length; | ||
56 | } | ||
diff --git a/src/daemon/https/tls/gnutls_str.c b/src/daemon/https/tls/gnutls_str.c index 22f949d6..d5e95366 100644 --- a/src/daemon/https/tls/gnutls_str.c +++ b/src/daemon/https/tls/gnutls_str.c | |||
@@ -236,12 +236,18 @@ mhd_gtls_string_append_printf (mhd_gtls_string * dest, const char *fmt, ...) | |||
236 | char *str; | 236 | char *str; |
237 | 237 | ||
238 | va_start (args, fmt); | 238 | va_start (args, fmt); |
239 | len = vasprintf (&str, fmt, args); | 239 | len = vsnprintf (NULL, 0, fmt, args); |
240 | va_end (args); | 240 | va_end (args); |
241 | 241 | if (len < 0) | |
242 | if (len < 0 || !str) | 242 | return -1; |
243 | str = malloc(len + 1); | ||
244 | if (! str) | ||
243 | return -1; | 245 | return -1; |
244 | 246 | ||
247 | va_start (args, fmt); | ||
248 | len = vsprintf (str, fmt, args); | ||
249 | va_end (args); | ||
250 | |||
245 | len = mhd_gtls_string_append_str (dest, str); | 251 | len = mhd_gtls_string_append_str (dest, str); |
246 | 252 | ||
247 | free (str); | 253 | free (str); |