[Nagiosplug-checkins] SF.net SVN: nagiosplug: [1817] nagiosplug/trunk
dermoth at users.sourceforge.net
dermoth at users.sourceforge.net
Fri Nov 9 22:17:05 CET 2007
Revision: 1817
http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1817&view=rev
Author: dermoth
Date: 2007-11-09 13:17:03 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
Moved base64 function to /lib.
Modified Paths:
--------------
nagiosplug/trunk/lib/Makefile.am
nagiosplug/trunk/plugins/check_http.c
nagiosplug/trunk/plugins/check_smtp.c
Added Paths:
-----------
nagiosplug/trunk/lib/base64.c
nagiosplug/trunk/lib/base64.h
Modified: nagiosplug/trunk/lib/Makefile.am
===================================================================
--- nagiosplug/trunk/lib/Makefile.am 2007-11-09 18:24:48 UTC (rev 1816)
+++ nagiosplug/trunk/lib/Makefile.am 2007-11-09 21:17:03 UTC (rev 1817)
@@ -5,8 +5,8 @@
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
Added: nagiosplug/trunk/lib/base64.c
===================================================================
--- nagiosplug/trunk/lib/base64.c (rev 0)
+++ nagiosplug/trunk/lib/base64.c 2007-11-09 21:17:03 UTC (rev 1817)
@@ -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;
+}
+
Added: nagiosplug/trunk/lib/base64.h
===================================================================
--- nagiosplug/trunk/lib/base64.h (rev 0)
+++ nagiosplug/trunk/lib/base64.h 2007-11-09 21:17:03 UTC (rev 1817)
@@ -0,0 +1,4 @@
+/* Header file for base64.c */
+
+char *base64 (const char *bin, size_t len);
+
Modified: nagiosplug/trunk/plugins/check_http.c
===================================================================
--- nagiosplug/trunk/plugins/check_http.c 2007-11-09 18:24:48 UTC (rev 1816)
+++ nagiosplug/trunk/plugins/check_http.c 2007-11-09 21:17:03 UTC (rev 1817)
@@ -48,6 +48,7 @@
#include "common.h"
#include "netutils.h"
#include "utils.h"
+#include "base64.h"
#define INPUT_DELIMITER ";"
@@ -125,7 +126,6 @@
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);
@@ -455,49 +455,6 @@
-/* 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)
Modified: nagiosplug/trunk/plugins/check_smtp.c
===================================================================
--- nagiosplug/trunk/plugins/check_smtp.c 2007-11-09 18:24:48 UTC (rev 1816)
+++ nagiosplug/trunk/plugins/check_smtp.c 2007-11-09 21:17:03 UTC (rev 1817)
@@ -45,6 +45,7 @@
#include "common.h"
#include "netutils.h"
#include "utils.h"
+#include "base64.h"
#ifdef HAVE_SSL
int check_cert = FALSE;
@@ -122,47 +123,7 @@
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)
{
@@ -567,6 +528,7 @@
break;
case 'A':
authtype = optarg;
+ use_ehlo = TRUE;
break;
case 'U':
authuser = optarg;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list