reimplement uncompressed literal support
[httpd-crcsyncproxy.git] / crccache / mod_crccache_client.h
blob92b126cfe28bc7021eaf60df48e780aa3ffeb5a6
1 /*
2 * crccache.h
4 * Created on: 15/03/2009
5 * Author: awulms
6 */
8 #ifndef MOD_CRCCACHE_CLIENT_H
9 #define MOD_CRCCACHE_CLIENT_H
11 #include "cache/cache.h"
12 #include <zlib.h>
13 #include <openssl/evp.h>
14 #include <ap_config.h>
15 #include <http_config.h>
16 #include <apr-1.0/apr_optional.h>
18 extern module AP_MODULE_DECLARE_DATA crccache_client_module;
20 const char* cache_create_key( request_rec*r );
22 APR_DECLARE_OPTIONAL_FN(apr_status_t,
23 ap_cache_generate_key,
24 (request_rec *r, apr_pool_t*p, char**key ));
26 extern APR_OPTIONAL_FN_TYPE(ap_cache_generate_key) *cache_generate_key;
28 /* Forward declarations */
29 int remove_entity(cache_handle_t *h);
30 apr_status_t store_headers(cache_handle_t *h, request_rec *r,
31 cache_info *i);
32 apr_status_t store_body(cache_handle_t *h, request_rec *r,
33 apr_bucket_brigade *b);
34 apr_status_t recall_headers(cache_handle_t *h, request_rec *r);
35 apr_status_t recall_body(cache_handle_t *h, apr_pool_t *p,
36 apr_bucket_brigade *bb);
37 apr_status_t read_array(request_rec *r, apr_array_header_t* arr,
38 apr_file_t *file);
40 int remove_url(cache_handle_t *h, apr_pool_t *p);
41 int create_entity(cache_handle_t *h, request_rec *r, const char *key, apr_off_t len);
42 int open_entity(cache_handle_t *h, request_rec *r, const char *key);
44 // hashes per file
45 #define FULL_BLOCK_COUNT 40
47 typedef enum decoding_state {
48 DECODING_NEW_SECTION,
49 DECODING_COMPRESSED,
50 DECODING_LITERAL_BODY,
51 DECODING_LITERAL_SIZE,
52 DECODING_HASH,
53 DECODING_BLOCK_HEADER,
54 DECODING_BLOCK
55 } decoding_state;
57 typedef enum {
58 DECOMPRESSION_INITIALIZED,
59 DECOMPRESSION_ENDED
60 } decompression_state_t;
62 typedef struct crccache_client_ctx_t {
63 apr_bucket_brigade *bb;
64 size_t block_size;
65 size_t tail_block_size;
66 apr_bucket * cached_bucket;// original data so we can fill in the matched blocks
68 decoding_state state;
69 decompression_state_t decompression_state;
70 z_stream *decompression_stream;
71 int headers_checked;
72 EVP_MD_CTX mdctx;
73 unsigned char md_value_calc[EVP_MAX_MD_SIZE];
74 unsigned char md_value_rx[EVP_MAX_MD_SIZE];
75 unsigned rx_count;
76 unsigned literal_size;
77 unsigned char * partial_literal;// original data so we can fill in the matched blocks
78 } crccache_client_ctx;
80 struct cache_enable {
81 apr_uri_t url;
82 const char *type;
83 apr_size_t pathlen;
86 struct cache_disable {
87 apr_uri_t url;
88 apr_size_t pathlen;
91 /* static information about the local cache */
92 typedef struct {
93 // from mod cache
94 apr_array_header_t *cacheenable; /* URLs to cache */
95 apr_array_header_t *cachedisable; /* URLs not to cache */
96 /* Maximum time to keep cached files in msecs */
97 apr_time_t maxex;
98 int maxex_set;
99 /* default time to keep cached file in msecs */
100 apr_time_t defex;
101 int defex_set;
102 /* factor for estimating expires date */
103 double factor;
104 int factor_set;
105 /** ignore the last-modified header when deciding to cache this request */
106 int no_last_mod_ignore_set;
107 int no_last_mod_ignore;
108 /** ignore client's requests for uncached responses */
109 int ignorecachecontrol;
110 int ignorecachecontrol_set;
111 /** ignore Cache-Control: private header from server */
112 int store_private;
113 int store_private_set;
114 /** ignore Cache-Control: no-store header from client or server */
115 int store_nostore;
116 int store_nostore_set;
117 /** store the headers that should not be stored in the cache */
118 apr_array_header_t *ignore_headers;
119 /* flag if CacheIgnoreHeader has been set */
120 #define CACHE_IGNORE_HEADERS_SET 1
121 #define CACHE_IGNORE_HEADERS_UNSET 0
122 int ignore_headers_set;
123 /* Minimum time to keep cached files in msecs */
124 apr_time_t minex;
125 int minex_set;
126 /** ignore query-string when caching */
127 int ignorequerystring;
128 int ignorequerystring_set;
130 // from mod diskcache
131 const char* cache_root;
132 apr_size_t cache_root_len;
133 int dirlevels; /* Number of levels of subdirectories */
134 int dirlength; /* Length of subdirectory names */
135 apr_off_t minfs; /* minimum file size for cached files */
136 apr_off_t maxfs; /* maximum file size for cached files */
137 } crccache_client_conf;
139 #endif /*MOD_CRCCACHE_CLIENT_H*/