/usr/src/redhat/BUILD/httpd-2.2.3/modules/cache/mod_cache.h

説明を見る。
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00026 #ifndef MOD_CACHE_H
00027 #define MOD_CACHE_H 
00028 
00029 #define CORE_PRIVATE
00030 
00031 #include "apr_hooks.h"
00032 #include "apr.h"
00033 #include "apr_lib.h"
00034 #include "apr_strings.h"
00035 #include "apr_buckets.h"
00036 #include "apr_md5.h"
00037 #include "apr_pools.h"
00038 #include "apr_strings.h"
00039 #include "apr_optional.h"
00040 #define APR_WANT_STRFUNC
00041 #include "apr_want.h"
00042 
00043 #include "httpd.h"
00044 #include "http_config.h"
00045 #include "ap_config.h"
00046 #include "http_core.h"
00047 #include "http_protocol.h"
00048 #include "http_request.h"
00049 #include "http_vhost.h"
00050 #include "http_main.h"
00051 #include "http_log.h"
00052 #include "http_connection.h"
00053 #include "util_filter.h"
00054 #include "apr_date.h"
00055 #include "apr_uri.h"
00056 
00057 #ifdef HAVE_NETDB_H
00058 #include <netdb.h>
00059 #endif
00060 
00061 #ifdef HAVE_SYS_SOCKET_H
00062 #include <sys/socket.h>
00063 #endif
00064 
00065 #ifdef HAVE_NETINET_IN_H
00066 #include <netinet/in.h>
00067 #endif
00068 
00069 #ifdef HAVE_ARPA_INET_H
00070 #include <arpa/inet.h>
00071 #endif
00072 
00073 #include "apr_atomic.h"
00074 
00075 #ifndef MAX
00076 #define MAX(a,b)                ((a) > (b) ? (a) : (b))
00077 #endif
00078 #ifndef MIN
00079 #define MIN(a,b)                ((a) < (b) ? (a) : (b))
00080 #endif
00081 
00082 #define MSEC_ONE_DAY    ((apr_time_t)(86400*APR_USEC_PER_SEC)) /* one day, in microseconds */
00083 #define MSEC_ONE_HR     ((apr_time_t)(3600*APR_USEC_PER_SEC))  /* one hour, in microseconds */
00084 #define MSEC_ONE_MIN    ((apr_time_t)(60*APR_USEC_PER_SEC))    /* one minute, in microseconds */
00085 #define MSEC_ONE_SEC    ((apr_time_t)(APR_USEC_PER_SEC))       /* one second, in microseconds */
00086 #define DEFAULT_CACHE_MAXEXPIRE MSEC_ONE_DAY
00087 #define DEFAULT_CACHE_EXPIRE    MSEC_ONE_HR
00088 #define DEFAULT_CACHE_LMFACTOR  (0.1)
00089 
00090 /* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and 
00091  * PROXY_DECLARE_DATA with appropriate export and import tags for the platform
00092  */
00093 #if !defined(WIN32)
00094 #define CACHE_DECLARE(type)            type
00095 #define CACHE_DECLARE_NONSTD(type)     type
00096 #define CACHE_DECLARE_DATA
00097 #elif defined(CACHE_DECLARE_STATIC)
00098 #define CACHE_DECLARE(type)            type __stdcall
00099 #define CACHE_DECLARE_NONSTD(type)     type
00100 #define CACHE_DECLARE_DATA
00101 #elif defined(CACHE_DECLARE_EXPORT)
00102 #define CACHE_DECLARE(type)            __declspec(dllexport) type __stdcall
00103 #define CACHE_DECLARE_NONSTD(type)     __declspec(dllexport) type
00104 #define CACHE_DECLARE_DATA             __declspec(dllexport)
00105 #else
00106 #define CACHE_DECLARE(type)            __declspec(dllimport) type __stdcall
00107 #define CACHE_DECLARE_NONSTD(type)     __declspec(dllimport) type
00108 #define CACHE_DECLARE_DATA             __declspec(dllimport)
00109 #endif
00110 
00111 struct cache_enable {
00112     apr_uri_t url;
00113     const char *type;
00114     apr_size_t pathlen;
00115 };
00116 
00117 struct cache_disable {
00118     apr_uri_t url;
00119     apr_size_t pathlen;
00120 };
00121 
00122 /* static information about the local cache */
00123 typedef struct {
00124     apr_array_header_t *cacheenable;    /* URLs to cache */
00125     apr_array_header_t *cachedisable;   /* URLs not to cache */
00126     /* Maximum time to keep cached files in msecs */
00127     apr_time_t maxex;
00128     int maxex_set;
00129     /* default time to keep cached file in msecs */
00130     apr_time_t defex;
00131     int defex_set;
00132     /* factor for estimating expires date */
00133     double factor;
00134     int factor_set;
00136     int no_last_mod_ignore_set;
00137     int no_last_mod_ignore; 
00139     int ignorecachecontrol;
00140     int ignorecachecontrol_set;
00142     int store_private;
00143     int store_private_set;
00145     int store_nostore;
00146     int store_nostore_set;
00148     apr_array_header_t *ignore_headers;
00149     /* flag if CacheIgnoreHeader has been set */
00150     #define CACHE_IGNORE_HEADERS_SET   1
00151     #define CACHE_IGNORE_HEADERS_UNSET 0
00152     int ignore_headers_set;
00154     int ignorequerystring;
00155     int ignorequerystring_set;
00156 } cache_server_conf;
00157 
00158 /* cache info information */
00159 typedef struct cache_info cache_info;
00160 struct cache_info {
00161     int status;
00162     apr_time_t date;
00163     apr_time_t expire;
00164     apr_time_t request_time;
00165     apr_time_t response_time;
00166 };
00167 
00168 /* cache handle information */
00169 
00170 /* XXX TODO On the next structure change/MMN bump, 
00171  * count must become an apr_off_t, representing
00172  * the potential size of disk cached objects.
00173  * Then dig for
00174  * "XXX Bad Temporary Cast - see cache_object_t notes" 
00175  */
00176 typedef struct cache_object cache_object_t;
00177 struct cache_object {
00178     const char *key;
00179     cache_object_t *next;
00180     cache_info info;
00181     /* Opaque portion (specific to the implementation) of the cache object */
00182     void *vobj;
00183     /* FIXME: These are only required for mod_mem_cache. */
00184     apr_size_t count;   /* Number of body bytes written to the cache so far */
00185     int complete;
00186     apr_uint32_t refcount;  /* refcount and bit flag to cleanup object */
00187 };
00188 
00189 typedef struct cache_handle cache_handle_t;
00190 struct cache_handle {
00191     cache_object_t *cache_obj;
00192     apr_table_t *req_hdrs;        /* cached request headers */
00193     apr_table_t *resp_hdrs;       /* cached response headers */
00194 };
00195 
00196 #define CACHE_PROVIDER_GROUP "cache"
00197 
00198 typedef struct {
00199     int (*remove_entity) (cache_handle_t *h);
00200     apr_status_t (*store_headers)(cache_handle_t *h, request_rec *r, cache_info *i);
00201     apr_status_t (*store_body)(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b);
00202     apr_status_t (*recall_headers) (cache_handle_t *h, request_rec *r);
00203     apr_status_t (*recall_body) (cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); 
00204     int (*create_entity) (cache_handle_t *h, request_rec *r,
00205                            const char *urlkey, apr_off_t len);
00206     int (*open_entity) (cache_handle_t *h, request_rec *r,
00207                            const char *urlkey);
00208     int (*remove_url) (cache_handle_t *h, apr_pool_t *p);
00209 } cache_provider;
00210 
00211 /* A linked-list of authn providers. */
00212 typedef struct cache_provider_list cache_provider_list;
00213 
00214 struct cache_provider_list {
00215     const char *provider_name;
00216     const cache_provider *provider;
00217     cache_provider_list *next;
00218 };
00219 
00220 /* per request cache information */
00221 typedef struct {
00222     cache_provider_list *providers;     /* possible cache providers */
00223     const cache_provider *provider;     /* current cache provider */
00224     const char *provider_name;          /* current cache provider name */
00225     int fresh;                          /* is the entitey fresh? */
00226     cache_handle_t *handle;             /* current cache handle */
00227     cache_handle_t *stale_handle;       /* stale cache handle */
00228     apr_table_t *stale_headers;         /* original request headers. */
00229     int in_checked;                     /* CACHE_SAVE must cache the entity */
00230     int block_response;                 /* CACHE_SAVE must block response. */
00231     apr_bucket_brigade *saved_brigade;  /* copy of partial response */
00232     apr_off_t saved_size;               /* length of saved_brigade */
00233     apr_time_t exp;                     /* expiration */
00234     apr_time_t lastmod;                 /* last-modified time */
00235     cache_info *info;                   /* current cache info */
00236     ap_filter_t *remove_url_filter;     /* Enable us to remove the filter */
00237     char *key;                          /* The cache key created for this
00238                                          * request
00239                                          */
00240 } cache_request_rec;
00241 
00242 
00243 /* cache_util.c */
00244 /* do a HTTP/1.1 age calculation */
00245 CACHE_DECLARE(apr_time_t) ap_cache_current_age(cache_info *info, const apr_time_t age_value,
00246                                                apr_time_t now);
00247 
00254 CACHE_DECLARE(int) ap_cache_check_freshness(cache_handle_t *h, request_rec *r);
00255 
00263 CACHE_DECLARE(void) ap_cache_accept_headers(cache_handle_t *h, request_rec *r,
00264                                             int preserve_orig);
00265 
00266 CACHE_DECLARE(apr_time_t) ap_cache_hex2usec(const char *x);
00267 CACHE_DECLARE(void) ap_cache_usec2hex(apr_time_t j, char *y);
00268 CACHE_DECLARE(char *) ap_cache_generate_name(apr_pool_t *p, int dirlevels, 
00269                                              int dirlength, 
00270                                              const char *name);
00271 CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r, cache_server_conf *conf, apr_uri_t uri);
00272 CACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
00273                                     const char *key, char **val);
00274 CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list, const char **str);
00275 
00276 /* Create a new table consisting of those elements from a request_rec's
00277  * headers_out that are allowed to be stored in a cache
00278  */
00279 CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
00280                                                         apr_table_t *t,
00281                                                         server_rec *s);
00282 
00286 int cache_remove_url(cache_request_rec *cache, apr_pool_t *p);
00287 int cache_create_entity(request_rec *r, apr_off_t size);
00288 int cache_select(request_rec *r);
00289 apr_status_t cache_generate_key_default( request_rec *r, apr_pool_t*p, char**key );
00294 const char* cache_create_key( request_rec*r );
00295 
00296 /*
00297 apr_status_t cache_store_entity_headers(cache_handle_t *h, request_rec *r, cache_info *info);
00298 apr_status_t cache_store_entity_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *bb);
00299 
00300 apr_status_t cache_recall_entity_headers(cache_handle_t *h, request_rec *r);
00301 apr_status_t cache_recall_entity_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
00302 */
00303 
00304 /* hooks */
00305 
00306 /* Create a set of CACHE_DECLARE(type), CACHE_DECLARE_NONSTD(type) and 
00307  * CACHE_DECLARE_DATA with appropriate export and import tags for the platform
00308  */
00309 #if !defined(WIN32)
00310 #define CACHE_DECLARE(type)            type
00311 #define CACHE_DECLARE_NONSTD(type)     type
00312 #define CACHE_DECLARE_DATA
00313 #elif defined(CACHE_DECLARE_STATIC)
00314 #define CACHE_DECLARE(type)            type __stdcall
00315 #define CACHE_DECLARE_NONSTD(type)     type
00316 #define CACHE_DECLARE_DATA
00317 #elif defined(CACHE_DECLARE_EXPORT)
00318 #define CACHE_DECLARE(type)            __declspec(dllexport) type __stdcall
00319 #define CACHE_DECLARE_NONSTD(type)     __declspec(dllexport) type
00320 #define CACHE_DECLARE_DATA             __declspec(dllexport)
00321 #else
00322 #define CACHE_DECLARE(type)            __declspec(dllimport) type __stdcall
00323 #define CACHE_DECLARE_NONSTD(type)     __declspec(dllimport) type
00324 #define CACHE_DECLARE_DATA             __declspec(dllimport)
00325 #endif
00326 
00327 APR_DECLARE_OPTIONAL_FN(apr_status_t, 
00328                         ap_cache_generate_key, 
00329                         (request_rec *r, apr_pool_t*p, char**key ));
00330 
00331 
00332 #endif /*MOD_CACHE_H*/
00333 

Apacheに対してSun Jul 19 22:05:23 2009に生成されました。  doxygen 1.4.7