Renamed versiondisp() to display_version() and added the PACKAGE, VERSION,

and TARGET_SYSTEM into the version list. Also moved the license into a
separate function. Renamed usagedisp() to display_usage(). Fixed a problem
where the anonymous search tree was being created _after_ it was being
accessed.
This commit is contained in:
Robert James Kaes 2001-08-26 21:17:30 +00:00
parent 7fe7ee2828
commit 5530451545

View File

@ -1,4 +1,4 @@
/* $Id: tinyproxy.c,v 1.11 2001-06-04 23:30:34 rjkaes Exp $ /* $Id: tinyproxy.c,v 1.12 2001-08-26 21:17:30 rjkaes Exp $
* *
* The initialise routine. Basically sets up all the initial stuff (logfile, * The initialise routine. Basically sets up all the initial stuff (logfile,
* listening socket, config options, etc.) and then sits there and loops * listening socket, config options, etc.) and then sits there and loops
@ -94,36 +94,51 @@ void takesig(int sig)
/* /*
* Display the version information for the user. * Display the version information for the user.
*/ */
static void versiondisp(void) static void display_version(void)
{ {
printf("tinyproxy " VERSION "\n"); printf("%s %s (%s)\n", PACKAGE, VERSION, TARGET_SYSTEM);
}
/*
* Display the copyright and license for this program.
*/
static void display_license(void)
{
display_version();
printf("\ printf("\
Copyright 1998 Steven Young (sdyoung@well.com)\n\ Copyright 1998 Steven Young (sdyoung@well.com)\n\
Copyright 1998-2000 Robert James Kaes (rjkaes@flarenet.com)\n\ Copyright 1998-2001 Robert James Kaes (rjkaes@users.sourceforge.net)\n\
Copyright 2000 Chris Lightfoot (chris@ex-parrot.com)\n\ Copyright 1999 George Talusan (gstalusan@uwaterloo.ca)\n\
Copyright 2000 Chris Lightfoot (chris@ex-parrot.com)\n\
\n\ \n\
This program is free software; you can redistribute it and/or modify it\n\ This program is free software; you can redistribute it and/or modify\n\
under the terms of the GNU General Public License as published by the Free\n\ it under the terms of the GNU General Public License as published by\n\
Software Foundation; either version 2, or (at your option) any later\n\ the Free Software Foundation; either version 2, or (at your option)\n\
version.\n\ any later version.\n\
\n\ \n\
This program is distributed in the hope that it will be useful, but WITHOUT\n\ This program is distributed in the hope that it will be useful,\n\
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n\ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
more details.\n"); GNU General Public License for more details.\n\
\n\
You should have received a copy of the GNU General Public License\n\
along with this program; if not, write to the Free Software\n\
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.\n");
} }
/* /*
* Display usage to the user. * Display usage to the user.
*/ */
static void usagedisp(void) static void display_usage(void)
{ {
printf("Usage: %s [options]\n", PACKAGE);
printf("\ printf("\
Usage: tinyproxy [options]\n\
Options:\n\ Options:\n\
-d Operate in DEBUG mode.\n\ -d Operate in DEBUG mode.\n\
-c FILE Use an alternate configuration file.\n\ -c FILE Use an alternate configuration file.\n\
-h Display this usage information.\n\ -h Display this usage information.\n\
-l Display the license.\n\
-v Display the version number.\n"); -v Display the version number.\n");
@ -166,11 +181,14 @@ int main(int argc, char **argv)
/* /*
* Process the various options * Process the various options
*/ */
while ((optch = getopt(argc, argv, "c:vdh")) != while ((optch = getopt(argc, argv, "c:vldh")) !=
EOF) { EOF) {
switch (optch) { switch (optch) {
case 'v': case 'v':
versiondisp(); display_version();
exit(EX_OK);
case 'l':
display_license();
exit(EX_OK); exit(EX_OK);
case 'd': case 'd':
godaemon = FALSE; godaemon = FALSE;
@ -184,7 +202,7 @@ int main(int argc, char **argv)
break; break;
case 'h': case 'h':
default: default:
usagedisp(); display_usage();
exit(EX_OK); exit(EX_OK);
} }
} }
@ -249,9 +267,9 @@ int main(int argc, char **argv)
* hand in hand with Content-Length. * hand in hand with Content-Length.
* - rjkaes * - rjkaes
*/ */
if (config.anonymous) { if (is_anonymous_enabled()) {
anon_insert("Content-Length:"); anonymous_insert("Content-Length");
anon_insert("Content-Type:"); anonymous_insert("Content-Type");
} }
if (godaemon == TRUE) if (godaemon == TRUE)
@ -335,9 +353,6 @@ int main(int argc, char **argv)
log_message(LOG_INFO, "Starting the DNS caching subsystem."); log_message(LOG_INFO, "Starting the DNS caching subsystem.");
if (!new_dnscache()) if (!new_dnscache())
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
log_message(LOG_INFO, "Starting the Anonymous header subsystem.");
if (!new_anonymous())
exit(EX_SOFTWARE);
/* /*
* Start the main loop. * Start the main loop.
@ -356,7 +371,7 @@ int main(int argc, char **argv)
*/ */
if (unlink(config.pidpath) < 0) { if (unlink(config.pidpath) < 0) {
log_message(LOG_WARNING, "Could not remove PID file %s: %s", log_message(LOG_WARNING, "Could not remove PID file %s: %s",
config.pidpath, strerror(errno)); config.pidpath, strerror(errno));
} }
#ifdef FILTER_ENABLE #ifdef FILTER_ENABLE