3 /*********************************************************************
5 * File : $Source: /cvsroot/ijbswa/current/cgi.h,v $
7 * Purpose : Declares functions to intercept request, generate
8 * html or gif answers, and to compose HTTP resonses.
10 * Functions declared include:
13 * Copyright : Written by and Copyright (C) 2001-2009 the
14 * Privoxy team. https://www.privoxy.org/
16 * Based on the Internet Junkbuster originally written
17 * by and Copyright (C) 1997 Anonymous Coders and
18 * Junkbusters Corporation. http://www.junkbusters.com
20 * This program is free software; you can redistribute it
21 * and/or modify it under the terms of the GNU General
22 * Public License as published by the Free Software
23 * Foundation; either version 2 of the License, or (at
24 * your option) any later version.
26 * This program is distributed in the hope that it will
27 * be useful, but WITHOUT ANY WARRANTY; without even the
28 * implied warranty of MERCHANTABILITY or FITNESS FOR A
29 * PARTICULAR PURPOSE. See the GNU General Public
30 * License for more details.
32 * The GNU General Public License should be included with
33 * this file. If not, you can view it at
34 * http://www.gnu.org/copyleft/gpl.html
35 * or write to the Free Software Foundation, Inc., 59
36 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 **********************************************************************/
44 * Main dispatch function
46 extern struct http_response *dispatch_cgi(struct client_state *csp);
48 /* Not exactly a CGI */
49 extern struct http_response *error_response(struct client_state *csp,
50 const char *templatename);
53 * CGI support functions
55 extern struct http_response * alloc_http_response(void);
56 extern void free_http_response(struct http_response *rsp);
58 extern struct http_response *finish_http_response(struct client_state *csp,
59 struct http_response *rsp);
61 extern struct map * default_exports(const struct client_state *csp, const char *caller);
63 extern jb_err map_block_killer (struct map *exports, const char *name);
64 extern jb_err map_block_keep (struct map *exports, const char *name);
65 extern jb_err map_conditional (struct map *exports, const char *name, int choose_first);
67 extern jb_err template_load(const struct client_state *csp, char ** template_ptr,
68 const char *templatename, int recursive);
69 extern jb_err template_fill(char ** template_ptr, const struct map *exports);
70 extern jb_err template_fill_for_cgi(const struct client_state *csp,
71 const char *templatename,
73 struct http_response *rsp);
75 extern void cgi_init_error_messages(void);
76 extern struct http_response *cgi_error_memory(void);
77 extern jb_err cgi_redirect (struct http_response * rsp, const char *target);
79 extern jb_err cgi_error_no_template(const struct client_state *csp,
80 struct http_response *rsp,
81 const char *template_name);
82 extern jb_err cgi_error_bad_param(const struct client_state *csp,
83 struct http_response *rsp);
84 extern jb_err cgi_error_disabled(const struct client_state *csp,
85 struct http_response *rsp);
86 extern jb_err cgi_error_unknown(const struct client_state *csp,
87 struct http_response *rsp,
88 jb_err error_to_report);
90 extern jb_err get_number_param(struct client_state *csp,
91 const struct map *parameters,
94 extern jb_err get_string_param(const struct map *parameters,
95 const char *param_name,
97 extern char get_char_param(const struct map *parameters,
98 const char *param_name);
99 #ifdef FEATURE_COMPRESSION
101 * Minimum length which a buffer has to reach before
102 * we bother to (re-)compress it. Completely arbitrary.
104 extern const size_t LOWER_LENGTH_LIMIT_FOR_COMPRESSION;
105 extern char *compress_buffer(char *buffer, size_t *buffer_length, int compression_level);
111 extern void get_http_time(int time_offset, char *buf, size_t buffer_size);
112 extern char *add_help_link(const char *item, struct configuration_spec *config);
113 extern char *make_menu(const char *self, const unsigned feature_flags);
114 extern char *dump_map(const struct map *the_map);
117 * Ad replacement images
119 extern const char image_pattern_data[];
120 extern const size_t image_pattern_length;
121 extern const char image_blank_data[];
122 extern const size_t image_blank_length;
124 #endif /* ndef CGI_H_INCLUDED */