summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 29471dd)
raw | patch | inline | side by side (parent: 29471dd)
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Fri, 9 Nov 2007 21:17:03 +0000 (21:17 +0000) | ||
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Fri, 9 Nov 2007 21:17:03 +0000 (21:17 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1817 f882894a-f735-0410-b71e-b25c423dba1c
lib/Makefile.am | patch | blob | history | |
lib/base64.c | [new file with mode: 0644] | patch | blob |
lib/base64.h | [new file with mode: 0644] | patch | blob |
plugins/check_http.c | patch | blob | history | |
plugins/check_smtp.c | patch | blob | history |
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 9dd3a0c2966456bca0d3bf8ebfe878333e15665c..1b309846dfb7b3d9a3ff8f86ce3c4b4aac426591 100644 (file)
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
noinst_LIBRARIES = libnagiosplug.a
-libnagiosplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c
-EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h
+libnagiosplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c base64.c
+EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h base64.h
INCLUDES = -I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
diff --git a/lib/base64.c b/lib/base64.c
--- /dev/null
+++ b/lib/base64.c
@@ -0,0 +1,50 @@
+/****************************************************************************
+* Function to encode in Base64
+*
+* Written by Lauri Alanko
+*
+*****************************************************************************/
+
+#include "common.h"
+#include "base64.h"
+
+char *
+base64 (const char *bin, size_t len)
+{
+
+ char *buf = (char *) malloc ((len + 2) / 3 * 4 + 1);
+ size_t i = 0, j = 0;
+
+ char BASE64_END = '=';
+ char base64_table[64];
+ strncpy (base64_table, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 64);
+
+ while (j < len - 2) {
+ buf[i++] = base64_table[bin[j] >> 2];
+ buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)];
+ buf[i++] = base64_table[((bin[j + 1] & 15) << 2) | (bin[j + 2] >> 6)];
+ buf[i++] = base64_table[bin[j + 2] & 63];
+ j += 3;
+ }
+
+ switch (len - j) {
+ case 1:
+ buf[i++] = base64_table[bin[j] >> 2];
+ buf[i++] = base64_table[(bin[j] & 3) << 4];
+ buf[i++] = BASE64_END;
+ buf[i++] = BASE64_END;
+ break;
+ case 2:
+ buf[i++] = base64_table[bin[j] >> 2];
+ buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)];
+ buf[i++] = base64_table[(bin[j + 1] & 15) << 2];
+ buf[i++] = BASE64_END;
+ break;
+ case 0:
+ break;
+ }
+
+ buf[i] = '\0';
+ return buf;
+}
+
diff --git a/lib/base64.h b/lib/base64.h
--- /dev/null
+++ b/lib/base64.h
@@ -0,0 +1,4 @@
+/* Header file for base64.c */
+
+char *base64 (const char *bin, size_t len);
+
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 901f6b668986b9e521bc6bc5b177abc4d1d8e93b..363742335e0e9c7cc267dd758f7e7b8d3f6dc869 100644 (file)
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
#include "common.h"
#include "netutils.h"
#include "utils.h"
+#include "base64.h"
#define INPUT_DELIMITER ";"
char buffer[MAX_INPUT_BUFFER];
int process_arguments (int, char **);
-static char *base64 (const char *bin, size_t len);
int check_http (void);
void redir (char *pos, char *status_line);
int server_type_check(const char *type);
-/* written by lauri alanko */
-static char *
-base64 (const char *bin, size_t len)
-{
-
- char *buf = (char *) malloc ((len + 2) / 3 * 4 + 1);
- size_t i = 0, j = 0;
-
- char BASE64_END = '=';
- char base64_table[64];
- strncpy (base64_table, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 64);
-
- while (j < len - 2) {
- buf[i++] = base64_table[bin[j] >> 2];
- buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)];
- buf[i++] = base64_table[((bin[j + 1] & 15) << 2) | (bin[j + 2] >> 6)];
- buf[i++] = base64_table[bin[j + 2] & 63];
- j += 3;
- }
-
- switch (len - j) {
- case 1:
- buf[i++] = base64_table[bin[j] >> 2];
- buf[i++] = base64_table[(bin[j] & 3) << 4];
- buf[i++] = BASE64_END;
- buf[i++] = BASE64_END;
- break;
- case 2:
- buf[i++] = base64_table[bin[j] >> 2];
- buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)];
- buf[i++] = base64_table[(bin[j + 1] & 15) << 2];
- buf[i++] = BASE64_END;
- break;
- case 0:
- break;
- }
-
- buf[i] = '\0';
- return buf;
-}
-
-
-
/* Returns 1 if we're done processing the document body; 0 to keep going */
static int
document_headers_done (char *full_page)
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 79c7cd35f004f903b61b5efb18f4cd68d2c954f6..f44e5331d048cc0eafca6465419542d863f57fff 100644 (file)
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
#include "common.h"
#include "netutils.h"
#include "utils.h"
+#include "base64.h"
#ifdef HAVE_SSL
int check_cert = FALSE;
UDP_PROTOCOL = 2,
};
-/* written by lauri alanko */
-static char *
-base64 (const char *bin, size_t len)
-{
-
- char *buf = (char *) malloc ((len + 2) / 3 * 4 + 1);
- size_t i = 0, j = 0;
-
- char BASE64_END = '=';
- char base64_table[64];
- strncpy (base64_table, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 64);
-
- while (j < len - 2) {
- buf[i++] = base64_table[bin[j] >> 2];
- buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)];
- buf[i++] = base64_table[((bin[j + 1] & 15) << 2) | (bin[j + 2] >> 6)];
- buf[i++] = base64_table[bin[j + 2] & 63];
- j += 3;
- }
-
- switch (len - j) {
- case 1:
- buf[i++] = base64_table[bin[j] >> 2];
- buf[i++] = base64_table[(bin[j] & 3) << 4];
- buf[i++] = BASE64_END;
- buf[i++] = BASE64_END;
- break;
- case 2:
- buf[i++] = base64_table[bin[j] >> 2];
- buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)];
- buf[i++] = base64_table[(bin[j + 1] & 15) << 2];
- buf[i++] = BASE64_END;
- break;
- case 0:
- break;
- }
-
- buf[i] = '\0';
- return buf;
-}
int
main (int argc, char **argv)
break;
case 'A':
authtype = optarg;
+ use_ehlo = TRUE;
break;
case 'U':
authuser = optarg;