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_http.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_http.c')
-rw-r--r-- | plugins/check_http.c | 45 |
1 files changed, 1 insertions, 44 deletions
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"; | |||
48 | #include "common.h" | 48 | #include "common.h" |
49 | #include "netutils.h" | 49 | #include "netutils.h" |
50 | #include "utils.h" | 50 | #include "utils.h" |
51 | #include "base64.h" | ||
51 | 52 | ||
52 | #define INPUT_DELIMITER ";" | 53 | #define INPUT_DELIMITER ";" |
53 | 54 | ||
@@ -125,7 +126,6 @@ char *http_content_type; | |||
125 | char buffer[MAX_INPUT_BUFFER]; | 126 | char buffer[MAX_INPUT_BUFFER]; |
126 | 127 | ||
127 | int process_arguments (int, char **); | 128 | int process_arguments (int, char **); |
128 | static char *base64 (const char *bin, size_t len); | ||
129 | int check_http (void); | 129 | int check_http (void); |
130 | void redir (char *pos, char *status_line); | 130 | void redir (char *pos, char *status_line); |
131 | int server_type_check(const char *type); | 131 | int server_type_check(const char *type); |
@@ -455,49 +455,6 @@ process_arguments (int argc, char **argv) | |||
455 | 455 | ||
456 | 456 | ||
457 | 457 | ||
458 | /* written by lauri alanko */ | ||
459 | static char * | ||
460 | base64 (const char *bin, size_t len) | ||
461 | { | ||
462 | |||
463 | char *buf = (char *) malloc ((len + 2) / 3 * 4 + 1); | ||
464 | size_t i = 0, j = 0; | ||
465 | |||
466 | char BASE64_END = '='; | ||
467 | char base64_table[64]; | ||
468 | strncpy (base64_table, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 64); | ||
469 | |||
470 | while (j < len - 2) { | ||
471 | buf[i++] = base64_table[bin[j] >> 2]; | ||
472 | buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)]; | ||
473 | buf[i++] = base64_table[((bin[j + 1] & 15) << 2) | (bin[j + 2] >> 6)]; | ||
474 | buf[i++] = base64_table[bin[j + 2] & 63]; | ||
475 | j += 3; | ||
476 | } | ||
477 | |||
478 | switch (len - j) { | ||
479 | case 1: | ||
480 | buf[i++] = base64_table[bin[j] >> 2]; | ||
481 | buf[i++] = base64_table[(bin[j] & 3) << 4]; | ||
482 | buf[i++] = BASE64_END; | ||
483 | buf[i++] = BASE64_END; | ||
484 | break; | ||
485 | case 2: | ||
486 | buf[i++] = base64_table[bin[j] >> 2]; | ||
487 | buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)]; | ||
488 | buf[i++] = base64_table[(bin[j + 1] & 15) << 2]; | ||
489 | buf[i++] = BASE64_END; | ||
490 | break; | ||
491 | case 0: | ||
492 | break; | ||
493 | } | ||
494 | |||
495 | buf[i] = '\0'; | ||
496 | return buf; | ||
497 | } | ||
498 | |||
499 | |||
500 | |||
501 | /* Returns 1 if we're done processing the document body; 0 to keep going */ | 458 | /* Returns 1 if we're done processing the document body; 0 to keep going */ |
502 | static int | 459 | static int |
503 | document_headers_done (char *full_page) | 460 | document_headers_done (char *full_page) |