]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: Drop appname and full_appname_string constant globals
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 2 Jul 2008 03:49:07 +0000 (15:49 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 2 Jul 2008 03:49:07 +0000 (15:49 +1200)
appname array only ever held a duplicate of "squid"
      - calling it APP_SHORTNAME now instead of a global

full_appname_string only ever held the catenation VERSION"/"PACKAGE macros
      - calling it APP_FULLNAME now instead of a global

15 files changed:
include/version.h
src/AuthUser.cc
src/HttpReply.cc
src/WinSvc.cc
src/cache_cf.cc
src/client_side.cc
src/debug.cc
src/globals.h
src/main.cc
src/snmp_agent.cc
src/stat.cc
src/tests/testCoss.cc
src/tests/testNull.cc
src/tools.cc
src/urn.cc

index 529043e6fa99f31195e0d103edf046ae7545182b..76786c7b12283ab1ccccf4eba6680f881ecc77e6 100644 (file)
 #ifndef SQUID_RELEASE_TIME
 #define SQUID_RELEASE_TIME squid_curtime
 #endif
+
+#ifndef APP_SHORTNAME
+#define APP_SHORTNAME "squid"
+#endif
+#ifndef APP_FULLNAME
+#define APP_FULLNAME  PACKAGE "/" VERSION
+#endif
index 9954764278962ae904a6e4cf58feed69d3dd1366..e9caf9482efef27e9615a6afeefb5afb04f796a9 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * $Id: AuthUser.cc,v 1.10 2007/12/14 23:11:45 amosjeffries Exp $
  *
index 52c052e28a015e66a7eef06cbc482b1a34d0948f..97e327313b1da870ffbab552a9d1362c4285e6a1 100644 (file)
@@ -251,7 +251,7 @@ HttpReply::redirect(http_status status, const char *loc)
     HttpVersion ver(1,0);
     httpStatusLineSet(&sline, ver, status, httpStatusString(status));
     hdr = &header;
-    hdr->putStr(HDR_SERVER, full_appname_string);
+    hdr->putStr(HDR_SERVER, APP_FULLNAME);
     hdr->putTime(HDR_DATE, squid_curtime);
     hdr->putInt64(HDR_CONTENT_LENGTH, 0);
     hdr->putStr(HDR_LOCATION, loc);
index 15021b9f75a6f25ec8c4889ca7fab078611f12cd..1e0fd2a1fd05b415ef7e88c331ca2fcb997f2ced 100755 (executable)
@@ -895,7 +895,7 @@ WIN32_sendSignal(int WIN32_signal)
                              fdwAccess);               /* specify access     */
 
     if (schService == NULL) {
-        fprintf(stderr, "%s: ERROR: Could not open Service %s\n", appname,
+        fprintf(stderr, "%s: ERROR: Could not open Service %s\n", APP_SHORTNAME,
                 WIN32_Service_name);
         exit(1);
     } else {
@@ -905,7 +905,7 @@ WIN32_sendSignal(int WIN32_signal)
                             fdwControl,        /* control value to send  */
                             &ssStatus)) {      /* address of status info */
             fprintf(stderr, "%s: ERROR: Could not Control Service %s\n",
-                    appname, WIN32_Service_name);
+                    APP_SHORTNAME, WIN32_Service_name);
             exit(1);
         } else {
             /* Print the service status. */
index 3ce9a2c05964e1824d668b61dd8f5720ba9626ee..f845cf2f2c1ca12a4f191bb90a3566055ddb1baa 100644 (file)
@@ -450,7 +450,7 @@ configDoConfigure(void)
     if (Config.onoff.httpd_suppress_version_string)
         visible_appname_string = (char *)appname_string;
     else
-        visible_appname_string = (char *)full_appname_string;
+        visible_appname_string = (char const *)APP_FULLNAME;
 
 #if USE_DNSSERVERS
 
index af5cb250f7e322b0a7b6d916169641b095ef352b..7faf19992539a6c52eebba25a2e5d8fd0538c9f5 100644 (file)
@@ -1058,8 +1058,8 @@ ClientHttpRequest::rangeBoundaryStr() const
 {
     assert(this);
     const char *key;
-    String b (full_appname_string);
-    b.append (":",1);
+    String b(APP_FULLNAME);
+    b.append(":",1);
     key = storeEntry()->getMD5Text();
     b.append(key, strlen(key));
     return b;
index b6cfdfe6b8bdf9bc9e12735845fe103878e268ef..25d15ee06b098272ce98498a0a93893a5878f455 100755 (executable)
@@ -465,7 +465,7 @@ _db_init(const char *logfile, const char *options) {
 #if HAVE_SYSLOG && defined(LOG_LOCAL4)
 
     if (opt_syslog_enable)
-        openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, syslog_facility);
+        openlog(APP_SHORTNAME, LOG_PID | LOG_NDELAY | LOG_CONS, syslog_facility);
 
 #endif /* HAVE_SYSLOG */
 
index 1694bd852113f1ee7b79d5ebb91d9015960c0af2..27c2e209774705b1b01bf97cd9564e66acc37b61 100644 (file)
@@ -64,14 +64,14 @@ extern "C"
     extern char config_input_line[BUFSIZ];
     extern const char *DefaultConfigFile;      /* DEFAULT_CONFIG_FILE */
     extern const char *cfg_filename;   /* NULL */
-    extern const char *const appname;  /* "squid" */
+//MOVED:version.h:APP_SHORTNAME    extern const char *const appname;   /* "squid" */
     extern const char *const dash_str; /* "-" */
     extern const char *const null_string;      /* "" */
     extern const char *const version_string;   /* VERSION */
-    extern const char *const full_appname_string;      /* PACKAGE "/" VERSION */
+//MOVED:versions.h:APP_FULLNAME    extern const char *const full_appname_string;       /* PACKAGE "/" VERSION */
     extern const char *const appname_string;   /* PACKAGE */
-    extern char * visible_appname_string;
     extern const char *const w_space;  /* " \t\n\r" */
+    extern char const * visible_appname_string; /* NULL */
     extern const char *fdTypeStr[];
     extern const char *hier_strings[];
     extern const char *memStatusStr[];
index 6310e4bf1799386d3aa00e3e63af559ed8f0f128..0a99057c61c940301c7116afbc19836d20f25488 100644 (file)
@@ -248,7 +248,7 @@ usage(void)
             "       -V        Virtual host httpd-accelerator.\n"
             "       -X        Force full debugging.\n"
             "       -Y        Only return UDP_HIT or UDP_MISS_NOFETCH during fast reload.\n",
-            appname, CACHE_HTTP_PORT, DefaultConfigFile, CACHE_ICP_PORT);
+            APP_SHORTNAME, CACHE_HTTP_PORT, DefaultConfigFile, CACHE_ICP_PORT);
     exit(1);
 }
 
@@ -1413,7 +1413,7 @@ sendSignal(void)
         } else
 #ifdef _SQUID_MSWIN_
         {
-            fprintf(stderr, "%s: ERROR: Could not send ", appname);
+            fprintf(stderr, "%s: ERROR: Could not send ", APP_SHORTNAME);
             fprintf(stderr, "signal to Squid Service:\n");
             fprintf(stderr, "missing -n command line switch.\n");
             exit(1);
@@ -1427,13 +1427,13 @@ sendSignal(void)
         if (kill(pid, opt_send_signal) &&
                 /* ignore permissions if just running check */
                 !(opt_send_signal == 0 && errno == EPERM)) {
-            fprintf(stderr, "%s: ERROR: Could not send ", appname);
+            fprintf(stderr, "%s: ERROR: Could not send ", APP_SHORTNAME);
             fprintf(stderr, "signal %d to process %d: %s\n",
                     opt_send_signal, (int) pid, xstrerror());
             exit(1);
         }
     } else {
-        fprintf(stderr, "%s: ERROR: No running copy\n", appname);
+        fprintf(stderr, "%s: ERROR: No running copy\n", APP_SHORTNAME);
         exit(1);
     }
 
@@ -1534,7 +1534,7 @@ watch_child(char *argv[])
     if (*(argv[0]) == '(')
         return;
 
-    openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4);
+    openlog(APP_SHORTNAME, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4);
 
     if ((pid = fork()) < 0)
         syslog(LOG_ALERT, "fork failed: %s", xstrerror());
@@ -1578,7 +1578,7 @@ watch_child(char *argv[])
 
         if ((pid = fork()) == 0) {
             /* child */
-            openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4);
+            openlog(APP_SHORTNAME, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4);
             prog = xstrdup(argv[0]);
             argv[0] = xstrdup("(squid)");
             execvp(prog, argv);
@@ -1586,7 +1586,7 @@ watch_child(char *argv[])
         }
 
         /* parent */
-        openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4);
+        openlog(APP_SHORTNAME, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4);
 
         syslog(LOG_NOTICE, "Squid Parent: child process %d started", pid);
 
index f0789b022039151ebf784e0f885d079c12843e0e..200b742a67fdf49752dd5aff4f9521b18753479e 100644 (file)
@@ -107,8 +107,8 @@ snmp_confFn(variable_list * Var, snint * ErrP)
     case CONF_VERSION:
         Answer = snmp_var_new(Var->name, Var->name_length);
         Answer->type = ASN_OCTET_STR;
-        Answer->val_len = strlen(appname);
-        Answer->val.string = (u_char *) xstrdup(appname);
+        Answer->val_len = strlen(APP_SHORTNAME);
+        Answer->val.string = (u_char *) xstrdup(APP_SHORTNAME);
         break;
 
     case CONF_VERSION_ID:
index 8cdca74f73abf4543e41b31503bcf878edfc7ac2..f1e69478d48417ffbd93ddeb4f5f37eb53860d12 100644 (file)
@@ -477,8 +477,7 @@ info_get(StoreEntry * sentry)
     storeAppendPrintf(sentry, "Current Time:\t%s\n",
                       mkrfc1123(current_time.tv_sec));
 
-    storeAppendPrintf(sentry, "Connection information for %s:\n",
-                      appname);
+    storeAppendPrintf(sentry, "Connection information for %s:\n",APP_SHORTNAME);
 
     storeAppendPrintf(sentry, "\tNumber of clients accessing cache:\t%u\n",
                       statCounter.client_http.clients);
@@ -517,8 +516,7 @@ info_get(StoreEntry * sentry)
     storeAppendPrintf(sentry, "\tSelect loop called: %d times, %0.3f ms avg\n",
                       statCounter.select_loops, 1000.0 * runtime / statCounter.select_loops);
 
-    storeAppendPrintf(sentry, "Cache information for %s:\n",
-                      appname);
+    storeAppendPrintf(sentry, "Cache information for %s:\n",APP_SHORTNAME);
 
     storeAppendPrintf(sentry, "\tHits as %% of all requests:\t5min: %3.1f%%, 60min: %3.1f%%\n",
                       statRequestHitRatio(5),
@@ -591,7 +589,7 @@ info_get(StoreEntry * sentry)
 
     cputime = rusage_cputime(&rusage);
 
-    storeAppendPrintf(sentry, "Resource usage for %s:\n", appname);
+    storeAppendPrintf(sentry, "Resource usage for %s:\n", APP_SHORTNAME);
 
     storeAppendPrintf(sentry, "\tUP Time:\t%.3f seconds\n", runtime);
 
@@ -623,8 +621,7 @@ info_get(StoreEntry * sentry)
 
     ms = mstats();
 
-    storeAppendPrintf(sentry, "Memory usage for %s via mstats():\n",
-                      appname);
+    storeAppendPrintf(sentry, "Memory usage for %s via mstats():\n",APP_SHORTNAME);
 
     storeAppendPrintf(sentry, "\tTotal space in arena:  %6d KB\n",
                       ms.bytes_total >> 10);
@@ -636,8 +633,7 @@ info_get(StoreEntry * sentry)
 
     mp = mallinfo();
 
-    storeAppendPrintf(sentry, "Memory usage for %s via mallinfo():\n",
-                      appname);
+    storeAppendPrintf(sentry, "Memory usage for %s via mallinfo():\n",APP_SHORTNAME);
 
     storeAppendPrintf(sentry, "\tTotal space in arena:  %6ld KB\n",
                       (long)mp.arena >> 10);
@@ -725,7 +721,7 @@ info_get(StoreEntry * sentry)
                           mp_stats.TheMeter->gb_freed.count);
     }
 
-    storeAppendPrintf(sentry, "File descriptor usage for %s:\n", appname);
+    storeAppendPrintf(sentry, "File descriptor usage for %s:\n", APP_SHORTNAME);
     storeAppendPrintf(sentry, "\tMaximum number of file descriptors:   %4d\n",
                       Squid_MaxFD);
     storeAppendPrintf(sentry, "\tLargest file desc currently in use:   %4d\n",
index 1a8dd4deb6c7a3dd85a94391c63fd5d1fa3c63a6..f66985771649165bb986207a31c44b9b0ee55b9e 100644 (file)
@@ -56,7 +56,7 @@ testCoss::commonInit()
     /* garh garh */
     storeReplAdd("lru", createRemovalPolicy_lru);
 
-    visible_appname_string = xstrdup(PACKAGE "/" VERSION);
+    visible_appname_string = xstrdup(APP_FULLNAME);
 
     Mem::Init();
 
index fcb2cc9bb8afeffcba061d2d8a5a1340c5c687e8..f2d04a3afd357af8d821268f70823659e7371e8a 100644 (file)
@@ -56,7 +56,7 @@ testNull::commonInit()
     /* garh garh */
     storeReplAdd("lru", createRemovalPolicy_lru);
 
-    visible_appname_string = xstrdup(PACKAGE "/" VERSION);
+    visible_appname_string = xstrdup(APP_FULLNAME);
 
     Mem::Init();
 
index 1b8e7ed82df4bee09cc4826883fe10296cde3adf..3b1df29a1a1a07f6eb191453bf619e2b524b79a6 100644 (file)
@@ -130,7 +130,7 @@ mail_warranty(void)
 
     char *filename;
 
-    if ((filename = tempnam(NULL, appname)) == NULL)
+    if ((filename = tempnam(NULL, APP_SHORTNAME)) == NULL)
         return;
 
     if ((fp = fopen(filename, "w")) == NULL)
@@ -141,7 +141,7 @@ mail_warranty(void)
     if (Config.EmailFrom)
         fprintf(fp, "From: %s\n", Config.EmailFrom);
     else
-        fprintf(fp, "From: %s@%s\n", appname, uniqueHostname());
+        fprintf(fp, "From: %s@%s\n", APP_SHORTNAME, uniqueHostname());
 
     fprintf(fp, "To: %s\n", Config.adminEmail);
 
@@ -177,7 +177,7 @@ dumpMallocStats(void)
 
     mp = mallinfo();
 
-    fprintf(debug_log, "Memory usage for %s via mallinfo():\n", appname);
+    fprintf(debug_log, "Memory usage for "APP_SHORTNAME" via mallinfo():\n");
 
     fprintf(debug_log, "\ttotal space in arena:  %6ld KB\n",
             (long)mp.arena >> 10);
@@ -851,7 +851,7 @@ readPidFile(void)
     int i;
 
     if (f == NULL || !strcmp(Config.pidFilename, "none")) {
-        fprintf(stderr, "%s: ERROR: No pid file name defined\n", appname);
+        fprintf(stderr, APP_SHORTNAME ": ERROR: No pid file name defined\n");
         exit(1);
     }
 
@@ -873,7 +873,7 @@ readPidFile(void)
         fclose(pid_fp);
     } else {
         if (errno != ENOENT) {
-            fprintf(stderr, "%s: ERROR: Could not read pid file\n", appname);
+            fprintf(stderr, APP_SHORTNAME ": ERROR: Could not read pid file\n");
             fprintf(stderr, "\t%s: %s\n", f, xstrerror());
             exit(1);
         }
index 23cde11c08ef94717f0781a8ed0ef4ce1c3d1a70..e03081030e36b3436407d04b18dee4bc27940f3a 100644 (file)
@@ -439,7 +439,7 @@ urnHandleReply(void *data, StoreIOBuffer result)
         "<ADDRESS>\n"
         "Generated by %s@%s\n"
         "</ADDRESS>\n",
-        full_appname_string, getMyHostname());
+        APP_FULLNAME, getMyHostname());
     rep = new HttpReply;
     rep->setHeaders(version, HTTP_MOVED_TEMPORARILY, NULL,
                     "text/html", mb->contentSize(), 0, squid_curtime);