From 7a05ad0166ac11d4206d934825728b56a58d8edd Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Fri, 9 Nov 2007 21:17:03 +0000 Subject: Moved base64 function to /lib. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1817 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/check_http.c | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) (limited to 'plugins/check_http.c') diff --git a/plugins/check_http.c b/plugins/check_http.c index 901f6b66..36374233 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -48,6 +48,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; #include "common.h" #include "netutils.h" #include "utils.h" +#include "base64.h" #define INPUT_DELIMITER ";" @@ -125,7 +126,6 @@ char *http_content_type; 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 @@ process_arguments (int argc, char **argv) -/* 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) -- cgit v1.2.3