From: Amos Jeffries Date: Wed, 2 Jul 2008 03:49:07 +0000 (+1200) Subject: Cleanup: Drop appname and full_appname_string constant globals X-Git-Tag: SQUID_3_1_0_1~49^2~173 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7dbca7a4b0bf79fe0d6575e03fd02b774d953de4;p=thirdparty%2Fsquid.git Cleanup: Drop appname and full_appname_string constant globals 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 --- diff --git a/include/version.h b/include/version.h index 529043e6fa..76786c7b12 100644 --- a/include/version.h +++ b/include/version.h @@ -11,3 +11,10 @@ #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 diff --git a/src/AuthUser.cc b/src/AuthUser.cc index 9954764278..e9caf9482e 100644 --- a/src/AuthUser.cc +++ b/src/AuthUser.cc @@ -1,4 +1,3 @@ - /* * $Id: AuthUser.cc,v 1.10 2007/12/14 23:11:45 amosjeffries Exp $ * diff --git a/src/HttpReply.cc b/src/HttpReply.cc index 52c052e28a..97e327313b 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -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); diff --git a/src/WinSvc.cc b/src/WinSvc.cc index 15021b9f75..1e0fd2a1fd 100755 --- a/src/WinSvc.cc +++ b/src/WinSvc.cc @@ -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. */ diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 3ce9a2c059..f845cf2f2c 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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 diff --git a/src/client_side.cc b/src/client_side.cc index af5cb250f7..7faf199925 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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; diff --git a/src/debug.cc b/src/debug.cc index b6cfdfe6b8..25d15ee06b 100755 --- a/src/debug.cc +++ b/src/debug.cc @@ -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 */ diff --git a/src/globals.h b/src/globals.h index 1694bd8521..27c2e20977 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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[]; diff --git a/src/main.cc b/src/main.cc index 6310e4bf17..0a99057c61 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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); diff --git a/src/snmp_agent.cc b/src/snmp_agent.cc index f0789b0220..200b742a67 100644 --- a/src/snmp_agent.cc +++ b/src/snmp_agent.cc @@ -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: diff --git a/src/stat.cc b/src/stat.cc index 8cdca74f73..f1e69478d4 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -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", diff --git a/src/tests/testCoss.cc b/src/tests/testCoss.cc index 1a8dd4deb6..f669857716 100644 --- a/src/tests/testCoss.cc +++ b/src/tests/testCoss.cc @@ -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(); diff --git a/src/tests/testNull.cc b/src/tests/testNull.cc index fcb2cc9bb8..f2d04a3afd 100644 --- a/src/tests/testNull.cc +++ b/src/tests/testNull.cc @@ -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(); diff --git a/src/tools.cc b/src/tools.cc index 1b8e7ed82d..3b1df29a1a 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -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); } diff --git a/src/urn.cc b/src/urn.cc index 23cde11c08..e03081030e 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -439,7 +439,7 @@ urnHandleReply(void *data, StoreIOBuffer result) "
\n" "Generated by %s@%s\n" "
\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);