diff options
Diffstat (limited to 'src/microhttpd')
-rw-r--r-- | src/microhttpd/Makefile.am | 3 | ||||
-rw-r--r-- | src/microhttpd/base64.c | 85 | ||||
-rw-r--r-- | src/microhttpd/base64.h | 26 |
3 files changed, 1 insertions, 113 deletions
diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am index f491f13b..11e4537c 100644 --- a/src/microhttpd/Makefile.am +++ b/src/microhttpd/Makefile.am | |||
@@ -175,8 +175,7 @@ endif | |||
175 | 175 | ||
176 | if ENABLE_BAUTH | 176 | if ENABLE_BAUTH |
177 | libmicrohttpd_la_SOURCES += \ | 177 | libmicrohttpd_la_SOURCES += \ |
178 | basicauth.c basicauth.h \ | 178 | basicauth.c basicauth.h |
179 | base64.c base64.h | ||
180 | endif | 179 | endif |
181 | 180 | ||
182 | if ENABLE_HTTPS | 181 | if ENABLE_HTTPS |
diff --git a/src/microhttpd/base64.c b/src/microhttpd/base64.c deleted file mode 100644 index 3d2dd3f1..00000000 --- a/src/microhttpd/base64.c +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | /* | ||
2 | * This code implements the BASE64 algorithm. | ||
3 | * This code is in the public domain; do with it what you wish. | ||
4 | * | ||
5 | * @file base64.c | ||
6 | * @brief This code implements the BASE64 algorithm | ||
7 | * @author Matthieu Speder | ||
8 | * @author Karlson2k (Evgeny Grin): fixes and improvements | ||
9 | */ | ||
10 | #include "mhd_options.h" | ||
11 | #include <stdio.h> | ||
12 | #ifdef HAVE_STDLIB_H | ||
13 | #include <stdlib.h> | ||
14 | #endif /* HAVE_STDLIB_H */ | ||
15 | #include <string.h> | ||
16 | #ifdef HAVE_UNISTD_H | ||
17 | #include <unistd.h> | ||
18 | #endif | ||
19 | #ifdef HAVE_STDDEF_H | ||
20 | #include <stddef.h> | ||
21 | #endif /* HAVE_STDDEF_H */ | ||
22 | #include "base64.h" | ||
23 | |||
24 | static const char base64_digits[] = | ||
25 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
26 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
27 | 0, 0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, | ||
28 | 0, 0, 0, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, | ||
29 | 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, | ||
30 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, | ||
31 | 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
32 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
33 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
34 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
35 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
36 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; | ||
37 | |||
38 | |||
39 | char * | ||
40 | BASE64Decode (const char *src, | ||
41 | size_t in_len, | ||
42 | size_t *out_len) | ||
43 | { | ||
44 | unsigned char *dest; | ||
45 | char *result; | ||
46 | |||
47 | if (in_len % 4) | ||
48 | { | ||
49 | /* Wrong base64 string length */ | ||
50 | return NULL; | ||
51 | } | ||
52 | dest = (unsigned char *) malloc (in_len / 4 * 3 + 1); | ||
53 | result = (char *) dest; | ||
54 | if (NULL == result) | ||
55 | return NULL; /* out of memory */ | ||
56 | for (; 0 < in_len && 0 != *src; in_len -= 4) | ||
57 | { | ||
58 | char a = base64_digits[(unsigned char) *(src++)]; | ||
59 | char b = base64_digits[(unsigned char) *(src++)]; | ||
60 | char c = base64_digits[(unsigned char) *(src++)]; | ||
61 | char d = base64_digits[(unsigned char) *(src++)]; | ||
62 | if (((char) -1 == a) || (0 == a) || (0 == b) || (0 == c) || (0 == d)) | ||
63 | { | ||
64 | free (result); | ||
65 | return NULL; | ||
66 | } | ||
67 | *(dest++) = (unsigned char) (((unsigned char) a) << 2) | ||
68 | | (unsigned char) ((((unsigned char) b) & 0x30) >> 4); | ||
69 | if (c == (char) -1) | ||
70 | break; | ||
71 | *(dest++) = (unsigned char) ((((unsigned char) b) & 0x0f) << 4) | ||
72 | | (unsigned char) ((((unsigned char) c) & 0x3c) >> 2); | ||
73 | if (d == (char) -1) | ||
74 | break; | ||
75 | *(dest++) = (unsigned char) ((((unsigned char) c) & 0x03) << 6) | ||
76 | | ((unsigned char) d); | ||
77 | } | ||
78 | *dest = 0; | ||
79 | if (NULL != out_len) | ||
80 | *out_len = (size_t) (dest - (unsigned char *) result); | ||
81 | return result; | ||
82 | } | ||
83 | |||
84 | |||
85 | /* end of base64.c */ | ||
diff --git a/src/microhttpd/base64.h b/src/microhttpd/base64.h deleted file mode 100644 index e5f11319..00000000 --- a/src/microhttpd/base64.h +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | /* | ||
2 | * This code implements the BASE64 algorithm. | ||
3 | * This code is in the public domain; do with it what you wish. | ||
4 | * | ||
5 | * @file base64.c | ||
6 | * @brief This code implements the BASE64 algorithm | ||
7 | * @author Matthieu Speder | ||
8 | */ | ||
9 | #ifndef BASE64_H | ||
10 | #define BASE64_H | ||
11 | |||
12 | #include "mhd_options.h" | ||
13 | #ifdef HAVE_STDDEF_H | ||
14 | #include <stddef.h> | ||
15 | #elif defined(HAVE_STDLIB_H) | ||
16 | #include <stdlib.h> | ||
17 | #else | ||
18 | #include <stdio.h> | ||
19 | #endif | ||
20 | |||
21 | char * | ||
22 | BASE64Decode (const char *src, | ||
23 | size_t in_len, | ||
24 | size_t *out_len); | ||
25 | |||
26 | #endif /* !BASE64_H */ | ||