00001 #ifndef CGI_H_INCLUDED 00002 #define CGI_H_INCLUDED 00003 #define CGI_H_VERSION "$Id: cgi.h,v 2.0 2002/06/04 14:34:21 jongfoster Exp $" 00004 /* ****************************************************************** 00005 * $Source: /cvsroot/ijbswa/current/src/cgi.h,v $ 00006 * ****************************************************************** 00007 * 00008 * Written by and Copyright (C) 2001 the SourceForge 00009 * Privoxy team. http://www.privoxy.org/ 00010 * 00011 * Based on the Internet Junkbuster originally written 00012 * by and Copyright (C) 1997 Anonymous Coders and 00013 * Junkbusters Corporation. http://www.junkbusters.com 00014 * 00015 * This program is free software; you can redistribute it 00016 * and/or modify it under the terms of the GNU General 00017 * Public License as published by the Free Software 00018 * Foundation; either version 2 of the License, or (at 00019 * your option) any later version. 00020 * 00021 * This program is distributed in the hope that it will 00022 * be useful, but WITHOUT ANY WARRANTY; without even the 00023 * implied warranty of MERCHANTABILITY or FITNESS FOR A 00024 * PARTICULAR PURPOSE. See the GNU General Public 00025 * License for more details. 00026 * 00027 * The GNU General Public License should be included with 00028 * this file. If not, you can view it at 00029 * http://www.gnu.org/copyleft/gpl.html 00030 * or write to the Free Software Foundation, Inc., 59 00031 * Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00032 * 00033 * *****************************************************************/ 00034 /** 00035 * @file 00036 * 00037 * Declares functions to intercept request, generate 00038 * html or gif answers, and to compose HTTP resonses. 00039 * 00040 * Functions declared include: 00041 * 00042 * 00043 * 00044 * $Log: cgi.h,v $ 00045 * Revision 2.0 2002/06/04 14:34:21 jongfoster 00046 * Moving source files to src/ 00047 * 00048 * Revision 1.29 2002/05/19 11:33:21 jongfoster 00049 * If a CGI error was not handled, and propogated back to 00050 * dispatch_known_cgi(), then it was assumed to be "out of memory". 00051 * This gave a very misleading error message. 00052 * 00053 * Now other errors will cause a simple message giving the error 00054 * number and asking the user to report a bug. 00055 * 00056 * Bug report: 00057 * http://sourceforge.net/tracker/index.php?func=detail 00058 * &aid=557905&group_id=11118&atid=111118 00059 * 00060 * Revision 1.28 2002/04/26 12:54:03 oes 00061 * New function add_help_link 00062 * 00063 * Revision 1.27 2002/04/24 02:16:51 oes 00064 * Moved get_char_param, get_string_param and get_number_param here from cgiedit.c 00065 * 00066 * Revision 1.26 2002/04/10 13:38:35 oes 00067 * load_template signature changed 00068 * 00069 * Revision 1.25 2002/04/08 20:50:25 swa 00070 * fixed JB spelling 00071 * 00072 * Revision 1.24 2002/03/26 22:29:54 swa 00073 * we have a new homepage! 00074 * 00075 * Revision 1.23 2002/03/24 16:18:15 jongfoster 00076 * Removing old logo 00077 * 00078 * Revision 1.22 2002/03/24 13:25:43 swa 00079 * name change related issues 00080 * 00081 * Revision 1.21 2002/03/07 03:48:38 oes 00082 * - Changed built-in images from GIF to PNG 00083 * (with regard to Unisys patent issue) 00084 * - Added a 4x4 pattern PNG which is less intrusive 00085 * than the logo but also clearly marks the deleted banners 00086 * 00087 * Revision 1.20 2002/03/04 17:53:22 oes 00088 * Fixed compiled warning 00089 * 00090 * Revision 1.19 2002/01/21 00:33:52 jongfoster 00091 * Adding map_block_keep() to save a few bytes in the edit-actions-list HTML. 00092 * 00093 * Revision 1.18 2001/11/16 00:46:31 jongfoster 00094 * Fixing compiler warnings 00095 * 00096 * Revision 1.17 2001/10/23 21:48:19 jongfoster 00097 * Cleaning up error handling in CGI functions - they now send back 00098 * a HTML error page and should never cause a FATAL error. (Fixes one 00099 * potential source of "denial of service" attacks). 00100 * 00101 * CGI actions file editor that works and is actually useful. 00102 * 00103 * Ability to toggle Junkbuster remotely using a CGI call. 00104 * 00105 * You can turn off both the above features in the main configuration 00106 * file, e.g. if you are running a multi-user proxy. 00107 * 00108 * Revision 1.16 2001/09/16 17:08:54 jongfoster 00109 * Moving simple CGI functions from cgi.c to new file cgisimple.c 00110 * 00111 * Revision 1.15 2001/09/16 15:02:35 jongfoster 00112 * Adding i.j.b/robots.txt. 00113 * Inlining add_stats() since it's only ever called from one place. 00114 * 00115 * Revision 1.14 2001/09/16 11:38:02 jongfoster 00116 * Splitting fill_template() into 2 functions: 00117 * template_load() loads the file 00118 * template_fill() performs the PCRS regexps. 00119 * This is because the CGI edit interface has a "table row" 00120 * template which is used many times in the page - this 00121 * change means it's only loaded from disk once. 00122 * 00123 * Revision 1.13 2001/09/16 11:00:10 jongfoster 00124 * New function alloc_http_response, for symmetry with free_http_response 00125 * 00126 * Revision 1.12 2001/09/13 23:31:25 jongfoster 00127 * Moving image data to cgi.c rather than cgi.h. 00128 * 00129 * Revision 1.11 2001/08/05 16:06:20 jongfoster 00130 * Modifiying "struct map" so that there are now separate header and 00131 * "map_entry" structures. This means that functions which modify a 00132 * map no longer need to return a pointer to the modified map. 00133 * Also, it no longer reverses the order of the entries (which may be 00134 * important with some advanced template substitutions). 00135 * 00136 * Revision 1.10 2001/08/01 21:19:22 jongfoster 00137 * Moving file version information to a separate CGI page. 00138 * 00139 * Revision 1.9 2001/08/01 00:17:54 jongfoster 00140 * Adding prototype for map_conditional 00141 * 00142 * Revision 1.8 2001/07/30 22:08:36 jongfoster 00143 * Tidying up #defines: 00144 * - All feature #defines are now of the form FEATURE_xxx 00145 * - Permanently turned off WIN_GUI_EDIT 00146 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS 00147 * 00148 * Revision 1.7 2001/07/29 18:43:08 jongfoster 00149 * Changing #ifdef _FILENAME_H to FILENAME_H_INCLUDED, to conform to 00150 * ANSI C rules. 00151 * 00152 * Revision 1.6 2001/06/29 21:45:41 oes 00153 * Indentation, CRLF->LF, Tab-> Space 00154 * 00155 * Revision 1.5 2001/06/29 13:22:44 oes 00156 * - Cleaned up 00157 * - Added new functions: default_exports(), make_menu(), 00158 * error_response() etc, ranamed others and changed 00159 * param and return types. 00160 * - Removed HTTP/HTML snipplets 00161 * - Removed logentry from cancelled commit 00162 * 00163 * Revision 1.4 2001/06/09 10:50:58 jongfoster 00164 * Changing "show URL info" handler to new style. 00165 * Adding "extern" to some function prototypes. 00166 * 00167 * Revision 1.3 2001/06/03 19:12:16 oes 00168 * introduced new cgi handling 00169 * 00170 * No revisions before 1.3 00171 * 00172 */ 00173 /* *****************************************************************/ 00174 00175 00176 #include "project.h" 00177 00178 #ifdef __cplusplus 00179 extern "C" { 00180 #endif 00181 00182 /* 00183 * Main dispatch function 00184 */ 00185 extern struct http_response *dispatch_cgi(struct client_state *csp); 00186 00187 /* Not exactly a CGI */ 00188 extern struct http_response * error_response(struct client_state *csp, 00189 const char *templatename, 00190 int err); 00191 00192 /* 00193 * CGI support functions 00194 */ 00195 extern struct http_response * alloc_http_response(void); 00196 extern void free_http_response(struct http_response *rsp); 00197 00198 extern struct http_response *finish_http_response(struct http_response *rsp); 00199 00200 extern struct map * default_exports(const struct client_state *csp, const char *caller); 00201 00202 extern jb_err map_block_killer (struct map *exports, const char *name); 00203 extern jb_err map_block_keep (struct map *exports, const char *name); 00204 extern jb_err map_conditional (struct map *exports, const char *name, int choose_first); 00205 00206 extern jb_err template_load(struct client_state *csp, char ** template_ptr, 00207 const char *templatename, int recursive); 00208 extern jb_err template_fill(char ** template_ptr, const struct map *exports); 00209 extern jb_err template_fill_for_cgi(struct client_state *csp, 00210 const char *templatename, 00211 struct map *exports, 00212 struct http_response *rsp); 00213 00214 extern void cgi_init_error_messages(void); 00215 extern struct http_response *cgi_error_memory(void); 00216 extern jb_err cgi_error_no_template(struct client_state *csp, 00217 struct http_response *rsp, 00218 const char *template_name); 00219 extern jb_err cgi_error_bad_param(struct client_state *csp, 00220 struct http_response *rsp); 00221 jb_err cgi_error_unknown(struct client_state *csp, 00222 struct http_response *rsp, 00223 jb_err error_to_report); 00224 00225 extern jb_err get_number_param(struct client_state *csp, 00226 const struct map *parameters, 00227 char *name, 00228 unsigned *pvalue); 00229 extern jb_err get_string_param(const struct map *parameters, 00230 const char *param_name, 00231 const char **pparam); 00232 extern char get_char_param(const struct map *parameters, 00233 const char *param_name); 00234 00235 /* 00236 * Text generators 00237 */ 00238 extern void get_http_time(int time_offset, char * buf); 00239 extern char *add_help_link(const char *item, struct configuration_spec *config); 00240 extern char *make_menu(const char *self); 00241 extern char *dump_map(const struct map *the_map); 00242 00243 /* 00244 * Ad replacement images 00245 */ 00246 extern const char image_pattern_data[]; 00247 extern const size_t image_pattern_length; 00248 extern const char image_blank_data[]; 00249 extern const size_t image_blank_length; 00250 00251 /* Revision control strings from this header and associated .c file */ 00252 00253 /** Version information about cgi.c. */ 00254 extern const char cgi_rcs[]; 00255 00256 /** Version information about cgi.h. */ 00257 extern const char cgi_h_rcs[]; 00258 00259 #ifdef __cplusplus 00260 } /* extern "C" */ 00261 #endif 00262 00263 #endif /* ndef CGI_H_INCLUDED */ 00264 00265 /* 00266 Local Variables: 00267 tab-width: 3 00268 end: 00269 */
1.2.15