diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-11-09 21:17:03 +0000 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-11-09 21:17:03 +0000 |
commit | 7a05ad0166ac11d4206d934825728b56a58d8edd (patch) | |
tree | 771b5f856eaa9e38ed4ef525ecefcf1b72e85949 /plugins/check_smtp.c | |
parent | 29471dda5ae9e750809e7a25b93d6bf6a2913bc2 (diff) | |
download | monitoring-plugins-7a05ad0166ac11d4206d934825728b56a58d8edd.tar.gz |
Moved base64 function to /lib.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1817 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_smtp.c')
-rw-r--r-- | plugins/check_smtp.c | 42 |
1 files changed, 2 insertions, 40 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 79c7cd35..f44e5331 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
@@ -45,6 +45,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
45 | #include "common.h" | 45 | #include "common.h" |
46 | #include "netutils.h" | 46 | #include "netutils.h" |
47 | #include "utils.h" | 47 | #include "utils.h" |
48 | #include "base64.h" | ||
48 | 49 | ||
49 | #ifdef HAVE_SSL | 50 | #ifdef HAVE_SSL |
50 | int check_cert = FALSE; | 51 | int check_cert = FALSE; |
@@ -122,46 +123,6 @@ enum { | |||
122 | UDP_PROTOCOL = 2, | 123 | UDP_PROTOCOL = 2, |
123 | }; | 124 | }; |
124 | 125 | ||
125 | /* written by lauri alanko */ | ||
126 | static char * | ||
127 | base64 (const char *bin, size_t len) | ||
128 | { | ||
129 | |||
130 | char *buf = (char *) malloc ((len + 2) / 3 * 4 + 1); | ||
131 | size_t i = 0, j = 0; | ||
132 | |||
133 | char BASE64_END = '='; | ||
134 | char base64_table[64]; | ||
135 | strncpy (base64_table, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 64); | ||
136 | |||
137 | while (j < len - 2) { | ||
138 | buf[i++] = base64_table[bin[j] >> 2]; | ||
139 | buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)]; | ||
140 | buf[i++] = base64_table[((bin[j + 1] & 15) << 2) | (bin[j + 2] >> 6)]; | ||
141 | buf[i++] = base64_table[bin[j + 2] & 63]; | ||
142 | j += 3; | ||
143 | } | ||
144 | |||
145 | switch (len - j) { | ||
146 | case 1: | ||
147 | buf[i++] = base64_table[bin[j] >> 2]; | ||
148 | buf[i++] = base64_table[(bin[j] & 3) << 4]; | ||
149 | buf[i++] = BASE64_END; | ||
150 | buf[i++] = BASE64_END; | ||
151 | break; | ||
152 | case 2: | ||
153 | buf[i++] = base64_table[bin[j] >> 2]; | ||
154 | buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)]; | ||
155 | buf[i++] = base64_table[(bin[j + 1] & 15) << 2]; | ||
156 | buf[i++] = BASE64_END; | ||
157 | break; | ||
158 | case 0: | ||
159 | break; | ||
160 | } | ||
161 | |||
162 | buf[i] = '\0'; | ||
163 | return buf; | ||
164 | } | ||
165 | 126 | ||
166 | int | 127 | int |
167 | main (int argc, char **argv) | 128 | main (int argc, char **argv) |
@@ -567,6 +528,7 @@ process_arguments (int argc, char **argv) | |||
567 | break; | 528 | break; |
568 | case 'A': | 529 | case 'A': |
569 | authtype = optarg; | 530 | authtype = optarg; |
531 | use_ehlo = TRUE; | ||
570 | break; | 532 | break; |
571 | case 'U': | 533 | case 'U': |
572 | authuser = optarg; | 534 | authuser = optarg; |