From c8f782a4a2fe5672307ed43f81ebd1816d4ca93d Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 27 Jan 2007 13:09:16 +0000 Subject: [PATCH] Add new config option "templdir" to change the templates directory. --- cgi.c | 29 +++++++++++++++++++++++------ loadcfg.c | 18 ++++++++++++++++-- project.h | 9 ++++++++- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/cgi.c b/cgi.c index 925063d5..7ca1d2cd 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.89 2007/01/23 15:51:16 fabiankeil Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.90 2007/01/25 13:47:26 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -38,6 +38,9 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.89 2007/01/23 15:51:16 fabiankeil Exp $"; * * Revisions : * $Log: cgi.c,v $ + * Revision 1.90 2007/01/25 13:47:26 fabiankeil + * Added "forwarding-failed" template support for error_response(). + * * Revision 1.89 2007/01/23 15:51:16 fabiankeil * Add favicon delivery functions. * @@ -2109,9 +2112,8 @@ void free_http_response(struct http_response *rsp) * Function : template_load * * Description : CGI support function that loads a given HTML - * template from the confdir, ignoring comment - * lines and following #include statements up to - * a depth of 1. + * template, ignoring comment lines and following + * #include statements up to a depth of 1. * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) @@ -2158,11 +2160,23 @@ jb_err template_load(struct client_state *csp, char **template_ptr, } } - /* Generate full path */ + /* + * Generate full path using either templdir + * or confdir/templates as base directory. + */ + if (NULL != csp->config->templdir) + { + templates_dir_path = strdup(csp->config->templdir); + } + else + { + templates_dir_path = make_path(csp->config->confdir, "templates"); + } - templates_dir_path = make_path(csp->config->confdir, "templates"); if (templates_dir_path == NULL) { + log_error(LOG_LEVEL_ERROR, "Out of memory while generating template path for %s.", + templatename); return JB_ERR_MEMORY; } @@ -2170,6 +2184,8 @@ jb_err template_load(struct client_state *csp, char **template_ptr, free(templates_dir_path); if (full_path == NULL) { + log_error(LOG_LEVEL_ERROR, "Out of memory while generating full template path for %s.", + templatename); return JB_ERR_MEMORY; } @@ -2178,6 +2194,7 @@ jb_err template_load(struct client_state *csp, char **template_ptr, file_buffer = strdup(""); if (file_buffer == NULL) { + log_error(LOG_LEVEL_ERROR, "Not enough free memory to buffer %s.", full_path); free(full_path); return JB_ERR_MEMORY; } diff --git a/loadcfg.c b/loadcfg.c index dff73258..160ff0da 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,4 +1,4 @@ -const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.58 2006/12/31 14:24:29 fabiankeil Exp $"; +const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.59 2006/12/31 17:56:38 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ @@ -8,7 +8,7 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.58 2006/12/31 14:24:29 fabiankeil * routine to load the configuration and the global * variables it writes to. * - * Copyright : Written by and Copyright (C) 2001 the SourceForge + * Copyright : Written by and Copyright (C) 2001-2007 the SourceForge * Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written @@ -35,6 +35,10 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.58 2006/12/31 14:24:29 fabiankeil * * Revisions : * $Log: loadcfg.c,v $ + * Revision 1.59 2006/12/31 17:56:38 fabiankeil + * Added config option accept-intercepted-requests + * and disabled it by default. + * * Revision 1.58 2006/12/31 14:24:29 fabiankeil * Fix gcc43 compiler warnings. * @@ -492,6 +496,7 @@ static struct file_list *current_configfile = NULL; #define hash_single_threaded 4250084780ul /* "single-threaded" */ #define hash_split_large_cgi_forms 671658948ul /* "split-large-cgi-forms" */ #define hash_suppress_blocklists 1948693308ul /* "suppress-blocklists" */ +#define hash_templdir 11067889ul /* "templdir" */ #define hash_toggle 447966ul /* "toggle" */ #define hash_trust_info_url 430331967ul /* "trust-info-url" */ #define hash_trustfile 56494766ul /* "trustfile" */ @@ -562,6 +567,7 @@ void unload_configfile (void * data) freez(config->confdir); freez(config->logdir); + freez(config->templdir); freez(config->haddr); freez(config->logfile); @@ -1347,6 +1353,14 @@ struct configuration_spec * load_config(void) } continue; +/* ************************************************************************* + * templdir directory-name + * *************************************************************************/ + case hash_templdir : + freez(config->templdir); + config->templdir = make_path(NULL, arg); + continue; + /* ************************************************************************* * toggle (0|1) * *************************************************************************/ diff --git a/project.h b/project.h index 32312fe4..c2235423 100644 --- a/project.h +++ b/project.h @@ -1,7 +1,7 @@ #ifndef PROJECT_H_INCLUDED #define PROJECT_H_INCLUDED /** Version string. */ -#define PROJECT_H_VERSION "$Id: project.h,v 1.87 2007/01/01 19:36:37 fabiankeil Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.88 2007/01/25 13:36:59 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -37,6 +37,10 @@ * * Revisions : * $Log: project.h,v $ + * Revision 1.88 2007/01/25 13:36:59 fabiankeil + * Add csp->error_message for failure reasons + * that should be embedded into the CGI pages. + * * Revision 1.87 2007/01/01 19:36:37 fabiankeil * Integrate a modified version of Wil Mahan's * zlib patch (PR #895531). @@ -1488,6 +1492,9 @@ struct configuration_spec /** The config file directory. */ const char *confdir; + /** The directory for customized CGI templates. */ + const char *templdir; + /** The log file directory. */ const char *logdir; -- 2.39.2