From: Amos Jeffries Date: Thu, 3 Sep 2009 08:21:00 +0000 (+1200) Subject: Fix some build errors X-Git-Tag: SQUID_3_2_0_1~741^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ec85ebda81e7645a60fd0cc947a10754a668c55e;p=thirdparty%2Fsquid.git Fix some build errors --- diff --git a/helpers/url_rewrite/fake/Makefile.am b/helpers/url_rewrite/fake/Makefile.am index 00c1e77c52..eb1040ec45 100644 --- a/helpers/url_rewrite/fake/Makefile.am +++ b/helpers/url_rewrite/fake/Makefile.am @@ -1,6 +1,10 @@ include $(top_srcdir)/src/Common.am -libexec_PROGRAMS = url_fake_rewrite url_fake_rewrite.sh - +libexec_PROGRAMS = url_fake_rewrite url_fake_rewrite_SOURCES = fake.cc + url_fake_rewrite_LDADD = $(COMPAT_LIB) + +libexec_SCRIPTS = url_fake_rewrite.sh + +EXTRA_DIST = url_fake_rewrite.sh diff --git a/helpers/url_rewrite/fake/fake.cc b/helpers/url_rewrite/fake/fake.cc index a30de66004..59604cc0eb 100644 --- a/helpers/url_rewrite/fake/fake.cc +++ b/helpers/url_rewrite/fake/fake.cc @@ -14,6 +14,10 @@ #include "config.h" +#if HAVE_CSTRING +#include +#endif + #define BUFFER_SIZE 10240 /** @@ -66,7 +70,6 @@ main(int argc, char *argv[]) { char buf[BUFFER_SIZE]; int buflen = 0; - char helper_command[3]; setbuf(stdout, NULL); setbuf(stderr, NULL); @@ -78,6 +81,7 @@ main(int argc, char *argv[]) debug("%s build " __DATE__ ", " __TIME__ " starting up...\n", my_program_name); while (fgets(buf, BUFFER_SIZE, stdin) != NULL) { + char *p; if ((p = strchr(buf, '\n')) != NULL) { *p = '\0'; /* strip \n */ diff --git a/src/Debug.h b/src/Debug.h index b2134c1bc3..1a30f17c9a 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -137,9 +137,10 @@ inline std::ostream& operator <<(std::ostream &os, const uint8_t d) } /* Legacy debug style. Still used in some places. needs to die... */ -#define do_debug(SECTION, LEVEL) ((Debug::level = (LEVEL)) > Debug::Levels[SECTION]) -#define old_debug(SECTION, LEVEL) \ - do_debug(SECTION, LEVEL) ? (void) 0 : _db_print +#define do_debug(SECTION, LEVEL) ((Debug::level = (LEVEL)) > Debug::Levels[SECTION]) +#define old_debug(SECTION, LEVEL) if( (Debug::level=(LEVEL)) <= Debug::Levels[SECTION] ) _db_print +/* Legacy debug function definitions */ +SQUIDCEXTERN void _db_print(const char *,...) PRINTF_FORMAT_ARG1; #endif /* SQUID_DEBUG_H */ diff --git a/src/protos.h b/src/protos.h index 459820d3bc..d94028dbaf 100644 --- a/src/protos.h +++ b/src/protos.h @@ -106,8 +106,6 @@ SQUIDCEXTERN void _db_set_syslog(const char *facility); SQUIDCEXTERN void _db_init(const char *logfile, const char *options); SQUIDCEXTERN void _db_rotate_log(void); -SQUIDCEXTERN void _db_print(const char *,...) PRINTF_FORMAT_ARG1; - /* packs, then prints an object using debugs() */ SQUIDCEXTERN void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm); diff --git a/tools/cachemgr.cc b/tools/cachemgr.cc index d36e9935c7..8d953a709b 100644 --- a/tools/cachemgr.cc +++ b/tools/cachemgr.cc @@ -146,17 +146,6 @@ typedef struct { char *pub_auth; } cachemgr_request; -/* - * Debugging macros (info goes to error_log on your web server) - * Note: do not run cache manager with non zero debugging level - * if you do not debug, it may write a lot of [sensitive] - * information to your error log. - */ - -/* debugging level 0 (disabled) - 3 (max) */ -#define DEBUG_LEVEL 0 -#define debug(level) if ((level) <= DEBUG_LEVEL && DEBUG_LEVEL > 0) - /* * Static variables and constants */ @@ -871,9 +860,9 @@ process_request(cachemgr_request * req) req->action, make_auth_header(req)); if (write(s, buf, l) < 0) { - debug(1) fprintf(stderr, "ERROR: (%d) writing request: '%s'\n", errno, buf); + fprintf(stderr,"ERROR: (%d) writing request: '%s'\n", errno, buf); } else { - debug(1) fprintf(stderr, "wrote request: '%s'\n", buf); + debug("wrote request: '%s'\n", buf); } return read_reply(s, req); } @@ -906,6 +895,31 @@ main(int argc, char *argv[]) if ((s = getenv("SCRIPT_NAME")) != NULL) script_name = xstrdup(s); + char **args = argv; + while (argc > 1 && args[1][0] == '-') { +// const char *value = ""; + char option = args[1][1]; + switch (option) { + case 'd': + debug_enabled = 1; + break; + default: +#if 0 // unused for now. + if (strlen(args[1]) > 2) { + value = args[1] + 2; + } else if (argc > 2) { + value = args[2]; + args++; + argc--; + } else + value = ""; + break; +#endif + } + args++; + argc--; + } + req = read_request(); return process_request(req); @@ -1019,7 +1033,7 @@ read_request(void) } make_pub_auth(req); - debug(1) fprintf(stderr, "cmgr: got req: host: '%s' port: %d uname: '%s' passwd: '%s' auth: '%s' oper: '%s'\n", + debug("cmgr: got req: host: '%s' port: %d uname: '%s' passwd: '%s' auth: '%s' oper: '%s'\n", safe_str(req->hostname), req->port, safe_str(req->user_name), safe_str(req->passwd), safe_str(req->pub_auth), safe_str(req->action)); return req; } @@ -1036,7 +1050,7 @@ make_pub_auth(cachemgr_request * req) { static char buf[1024]; safe_free(req->pub_auth); - debug(3) fprintf(stderr, "cmgr: encoding for pub...\n"); + debug("cmgr: encoding for pub...\n"); if (!req->passwd || !strlen(req->passwd)) return; @@ -1048,9 +1062,8 @@ make_pub_auth(cachemgr_request * req) req->user_name ? req->user_name : "", req->passwd); - debug(3) fprintf(stderr, "cmgr: pre-encoded for pub: %s\n", buf); - - debug(3) fprintf(stderr, "cmgr: encoded: '%s'\n", base64_encode(buf)); + debug("cmgr: pre-encoded for pub: %s\n", buf); + debug("cmgr: encoded: '%s'\n", base64_encode(buf)); req->pub_auth = xstrdup(base64_encode(buf)); } @@ -1064,7 +1077,7 @@ decode_pub_auth(cachemgr_request * req) const char *user_name; const char *passwd; - debug(2) fprintf(stderr, "cmgr: decoding pub: '%s'\n", safe_str(req->pub_auth)); + debug("cmgr: decoding pub: '%s'\n", safe_str(req->pub_auth)); safe_free(req->passwd); if (!req->pub_auth || strlen(req->pub_auth) < 4 + strlen(safe_str(req->hostname))) @@ -1072,28 +1085,28 @@ decode_pub_auth(cachemgr_request * req) buf = xstrdup(base64_decode(req->pub_auth)); - debug(3) fprintf(stderr, "cmgr: length ok\n"); + debug("cmgr: length ok\n"); /* parse ( a lot of memory leaks, but that is cachemgr style :) */ if ((host_name = strtok(buf, "|")) == NULL) return; - debug(3) fprintf(stderr, "cmgr: decoded host: '%s'\n", host_name); + debug("cmgr: decoded host: '%s'\n", host_name); if ((time_str = strtok(NULL, "|")) == NULL) return; - debug(3) fprintf(stderr, "cmgr: decoded time: '%s' (now: %d)\n", time_str, (int) now); + debug("cmgr: decoded time: '%s' (now: %d)\n", time_str, (int) now); if ((user_name = strtok(NULL, "|")) == NULL) return; - debug(3) fprintf(stderr, "cmgr: decoded uname: '%s'\n", user_name); + debug("cmgr: decoded uname: '%s'\n", user_name); if ((passwd = strtok(NULL, "|")) == NULL) return; - debug(2) fprintf(stderr, "cmgr: decoded passwd: '%s'\n", passwd); + debug("cmgr: decoded passwd: '%s'\n", passwd); /* verify freshness and validity */ if (atoi(time_str) + passwd_ttl < now) @@ -1102,7 +1115,7 @@ decode_pub_auth(cachemgr_request * req) if (strcasecmp(host_name, req->hostname)) return; - debug(1) fprintf(stderr, "cmgr: verified auth. info.\n"); + debug("cmgr: verified auth. info.\n"); /* ok, accept */ xfree(req->user_name);