diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 12:03:58 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 12:03:58 (GMT) |
commit | abbad00edd7f5f3d33ae77a9d5ac338e5bea5fb3 (patch) | |
tree | 0d55fb4d8e5ad7a9376d1bccdea31104cbecacfe /lib/base64.c | |
parent | bd7029a99b0c2974265c6665638ef14a052f42ab (diff) | |
download | monitoring-plugins-abbad00edd7f5f3d33ae77a9d5ac338e5bea5fb3.tar.gz |
Import Gnulib floorf and base64 and removed our old base64 library.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1926 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/base64.c')
-rw-r--r-- | lib/base64.c | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/lib/base64.c b/lib/base64.c deleted file mode 100644 index 1f1fcb8..0000000 --- a/lib/base64.c +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | /**************************************************************************** | ||
2 | * Function to encode in Base64 | ||
3 | * | ||
4 | * Written by Lauri Alanko | ||
5 | * | ||
6 | *****************************************************************************/ | ||
7 | |||
8 | #include "common.h" | ||
9 | #include "base64.h" | ||
10 | |||
11 | char * | ||
12 | base64 (const char *bin, size_t len) | ||
13 | { | ||
14 | |||
15 | char *buf = (char *) malloc ((len + 2) / 3 * 4 + 1); | ||
16 | size_t i = 0, j = 0; | ||
17 | |||
18 | char BASE64_END = '='; | ||
19 | char base64_table[64]; | ||
20 | strncpy (base64_table, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 64); | ||
21 | |||
22 | while (j < len - 2) { | ||
23 | buf[i++] = base64_table[bin[j] >> 2]; | ||
24 | buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)]; | ||
25 | buf[i++] = base64_table[((bin[j + 1] & 15) << 2) | (bin[j + 2] >> 6)]; | ||
26 | buf[i++] = base64_table[bin[j + 2] & 63]; | ||
27 | j += 3; | ||
28 | } | ||
29 | |||
30 | switch (len - j) { | ||
31 | case 1: | ||
32 | buf[i++] = base64_table[bin[j] >> 2]; | ||
33 | buf[i++] = base64_table[(bin[j] & 3) << 4]; | ||
34 | buf[i++] = BASE64_END; | ||
35 | buf[i++] = BASE64_END; | ||
36 | break; | ||
37 | case 2: | ||
38 | buf[i++] = base64_table[bin[j] >> 2]; | ||
39 | buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)]; | ||
40 | buf[i++] = base64_table[(bin[j + 1] & 15) << 2]; | ||
41 | buf[i++] = BASE64_END; | ||
42 | break; | ||
43 | case 0: | ||
44 | break; | ||
45 | } | ||
46 | |||
47 | buf[i] = '\0'; | ||
48 | return buf; | ||
49 | } | ||
50 | |||