Apache-ImageMagick
view release on metacpan or search on metacpan
mod_aimproxy.c view on Meta::CPAN
/*
##--------------------------------------------------------------------------
##
## Copyright (c) 2001 Gerald Richter / ecos gmbh www.ecos.de
##
## You may distribute under the terms of either the GNU General Public
## License or the Artistic License, as specified in the Perl README file.
##
## THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
## WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
## MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
##
## $Id: mod_aimproxy.c,v 1.1 2001/08/13 06:26:24 richter Exp $
##
##--------------------------------------------------------------------------
*/
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_request.h"
#include "util_md5.h"
static void *aimproxySrvConfig(pool *p, char *d) ;
static const char * aimproxyCmdCacheDir(cmd_parms *cmd, void *config, char *val) ;
static const char * aimproxyCmdProxyPass(cmd_parms *cmd, void *config, char *val1, char * val2) ;
static int aimproxyHandler (request_rec *r) ;
/* the table of commands we provide */
static const command_rec command_table[] = {
{ "AIMCacheDir", aimproxyCmdCacheDir, NULL, RSRC_CONF, TAKE1,
"Gives the cache directory for Apache::ImageMagick Proxy" },
{ "AIMProxyPassTo", aimproxyCmdProxyPass, NULL, RSRC_CONF, TAKE2,
"Gives the destination host for images not cached" },
};
/* the main config structure */
module MODULE_VAR_EXPORT aimproxy_module = {
STANDARD_MODULE_STUFF,
NULL, /* module initializer */
NULL, /* create per-dir config structures */
NULL, /* merge per-dir config structures */
aimproxySrvConfig, /* create per-server config structures */
NULL, /* merge per-server config structures */
command_table, /* table of config file commands */
NULL, /* [#8] MIME-typed-dispatched handlers */
NULL, /* [#1] URI to filename translation */
NULL, /* [#4] validate user id from request */
NULL, /* [#5] check if the user is ok _here_ */
NULL, /* [#3] check access by host address */
NULL, /* [#6] determine MIME type */
aimproxyHandler, /* [#7] pre-run fixups */
NULL, /* [#9] log a transaction */
NULL, /* [#2] header parser */
NULL, /* child_init */
NULL, /* child_exit */
NULL /* [#0] post read-request */
};
struct aimconfig
{
char * cachedir ;
array_header * pass ;
} ;
struct aimpass
{
char * proxysrc ;
int proxysrclen ;
char * proxyhost ;
} ;
typedef struct aimconfig aimconfig ;
typedef struct aimpass aimpass ;
static int aimproxyHandler (request_rec *r)
{
char * args ;
char * path_info ;
char * file ;
char * uri ;
char * md5 ;
char * ext ;
char * cachefn ;
char * cachedir ;
char * cachepath ;
aimconfig * c ;
struct stat finfo ;
int i, len;
int n ;
aimpass *ent ;
int found = 0 ;
char * proxyhost ;
if (r->proxyreq != NOT_PROXY)
{ /* someone has already set up the proxy */
return DECLINED ;
}
c = (aimconfig *) ap_get_module_config(r->server->module_config, &aimproxy_module);
ent = (aimpass *) c->pass->elts;
uri = r -> uri ;
n = c -> pass -> nelts ;
for (i = 0; i < n; i++)
{
( run in 1.260 second using v1.01-cache-2.11-cpan-39bf76dae61 )