]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix some build errors
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 3 Sep 2009 08:21:00 +0000 (20:21 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 3 Sep 2009 08:21:00 +0000 (20:21 +1200)
helpers/url_rewrite/fake/Makefile.am
helpers/url_rewrite/fake/fake.cc
src/Debug.h
src/protos.h
tools/cachemgr.cc

index 00c1e77c52c6916dc10a5d94b019701cf5ab3517..eb1040ec4556150cbeaf77d5a061a4d5cf5439e2 100644 (file)
@@ -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
index a30de66004a49e2821e83721718f37bfa04b6828..59604cc0ebe4a673426dea280140def4f896feb2 100644 (file)
 
 #include "config.h"
 
+#if HAVE_CSTRING
+#include <cstring>
+#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 */
index b2134c1bc333298506e4ac0a9a49b9b2f5b09b34..1a30f17c9a2c22c4aba80c26fd6ccf301823b5c9 100644 (file)
@@ -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 */
index 459820d3bc0766cbb8620526a10e49fc2af91e85..d94028dbaf4d9533cca7234eed8ab09c77203507 100644 (file)
@@ -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);
 
index d36e9935c7e73c9b517417e9c5761f925beb3129..8d953a709b31d3978e6893bfcc67d17f5b3b2e8f 100644 (file)
@@ -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);