Improve the handling of chunk-encoded responses
[privoxy.git] / filters.h
1 #ifndef FILTERS_H_INCLUDED
2 #define FILTERS_H_INCLUDED
3 /*********************************************************************
4  *
5  * File        :  $Source: /cvsroot/ijbswa/current/filters.h,v $
6  *
7  * Purpose     :  Declares functions to parse/crunch headers and pages.
8  *
9  * Copyright   :  Written by and Copyright (C) 2001-2010 the
10  *                Privoxy team. https://www.privoxy.org/
11  *
12  *                Based on the Internet Junkbuster originally written
13  *                by and Copyright (C) 1997 Anonymous Coders and
14  *                Junkbusters Corporation.  http://www.junkbusters.com
15  *
16  *                This program is free software; you can redistribute it
17  *                and/or modify it under the terms of the GNU General
18  *                Public License as published by the Free Software
19  *                Foundation; either version 2 of the License, or (at
20  *                your option) any later version.
21  *
22  *                This program is distributed in the hope that it will
23  *                be useful, but WITHOUT ANY WARRANTY; without even the
24  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
25  *                PARTICULAR PURPOSE.  See the GNU General Public
26  *                License for more details.
27  *
28  *                The GNU General Public License should be included with
29  *                this file.  If not, you can view it at
30  *                http://www.gnu.org/copyleft/gpl.html
31  *                or write to the Free Software Foundation, Inc., 59
32  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
33  *
34  *********************************************************************/
35
36
37 #include "project.h"
38
39 /*
40  * ACL checking
41  */
42 #ifdef FEATURE_ACL
43 extern int block_acl(const struct access_control_addr *dst, const struct client_state *csp);
44 extern int acl_addr(const char *aspec, struct access_control_addr *aca);
45 #endif /* def FEATURE_ACL */
46
47 /*
48  * Interceptors
49  */
50 extern struct http_response *block_url(struct client_state *csp);
51 extern struct http_response *redirect_url(struct client_state *csp);
52 #ifdef FEATURE_TRUST
53 extern struct http_response *trust_url(struct client_state *csp);
54 #endif /* def FEATURE_TRUST */
55
56 /*
57  * Request inspectors
58  */
59 #ifdef FEATURE_TRUST
60 extern int is_untrusted_url(const struct client_state *csp);
61 #endif /* def FEATURE_TRUST */
62 #ifdef FEATURE_IMAGE_BLOCKING
63 extern int is_imageurl(const struct client_state *csp);
64 #endif /* def FEATURE_IMAGE_BLOCKING */
65 extern int connect_port_is_forbidden(const struct client_state *csp);
66
67 /*
68  * Determining applicable actions
69  */
70 extern void get_url_actions(struct client_state *csp,
71                             struct http_request *http);
72
73 extern struct re_filterfile_spec *get_filter(const struct client_state *csp,
74                                              const char *requested_name,
75                                              enum filter_type requested_type);
76
77 /*
78  * Determining parent proxies
79  */
80 extern const struct forward_spec *forward_url(struct client_state *csp,
81                                               const struct http_request *http);
82
83 /*
84  * Content modification
85  */
86 extern char *execute_content_filters(struct client_state *csp);
87 extern int execute_client_body_filters(struct client_state *csp, size_t *content_length);
88 extern jb_err execute_client_body_taggers(struct client_state *csp, size_t content_length);
89 extern char *execute_single_pcrs_command(char *subject, const char *pcrs_command, int *hits);
90 extern char *rewrite_url(char *old_url, const char *pcrs_command);
91
92 extern pcrs_job *compile_dynamic_pcrs_job_list(const struct client_state *csp, const struct re_filterfile_spec *b);
93
94 extern int content_requires_filtering(struct client_state *csp);
95 extern int content_filters_enabled(const struct current_action_spec *action);
96 extern int client_body_filters_enabled(const struct current_action_spec *action);
97 extern int client_body_taggers_enabled(const struct current_action_spec *action);
98 extern int filters_available(const struct client_state *csp);
99
100 /*
101  * Handling Max-Forwards:
102  */
103 extern struct http_response *direct_response(struct client_state *csp);
104
105 extern int get_bytes_missing_from_chunked_data(char *buffer, size_t size, size_t offset);
106 extern int chunked_data_is_complete(char *buffer, size_t size, size_t offset);
107
108 #ifdef FUZZ
109 extern char *gif_deanimate_response(struct client_state *csp);
110 extern jb_err remove_chunked_transfer_coding(char *buffer, size_t *size);
111 #endif
112
113 #ifdef FEATURE_EXTENDED_STATISTICS
114 extern void register_filter_for_statistics(const char *filter);
115 extern void update_filter_statistics(const char *filter, int hits);
116 extern void get_filter_statistics(const char *filter,
117                                   unsigned long long *executions,
118                                   unsigned long long *pages_modified,
119                                   unsigned long long *hits);
120
121 extern void register_block_reason_for_statistics(const char *block_reason);
122 extern void get_block_reason_count(const char *block_reason,
123                                    unsigned long long *count);
124 #endif
125
126 #endif /* ndef FILTERS_H_INCLUDED */
127
128 /*
129   Local Variables:
130   tab-width: 3
131   end:
132 */