diff options
author | Christian Grothoff <christian@grothoff.org> | 2008-09-11 02:58:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2008-09-11 02:58:18 +0000 |
commit | cf41cfa6ae6ac0f6ecd3336bd5c53ac8154500ea (patch) | |
tree | 7f728cb8765edb979e6d8919981b96d7c18da344 | |
parent | d6ca58fa60e8008c927bae149e5a7c043364cd66 (diff) | |
download | libmicrohttpd-cf41cfa6ae6ac0f6ecd3336bd5c53ac8154500ea.tar.gz libmicrohttpd-cf41cfa6ae6ac0f6ecd3336bd5c53ac8154500ea.zip |
dead
-rw-r--r-- | src/daemon/https/lgl/Makefile.am | 3 | ||||
-rw-r--r-- | src/daemon/https/lgl/float+.h | 148 | ||||
-rw-r--r-- | src/daemon/https/lgl/read-file.c | 136 | ||||
-rw-r--r-- | src/daemon/https/lgl/read-file.h | 34 |
4 files changed, 1 insertions, 320 deletions
diff --git a/src/daemon/https/lgl/Makefile.am b/src/daemon/https/lgl/Makefile.am index 62c2643d..93423d2d 100644 --- a/src/daemon/https/lgl/Makefile.am +++ b/src/daemon/https/lgl/Makefile.am | |||
@@ -15,9 +15,8 @@ liblgl_la_SOURCES = \ | |||
15 | sha1.c sha1.h \ | 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 rijndael-api-fst.h \ |
19 | gc-pbkdf2-sha1.c gc.h \ | 19 | gc-pbkdf2-sha1.c gc.h \ |
20 | read-file.c read-file.h \ | ||
21 | rijndael-alg-fst.c rijndael-alg-fst.h \ | 20 | rijndael-alg-fst.c rijndael-alg-fst.h \ |
22 | hmac-md5.c hmac.h \ | 21 | hmac-md5.c hmac.h \ |
23 | hmac-sha1.c \ | 22 | hmac-sha1.c \ |
diff --git a/src/daemon/https/lgl/float+.h b/src/daemon/https/lgl/float+.h deleted file mode 100644 index f0c0c189..00000000 --- a/src/daemon/https/lgl/float+.h +++ /dev/null | |||
@@ -1,148 +0,0 @@ | |||
1 | /* Supplemental information about the floating-point formats. | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | Written by Bruno Haible <bruno@clisp.org>, 2007. | ||
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, or (at your option) | ||
8 | 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, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | #ifndef _FLOATPLUS_H | ||
20 | #define _FLOATPLUS_H | ||
21 | |||
22 | #include <float.h> | ||
23 | #include <limits.h> | ||
24 | |||
25 | /* Number of bits in the mantissa of a floating-point number, including the | ||
26 | "hidden bit". */ | ||
27 | #if FLT_RADIX == 2 | ||
28 | # define FLT_MANT_BIT FLT_MANT_DIG | ||
29 | # define DBL_MANT_BIT DBL_MANT_DIG | ||
30 | # define LDBL_MANT_BIT LDBL_MANT_DIG | ||
31 | #elif FLT_RADIX == 4 | ||
32 | # define FLT_MANT_BIT (FLT_MANT_DIG * 2) | ||
33 | # define DBL_MANT_BIT (DBL_MANT_DIG * 2) | ||
34 | # define LDBL_MANT_BIT (LDBL_MANT_DIG * 2) | ||
35 | #elif FLT_RADIX == 16 | ||
36 | # define FLT_MANT_BIT (FLT_MANT_DIG * 4) | ||
37 | # define DBL_MANT_BIT (DBL_MANT_DIG * 4) | ||
38 | # define LDBL_MANT_BIT (LDBL_MANT_DIG * 4) | ||
39 | #endif | ||
40 | |||
41 | /* Bit mask that can be used to mask the exponent, as an unsigned number. */ | ||
42 | #define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7) | ||
43 | #define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7) | ||
44 | #define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7) | ||
45 | |||
46 | /* Number of bits used for the exponent of a floating-point number, including | ||
47 | the exponent's sign. */ | ||
48 | #define FLT_EXP_BIT \ | ||
49 | (FLT_EXP_MASK < 0x100 ? 8 : \ | ||
50 | FLT_EXP_MASK < 0x200 ? 9 : \ | ||
51 | FLT_EXP_MASK < 0x400 ? 10 : \ | ||
52 | FLT_EXP_MASK < 0x800 ? 11 : \ | ||
53 | FLT_EXP_MASK < 0x1000 ? 12 : \ | ||
54 | FLT_EXP_MASK < 0x2000 ? 13 : \ | ||
55 | FLT_EXP_MASK < 0x4000 ? 14 : \ | ||
56 | FLT_EXP_MASK < 0x8000 ? 15 : \ | ||
57 | FLT_EXP_MASK < 0x10000 ? 16 : \ | ||
58 | FLT_EXP_MASK < 0x20000 ? 17 : \ | ||
59 | FLT_EXP_MASK < 0x40000 ? 18 : \ | ||
60 | FLT_EXP_MASK < 0x80000 ? 19 : \ | ||
61 | FLT_EXP_MASK < 0x100000 ? 20 : \ | ||
62 | FLT_EXP_MASK < 0x200000 ? 21 : \ | ||
63 | FLT_EXP_MASK < 0x400000 ? 22 : \ | ||
64 | FLT_EXP_MASK < 0x800000 ? 23 : \ | ||
65 | FLT_EXP_MASK < 0x1000000 ? 24 : \ | ||
66 | FLT_EXP_MASK < 0x2000000 ? 25 : \ | ||
67 | FLT_EXP_MASK < 0x4000000 ? 26 : \ | ||
68 | FLT_EXP_MASK < 0x8000000 ? 27 : \ | ||
69 | FLT_EXP_MASK < 0x10000000 ? 28 : \ | ||
70 | FLT_EXP_MASK < 0x20000000 ? 29 : \ | ||
71 | FLT_EXP_MASK < 0x40000000 ? 30 : \ | ||
72 | FLT_EXP_MASK <= 0x7fffffff ? 31 : \ | ||
73 | 32) | ||
74 | #define DBL_EXP_BIT \ | ||
75 | (DBL_EXP_MASK < 0x100 ? 8 : \ | ||
76 | DBL_EXP_MASK < 0x200 ? 9 : \ | ||
77 | DBL_EXP_MASK < 0x400 ? 10 : \ | ||
78 | DBL_EXP_MASK < 0x800 ? 11 : \ | ||
79 | DBL_EXP_MASK < 0x1000 ? 12 : \ | ||
80 | DBL_EXP_MASK < 0x2000 ? 13 : \ | ||
81 | DBL_EXP_MASK < 0x4000 ? 14 : \ | ||
82 | DBL_EXP_MASK < 0x8000 ? 15 : \ | ||
83 | DBL_EXP_MASK < 0x10000 ? 16 : \ | ||
84 | DBL_EXP_MASK < 0x20000 ? 17 : \ | ||
85 | DBL_EXP_MASK < 0x40000 ? 18 : \ | ||
86 | DBL_EXP_MASK < 0x80000 ? 19 : \ | ||
87 | DBL_EXP_MASK < 0x100000 ? 20 : \ | ||
88 | DBL_EXP_MASK < 0x200000 ? 21 : \ | ||
89 | DBL_EXP_MASK < 0x400000 ? 22 : \ | ||
90 | DBL_EXP_MASK < 0x800000 ? 23 : \ | ||
91 | DBL_EXP_MASK < 0x1000000 ? 24 : \ | ||
92 | DBL_EXP_MASK < 0x2000000 ? 25 : \ | ||
93 | DBL_EXP_MASK < 0x4000000 ? 26 : \ | ||
94 | DBL_EXP_MASK < 0x8000000 ? 27 : \ | ||
95 | DBL_EXP_MASK < 0x10000000 ? 28 : \ | ||
96 | DBL_EXP_MASK < 0x20000000 ? 29 : \ | ||
97 | DBL_EXP_MASK < 0x40000000 ? 30 : \ | ||
98 | DBL_EXP_MASK <= 0x7fffffff ? 31 : \ | ||
99 | 32) | ||
100 | #define LDBL_EXP_BIT \ | ||
101 | (LDBL_EXP_MASK < 0x100 ? 8 : \ | ||
102 | LDBL_EXP_MASK < 0x200 ? 9 : \ | ||
103 | LDBL_EXP_MASK < 0x400 ? 10 : \ | ||
104 | LDBL_EXP_MASK < 0x800 ? 11 : \ | ||
105 | LDBL_EXP_MASK < 0x1000 ? 12 : \ | ||
106 | LDBL_EXP_MASK < 0x2000 ? 13 : \ | ||
107 | LDBL_EXP_MASK < 0x4000 ? 14 : \ | ||
108 | LDBL_EXP_MASK < 0x8000 ? 15 : \ | ||
109 | LDBL_EXP_MASK < 0x10000 ? 16 : \ | ||
110 | LDBL_EXP_MASK < 0x20000 ? 17 : \ | ||
111 | LDBL_EXP_MASK < 0x40000 ? 18 : \ | ||
112 | LDBL_EXP_MASK < 0x80000 ? 19 : \ | ||
113 | LDBL_EXP_MASK < 0x100000 ? 20 : \ | ||
114 | LDBL_EXP_MASK < 0x200000 ? 21 : \ | ||
115 | LDBL_EXP_MASK < 0x400000 ? 22 : \ | ||
116 | LDBL_EXP_MASK < 0x800000 ? 23 : \ | ||
117 | LDBL_EXP_MASK < 0x1000000 ? 24 : \ | ||
118 | LDBL_EXP_MASK < 0x2000000 ? 25 : \ | ||
119 | LDBL_EXP_MASK < 0x4000000 ? 26 : \ | ||
120 | LDBL_EXP_MASK < 0x8000000 ? 27 : \ | ||
121 | LDBL_EXP_MASK < 0x10000000 ? 28 : \ | ||
122 | LDBL_EXP_MASK < 0x20000000 ? 29 : \ | ||
123 | LDBL_EXP_MASK < 0x40000000 ? 30 : \ | ||
124 | LDBL_EXP_MASK <= 0x7fffffff ? 31 : \ | ||
125 | 32) | ||
126 | |||
127 | /* Number of bits used for a floating-point number: the mantissa (not | ||
128 | counting the "hidden bit", since it may or may not be explicit), the | ||
129 | exponent, and the sign. */ | ||
130 | #define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1) | ||
131 | #define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1) | ||
132 | #define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1) | ||
133 | |||
134 | /* Number of bytes used for a floating-point number. | ||
135 | This can be smaller than the 'sizeof'. For example, on i386 systems, | ||
136 | 'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence | ||
137 | LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but | ||
138 | sizeof (long double) = 12 or = 16. */ | ||
139 | #define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) | ||
140 | #define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) | ||
141 | #define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) | ||
142 | |||
143 | /* Verify that SIZEOF_FLT <= sizeof (float) etc. */ | ||
144 | typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1]; | ||
145 | typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1]; | ||
146 | typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1]; | ||
147 | |||
148 | #endif /* _FLOATPLUS_H */ | ||
diff --git a/src/daemon/https/lgl/read-file.c b/src/daemon/https/lgl/read-file.c deleted file mode 100644 index a57bedf5..00000000 --- a/src/daemon/https/lgl/read-file.c +++ /dev/null | |||
@@ -1,136 +0,0 @@ | |||
1 | /* read-file.c -- read file contents into a string | ||
2 | Copyright (C) 2006 Free Software Foundation, Inc. | ||
3 | Written by Simon Josefsson and Bruno Haible. | ||
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, or (at your option) | ||
8 | 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, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | #include "MHD_config.h" | ||
20 | |||
21 | #include "read-file.h" | ||
22 | |||
23 | /* Get realloc, free. */ | ||
24 | #include <stdlib.h> | ||
25 | |||
26 | /* Get errno. */ | ||
27 | #include <errno.h> | ||
28 | |||
29 | /* Read a STREAM and return a newly allocated string with the content, | ||
30 | and set *LENGTH to the length of the string. The string is | ||
31 | zero-terminated, but the terminating zero byte is not counted in | ||
32 | *LENGTH. On errors, *LENGTH is undefined, errno preserves the | ||
33 | values set by system functions (if any), and NULL is returned. */ | ||
34 | char * | ||
35 | fread_file (FILE * stream, size_t * length) | ||
36 | { | ||
37 | char *buf = NULL; | ||
38 | size_t alloc = 0; | ||
39 | size_t size = 0; | ||
40 | int save_errno; | ||
41 | |||
42 | for (;;) | ||
43 | { | ||
44 | size_t count; | ||
45 | size_t requested; | ||
46 | |||
47 | if (size + BUFSIZ + 1 > alloc) | ||
48 | { | ||
49 | char *new_buf; | ||
50 | |||
51 | alloc += alloc / 2; | ||
52 | if (alloc < size + BUFSIZ + 1) | ||
53 | alloc = size + BUFSIZ + 1; | ||
54 | |||
55 | new_buf = realloc (buf, alloc); | ||
56 | if (!new_buf) | ||
57 | { | ||
58 | save_errno = errno; | ||
59 | break; | ||
60 | } | ||
61 | |||
62 | buf = new_buf; | ||
63 | } | ||
64 | |||
65 | requested = alloc - size - 1; | ||
66 | count = fread (buf + size, 1, requested, stream); | ||
67 | size += count; | ||
68 | |||
69 | if (count != requested) | ||
70 | { | ||
71 | save_errno = errno; | ||
72 | if (ferror (stream)) | ||
73 | break; | ||
74 | buf[size] = '\0'; | ||
75 | *length = size; | ||
76 | return buf; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | free (buf); | ||
81 | errno = save_errno; | ||
82 | return NULL; | ||
83 | } | ||
84 | |||
85 | static char * | ||
86 | internal_read_file (const char *filename, size_t * length, const char *mode) | ||
87 | { | ||
88 | FILE *stream = fopen (filename, mode); | ||
89 | char *out; | ||
90 | int save_errno; | ||
91 | |||
92 | if (!stream) | ||
93 | return NULL; | ||
94 | |||
95 | out = fread_file (stream, length); | ||
96 | |||
97 | save_errno = errno; | ||
98 | |||
99 | if (fclose (stream) != 0) | ||
100 | { | ||
101 | if (out) | ||
102 | { | ||
103 | save_errno = errno; | ||
104 | free (out); | ||
105 | } | ||
106 | errno = save_errno; | ||
107 | return NULL; | ||
108 | } | ||
109 | |||
110 | return out; | ||
111 | } | ||
112 | |||
113 | /* Open and read the contents of FILENAME, and return a newly | ||
114 | allocated string with the content, and set *LENGTH to the length of | ||
115 | the string. The string is zero-terminated, but the terminating | ||
116 | zero byte is not counted in *LENGTH. On errors, *LENGTH is | ||
117 | undefined, errno preserves the values set by system functions (if | ||
118 | any), and NULL is returned. */ | ||
119 | char * | ||
120 | read_file (const char *filename, size_t * length) | ||
121 | { | ||
122 | return internal_read_file (filename, length, "r"); | ||
123 | } | ||
124 | |||
125 | /* Open (on non-POSIX systems, in binary mode) and read the contents | ||
126 | of FILENAME, and return a newly allocated string with the content, | ||
127 | and set LENGTH to the length of the string. The string is | ||
128 | zero-terminated, but the terminating zero byte is not counted in | ||
129 | the LENGTH variable. On errors, *LENGTH is undefined, errno | ||
130 | preserves the values set by system functions (if any), and NULL is | ||
131 | returned. */ | ||
132 | char * | ||
133 | read_binary_file (const char *filename, size_t * length) | ||
134 | { | ||
135 | return internal_read_file (filename, length, "rb"); | ||
136 | } | ||
diff --git a/src/daemon/https/lgl/read-file.h b/src/daemon/https/lgl/read-file.h deleted file mode 100644 index 798d841f..00000000 --- a/src/daemon/https/lgl/read-file.h +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | /* read-file.h -- read file contents into a string | ||
2 | Copyright (C) 2006 Free Software Foundation, Inc. | ||
3 | Written by Simon Josefsson. | ||
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, or (at your option) | ||
8 | 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, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | #ifndef READ_FILE_H | ||
20 | #define READ_FILE_H | ||
21 | |||
22 | /* Get size_t. */ | ||
23 | #include <stddef.h> | ||
24 | |||
25 | /* Get FILE. */ | ||
26 | #include <stdio.h> | ||
27 | |||
28 | extern char *fread_file (FILE * stream, size_t * length); | ||
29 | |||
30 | extern char *read_file (const char *filename, size_t * length); | ||
31 | |||
32 | extern char *read_binary_file (const char *filename, size_t * length); | ||
33 | |||
34 | #endif /* READ_FILE_H */ | ||