# Added variables to config structure to keep track of the files to be

displayed for various HTTP errors and the stats page. [Steven Young]
This commit is contained in:
Robert James Kaes 2003-03-13 21:32:33 +00:00
parent b06f26cba1
commit badd237fe6
2 changed files with 37 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $Id: tinyproxy.c,v 1.44 2003-02-26 22:37:38 rjkaes Exp $ /* $Id: tinyproxy.c,v 1.45 2003-03-13 21:32:33 rjkaes Exp $
* *
* The initialize routine. Basically sets up all the initial stuff (logfile, * The initialize 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
@ -152,7 +152,6 @@ main(int argc, char **argv)
unsigned int godaemon = TRUE; /* boolean */ unsigned int godaemon = TRUE; /* boolean */
struct passwd *thisuser = NULL; struct passwd *thisuser = NULL;
struct group *thisgroup = NULL; struct group *thisgroup = NULL;
char *conf_file = DEFAULT_CONF_FILE;
/* /*
* Disable the creation of CORE files right up front. * Disable the creation of CORE files right up front.
@ -168,6 +167,9 @@ main(int argc, char **argv)
log_message(LOG_INFO, "Initializing " PACKAGE " ..."); log_message(LOG_INFO, "Initializing " PACKAGE " ...");
/* Default configuration file location */
config.config_file = DEFAULT_CONF_FILE;
/* /*
* Process the various options * Process the various options
*/ */
@ -183,8 +185,8 @@ main(int argc, char **argv)
godaemon = FALSE; godaemon = FALSE;
break; break;
case 'c': case 'c':
conf_file = safestrdup(optarg); config.config_file = safestrdup(optarg);
if (!conf_file) { if (!config.config_file) {
fprintf(stderr, fprintf(stderr,
"%s: Could not allocate memory.\n", "%s: Could not allocate memory.\n",
argv[0]); argv[0]);
@ -198,14 +200,20 @@ main(int argc, char **argv)
} }
} }
/*
* Make sure the HTML error pages array is NULL to begin with.
* (FIXME: Should have a better API for all this)
*/
config.errorpages = NULL;
/* /*
* Read in the settings from the config file. * Read in the settings from the config file.
*/ */
yyin = fopen(conf_file, "r"); yyin = fopen(config.config_file, "r");
if (!yyin) { if (!yyin) {
fprintf(stderr, fprintf(stderr,
"%s: Could not open configuration file \"%s\".\n", "%s: Could not open configuration file \"%s\".\n",
argv[0], conf_file); argv[0], config.config_file);
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
} }
yyparse(); yyparse();

View File

@ -1,4 +1,4 @@
/* $Id: tinyproxy.h,v 1.37 2003-01-27 17:57:37 rjkaes Exp $ /* $Id: tinyproxy.h,v 1.38 2003-03-13 21:32:33 rjkaes Exp $
* *
* See 'tinyproxy.c' for a detailed description. * See 'tinyproxy.c' for a detailed description.
* *
@ -27,6 +27,7 @@
struct config_s { struct config_s {
char *logf_name; char *logf_name;
char *config_file;
unsigned int syslog; /* boolean */ unsigned int syslog; /* boolean */
int port; int port;
char *stathost; char *stathost;
@ -51,10 +52,28 @@ struct config_s {
unsigned int idletimeout; unsigned int idletimeout;
char* bind_address; char* bind_address;
char* dnsserver_location;
char* dnsserver_socket;
unsigned int via_http_header; /* boolean */ unsigned int via_http_header; /* boolean */
/*
* Error page support. This is an array of pointers to structures
* which describe the error page path, and what HTTP error it handles.
* an example would be { "/usr/local/etc/tinyproxy/404.html", 404 }
* Ending of array is noted with NULL, 0.
*/
struct error_pages_s {
char *errorpage_path;
unsigned int errorpage_errnum;
} **errorpages;
/*
* Error page to be displayed if appropriate page cannot be located
* in the errorpages structure.
*/
char *errorpage_undef;
/*
* The HTML statistics page.
*/
char *statpage;
}; };
/* Global Structures used in the program */ /* Global Structures used in the program */