summaryrefslogtreecommitdiff
path: root/modules/experimental
diff options
context:
space:
mode:
Diffstat (limited to 'modules/experimental')
-rw-r--r--modules/experimental/.cvsignore11
-rw-r--r--modules/experimental/.indent.pro54
-rw-r--r--modules/experimental/Makefile.in3
-rw-r--r--modules/experimental/README41
-rw-r--r--modules/experimental/config.m414
-rw-r--r--modules/experimental/mod_cache.c124
-rw-r--r--modules/experimental/mod_cache.h65
-rw-r--r--modules/experimental/mod_case_filter.c113
-rw-r--r--modules/experimental/mod_charset_lite.c1142
-rw-r--r--modules/experimental/mod_disk_cache.c170
-rw-r--r--modules/experimental/mod_example.c1198
-rw-r--r--modules/experimental/mod_ext_filter.c793
-rw-r--r--modules/experimental/mod_generic_hook_export.c82
-rw-r--r--modules/experimental/mod_generic_hook_export.dsp95
-rw-r--r--modules/experimental/mod_generic_hook_export.h62
-rw-r--r--modules/experimental/mod_generic_hook_import.c83
-rw-r--r--modules/experimental/mod_generic_hook_import.dsp95
-rw-r--r--modules/experimental/mod_optional_fn_export.c86
-rw-r--r--modules/experimental/mod_optional_fn_export.h3
-rw-r--r--modules/experimental/mod_optional_fn_import.c93
20 files changed, 0 insertions, 4327 deletions
diff --git a/modules/experimental/.cvsignore b/modules/experimental/.cvsignore
deleted file mode 100644
index 15cf55fd3f..0000000000
--- a/modules/experimental/.cvsignore
+++ /dev/null
@@ -1,11 +0,0 @@
-.deps
-.libs
-*.la
-modules.mk
-Makefile
-*.lo
-*.slo
-*.so
-Debug
-Release
-*.plg
diff --git a/modules/experimental/.indent.pro b/modules/experimental/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/experimental/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/experimental/Makefile.in b/modules/experimental/Makefile.in
deleted file mode 100644
index 7c5c149d85..0000000000
--- a/modules/experimental/Makefile.in
+++ /dev/null
@@ -1,3 +0,0 @@
-# a modules Makefile has no explicit targets -- they will be defined by
-# whatever modules are enabled. just grab special.mk to deal with this.
-include $(top_srcdir)/build/special.mk
diff --git a/modules/experimental/README b/modules/experimental/README
deleted file mode 100644
index 1d80fa5855..0000000000
--- a/modules/experimental/README
+++ /dev/null
@@ -1,41 +0,0 @@
-README for Apache 2.0 Example Module
-[April, 1997, updated May 2000]
-
-The files in the src/modules/example directory under the Apache
-distribution directory tree are provided as an example to those that
-wish to write modules that use the Apache API.
-
-The main file is mod_example.c, which illustrates all the different
-callback mechanisms and call syntaces. By no means does an add-on
-module need to include routines for all of the callbacks - quite the
-contrary!
-
-The example module is an actual working module. If you link it into
-your server, enable the "example-handler" handler for a location, and then
-browse to that location, you will see a display of some of the tracing
-the example module did as the various callbacks were made.
-
-To include the example module in your server run `./configure
---enable-example` in the src directory before running `make`.
-
-To add another module of your own:
-
- A. mkdir src/modules/mymodule
- B. cp src/modules/example/* src/modules/mymodule
- C. Modify the files in the new directory
- D. Build the server as above, with appropriate changes.
-
-To activate the example module, include a block similar to the
-following in your httpd.conf file:
-
- <Location /example-info>
- SetHandler example-handler
- </Location>
-
-As an alternative, you can put the following into a .htaccess file and
-then request the file "test.example" from that location:
-
- AddHandler example-handler .example
-
-After reloading/restarting your server, you should be able to browse
-to this location and see the brief display mentioned earlier.
diff --git a/modules/experimental/config.m4 b/modules/experimental/config.m4
deleted file mode 100644
index 975e9d8329..0000000000
--- a/modules/experimental/config.m4
+++ /dev/null
@@ -1,14 +0,0 @@
-
-APACHE_MODPATH_INIT(experimental)
-
-APACHE_MODULE(charset_lite, character set translation, , , no)
-APACHE_MODULE(cache, dynamic file caching, , , no)
-APACHE_MODULE(disk_cache, disk caching module, , , no)
-APACHE_MODULE(ext_filter, external filter module, , , no)
-APACHE_MODULE(case_filter, example uppercase conversion filter, , , no)
-APACHE_MODULE(generic_hook_export, example hook exporter, , , no)
-APACHE_MODULE(generic_hook_import, example hook importer, , , no)
-APACHE_MODULE(optional_fn_import, example optional function importer, , , no)
-APACHE_MODULE(optional_fn_export, example optional function exporter, , , no)
-
-APACHE_MODPATH_FINISH
diff --git a/modules/experimental/mod_cache.c b/modules/experimental/mod_cache.c
deleted file mode 100644
index 49871abe58..0000000000
--- a/modules/experimental/mod_cache.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-#include "apr_strings.h"
-#include "ap_config.h"
-#include "util_filter.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "util_script.h"
-#include "http_core.h"
-#include "mod_cache.h"
-#include "apr_hooks.h"
-
-module AP_DECLARE_DATA cache_module;
-
-APR_HOOK_STRUCT(
- APR_HOOK_LINK(serve_cache)
- APR_HOOK_LINK(store_cache)
-)
-
-AP_IMPLEMENT_HOOK_RUN_FIRST(int,serve_cache,(request_rec *r),(r),DECLINED)
-AP_IMPLEMENT_HOOK_RUN_FIRST(int,store_cache,(request_rec *r, apr_bucket_brigade *bb, void **cf),
- (r, bb, cf),DECLINED)
-
-static int cache_handler(request_rec *r)
-{
- /* I am sure there is common error checking that belongs in this function,
- * but I'm not sure what it is.
- */
- return ap_run_serve_cache(r);
-}
-
-typedef struct cache_struct {
- void *cf;
-} cache_struct;
-
-static int cache_filter(ap_filter_t *f, apr_bucket_brigade *bb)
-{
- cache_struct *ctx = f->ctx;
-
- if (ctx == NULL) {
- f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx));
- }
-
- ap_run_store_cache(f->r, bb, &ctx->cf);
- ap_pass_brigade(f->next, bb);
- return APR_SUCCESS;
-}
-
-static void cache_register_hook(apr_pool_t *p)
-{
- ap_hook_handler(cache_handler, NULL, NULL, APR_HOOK_MIDDLE);
- ap_register_output_filter("CACHE", cache_filter, AP_FTYPE_HTTP_HEADER);
-}
-
-module AP_DECLARE_DATA cache_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- NULL, /* command apr_table_t */
- cache_register_hook /* register hooks */
-};
diff --git a/modules/experimental/mod_cache.h b/modules/experimental/mod_cache.h
deleted file mode 100644
index 7f2cf9b0c1..0000000000
--- a/modules/experimental/mod_cache.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-#include "apr_buckets.h"
-#include "apr_hooks.h"
-#include "httpd.h"
-
-AP_DECLARE_HOOK(int,serve_cache,(request_rec *r));
-AP_DECLARE_HOOK(int,store_cache,(request_rec *r, apr_bucket_brigade *bb, void **cf));
-
diff --git a/modules/experimental/mod_case_filter.c b/modules/experimental/mod_case_filter.c
deleted file mode 100644
index bb59985ae4..0000000000
--- a/modules/experimental/mod_case_filter.c
+++ /dev/null
@@ -1,113 +0,0 @@
-// Ben messing around...
-
-#include "httpd.h"
-#include "http_config.h"
-#include "apr_general.h"
-#include "util_filter.h"
-#include "apr_buckets.h"
-#include "http_request.h"
-
-static const char s_szCaseFilterName[]="CaseFilter";
-module case_filter_module;
-
-typedef struct
- {
- int bEnabled;
- } CaseFilterConfig;
-
-static void *CaseFilterCreateServerConfig(apr_pool_t *p,server_rec *s)
- {
- CaseFilterConfig *pConfig=apr_pcalloc(p,sizeof *pConfig);
-
- pConfig->bEnabled=0;
-
- return pConfig;
- }
-
-static void CaseFilterInsertFilter(request_rec *r)
- {
- CaseFilterConfig *pConfig=ap_get_module_config(r->server->module_config,
- &case_filter_module);
-
- if(!pConfig->bEnabled)
- return;
-
- ap_add_output_filter(s_szCaseFilterName,NULL,r,r->connection);
- }
-
-static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
- apr_bucket_brigade *pbbIn)
- {
- apr_bucket *pbktIn;
- apr_bucket_brigade *pbbOut;
-
- // XXX: is this the most appropriate pool?
- pbbOut=apr_brigade_create(f->r->pool);
- APR_BRIGADE_FOREACH(pbktIn,pbbIn)
- {
- const char *data;
- apr_size_t len;
- char *buf;
- apr_size_t n;
- apr_bucket *pbktOut;
-
- if(APR_BUCKET_IS_EOS(pbktIn))
- {
- // XXX: why can't I reuse pbktIn???
- apr_bucket *pbktEOS=apr_bucket_eos_create();
- APR_BRIGADE_INSERT_TAIL(pbbOut,pbktEOS);
- break;
- }
-
- // read
- apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ);
-
- // write
- buf=apr_palloc(f->r->pool,len);
- for(n=0 ; n < len ; ++n)
- buf[n]=toupper(data[n]);
-
- // XXX: should we use a heap bucket instead? Or a transient (in
- // which case we need a separate brigade for each bucket)?
- pbktOut=apr_bucket_pool_create(buf,len,f->r->pool);
- APR_BRIGADE_INSERT_TAIL(pbbOut,pbktOut);
- }
-
- // XXX: is there any advantage to passing a brigade for each bucket?
- return ap_pass_brigade(f->next,pbbOut);
- }
-
-static const char *CaseFilterEnable(cmd_parms *cmd, void *dummy, int arg)
- {
- CaseFilterConfig *pConfig=ap_get_module_config(cmd->server->module_config,
- &case_filter_module);
- pConfig->bEnabled=arg;
-
- return NULL;
- }
-
-static const command_rec CaseFilterCmds[] =
- {
- AP_INIT_FLAG("CaseFilter", CaseFilterEnable, NULL, RSRC_CONF,
- "Run a case filter on this host"),
- { NULL }
- };
-
-static void CaseFilterRegisterHooks(void)
- {
- ap_hook_insert_filter(CaseFilterInsertFilter,NULL,NULL,APR_HOOK_MIDDLE);
- ap_register_output_filter(s_szCaseFilterName,CaseFilterOutFilter,
- AP_FTYPE_CONTENT);
- }
-
-module case_filter_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL,
- NULL,
- CaseFilterCreateServerConfig,
- NULL,
- CaseFilterCmds,
- NULL,
- CaseFilterRegisterHooks
-};
diff --git a/modules/experimental/mod_charset_lite.c b/modules/experimental/mod_charset_lite.c
deleted file mode 100644
index 79830eed08..0000000000
--- a/modules/experimental/mod_charset_lite.c
+++ /dev/null
@@ -1,1142 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-/*
- * simple hokey charset recoding configuration module
- *
- * See mod_ebcdic and mod_charset for more thought-out examples. This
- * one is just so Jeff can learn how a module works and experiment with
- * basic character set recoding configuration.
- *
- * !!!This is an extremely cheap ripoff of mod_charset.c from Russian Apache!!!
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#define CORE_PRIVATE
-#include "http_core.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "util_charset.h"
-#include "apr_buckets.h"
-#include "util_filter.h"
-#include "apr_strings.h"
-#include "apr_lib.h"
-#define APR_WANT_STRFUNC
-#include "apr_want.h"
-
-#ifndef APACHE_XLATE
-#error mod_charset_lite cannot work without APACHE_XLATE enabled
-#endif
-
-#define OUTPUT_XLATE_BUF_SIZE (16*1024) /* size of translation buffer used on output */
-#define INPUT_XLATE_BUF_SIZE (8*1024) /* size of translation buffer used on input */
-
-/* XXX this works around an issue with the heap bucket: apr_bucket_heap_create will
- * copy only the first 4096 bytes
- */
-#undef INPUT_XLATE_BUF_SIZE /* XXX */
-#define INPUT_XLATE_BUF_SIZE (4096) /* XXX must match DEFAULT_BUCKET_SIZE */
-
-#define XLATE_MIN_BUFF_LEFT 128 /* flush once there is no more than this much
- * space is left in the translation buffer
- */
-
-#define FATTEST_CHAR 8 /* we don't handle chars wider than this that straddle
- * two buckets
- */
-
-/* extended error status codes; this is used in addition to an apr_status_t to
- * track errors in the translation filter
- */
-typedef enum {
- EES_INIT = 0, /* no error info yet; value must be 0 for easy init */
- EES_LIMIT, /* built-in restriction encountered */
- EES_INCOMPLETE_CHAR, /* incomplete multi-byte char at end of content */
- EES_BUCKET_READ,
- EES_DOWNSTREAM, /* something bad happened in a filter below xlate */
- EES_BAD_INPUT /* input data invalid */
-} ees_t;
-
-/* registered name of the output translation filter */
-#define XLATEOUT_FILTER_NAME "XLATEOUT"
-/* registered name of input translation filter */
-#define XLATEIN_FILTER_NAME "XLATEIN"
-
-typedef struct charset_dir_t {
- /** debug level; -1 means uninitialized, 0 means no debug */
- int debug;
- const char *charset_source; /* source encoding */
- const char *charset_default; /* how to ship on wire */
- /** module does ap_add_*_filter()? */
- enum {IA_INIT, IA_IMPADD, IA_NOIMPADD} implicit_add;
-} charset_dir_t;
-
-/* charset_filter_ctx_t is created for each filter instance; because the same
- * filter code is used for translating in both directions, we need this context
- * data to tell the filter which translation handle to use; it also can hold a
- * character which was split between buckets
- */
-typedef struct charset_filter_ctx_t {
- apr_xlate_t *xlate;
- charset_dir_t *dc;
- ees_t ees; /* extended error status */
- apr_size_t saved;
- char buf[FATTEST_CHAR]; /* we want to be able to build a complete char here */
- int ran; /* has filter instance run before? */
- int noop; /* should we pass brigades through unchanged? */
- char *tmp; /* buffer for input filtering */
- apr_bucket_brigade *bb; /* input buckets we couldn't finish translating */
-} charset_filter_ctx_t;
-
-/* charset_req_t is available via r->request_config if any translation is
- * being performed
- */
-typedef struct charset_req_t {
- charset_dir_t *dc;
- charset_filter_ctx_t *output_ctx, *input_ctx;
-} charset_req_t;
-
-/* debug level definitions */
-#define DBGLVL_GORY 9 /* gory details */
-#define DBGLVL_FLOW 4 /* enough messages to see what happens on
- * each request */
-#define DBGLVL_PMC 2 /* messages about possible misconfiguration */
-
-module charset_lite_module;
-
-static void *create_charset_dir_conf(apr_pool_t *p,char *dummy)
-{
- charset_dir_t *dc = (charset_dir_t *)apr_pcalloc(p,sizeof(charset_dir_t));
-
- dc->debug = -1;
- return dc;
-}
-
-static void *merge_charset_dir_conf(apr_pool_t *p, void *basev, void *overridesv)
-{
- charset_dir_t *a = (charset_dir_t *)apr_pcalloc (p, sizeof(charset_dir_t));
- charset_dir_t *base = (charset_dir_t *)basev,
- *over = (charset_dir_t *)overridesv;
-
- /* If it is defined in the current container, use it. Otherwise, use the one
- * from the enclosing container.
- */
-
- a->debug =
- over->debug != -1 ? over->debug : base->debug;
- a->charset_default =
- over->charset_default ? over->charset_default : base->charset_default;
- a->charset_source =
- over->charset_source ? over->charset_source : base->charset_source;
- a->implicit_add =
- over->implicit_add != IA_INIT ? over->implicit_add : base->implicit_add;
- return a;
-}
-
-/* CharsetSourceEnc charset
- */
-static const char *add_charset_source(cmd_parms *cmd, void *in_dc,
- const char *name)
-{
- charset_dir_t *dc = in_dc;
-
- dc->charset_source = name;
- return NULL;
-}
-
-/* CharsetDefault charset
- */
-static const char *add_charset_default(cmd_parms *cmd, void *in_dc,
- const char *name)
-{
- charset_dir_t *dc = in_dc;
-
- dc->charset_default = name;
- return NULL;
-}
-
-/* CharsetOptions optionflag...
- */
-static const char *add_charset_options(cmd_parms *cmd, void *in_dc,
- const char *flag)
-{
- charset_dir_t *dc = in_dc;
-
- if (!strcasecmp(flag, "ImplicitAdd")) {
- dc->implicit_add = IA_IMPADD;
- }
- else if (!strcasecmp(flag, "NoImplicitAdd")) {
- dc->implicit_add = IA_NOIMPADD;
- }
- else if (!strncasecmp(flag, "DebugLevel=", 11)) {
- dc->debug = atoi(flag + 11);
- }
- else {
- return apr_pstrcat(cmd->temp_pool,
- "Invalid CharsetOptions option: ",
- flag,
- NULL);
- }
-
- return NULL;
-}
-
-/* find_code_page() is a fixup hook that decides if translation should be
- * enabled; if so, it sets up request data for use by the filter registration
- * hook so that it knows what to do
- */
-static int find_code_page(request_rec *r)
-{
- charset_dir_t *dc = ap_get_module_config(r->per_dir_config,
- &charset_lite_module);
- charset_req_t *reqinfo;
- charset_filter_ctx_t *input_ctx, *output_ctx;
- apr_status_t rv;
- const char *mime_type;
-
- if (dc->debug >= DBGLVL_FLOW) {
- ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO, 0, r,
- "uri: %s file: %s method: %d "
- "imt: %s flags: %s%s%s %s->%s",
- r->uri, r->filename, r->method_number,
- r->content_type ? r->content_type : "(unknown)",
- r->main ? "S" : "", /* S if subrequest */
- r->prev ? "R" : "", /* R if redirect */
- r->proxyreq ? "P" : "", /* P if proxy */
- dc->charset_source, dc->charset_default);
- }
-
- /* If we don't have a full directory configuration, bail out.
- */
- if (!dc->charset_source || !dc->charset_default) {
- if (dc->debug >= DBGLVL_PMC) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
- "incomplete configuration: src %s, dst %s",
- dc->charset_source ? dc->charset_source : "unspecified",
- dc->charset_default ? dc->charset_default : "unspecified");
- }
- return DECLINED;
- }
-
- /* catch proxy requests */
- if (r->proxyreq) return DECLINED;
- /* mod_rewrite indicators */
- if (!strncmp(r->filename, "redirect:", 9)) return DECLINED;
- if (!strncmp(r->filename, "gone:", 5)) return DECLINED;
- if (!strncmp(r->filename, "passthrough:", 12)) return DECLINED;
- if (!strncmp(r->filename, "forbidden:", 10)) return DECLINED;
-
- mime_type = r->content_type ? r->content_type : ap_default_type(r);
-
- /* If mime type isn't text or message, bail out.
- */
-
-/* XXX When we handle translation of the request body, watch out here as
- * 1.3 allowed additional mime types: multipart and
- * application/x-www-form-urlencoded
- */
-
- if (strncasecmp(mime_type, "text/", 5) &&
-#if APR_CHARSET_EBCDIC
- /* On an EBCDIC machine, be willing to translate mod_autoindex-
- * generated output. Otherwise, it doesn't look too cool.
- *
- * XXX This isn't a perfect fix because this doesn't trigger us
- * to convert from the charset of the source code to ASCII. The
- * general solution seems to be to allow a generator to set an
- * indicator in the r specifying that the body is coded in the
- * implementation character set (i.e., the charset of the source
- * code). This would get several different types of documents
- * translated properly: mod_autoindex output, mod_status output,
- * mod_info output, hard-coded error documents, etc.
- */
- strcmp(mime_type, DIR_MAGIC_TYPE) &&
-#endif
- strncasecmp(mime_type, "message/", 8)) {
- if (dc->debug >= DBGLVL_GORY) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
- "mime type is %s; no translation selected",
- mime_type);
- }
- return DECLINED;
- }
-
- if (dc->debug >= DBGLVL_GORY) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
- "charset_source: %s charset_default: %s",
- dc && dc->charset_source ? dc->charset_source : "(none)",
- dc && dc->charset_default ? dc->charset_default : "(none)");
- }
-
- /* Get storage for the request data and the output filter context.
- * We rarely need the input filter context, so allocate that separately.
- */
- reqinfo = (charset_req_t *)apr_pcalloc(r->pool,
- sizeof(charset_req_t) +
- sizeof(charset_filter_ctx_t));
- output_ctx = (charset_filter_ctx_t *)(reqinfo + 1);
-
- reqinfo->dc = dc;
- output_ctx->dc = dc;
- ap_set_module_config(r->request_config, &charset_lite_module, reqinfo);
-
- reqinfo->output_ctx = output_ctx;
- rv = apr_xlate_open(&output_ctx->xlate,
- dc->charset_default, dc->charset_source, r->pool);
- if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "can't open translation %s->%s",
- dc->charset_source, dc->charset_default);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- switch (r->method_number) {
- case M_PUT:
- case M_POST:
- /* Set up input translation. Note: A request body can be included
- * with the OPTIONS method, but for now we don't set up translation
- * of it.
- */
- input_ctx = apr_pcalloc(r->pool, sizeof(charset_filter_ctx_t));
- input_ctx->bb = apr_brigade_create(r->pool);
- input_ctx->tmp = apr_palloc(r->pool, INPUT_XLATE_BUF_SIZE);
- input_ctx->dc = dc;
- reqinfo->input_ctx = input_ctx;
- rv = apr_xlate_open(&input_ctx->xlate, dc->charset_source,
- dc->charset_default, r->pool);
- if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "can't open translation %s->%s",
- dc->charset_default, dc->charset_source);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- }
-
- return DECLINED;
-}
-
-static int configured_on_input(request_rec *r, const char *filter_name)
-{
- int i;
- core_dir_config *conf =
- (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
- char **items = (char **)conf->input_filters->elts;
-
- for (i = 0; i < conf->input_filters->nelts; i++) {
- if (!strcmp(items[i], filter_name))
- return 1;
- }
- return 0;
-}
-
-static int configured_on_output(request_rec *r, const char *filter_name)
-{
- int i;
- core_dir_config *conf =
- (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
- char **items = (char **)conf->output_filters->elts;
-
- for (i = 0; i < conf->output_filters->nelts; i++) {
- if (!strcmp(items[i], filter_name))
- return 1;
- }
- return 0;
-}
-
-/* xlate_insert_filter() is a filter hook which decides whether or not
- * to insert a translation filter for the current request.
- */
-static void xlate_insert_filter(request_rec *r)
-{
- /* Hey... don't be so quick to use reqinfo->dc here; reqinfo may be NULL */
- charset_req_t *reqinfo = ap_get_module_config(r->request_config,
- &charset_lite_module);
- charset_dir_t *dc = ap_get_module_config(r->per_dir_config,
- &charset_lite_module);
-
- if (reqinfo) {
- if (reqinfo->output_ctx && !configured_on_output(r, XLATEOUT_FILTER_NAME)) {
- ap_add_output_filter(XLATEOUT_FILTER_NAME, reqinfo->output_ctx, r,
- r->connection);
- }
- else if (dc->debug >= DBGLVL_FLOW) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
- "xlate output filter not added implicitly because %s",
- !reqinfo->output_ctx ?
- "no output configuration available" :
- "SetOutputFilter was used to add the filter");
- }
-
- if (reqinfo->input_ctx && !configured_on_input(r, XLATEIN_FILTER_NAME)) {
- ap_add_input_filter(XLATEIN_FILTER_NAME, reqinfo->input_ctx, r,
- r->connection);
- }
- else if (dc->debug >= DBGLVL_FLOW) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
- "xlate input filter not added implicitly because %s",
- !reqinfo->input_ctx ?
- "no input configuration available" :
- "SetInputFilter was used to add the filter");
- }
- }
-}
-
-/* stuff that sucks that I know of:
- *
- * bucket handling:
- * why create an eos bucket when we see it come down the stream? just send the one
- * passed as input... news flash: this will be fixed when xlate_out_filter() starts
- * using the more generic xlate_brigade()
- *
- * translation mechanics:
- * we don't handle characters that straddle more than two buckets; an error
- * will be generated
- */
-
-/* send_downstream() is passed the translated data; it puts it in a single-
- * bucket brigade and passes the brigade to the next filter
- */
-static apr_status_t send_downstream(ap_filter_t *f, const char *tmp, apr_size_t len)
-{
- apr_bucket_brigade *bb;
- apr_bucket *b;
- charset_filter_ctx_t *ctx = f->ctx;
- apr_status_t rv;
-
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_transient_create(tmp, len);
- APR_BRIGADE_INSERT_TAIL(bb, b);
- rv = ap_pass_brigade(f->next, bb);
- if (rv != APR_SUCCESS) {
- ctx->ees = EES_DOWNSTREAM;
- }
- return rv;
-}
-
-static apr_status_t send_eos(ap_filter_t *f)
-{
- apr_bucket_brigade *bb;
- apr_bucket *b;
- charset_filter_ctx_t *ctx = f->ctx;
- apr_status_t rv;
-
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_eos_create();
- APR_BRIGADE_INSERT_TAIL(bb, b);
- rv = ap_pass_brigade(f->next, bb);
- if (rv != APR_SUCCESS) {
- ctx->ees = EES_DOWNSTREAM;
- }
- return rv;
-}
-
-static apr_status_t set_aside_partial_char(charset_filter_ctx_t *ctx,
- const char *partial,
- apr_size_t partial_len)
-{
- apr_status_t rv;
-
- if (sizeof(ctx->buf) > partial_len) {
- ctx->saved = partial_len;
- memcpy(ctx->buf, partial, partial_len);
- rv = APR_SUCCESS;
- }
- else {
- rv = APR_INCOMPLETE;
- ctx->ees = EES_LIMIT; /* we don't handle chars this wide which straddle
- * buckets
- */
- }
- return rv;
-}
-
-static apr_status_t finish_partial_char(charset_filter_ctx_t *ctx,
- /* input buffer: */
- const char **cur_str,
- apr_size_t *cur_len,
- /* output buffer: */
- char **out_str,
- apr_size_t *out_len)
-{
- apr_status_t rv;
- apr_size_t tmp_input_len;
-
- /* Keep adding bytes from the input string to the saved string until we
- * 1) finish the input char
- * 2) get an error
- * or 3) run out of bytes to add
- */
-
- do {
- ctx->buf[ctx->saved] = **cur_str;
- ++ctx->saved;
- ++*cur_str;
- --*cur_len;
- tmp_input_len = ctx->saved;
- rv = apr_xlate_conv_buffer(ctx->xlate,
- ctx->buf,
- &tmp_input_len,
- *out_str,
- out_len);
- } while (rv == APR_INCOMPLETE && *cur_len);
-
- if (rv == APR_SUCCESS) {
- ctx->saved = 0;
- }
- else {
- ctx->ees = EES_LIMIT; /* code isn't smart enough to handle chars
- * straddling more than two buckets
- */
- }
-
- return rv;
-}
-
-static void log_xlate_error(ap_filter_t *f, apr_status_t rv)
-{
- charset_filter_ctx_t *ctx = f->ctx;
- const char *msg;
- char msgbuf[100];
- int cur;
- int flags = APLOG_ERR;
-
- switch(ctx->ees) {
- case EES_LIMIT:
- flags |= APLOG_NOERRNO;
- msg = "xlate filter - a built-in restriction was encountered";
- break;
- case EES_BAD_INPUT:
- flags |= APLOG_NOERRNO;
- msg = "xlate filter - an input character was invalid";
- break;
- case EES_BUCKET_READ:
- msg = "xlate filter - bucket read routine failed";
- break;
- case EES_INCOMPLETE_CHAR:
- flags |= APLOG_NOERRNO;
- strcpy(msgbuf, "xlate filter - incomplete char at end of input - ");
- cur = 0;
- while (cur < ctx->saved) {
- apr_snprintf(msgbuf + strlen(msgbuf), sizeof(msgbuf) - strlen(msgbuf),
- "%02X", (unsigned)ctx->buf[cur]);
- ++cur;
- }
- msg = msgbuf;
- break;
- case EES_DOWNSTREAM:
- msg = "xlate filter - an error occurred in a lower filter";
- break;
- default:
- msg = "xlate filter - returning error";
- }
- ap_log_rerror(APLOG_MARK, flags, rv, f->r,
- "%s", msg);
-}
-
-/* chk_filter_chain() is called once per filter instance; it tries to
- * determine if the current filter instance should be disabled because
- * its translation is incompatible with the translation of an existing
- * instance of the translate filter
- *
- * Example bad scenario:
- *
- * configured filter chain for the request:
- * INCLUDES XLATEOUT(8859-1->UTS-16)
- * configured filter chain for the subrequest:
- * XLATEOUT(8859-1->UTS-16)
- *
- * When the subrequest is processed, the filter chain will be
- * XLATEOUT(8859-1->UTS-16) XLATEOUT(8859-1->UTS-16)
- * This makes no sense, so the instance of XLATEOUT added for the
- * subrequest will be noop-ed.
- *
- * Example good scenario:
- *
- * configured filter chain for the request:
- * INCLUDES XLATEOUT(8859-1->UTS-16)
- * configured filter chain for the subrequest:
- * XLATEOUT(IBM-1047->8859-1)
- *
- * When the subrequest is processed, the filter chain will be
- * XLATEOUT(IBM-1047->8859-1) XLATEOUT(8859-1->UTS-16)
- * This makes sense, so the instance of XLATEOUT added for the
- * subrequest will be left alone and it will translate from
- * IBM-1047->8859-1.
- */
-static void chk_filter_chain(ap_filter_t *f)
-{
- ap_filter_t *curf;
- charset_filter_ctx_t *curctx, *last_xlate_ctx = NULL,
- *ctx = f->ctx;
- int debug = ctx->dc->debug;
- int output = !strcmp(f->frec->name, XLATEOUT_FILTER_NAME);
-
- if (ctx->noop) {
- return;
- }
-
- /* walk the filter chain; see if it makes sense for our filter to
- * do any translation
- */
- curf = output ? f->r->output_filters : f->r->input_filters;
- while (curf) {
- if (!strcmp(curf->frec->name, f->frec->name) &&
- curf->ctx) {
- curctx = (charset_filter_ctx_t *)curf->ctx;
- if (!last_xlate_ctx) {
- last_xlate_ctx = curctx;
- }
- else {
- if (strcmp(last_xlate_ctx->dc->charset_default,
- curctx->dc->charset_source)) {
- /* incompatible translation
- * if our filter instance is incompatible with an instance
- * already in place, noop our instance
- * Notes:
- * . We are only willing to noop our own instance.
- * . It is possible to noop another instance which has not
- * yet run, but this is not currently implemented.
- * Hopefully it will not be needed.
- * . It is not possible to noop an instance which has
- * already run.
- */
- if (last_xlate_ctx == f->ctx) {
- last_xlate_ctx->noop = 1;
- if (debug >= DBGLVL_PMC) {
- const char *symbol = output ? "->" : "<-";
-
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO,
- 0, f->r,
- "%s %s - disabling "
- "translation %s%s%s; existing "
- "translation %s%s%s",
- f->r->uri ? "uri" : "file",
- f->r->uri ? f->r->uri : f->r->filename,
- last_xlate_ctx->dc->charset_source,
- symbol,
- last_xlate_ctx->dc->charset_default,
- curctx->dc->charset_source,
- symbol,
- curctx->dc->charset_default);
- }
- }
- else {
- const char *symbol = output ? "->" : "<-";
-
- ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO,
- 0, f->r,
- "chk_filter_chain() - can't disable "
- "translation %s%s%s; existing "
- "translation %s%s%s",
- last_xlate_ctx->dc->charset_source,
- symbol,
- last_xlate_ctx->dc->charset_default,
- curctx->dc->charset_source,
- symbol,
- curctx->dc->charset_default);
- }
- break;
- }
- }
- }
- curf = curf->next;
- }
-}
-
-/* xlate_brigade() is used to filter request and response bodies
- *
- * we'll stop when one of the following occurs:
- * . we run out of buckets
- * . we run out of space in the output buffer
- * . we hit an error
- *
- * inputs:
- * bb: brigade to process
- * buffer: storage to hold the translated characters
- * buffer_size: size of buffer
- * (and a few more uninteresting parms)
- *
- * outputs:
- * return value: APR_SUCCESS or some error code
- * bb: we've removed any buckets representing the
- * translated characters; the eos bucket, if
- * present, will be left in the brigade
- * buffer: filled in with translated characters
- * buffer_size: updated with the bytes remaining
- * hit_eos: did we hit an EOS bucket?
- */
-static apr_status_t xlate_brigade(charset_filter_ctx_t *ctx,
- apr_bucket_brigade *bb,
- char *buffer,
- apr_size_t *buffer_avail,
- int *hit_eos)
-{
- apr_bucket *b, *consumed_bucket;
- const char *bucket;
- apr_size_t bytes_in_bucket; /* total bytes read from current bucket */
- apr_size_t bucket_avail; /* bytes left in current bucket */
- apr_status_t rv = APR_SUCCESS;
-
- *hit_eos = 0;
- bucket_avail = 0;
- consumed_bucket = NULL;
- while (1) {
- if (!bucket_avail) { /* no bytes left to process in the current bucket... */
- if (consumed_bucket) {
- apr_bucket_delete(consumed_bucket);
- consumed_bucket = NULL;
- }
- b = APR_BRIGADE_FIRST(bb);
- if (b == APR_BRIGADE_SENTINEL(bb) ||
- APR_BUCKET_IS_EOS(b)) {
- break;
- }
- rv = apr_bucket_read(b, &bucket, &bytes_in_bucket, APR_BLOCK_READ);
- if (rv != APR_SUCCESS) {
- ctx->ees = EES_BUCKET_READ;
- break;
- }
- bucket_avail = bytes_in_bucket;
- consumed_bucket = b; /* for axing when we're done reading it */
- }
- if (bucket_avail) {
- /* We've got data, so translate it. */
- if (ctx->saved) {
- /* Rats... we need to finish a partial character from the previous
- * bucket.
- *
- * Strangely, finish_partial_char() increments the input buffer
- * pointer but does not increment the output buffer pointer.
- */
- apr_size_t old_buffer_avail = *buffer_avail;
- rv = finish_partial_char(ctx,
- &bucket, &bucket_avail,
- &buffer, buffer_avail);
- buffer += old_buffer_avail - *buffer_avail;
- }
- else {
- apr_size_t old_buffer_avail = *buffer_avail;
- apr_size_t old_bucket_avail = bucket_avail;
- rv = apr_xlate_conv_buffer(ctx->xlate,
- bucket, &bucket_avail,
- buffer,
- buffer_avail);
- buffer += old_buffer_avail - *buffer_avail;
- bucket += old_bucket_avail - bucket_avail;
-
- if (rv == APR_INCOMPLETE) { /* partial character at end of input */
- /* We need to save the final byte(s) for next time; we can't
- * convert it until we look at the next bucket.
- */
- rv = set_aside_partial_char(ctx, bucket, bucket_avail);
- bucket_avail = 0;
- }
- }
- if (rv != APR_SUCCESS) {
- /* bad input byte or partial char too big to store */
- break;
- }
- if (*buffer_avail < XLATE_MIN_BUFF_LEFT) {
- /* if any data remains in the current bucket, split there */
- if (bucket_avail) {
- apr_bucket_split(b, bytes_in_bucket - bucket_avail);
- }
- apr_bucket_delete(b);
- break;
- }
- }
- }
-
- if (!APR_BRIGADE_EMPTY(bb)) {
- b = APR_BRIGADE_FIRST(bb);
- if (APR_BUCKET_IS_EOS(b)) {
- /* Leave the eos bucket in the brigade for reporting to
- * subsequent filters.
- */
- *hit_eos = 1;
- if (ctx->saved) {
- /* Oops... we have a partial char from the previous bucket
- * that won't be completed because there's no more data.
- */
- rv = APR_INCOMPLETE;
- ctx->ees = EES_INCOMPLETE_CHAR;
- }
- }
- }
-
- return rv;
-}
-
-/* xlate_out_filter() handles (almost) arbitrary conversions from one charset
- * to another...
- * translation is determined in the fixup hook (find_code_page), which is
- * where the filter's context data is set up... the context data gives us
- * the translation handle
- */
-static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
-{
- charset_req_t *reqinfo = ap_get_module_config(f->r->request_config,
- &charset_lite_module);
- charset_dir_t *dc = ap_get_module_config(f->r->per_dir_config,
- &charset_lite_module);
- charset_filter_ctx_t *ctx = f->ctx;
- apr_bucket *dptr, *consumed_bucket;
- const char *cur_str;
- apr_size_t cur_len, cur_avail;
- char tmp[OUTPUT_XLATE_BUF_SIZE];
- apr_size_t space_avail;
- int done;
- apr_status_t rv = APR_SUCCESS;
-
- if (!ctx) {
- /* this is SetOutputFilter path; grab the preallocated context,
- * if any; note that if we decided not to do anything in an earlier
- * handler, we won't even have a reqinfo
- */
- if (reqinfo) {
- ctx = f->ctx = reqinfo->output_ctx;
- reqinfo->output_ctx = NULL; /* prevent SNAFU if user coded us twice
- * in the filter chain; we can't have two
- * instances using the same context
- */
- }
- if (!ctx) { /* no idea how to translate; don't do anything */
- ctx = f->ctx = apr_pcalloc(f->r->pool, sizeof(charset_filter_ctx_t));
- ctx->dc = dc;
- ctx->noop = 1;
- }
- }
-
- if (dc->debug >= DBGLVL_GORY) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, f->r,
- "xlate_out_filter() - "
- "charset_source: %s charset_default: %s",
- dc && dc->charset_source ? dc->charset_source : "(none)",
- dc && dc->charset_default ? dc->charset_default : "(none)");
- }
-
- if (!ctx->ran) { /* filter never ran before */
- chk_filter_chain(f);
- ctx->ran = 1;
- }
-
- if (ctx->noop) {
- return ap_pass_brigade(f->next, bb);
- }
-
- dptr = APR_BRIGADE_FIRST(bb);
- done = 0;
- cur_len = 0;
- space_avail = sizeof(tmp);
- consumed_bucket = NULL;
- while (!done) {
- if (!cur_len) { /* no bytes left to process in the current bucket... */
- if (consumed_bucket) {
- apr_bucket_delete(consumed_bucket);
- consumed_bucket = NULL;
- }
- if (dptr == APR_BRIGADE_SENTINEL(bb)) {
- done = 1;
- break;
- }
- if (APR_BUCKET_IS_EOS(dptr)) {
- done = 1;
- cur_len = -1; /* XXX yuck, but that tells us to send
- * eos down; when we minimize our bb construction
- * we'll fix this crap */
- if (ctx->saved) {
- /* Oops... we have a partial char from the previous bucket
- * that won't be completed because there's no more data.
- */
- rv = APR_INCOMPLETE;
- ctx->ees = EES_INCOMPLETE_CHAR;
- }
- break;
- }
- rv = apr_bucket_read(dptr, &cur_str, &cur_len, APR_BLOCK_READ);
- if (rv != APR_SUCCESS) {
- done = 1;
- ctx->ees = EES_BUCKET_READ;
- break;
- }
- consumed_bucket = dptr; /* for axing when we're done reading it */
- dptr = APR_BUCKET_NEXT(dptr); /* get ready for when we access the
- * next bucket */
- }
- /* Try to fill up our tmp buffer with translated data. */
- cur_avail = cur_len;
-
- if (cur_len) { /* maybe we just hit the end of a pipe (len = 0) ? */
- if (ctx->saved) {
- /* Rats... we need to finish a partial character from the previous
- * bucket.
- */
- char *tmp_tmp;
-
- tmp_tmp = tmp + sizeof(tmp) - space_avail;
- rv = finish_partial_char(ctx,
- &cur_str, &cur_len,
- &tmp_tmp, &space_avail);
- }
- else {
- rv = apr_xlate_conv_buffer(ctx->xlate,
- cur_str, &cur_avail,
- tmp + sizeof(tmp) - space_avail, &space_avail);
-
- /* Update input ptr and len after consuming some bytes */
- cur_str += cur_len - cur_avail;
- cur_len = cur_avail;
-
- if (rv == APR_INCOMPLETE) { /* partial character at end of input */
- /* We need to save the final byte(s) for next time; we can't
- * convert it until we look at the next bucket.
- */
- rv = set_aside_partial_char(ctx, cur_str, cur_len);
- cur_len = 0;
- }
- }
- }
-
- if (rv != APR_SUCCESS) {
- /* bad input byte or partial char too big to store */
- done = 1;
- }
-
- if (space_avail < XLATE_MIN_BUFF_LEFT) {
- /* It is time to flush, as there is not enough space left in the
- * current output buffer to bother with converting more data.
- */
- rv = send_downstream(f, tmp, sizeof(tmp) - space_avail);
- if (rv != APR_SUCCESS) {
- done = 1;
- }
-
- /* tmp is now empty */
- space_avail = sizeof(tmp);
- }
- }
-
- if (rv == APR_SUCCESS) {
- if (space_avail < sizeof(tmp)) { /* gotta write out what we converted */
- rv = send_downstream(f, tmp, sizeof(tmp) - space_avail);
- }
- }
- if (rv == APR_SUCCESS) {
- if (cur_len == -1) {
- rv = send_eos(f);
- }
- }
- else {
- log_xlate_error(f, rv);
- }
-
- return rv;
-}
-
-static void transfer_brigade(apr_bucket_brigade *in, apr_bucket_brigade *out)
-{
- apr_bucket *b;
-
- while (!APR_BRIGADE_EMPTY(in)) {
- b = APR_BRIGADE_FIRST(in);
- APR_BUCKET_REMOVE(b);
- APR_BRIGADE_INSERT_TAIL(out, b);
- }
-}
-
-static int xlate_in_filter(ap_filter_t *f, apr_bucket_brigade *bb,
- ap_input_mode_t mode, apr_size_t *readbytes)
-{
- apr_status_t rv;
- charset_req_t *reqinfo = ap_get_module_config(f->r->request_config,
- &charset_lite_module);
- charset_dir_t *dc = ap_get_module_config(f->r->per_dir_config,
- &charset_lite_module);
- charset_filter_ctx_t *ctx = f->ctx;
- apr_size_t buffer_size;
- int hit_eos;
-
- if (!ctx) {
- /* this is SetInputFilter path; grab the preallocated context,
- * if any; note that if we decided not to do anything in an earlier
- * handler, we won't even have a reqinfo
- */
- if (reqinfo) {
- ctx = f->ctx = reqinfo->input_ctx;
- reqinfo->input_ctx = NULL; /* prevent SNAFU if user coded us twice
- * in the filter chain; we can't have two
- * instances using the same context
- */
- }
- if (!ctx) { /* no idea how to translate; don't do anything */
- ctx = f->ctx = apr_pcalloc(f->r->pool, sizeof(charset_filter_ctx_t));
- ctx->dc = dc;
- ctx->noop = 1;
- }
- }
-
- if (dc->debug >= DBGLVL_GORY) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, f->r,
- "xlate_in_filter() - "
- "charset_source: %s charset_default: %s",
- dc && dc->charset_source ? dc->charset_source : "(none)",
- dc && dc->charset_default ? dc->charset_default : "(none)");
- }
-
- if (!ctx->ran) { /* filter never ran before */
- chk_filter_chain(f);
- ctx->ran = 1;
- }
-
- if (ctx->noop) {
- return ap_get_brigade(f->next, bb, mode, readbytes);
- }
-
- if (APR_BRIGADE_EMPTY(ctx->bb)) {
- if ((rv = ap_get_brigade(f->next, bb, mode, readbytes)) != APR_SUCCESS) {
- return rv;
- }
- }
- else {
- transfer_brigade(ctx->bb, bb); /* first use the leftovers */
- }
-
- buffer_size = INPUT_XLATE_BUF_SIZE;
- rv = xlate_brigade(ctx, bb, ctx->tmp, &buffer_size, &hit_eos);
- if (rv == APR_SUCCESS) {
- if (!hit_eos) {
- /* move anything leftover into our context for next time;
- * we don't currently "set aside" since the data came from
- * down below, but I suspect that for long-term we need to
- * do that
- */
- transfer_brigade(bb, ctx->bb);
- }
- if (buffer_size < INPUT_XLATE_BUF_SIZE) { /* do we have output? */
- apr_bucket *e;
-
- e = apr_bucket_heap_create(ctx->tmp,
- INPUT_XLATE_BUF_SIZE - buffer_size, 1,
- NULL);
- /* make sure we insert at the head, because there may be
- * an eos bucket already there, and the eos bucket should
- * come after the data
- */
- APR_BRIGADE_INSERT_HEAD(bb, e);
- }
- else {
- /* XXX need to get some more data... what if the last brigade
- * we got had only the first byte of a multibyte char? we need
- * to grab more data from the network instead of returning an
- * empty brigade
- */
- }
- }
- else {
- log_xlate_error(f, rv);
- }
-
- return rv;
-}
-
-static const command_rec cmds[] =
-{
- AP_INIT_TAKE1("CharsetSourceEnc",
- add_charset_source,
- NULL,
- OR_FILEINFO,
- "source (html,cgi,ssi) file charset"),
- AP_INIT_TAKE1("CharsetDefault",
- add_charset_default,
- NULL,
- OR_FILEINFO,
- "name of default charset"),
- AP_INIT_ITERATE("CharsetOptions",
- add_charset_options,
- NULL,
- OR_FILEINFO,
- "valid options: ImplicitAdd, NoImplicitAdd, DebugLevel=n"),
- {NULL}
-};
-
-static void charset_register_hooks(apr_pool_t *p)
-{
- ap_hook_fixups(find_code_page, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_insert_filter(xlate_insert_filter, NULL, NULL, APR_HOOK_MIDDLE);
- ap_register_output_filter(XLATEOUT_FILTER_NAME, xlate_out_filter,
- AP_FTYPE_CONTENT);
- ap_register_input_filter(XLATEIN_FILTER_NAME, xlate_in_filter,
- AP_FTYPE_CONTENT);
-}
-
-module charset_lite_module =
-{
- STANDARD20_MODULE_STUFF,
- create_charset_dir_conf,
- merge_charset_dir_conf,
- NULL,
- NULL,
- cmds,
- charset_register_hooks
-};
-
diff --git a/modules/experimental/mod_disk_cache.c b/modules/experimental/mod_disk_cache.c
deleted file mode 100644
index cbd28bf04a..0000000000
--- a/modules/experimental/mod_disk_cache.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-#include "mod_cache.h"
-#include "apr_file_io.h"
-#include "apr_strings.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "util_filter.h"
-
-module MODULE_VAR_EXPORT disk_cache_module;
-
-static int disk_serve(request_rec *r)
-{
- apr_bucket *e;
- apr_bucket_brigade *bb = apr_brigade_create(r->pool);
- const char *filename;
- apr_file_t *fd = NULL;
- apr_status_t rv;
- ap_filter_t *f;
- char str[256];
- apr_off_t offset = 0;
-
- filename = ap_server_root_relative(r->pool,
- apr_pstrcat(r->pool, "proxy", r->uri, NULL));
- if ((rv = apr_file_open(&fd, filename, APR_READ,
- APR_UREAD, r->connection->pool)) != APR_SUCCESS) {
- return DECLINED;
- }
-
- /* skip the cached headers. */
- do {
- apr_file_gets(str, 256, fd);
- offset += strlen(str);
- } while (strcmp(str, CRLF));
-
- /* If we are serving from the cache, we don't want to try to cache it
- * again.
- */
- for ((f = r->output_filters); (f = f->next);) {
- if (!strcmp(f->frec->name, "CACHE")) {
- ap_remove_output_filter(f);
- }
- }
-
- e = apr_bucket_file_create(fd, offset, r->finfo.size);
-
- APR_BRIGADE_INSERT_HEAD(bb, e);
- e = apr_bucket_eos_create();
- APR_BRIGADE_INSERT_TAIL(bb, e);
-
- ap_pass_brigade(r->output_filters, bb);
- return OK;
-}
-
-typedef struct cache_struct {
- const char *filename;
- apr_file_t *fd;
- int state;
-} cache_struct;
-
-static int disk_cache(request_rec *r, apr_bucket_brigade *bb, void **cf)
-{
- cache_struct *ctx = *cf;
- apr_bucket *e;
-
- if (ctx == NULL) {
- *cf = ctx = apr_pcalloc(r->pool, sizeof(*ctx));
- }
- if (ctx->filename == NULL) {
- apr_status_t rv;
- apr_dir_make(ap_server_root_relative(r->pool, "proxy"), APR_UREAD | APR_UWRITE | APR_UEXECUTE | APR_GREAD | APR_GWRITE, r->pool);
-
- /* currently, we are using the uri as the cache key. This is
- * probably wrong, but it is much better than a hard-coded filename.
- */
- ctx->filename = ap_server_root_relative(r->pool,
- apr_pstrcat(r->pool, "proxy", r->uri, NULL));
- if ((rv = apr_file_open(&ctx->fd, ctx->filename,
- APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED,
- APR_UREAD | APR_UWRITE, r->pool)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "Could not create cache file");
- *cf = NULL;
- return DECLINED;
- }
- }
- APR_BRIGADE_FOREACH(e, bb) {
- const char *str;
- apr_ssize_t length;
-
- apr_bucket_read(e, &str, &length, APR_BLOCK_READ);
- apr_file_write(ctx->fd, str, &length);
- }
- if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) {
- apr_file_close(ctx->fd);
- }
- return OK;
-}
-
-static void disk_cache_register_hook(apr_pool_t *p)
-{
- ap_hook_store_cache(disk_cache, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_serve_cache(disk_serve, NULL, NULL, APR_HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT disk_cache_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- NULL, /* command apr_table_t */
- disk_cache_register_hook /* register hooks */
-};
diff --git a/modules/experimental/mod_example.c b/modules/experimental/mod_example.c
deleted file mode 100644
index 5d8de38777..0000000000
--- a/modules/experimental/mod_example.c
+++ /dev/null
@@ -1,1198 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-/*
- * Apache example module. Provide demonstrations of how modules do things.
- *
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "util_script.h"
-
-#include "apr_strings.h"
-
-#include <stdio.h>
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* Data declarations. */
-/* */
-/* Here are the static cells and structure declarations private to our */
-/* module. */
-/* */
-/*--------------------------------------------------------------------------*/
-
-/*
- * Sample configuration record. Used for both per-directory and per-server
- * configuration data.
- *
- * It's perfectly reasonable to have two different structures for the two
- * different environments. The same command handlers will be called for
- * both, though, so the handlers need to be able to tell them apart. One
- * possibility is for both structures to start with an int which is zero for
- * one and 1 for the other.
- *
- * Note that while the per-directory and per-server configuration records are
- * available to most of the module handlers, they should be treated as
- * READ-ONLY by all except the command and merge handlers. Sometimes handlers
- * are handed a record that applies to the current location by implication or
- * inheritance, and modifying it will change the rules for other locations.
- */
-typedef struct excfg {
- int cmode; /* Environment to which record applies (directory,
- * server, or combination).
- */
-#define CONFIG_MODE_SERVER 1
-#define CONFIG_MODE_DIRECTORY 2
-#define CONFIG_MODE_COMBO 3 /* Shouldn't ever happen. */
- int local; /* Boolean: "Example" directive declared here? */
- int congenital; /* Boolean: did we inherit an "Example"? */
- char *trace; /* Pointer to trace string. */
- char *loc; /* Location to which this record applies. */
-} excfg;
-
-/*
- * Let's set up a module-local static cell to point to the accreting callback
- * trace. As each API callback is made to us, we'll tack on the particulars
- * to whatever we've already recorded. To avoid massive memory bloat as
- * directories are walked again and again, we record the routine/environment
- * the first time (non-request context only), and ignore subsequent calls for
- * the same routine/environment.
- */
-static const char *trace = NULL;
-static apr_table_t *static_calls_made = NULL;
-
-/*
- * To avoid leaking memory from pools other than the per-request one, we
- * allocate a module-private pool, and then use a sub-pool of that which gets
- * freed each time we modify the trace. That way previous layers of trace
- * data don't get lost.
- */
-static apr_pool_t *example_pool = NULL;
-static apr_pool_t *example_subpool = NULL;
-
-/*
- * Declare ourselves so the configuration routines can find and know us.
- * We'll fill it in at the end of the module.
- */
-module example_module;
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* The following pseudo-prototype declarations illustrate the parameters */
-/* passed to command handlers for the different types of directive */
-/* syntax. If an argument was specified in the directive definition */
-/* (look for "command_rec" below), it's available to the command handler */
-/* via the (void *) info field in the cmd_parms argument passed to the */
-/* handler (cmd->info for the examples below). */
-/* */
-/*--------------------------------------------------------------------------*/
-
-/*
- * Command handler for a NO_ARGS directive.
- *
- * static const char *handle_NO_ARGS(cmd_parms *cmd, void *mconfig);
- */
-
-/*
- * Command handler for a RAW_ARGS directive. The "args" argument is the text
- * of the commandline following the directive itself.
- *
- * static const char *handle_RAW_ARGS(cmd_parms *cmd, void *mconfig,
- * const char *args);
- */
-
-/*
- * Command handler for a FLAG directive. The single parameter is passed in
- * "bool", which is either zero or not for Off or On respectively.
- *
- * static const char *handle_FLAG(cmd_parms *cmd, void *mconfig, int bool);
- */
-
-/*
- * Command handler for a TAKE1 directive. The single parameter is passed in
- * "word1".
- *
- * static const char *handle_TAKE1(cmd_parms *cmd, void *mconfig,
- * char *word1);
- */
-
-/*
- * Command handler for a TAKE2 directive. TAKE2 commands must always have
- * exactly two arguments.
- *
- * static const char *handle_TAKE2(cmd_parms *cmd, void *mconfig,
- * char *word1, char *word2);
- */
-
-/*
- * Command handler for a TAKE3 directive. Like TAKE2, these must have exactly
- * three arguments, or the parser complains and doesn't bother calling us.
- *
- * static const char *handle_TAKE3(cmd_parms *cmd, void *mconfig,
- * char *word1, char *word2, char *word3);
- */
-
-/*
- * Command handler for a TAKE12 directive. These can take either one or two
- * arguments.
- * - word2 is a NULL pointer if no second argument was specified.
- *
- * static const char *handle_TAKE12(cmd_parms *cmd, void *mconfig,
- * char *word1, char *word2);
- */
-
-/*
- * Command handler for a TAKE123 directive. A TAKE123 directive can be given,
- * as might be expected, one, two, or three arguments.
- * - word2 is a NULL pointer if no second argument was specified.
- * - word3 is a NULL pointer if no third argument was specified.
- *
- * static const char *handle_TAKE123(cmd_parms *cmd, void *mconfig,
- * char *word1, char *word2, char *word3);
- */
-
-/*
- * Command handler for a TAKE13 directive. Either one or three arguments are
- * permitted - no two-parameters-only syntax is allowed.
- * - word2 and word3 are NULL pointers if only one argument was specified.
- *
- * static const char *handle_TAKE13(cmd_parms *cmd, void *mconfig,
- * char *word1, char *word2, char *word3);
- */
-
-/*
- * Command handler for a TAKE23 directive. At least two and as many as three
- * arguments must be specified.
- * - word3 is a NULL pointer if no third argument was specified.
- *
- * static const char *handle_TAKE23(cmd_parms *cmd, void *mconfig,
- * char *word1, char *word2, char *word3);
- */
-
-/*
- * Command handler for a ITERATE directive.
- * - Handler is called once for each of n arguments given to the directive.
- * - word1 points to each argument in turn.
- *
- * static const char *handle_ITERATE(cmd_parms *cmd, void *mconfig,
- * char *word1);
- */
-
-/*
- * Command handler for a ITERATE2 directive.
- * - Handler is called once for each of the second and subsequent arguments
- * given to the directive.
- * - word1 is the same for each call for a particular directive instance (the
- * first argument).
- * - word2 points to each of the second and subsequent arguments in turn.
- *
- * static const char *handle_ITERATE2(cmd_parms *cmd, void *mconfig,
- * char *word1, char *word2);
- */
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* These routines are strictly internal to this module, and support its */
-/* operation. They are not referenced by any external portion of the */
-/* server. */
-/* */
-/*--------------------------------------------------------------------------*/
-
-/*
- * Locate our directory configuration record for the current request.
- */
-static excfg *our_dconfig(request_rec *r)
-{
-
- return (excfg *) ap_get_module_config(r->per_dir_config, &example_module);
-}
-
-#if 0
-/*
- * Locate our server configuration record for the specified server.
- */
-static excfg *our_sconfig(server_rec *s)
-{
-
- return (excfg *) ap_get_module_config(s->module_config, &example_module);
-}
-
-/*
- * Likewise for our configuration record for the specified request.
- */
-static excfg *our_rconfig(request_rec *r)
-{
-
- return (excfg *) ap_get_module_config(r->request_config, &example_module);
-}
-#endif
-
-/*
- * This routine sets up some module-wide cells if they haven't been already.
- */
-static void setup_module_cells(void)
-{
- /*
- * If we haven't already allocated our module-private pool, do so now.
- */
- if (example_pool == NULL) {
- apr_pool_create(&example_pool, NULL);
- };
- /*
- * Likewise for the apr_table_t of routine/environment pairs we visit outside of
- * request context.
- */
- if (static_calls_made == NULL) {
- static_calls_made = apr_table_make(example_pool, 16);
- };
-}
-
-/*
- * This routine is used to add a trace of a callback to the list. We're
- * passed the server record (if available), the request record (if available),
- * a pointer to our private configuration record (if available) for the
- * environment to which the callback is supposed to apply, and some text. We
- * turn this into a textual representation and add it to the tail of the list.
- * The list can be displayed by the example_handler() routine.
- *
- * If the call occurs within a request context (i.e., we're passed a request
- * record), we put the trace into the request apr_pool_t and attach it to the
- * request via the notes mechanism. Otherwise, the trace gets added
- * to the static (non-request-specific) list.
- *
- * Note that the r->notes apr_table_t is only for storing strings; if you need to
- * maintain per-request data of any other type, you need to use another
- * mechanism.
- */
-
-#define TRACE_NOTE "example-trace"
-
-static void trace_add(server_rec *s, request_rec *r, excfg *mconfig,
- const char *note)
-{
-
- const char *sofar;
- char *addon;
- char *where;
- apr_pool_t *p;
- const char *trace_copy;
-
- /*
- * Make sure our pools and tables are set up - we need 'em.
- */
- setup_module_cells();
- /*
- * Now, if we're in request-context, we use the request pool.
- */
- if (r != NULL) {
- p = r->pool;
- if ((trace_copy = apr_table_get(r->notes, TRACE_NOTE)) == NULL) {
- trace_copy = "";
- }
- }
- else {
- /*
- * We're not in request context, so the trace gets attached to our
- * module-wide pool. We do the create/destroy every time we're called
- * in non-request context; this avoids leaking memory in some of
- * the subsequent calls that allocate memory only once (such as the
- * key formation below).
- *
- * Make a new sub-pool and copy any existing trace to it. Point the
- * trace cell at the copied value.
- */
- apr_pool_create(&p, example_pool);
- if (trace != NULL) {
- trace = apr_pstrdup(p, trace);
- }
- /*
- * Now, if we have a sub-pool from before, nuke it and replace with
- * the one we just allocated.
- */
- if (example_subpool != NULL) {
- apr_pool_destroy(example_subpool);
- }
- example_subpool = p;
- trace_copy = trace;
- }
- /*
- * If we weren't passed a configuration record, we can't figure out to
- * what location this call applies. This only happens for co-routines
- * that don't operate in a particular directory or server context. If we
- * got a valid record, extract the location (directory or server) to which
- * it applies.
- */
- where = (mconfig != NULL) ? mconfig->loc : "nowhere";
- where = (where != NULL) ? where : "";
- /*
- * Now, if we're not in request context, see if we've been called with
- * this particular combination before. The apr_table_t is allocated in the
- * module's private pool, which doesn't get destroyed.
- */
- if (r == NULL) {
- char *key;
-
- key = apr_pstrcat(p, note, ":", where, NULL);
- if (apr_table_get(static_calls_made, key) != NULL) {
- /*
- * Been here, done this.
- */
- return;
- }
- else {
- /*
- * First time for this combination of routine and environment -
- * log it so we don't do it again.
- */
- apr_table_set(static_calls_made, key, "been here");
- }
- }
- addon = apr_pstrcat(p, " <LI>\n", " <DL>\n", " <DT><SAMP>",
- note, "</SAMP>\n", " </DT>\n", " <DD><SAMP>[",
- where, "]</SAMP>\n", " </DD>\n", " </DL>\n",
- " </LI>\n", NULL);
- sofar = (trace_copy == NULL) ? "" : trace_copy;
- trace_copy = apr_pstrcat(p, sofar, addon, NULL);
- if (r != NULL) {
- apr_table_set(r->notes, TRACE_NOTE, trace_copy);
- }
- else {
- trace = trace_copy;
- }
- /*
- * You *could* change the following if you wanted to see the calling
- * sequence reported in the server's error_log, but beware - almost all of
- * these co-routines are called for every single request, and the impact
- * on the size (and readability) of the error_log is considerable.
- */
-#define EXAMPLE_LOG_EACH 0
- if (EXAMPLE_LOG_EACH && (s != NULL)) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "mod_example: %s", note);
- }
-}
-
-/*--------------------------------------------------------------------------*/
-/* We prototyped the various syntax for command handlers (routines that */
-/* are called when the configuration parser detects a directive declared */
-/* by our module) earlier. Now we actually declare a "real" routine that */
-/* will be invoked by the parser when our "real" directive is */
-/* encountered. */
-/* */
-/* If a command handler encounters a problem processing the directive, it */
-/* signals this fact by returning a non-NULL pointer to a string */
-/* describing the problem. */
-/* */
-/* The magic return value DECLINE_CMD is used to deal with directives */
-/* that might be declared by multiple modules. If the command handler */
-/* returns NULL, the directive was processed; if it returns DECLINE_CMD, */
-/* the next module (if any) that declares the directive is given a chance */
-/* at it. If it returns any other value, it's treated as the text of an */
-/* error message. */
-/*--------------------------------------------------------------------------*/
-/*
- * Command handler for the NO_ARGS "Example" directive. All we do is mark the
- * call in the trace log, and flag the applicability of the directive to the
- * current location in that location's configuration record.
- */
-static const char *cmd_example(cmd_parms *cmd, void *mconfig)
-{
-
- excfg *cfg = (excfg *) mconfig;
-
- /*
- * "Example Wuz Here"
- */
- cfg->local = 1;
- trace_add(cmd->server, NULL, cfg, "cmd_example()");
- return NULL;
-}
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* Now we declare our content handlers, which are invoked when the server */
-/* encounters a document which our module is supposed to have a chance to */
-/* see. (See mod_mime's SetHandler and AddHandler directives, and the */
-/* mod_info and mod_status examples, for more details.) */
-/* */
-/* Since content handlers are dumping data directly into the connexion */
-/* (using the r*() routines, such as rputs() and rprintf()) without */
-/* intervention by other parts of the server, they need to make */
-/* sure any accumulated HTTP headers are sent first. This is done by */
-/* calling send_http_header(). Otherwise, no header will be sent at all, */
-/* and the output sent to the client will actually be HTTP-uncompliant. */
-/*--------------------------------------------------------------------------*/
-/*
- * Sample content handler. All this does is display the call list that has
- * been built up so far.
- *
- * The return value instructs the caller concerning what happened and what to
- * do next:
- * OK ("we did our thing")
- * DECLINED ("this isn't something with which we want to get involved")
- * HTTP_mumble ("an error status should be reported")
- */
-static int example_handler(request_rec *r)
-{
-
- excfg *dcfg;
-
- dcfg = our_dconfig(r);
- trace_add(r->server, r, dcfg, "example_handler()");
- /*
- * We're about to start sending content, so we need to force the HTTP
- * headers to be sent at this point. Otherwise, no headers will be sent
- * at all. We can set any we like first, of course. **NOTE** Here's
- * where you set the "Content-type" header, and you do so by putting it in
- * r->content_type, *not* r->headers_out("Content-type"). If you don't
- * set it, it will be filled in with the server's default type (typically
- * "text/plain"). You *must* also ensure that r->content_type is lower
- * case.
- *
- * We also need to start a timer so the server can know if the connexion
- * is broken.
- */
- r->content_type = "text/html";
- /*
- * If we're only supposed to send header information (HEAD request), we're
- * already there.
- */
- if (r->header_only) {
- return OK;
- }
-
- /*
- * Now send our actual output. Since we tagged this as being
- * "text/html", we need to embed any HTML.
- */
- ap_rputs(DOCTYPE_HTML_3_2, r);
- ap_rputs("<HTML>\n", r);
- ap_rputs(" <HEAD>\n", r);
- ap_rputs(" <TITLE>mod_example Module Content-Handler Output\n", r);
- ap_rputs(" </TITLE>\n", r);
- ap_rputs(" </HEAD>\n", r);
- ap_rputs(" <BODY>\n", r);
- ap_rputs(" <H1><SAMP>mod_example</SAMP> Module Content-Handler Output\n", r);
- ap_rputs(" </H1>\n", r);
- ap_rputs(" <P>\n", r);
- ap_rprintf(r, " Apache HTTP Server version: \"%s\"\n",
- ap_get_server_version());
- ap_rputs(" <BR>\n", r);
- ap_rprintf(r, " Server built: \"%s\"\n", ap_get_server_built());
- ap_rputs(" </P>\n", r);;
- ap_rputs(" <P>\n", r);
- ap_rputs(" The format for the callback trace is:\n", r);
- ap_rputs(" </P>\n", r);
- ap_rputs(" <DL>\n", r);
- ap_rputs(" <DT><EM>n</EM>.<SAMP>&lt;routine-name&gt;", r);
- ap_rputs("(&lt;routine-data&gt;)</SAMP>\n", r);
- ap_rputs(" </DT>\n", r);
- ap_rputs(" <DD><SAMP>[&lt;applies-to&gt;]</SAMP>\n", r);
- ap_rputs(" </DD>\n", r);
- ap_rputs(" </DL>\n", r);
- ap_rputs(" <P>\n", r);
- ap_rputs(" The <SAMP>&lt;routine-data&gt;</SAMP> is supplied by\n", r);
- ap_rputs(" the routine when it requests the trace,\n", r);
- ap_rputs(" and the <SAMP>&lt;applies-to&gt;</SAMP> is extracted\n", r);
- ap_rputs(" from the configuration record at the time of the trace.\n", r);
- ap_rputs(" <STRONG>SVR()</STRONG> indicates a server environment\n", r);
- ap_rputs(" (blank means the main or default server, otherwise it's\n", r);
- ap_rputs(" the name of the VirtualHost); <STRONG>DIR()</STRONG>\n", r);
- ap_rputs(" indicates a location in the URL or filesystem\n", r);
- ap_rputs(" namespace.\n", r);
- ap_rputs(" </P>\n", r);
- ap_rprintf(r, " <H2>Static callbacks so far:</H2>\n <OL>\n%s </OL>\n",
- trace);
- ap_rputs(" <H2>Request-specific callbacks so far:</H2>\n", r);
- ap_rprintf(r, " <OL>\n%s </OL>\n", apr_table_get(r->notes, TRACE_NOTE));
- ap_rputs(" <H2>Environment for <EM>this</EM> call:</H2>\n", r);
- ap_rputs(" <UL>\n", r);
- ap_rprintf(r, " <LI>Applies-to: <SAMP>%s</SAMP>\n </LI>\n", dcfg->loc);
- ap_rprintf(r, " <LI>\"Example\" directive declared here: %s\n </LI>\n",
- (dcfg->local ? "YES" : "NO"));
- ap_rprintf(r, " <LI>\"Example\" inherited: %s\n </LI>\n",
- (dcfg->congenital ? "YES" : "NO"));
- ap_rputs(" </UL>\n", r);
- ap_rputs(" </BODY>\n", r);
- ap_rputs("</HTML>\n", r);
- /*
- * We're all done, so cancel the timeout we set. Since this is probably
- * the end of the request we *could* assume this would be done during
- * post-processing - but it's possible that another handler might be
- * called and inherit our outstanding timer. Not good; to each its own.
- */
- /*
- * We did what we wanted to do, so tell the rest of the server we
- * succeeded.
- */
- return OK;
-}
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* Now let's declare routines for each of the callback phase in order. */
-/* (That's the order in which they're listed in the callback list, *not */
-/* the order in which the server calls them! See the command_rec */
-/* declaration near the bottom of this file.) Note that these may be */
-/* called for situations that don't relate primarily to our function - in */
-/* other words, the fixup handler shouldn't assume that the request has */
-/* to do with "example" stuff. */
-/* */
-/* With the exception of the content handler, all of our routines will be */
-/* called for each request, unless an earlier handler from another module */
-/* aborted the sequence. */
-/* */
-/* Handlers that are declared as "int" can return the following: */
-/* */
-/* OK Handler accepted the request and did its thing with it. */
-/* DECLINED Handler took no action. */
-/* HTTP_mumble Handler looked at request and found it wanting. */
-/* */
-/* What the server does after calling a module handler depends upon the */
-/* handler's return value. In all cases, if the handler returns */
-/* DECLINED, the server will continue to the next module with an handler */
-/* for the current phase. However, if the handler return a non-OK, */
-/* non-DECLINED status, the server aborts the request right there. If */
-/* the handler returns OK, the server's next action is phase-specific; */
-/* see the individual handler comments below for details. */
-/* */
-/*--------------------------------------------------------------------------*/
-/*
- * This function is called during server initialisation. Any information
- * that needs to be recorded must be in static cells, since there's no
- * configuration record.
- *
- * There is no return value.
- */
-
-/*
- * All our module initialiser does is add its trace to the log.
- */
-static void example_init(apr_pool_t *p, apr_pool_t *ptemp,
- apr_pool_t *plog, server_rec *s)
-{
-
- char *note;
- char *sname = s->server_hostname;
-
- /*
- * Set up any module cells that ought to be initialised.
- */
- setup_module_cells();
- /*
- * The arbitrary text we add to our trace entry indicates for which server
- * we're being called.
- */
- sname = (sname != NULL) ? sname : "";
- note = apr_pstrcat(p, "example_init(", sname, ")", NULL);
- trace_add(s, NULL, NULL, note);
-}
-
-/*
- * This function is called when an heavy-weight process (such as a child) is
- * being run down or destroyed. As with the child initialisation function,
- * any information that needs to be recorded must be in static cells, since
- * there's no configuration record.
- *
- * There is no return value.
- */
-
-/*
- * All our process-death routine does is add its trace to the log.
- */
-static apr_status_t example_child_exit(void *sv)
-{
- server_rec *s = sv;
- char *note;
- char *sname = s->server_hostname;
-
- /*
- * The arbitrary text we add to our trace entry indicates for which server
- * we're being called.
- */
- sname = (sname != NULL) ? sname : "";
- note = apr_pstrcat(s->process->pool, "example_child_exit(", sname, ")", NULL);
- trace_add(s, NULL, NULL, note);
- return APR_SUCCESS;
-}
-
-/*
- * This function is called during server initialisation when an heavy-weight
- * process (such as a child) is being initialised. As with the
- * module initialisation function, any information that needs to be recorded
- * must be in static cells, since there's no configuration record.
- *
- * There is no return value.
- */
-
-/*
- * All our process initialiser does is add its trace to the log.
- */
-static void example_child_init(apr_pool_t *p, server_rec *s)
-{
-
- char *note;
- char *sname = s->server_hostname;
-
- /*
- * Set up any module cells that ought to be initialised.
- */
- setup_module_cells();
- /*
- * The arbitrary text we add to our trace entry indicates for which server
- * we're being called.
- */
- sname = (sname != NULL) ? sname : "";
- note = apr_pstrcat(p, "example_child_init(", sname, ")", NULL);
- trace_add(s, NULL, NULL, note);
-
- apr_pool_cleanup_register(p, s, example_child_exit, example_child_exit);
-}
-
-/*
- * This function gets called to create a per-directory configuration
- * record. This will be called for the "default" server environment, and for
- * each directory for which the parser finds any of our directives applicable.
- * If a directory doesn't have any of our directives involved (i.e., they
- * aren't in the .htaccess file, or a <Location>, <Directory>, or related
- * block), this routine will *not* be called - the configuration for the
- * closest ancestor is used.
- *
- * The return value is a pointer to the created module-specific
- * structure.
- */
-static void *example_create_dir_config(apr_pool_t *p, char *dirspec)
-{
-
- excfg *cfg;
- char *dname = dirspec;
-
- /*
- * Allocate the space for our record from the pool supplied.
- */
- cfg = (excfg *) apr_pcalloc(p, sizeof(excfg));
- /*
- * Now fill in the defaults. If there are any `parent' configuration
- * records, they'll get merged as part of a separate callback.
- */
- cfg->local = 0;
- cfg->congenital = 0;
- cfg->cmode = CONFIG_MODE_DIRECTORY;
- /*
- * Finally, add our trace to the callback list.
- */
- dname = (dname != NULL) ? dname : "";
- cfg->loc = apr_pstrcat(p, "DIR(", dname, ")", NULL);
- trace_add(NULL, NULL, cfg, "example_create_dir_config()");
- return (void *) cfg;
-}
-
-/*
- * This function gets called to merge two per-directory configuration
- * records. This is typically done to cope with things like .htaccess files
- * or <Location> directives for directories that are beneath one for which a
- * configuration record was already created. The routine has the
- * responsibility of creating a new record and merging the contents of the
- * other two into it appropriately. If the module doesn't declare a merge
- * routine, the record for the closest ancestor location (that has one) is
- * used exclusively.
- *
- * The routine MUST NOT modify any of its arguments!
- *
- * The return value is a pointer to the created module-specific structure
- * containing the merged values.
- */
-static void *example_merge_dir_config(apr_pool_t *p, void *parent_conf,
- void *newloc_conf)
-{
-
- excfg *merged_config = (excfg *) apr_pcalloc(p, sizeof(excfg));
- excfg *pconf = (excfg *) parent_conf;
- excfg *nconf = (excfg *) newloc_conf;
- char *note;
-
- /*
- * Some things get copied directly from the more-specific record, rather
- * than getting merged.
- */
- merged_config->local = nconf->local;
- merged_config->loc = apr_pstrdup(p, nconf->loc);
- /*
- * Others, like the setting of the `congenital' flag, get ORed in. The
- * setting of that particular flag, for instance, is TRUE if it was ever
- * true anywhere in the upstream configuration.
- */
- merged_config->congenital = (pconf->congenital | pconf->local);
- /*
- * If we're merging records for two different types of environment (server
- * and directory), mark the new record appropriately. Otherwise, inherit
- * the current value.
- */
- merged_config->cmode =
- (pconf->cmode == nconf->cmode) ? pconf->cmode : CONFIG_MODE_COMBO;
- /*
- * Now just record our being called in the trace list. Include the
- * locations we were asked to merge.
- */
- note = apr_pstrcat(p, "example_merge_dir_config(\"", pconf->loc, "\",\"",
- nconf->loc, "\")", NULL);
- trace_add(NULL, NULL, merged_config, note);
- return (void *) merged_config;
-}
-
-/*
- * This function gets called to create a per-server configuration
- * record. It will always be called for the "default" server.
- *
- * The return value is a pointer to the created module-specific
- * structure.
- */
-static void *example_create_server_config(apr_pool_t *p, server_rec *s)
-{
-
- excfg *cfg;
- char *sname = s->server_hostname;
-
- /*
- * As with the example_create_dir_config() reoutine, we allocate and fill
- * in an empty record.
- */
- cfg = (excfg *) apr_pcalloc(p, sizeof(excfg));
- cfg->local = 0;
- cfg->congenital = 0;
- cfg->cmode = CONFIG_MODE_SERVER;
- /*
- * Note that we were called in the trace list.
- */
- sname = (sname != NULL) ? sname : "";
- cfg->loc = apr_pstrcat(p, "SVR(", sname, ")", NULL);
- trace_add(s, NULL, cfg, "example_create_server_config()");
- return (void *) cfg;
-}
-
-/*
- * This function gets called to merge two per-server configuration
- * records. This is typically done to cope with things like virtual hosts and
- * the default server configuration The routine has the responsibility of
- * creating a new record and merging the contents of the other two into it
- * appropriately. If the module doesn't declare a merge routine, the more
- * specific existing record is used exclusively.
- *
- * The routine MUST NOT modify any of its arguments!
- *
- * The return value is a pointer to the created module-specific structure
- * containing the merged values.
- */
-static void *example_merge_server_config(apr_pool_t *p, void *server1_conf,
- void *server2_conf)
-{
-
- excfg *merged_config = (excfg *) apr_pcalloc(p, sizeof(excfg));
- excfg *s1conf = (excfg *) server1_conf;
- excfg *s2conf = (excfg *) server2_conf;
- char *note;
-
- /*
- * Our inheritance rules are our own, and part of our module's semantics.
- * Basically, just note whence we came.
- */
- merged_config->cmode =
- (s1conf->cmode == s2conf->cmode) ? s1conf->cmode : CONFIG_MODE_COMBO;
- merged_config->local = s2conf->local;
- merged_config->congenital = (s1conf->congenital | s1conf->local);
- merged_config->loc = apr_pstrdup(p, s2conf->loc);
- /*
- * Trace our call, including what we were asked to merge.
- */
- note = apr_pstrcat(p, "example_merge_server_config(\"", s1conf->loc, "\",\"",
- s2conf->loc, "\")", NULL);
- trace_add(NULL, NULL, merged_config, note);
- return (void *) merged_config;
-}
-
-/*
- * This routine is called after the request has been read but before any other
- * phases have been processed. This allows us to make decisions based upon
- * the input header fields.
- *
- * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no
- * further modules are called for this phase.
- */
-static int example_post_read_request(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- /*
- * We don't actually *do* anything here, except note the fact that we were
- * called.
- */
- trace_add(r->server, r, cfg, "example_post_read_request()");
- return DECLINED;
-}
-
-/*
- * This routine gives our module an opportunity to translate the URI into an
- * actual filename. If we don't do anything special, the server's default
- * rules (Alias directives and the like) will continue to be followed.
- *
- * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no
- * further modules are called for this phase.
- */
-static int example_translate_handler(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- /*
- * We don't actually *do* anything here, except note the fact that we were
- * called.
- */
- trace_add(r->server, r, cfg, "example_translate_handler()");
- return DECLINED;
-}
-
-/*
- * This routine is called to check the authentication information sent with
- * the request (such as looking up the user in a database and verifying that
- * the [encrypted] password sent matches the one in the database).
- *
- * The return value is OK, DECLINED, or some HTTP_mumble error (typically
- * HTTP_UNAUTHORIZED). If we return OK, no other modules are given a chance
- * at the request during this phase.
- */
-static int example_check_user_id(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- /*
- * Don't do anything except log the call.
- */
- trace_add(r->server, r, cfg, "example_check_user_id()");
- return DECLINED;
-}
-
-/*
- * This routine is called to check to see if the resource being requested
- * requires authorisation.
- *
- * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no
- * other modules are called during this phase.
- *
- * If *all* modules return DECLINED, the request is aborted with a server
- * error.
- */
-static int example_auth_checker(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- /*
- * Log the call and return OK, or access will be denied (even though we
- * didn't actually do anything).
- */
- trace_add(r->server, r, cfg, "example_auth_checker()");
- return DECLINED;
-}
-
-/*
- * This routine is called to check for any module-specific restrictions placed
- * upon the requested resource. (See the mod_access module for an example.)
- *
- * The return value is OK, DECLINED, or HTTP_mumble. All modules with an
- * handler for this phase are called regardless of whether their predecessors
- * return OK or DECLINED. The first one to return any other status, however,
- * will abort the sequence (and the request) as usual.
- */
-static int example_access_checker(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- trace_add(r->server, r, cfg, "example_access_checker()");
- return DECLINED;
-}
-
-/*
- * This routine is called to determine and/or set the various document type
- * information bits, like Content-type (via r->content_type), language, et
- * cetera.
- *
- * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no
- * further modules are given a chance at the request for this phase.
- */
-static int example_type_checker(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- /*
- * Log the call, but don't do anything else - and report truthfully that
- * we didn't do anything.
- */
- trace_add(r->server, r, cfg, "example_type_checker()");
- return DECLINED;
-}
-
-/*
- * This routine is called to perform any module-specific fixing of header
- * fields, et cetera. It is invoked just before any content-handler.
- *
- * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, the
- * server will still call any remaining modules with an handler for this
- * phase.
- */
-static int example_fixer_upper(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- /*
- * Log the call and exit.
- */
- trace_add(r->server, r, cfg, "example_fixer_upper()");
- return OK;
-}
-
-/*
- * This routine is called to perform any module-specific logging activities
- * over and above the normal server things.
- *
- * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, any
- * remaining modules with an handler for this phase will still be called.
- */
-static int example_logger(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- trace_add(r->server, r, cfg, "example_logger()");
- return DECLINED;
-}
-
-/*
- * This routine is called to give the module a chance to look at the request
- * headers and take any appropriate specific actions early in the processing
- * sequence.
- *
- * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, any
- * remaining modules with handlers for this phase will still be called.
- */
-static int example_header_parser(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- trace_add(r->server, r, cfg, "example_header_parser()");
- return DECLINED;
-}
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* Which functions are responsible for which hooks in the server. */
-/* */
-/*--------------------------------------------------------------------------*/
-/*
- * Each function our module provides to handle a particular hook is
- * specified here. The functions are registered using
- * ap_hook_foo(name, predecessors, successors, position)
- * where foo is the name of the hook.
- *
- * The args are as follows:
- * name -> the name of the function to call.
- * predecessors -> a list of modules whose calls to this hook must come
- * before this module.
- * successors -> a list of modules whose calls to this hook must come
- * after this module.
- * position -> The relative position of this module. One of APR_HOOK_FIRST,
- * APR_HOOK_MIDDLE, or APR_HOOK_LAST. Most modules will use
- * APR_HOOK_MIDDLE. If multiple modules use the same relative
- * position, Apache will determine which to call first.
- * If your module relies on another module to run first,
- * or another module running after yours, use the
- * predecessors and/or successors.
- *
- * The number in brackets indicates the order in which the routine is called
- * during request processing. Note that not all routines are necessarily
- * called (such as if a resource doesn't have access restrictions).
- * The actual delivery of content to the browser [9] is not handled by
- * a hook; see the handler declarations below.
- */
-static void example_register_hooks(apr_pool_t *p)
-{
- /* module initializer */
- ap_hook_post_config(example_init,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* [1] post read_request handling */
- ap_hook_post_read_request(example_post_read_request,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* [2] filename-to-URI translation */
- ap_hook_translate_name(example_translate_handler,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* [3] header parser */
- ap_hook_header_parser(example_header_parser,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* [4] check access by host address */
- ap_hook_access_checker(example_access_checker,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* [5] check/validate user_id */
- ap_hook_check_user_id(example_check_user_id,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* [6] check user_id is valid *here* */
- ap_hook_auth_checker(example_auth_checker,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* [7] MIME type checker/setter */
- ap_hook_type_checker(example_type_checker,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* [8] fixups */
- ap_hook_fixups(example_fixer_upper,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* [9] is for the handlers; see below */
-
- /* [10] logger */
- ap_hook_log_transaction(example_logger,
- NULL, NULL, APR_HOOK_MIDDLE);
- /* process initializer */
- ap_hook_child_init(example_child_init,
- NULL, NULL, APR_HOOK_MIDDLE);
-}
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* All of the routines have been declared now. Here's the list of */
-/* directives specific to our module, and information about where they */
-/* may appear and how the command parser should pass them to us for */
-/* processing. Note that care must be taken to ensure that there are NO */
-/* collisions of directive names between modules. */
-/* */
-/*--------------------------------------------------------------------------*/
-/*
- * List of directives specific to our module.
- */
-static const command_rec example_cmds[] =
-{
- AP_INIT_NO_ARGS(
- "Example", /* directive name */
- cmd_example, /* config action routine */
- NULL, /* argument to include in call */
- OR_OPTIONS, /* where available */
- "Example directive - no arguments" /* directive description */
- ),
- {NULL}
-};
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* Now the list of content handlers available from this module. */
-/* */
-/*--------------------------------------------------------------------------*/
-/*
- * List of content handlers our module supplies. Each handler is defined by
- * two parts: a name by which it can be referenced (such as by
- * {Add,Set}Handler), and the actual routine name. The list is terminated by
- * a NULL block, since it can be of variable length.
- *
- * Note that content-handlers are invoked on a most-specific to least-specific
- * basis; that is, a handler that is declared for "text/plain" will be
- * invoked before one that was declared for "text / *". Note also that
- * if a content-handler returns anything except DECLINED, no other
- * content-handlers will be called.
- */
-static const handler_rec example_handlers[] =
-{
- {"example-handler", example_handler},
- {NULL}
-};
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* Finally, the list of callback routines and data structures that provide */
-/* the static hooks into our module from the other parts of the server. */
-/* */
-/*--------------------------------------------------------------------------*/
-/*
- * Module definition for configuration. If a particular callback is not
- * needed, replace its routine name below with the word NULL.
- */
-module example_module =
-{
- STANDARD20_MODULE_STUFF,
- example_create_dir_config, /* per-directory config creator */
- example_merge_dir_config, /* dir config merger */
- example_create_server_config, /* server config creator */
- example_merge_server_config, /* server config merger */
- example_cmds, /* command table */
- example_handlers, /* list of content delivery handlers */
- example_register_hooks, /* set up other request processing hooks */
-};
diff --git a/modules/experimental/mod_ext_filter.c b/modules/experimental/mod_ext_filter.c
deleted file mode 100644
index 46b4b1e527..0000000000
--- a/modules/experimental/mod_ext_filter.c
+++ /dev/null
@@ -1,793 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-/*
- * mod_ext_filter allows Unix-style filters to filter http content.
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#define CORE_PRIVATE
-#include "http_core.h"
-#include "apr_buckets.h"
-#include "util_filter.h"
-#include "apr_strings.h"
-#include "apr_hash.h"
-#include "apr_lib.h"
-#define APR_WANT_STRFUNC
-#include "apr_want.h"
-
-typedef struct ef_server_t {
- apr_pool_t *p;
- apr_hash_t *h;
-} ef_server_t;
-
-typedef struct ef_filter_t {
- const char *name;
- enum {INPUT_FILTER=1, OUTPUT_FILTER} mode;
- const char *command;
- int numArgs;
- char *args[30];
- const char *intype; /* list of IMTs we process (well, just one for now) */
-#define INTYPE_ALL (char *)1
- const char *outtype; /* IMT of filtered output */
-#define OUTTYPE_UNCHANGED (char *)1
- int preserves_content_length;
-} ef_filter_t;
-
-typedef struct ef_dir_t {
- int debug;
- int log_stderr;
-} ef_dir_t;
-
-typedef struct ef_ctx_t {
- apr_pool_t *p;
- apr_proc_t *proc;
- apr_procattr_t *procattr;
- ef_dir_t *dc;
- ef_filter_t *filter;
- int noop;
-#if APR_FILES_AS_SOCKETS
- apr_pollfd_t *pollset;
-#endif
-} ef_ctx_t;
-
-module ext_filter_module;
-
-static apr_status_t ef_output_filter(ap_filter_t *, apr_bucket_brigade *);
-
-#define DBGLVL_SHOWOPTIONS 1
-#define DBGLVL_GORY 9
-
-static void *create_ef_dir_conf(apr_pool_t *p, char *dummy)
-{
- ef_dir_t *dc = (ef_dir_t *)apr_pcalloc(p, sizeof(ef_dir_t));
-
- dc->debug = -1;
- dc->log_stderr = -1;
-
- return dc;
-}
-
-static void *create_ef_server_conf(apr_pool_t *p, server_rec *s)
-{
- ef_server_t *conf;
-
- conf = (ef_server_t *)apr_pcalloc(p, sizeof(ef_server_t));
- conf->p = p;
- conf->h = apr_hash_make(conf->p);
- return conf;
-}
-
-static void *merge_ef_dir_conf(apr_pool_t *p, void *basev, void *overridesv)
-{
- ef_dir_t *a = (ef_dir_t *)apr_pcalloc (p, sizeof(ef_dir_t));
- ef_dir_t *base = (ef_dir_t *)basev, *over = (ef_dir_t *)overridesv;
-
- if (over->debug != -1) { /* if admin coded something... */
- a->debug = over->debug;
- }
- else {
- a->debug = base->debug;
- }
-
- if (over->log_stderr != -1) { /* if admin coded something... */
- a->log_stderr = over->log_stderr;
- }
- else {
- a->log_stderr = base->log_stderr;
- }
-
- return a;
-}
-
-static const char *add_options(cmd_parms *cmd, void *in_dc,
- const char *arg)
-{
- ef_dir_t *dc = in_dc;
-
- if (!strncasecmp(arg, "DebugLevel=", 11)) {
- dc->debug = atoi(arg + 11);
- }
- else if (!strcasecmp(arg, "LogStderr")) {
- dc->log_stderr = 1;
- }
- else if (!strcasecmp(arg, "NoLogStderr")) {
- dc->log_stderr = 0;
- }
- else {
- return apr_pstrcat(cmd->temp_pool,
- "Invalid ExtFilterOptions option: ",
- arg,
- NULL);
- }
-
- return NULL;
-}
-
-static const char *parse_cmd(apr_pool_t *p, const char **args, ef_filter_t *filter)
-{
- if (**args == '"') {
- const char *start = *args + 1;
- char *parms;
-
- ++*args; /* move past leading " */
- while (**args && **args != '"') {
- ++*args;
- }
- if (**args != '"') {
- return "Expected cmd= delimiter";
- }
- parms = apr_pstrndup(p, start, *args - start);
- ++*args; /* move past trailing " */
-
- /* parms now has the command-line to parse */
- while (filter->numArgs < 30 &&
- strlen(filter->args[filter->numArgs] = ap_getword_white_nc(p, &parms))) {
- ++filter->numArgs;
- }
- if (filter->numArgs < 1) {
- return "cmd= parse error";
- }
- filter->args[filter->numArgs] = NULL; /* we stored "" in the while() loop */
- filter->command = filter->args[0];
- }
- else
- {
- /* simple path */
- filter->args[0] = ap_getword_white(p, args);
- if (!filter->args[0]) {
- return "Invalid cmd= parameter";
- }
- filter->numArgs = 1;
- filter->command = filter->args[0];
- }
- return NULL;
-}
-
-static const char *define_filter(cmd_parms *cmd, void *dummy, const char *args)
-{
- ef_server_t *conf = ap_get_module_config(cmd->server->module_config,
- &ext_filter_module);
- const char *token;
- const char *name;
- ef_filter_t *filter;
-
- name = ap_getword_white(cmd->pool, &args);
- if (!name) {
- return "Filter name not found";
- }
-
- if (apr_hash_get(conf->h, name, APR_HASH_KEY_STRING)) {
- return apr_psprintf(cmd->pool, "ExtFilter %s is already defined",
- name);
- }
-
- filter = (ef_filter_t *)apr_pcalloc(conf->p, sizeof(ef_filter_t));
- filter->name = name;
- filter->mode = OUTPUT_FILTER;
- apr_hash_set(conf->h, name, APR_HASH_KEY_STRING, filter);
-
- while (*args) {
- while (apr_isspace(*args)) {
- ++args;
- }
-
- /* Nasty parsing... I wish I could simply use ap_getword_white()
- * here and then look at the token, but ap_getword_white() doesn't
- * do the right thing when we have cmd="word word word"
- */
- if (!strncasecmp(args, "preservescontentlength", 22)) {
- token = ap_getword_white(cmd->pool, &args);
- if (!strcasecmp(token, "preservescontentlength")) {
- filter->preserves_content_length = 1;
- }
- else {
- return apr_psprintf(cmd->pool,
- "mangled argument `%s'",
- token);
- }
- continue;
- }
-
- if (!strncasecmp(args, "mode=", 5)) {
- args += 5;
- token = ap_getword_white(cmd->pool, &args);
- if (!strcasecmp(token, "output")) {
- filter->mode = OUTPUT_FILTER;
- }
- else if (!strcasecmp(token, "input")) {
- filter->mode = INPUT_FILTER;
- }
- else {
- return apr_psprintf(cmd->pool, "Invalid mode: `%s'",
- token);
- }
- continue;
- }
-
- if (!strncasecmp(args, "intype=", 7)) {
- args += 7;
- filter->intype = ap_getword_white(cmd->pool, &args);
- continue;
- }
-
- if (!strncasecmp(args, "outtype=", 8)) {
- args += 8;
- filter->outtype = ap_getword_white(cmd->pool, &args);
- continue;
- }
-
- if (!strncasecmp(args, "cmd=", 4)) {
- args += 4;
- if ((token = parse_cmd(cmd->pool, &args, filter))) {
- return token;
- }
- continue;
- }
-
- return apr_psprintf(cmd->pool, "Unexpected parameter: `%s'",
- args);
- }
-
- /* parsing is done... register the filter
- */
- if (filter->mode == OUTPUT_FILTER) {
- /* XXX need a way to ensure uniqueness among all filters */
- ap_register_output_filter(filter->name, ef_output_filter, AP_FTYPE_CONTENT);
- }
-#if 0 /* no input filters yet */
- else if (filter->mode == INPUT_FILTER) {
- /* XXX need a way to ensure uniqueness among all filters */
- ap_register_input_filter(filter->name, ef_input_filter, AP_FTYPE_CONTENT);
- }
-#endif
- else {
- ap_assert(1 != 1); /* we set the field wrong somehow */
- }
-
- return NULL;
-}
-
-static const command_rec cmds[] =
-{
- AP_INIT_ITERATE("ExtFilterOptions",
- add_options,
- NULL,
- ACCESS_CONF, /* same as SetInputFilter/SetOutputFilter */
- "valid options: DebugLevel=n, LogStderr, NoLogStderr"),
- AP_INIT_RAW_ARGS("ExtFilterDefine",
- define_filter,
- NULL,
- RSRC_CONF,
- "Define an external filter"),
- {NULL}
-};
-
-static apr_status_t set_resource_limits(request_rec *r,
- apr_procattr_t *procattr)
-{
-#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \
- defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
- core_dir_config *conf =
- (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
- apr_status_t rv;
-
-#ifdef RLIMIT_CPU
- rv = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, conf->limit_cpu);
- ap_assert(rv == APR_SUCCESS); /* otherwise, we're out of sync with APR */
-#endif
-#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
- rv = apr_procattr_limit_set(procattr, APR_LIMIT_MEM, conf->limit_mem);
- ap_assert(rv == APR_SUCCESS); /* otherwise, we're out of sync with APR */
-#endif
-#ifdef RLIMIT_NPROC
- rv = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC, conf->limit_nproc);
- ap_assert(rv == APR_SUCCESS); /* otherwise, we're out of sync with APR */
-#endif
-
-#endif /* if at least one limit defined */
-
- return APR_SUCCESS;
-}
-
-static apr_status_t ef_close_file(void *vfile)
-{
- return apr_file_close(vfile);
-}
-
-/* init_ext_filter_process: get the external filter process going
- * This is per-filter-instance (i.e., per-request) initialization.
- */
-static apr_status_t init_ext_filter_process(ap_filter_t *f)
-{
- ef_ctx_t *ctx = f->ctx;
- apr_status_t rc;
- ef_dir_t *dc = ctx->dc;
-
- ctx->proc = apr_pcalloc(ctx->p, sizeof(*ctx->proc));
-
- rc = apr_procattr_create(&ctx->procattr, ctx->p);
- ap_assert(rc == APR_SUCCESS);
-
- rc = apr_procattr_io_set(ctx->procattr,
- APR_CHILD_BLOCK,
- APR_CHILD_BLOCK,
- APR_CHILD_BLOCK);
- ap_assert(rc == APR_SUCCESS);
-
- rc = set_resource_limits(f->r, ctx->procattr);
- ap_assert(rc == APR_SUCCESS);
-
- if (dc->log_stderr > 0) {
- rc = apr_procattr_child_err_set(ctx->procattr,
- f->r->server->error_log, /* stderr in child */
- NULL);
- ap_assert(rc == APR_SUCCESS);
- }
-
- rc = apr_proc_create(ctx->proc,
- ctx->filter->command,
- (const char * const *)ctx->filter->args,
- NULL, /* environment */
- ctx->procattr,
- ctx->p);
- if (rc != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, f->r,
- "couldn't create child process to run `%s'",
- ctx->filter->command);
- return rc;
- }
-
- apr_pool_note_subprocess(ctx->p, ctx->proc, kill_after_timeout);
-
- /* We don't want the handle to the child's stdin inherited by any
- * other processes created by httpd. Otherwise, when we close our
- * handle, the child won't see EOF because another handle will still
- * be open.
- */
-
- apr_pool_cleanup_register(ctx->p, ctx->proc->in,
- apr_pool_cleanup_null, /* other mechanism */
- ef_close_file);
-
-#if APR_FILES_AS_SOCKETS
- {
- apr_socket_t *newsock;
-
- rc = apr_poll_setup(&ctx->pollset, 2, ctx->p);
- ap_assert(rc == APR_SUCCESS);
- rc = apr_socket_from_file(&newsock, ctx->proc->in);
- ap_assert(rc == APR_SUCCESS);
- rc = apr_poll_socket_add(ctx->pollset, newsock, APR_POLLOUT);
- ap_assert(rc == APR_SUCCESS);
- rc = apr_socket_from_file(&newsock, ctx->proc->out);
- ap_assert(rc == APR_SUCCESS);
- rc = apr_poll_socket_add(ctx->pollset, newsock, APR_POLLIN);
- ap_assert(rc == APR_SUCCESS);
- }
-#endif
-
- return APR_SUCCESS;
-}
-
-static const char *get_cfg_string(ef_dir_t *dc, ef_filter_t *filter, apr_pool_t *p)
-{
- const char *debug_str = dc->debug == -1 ?
- "DebugLevel=0" : apr_psprintf(p, "DebugLevel=%d", dc->debug);
- const char *log_stderr_str = dc->log_stderr < 1 ?
- "NoLogStderr" : "LogStderr";
- const char *preserve_content_length_str = filter->preserves_content_length ?
- "PreservesContentLength" : "!PreserveContentLength";
- const char *intype_str = !filter->intype ?
- "*/*" : filter->intype;
- const char *outtype_str = !filter->outtype ?
- "(unchanged)" : filter->outtype;
-
- return apr_psprintf(p,
- "ExtFilterOptions %s %s %s ExtFilterInType %s "
- "ExtFilterOuttype %s",
- debug_str, log_stderr_str, preserve_content_length_str,
- intype_str, outtype_str);
-}
-
-static apr_status_t init_filter_instance(ap_filter_t *f)
-{
- ef_ctx_t *ctx;
- ef_dir_t *dc;
- ef_server_t *sc;
- apr_status_t rv;
-
- f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(ef_ctx_t));
- dc = ap_get_module_config(f->r->per_dir_config,
- &ext_filter_module);
- sc = ap_get_module_config(f->r->server->module_config,
- &ext_filter_module);
- ctx->dc = dc;
- /* look for the user-defined filter */
- ctx->filter = apr_hash_get(sc->h, f->frec->name, APR_HASH_KEY_STRING);
- if (!ctx->filter) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, f->r,
- "couldn't find definition of filter '%s'",
- f->frec->name);
- return APR_EINVAL;
- }
- ctx->p = f->r->pool;
- if (ctx->filter->intype &&
- ctx->filter->intype != INTYPE_ALL &&
- strcasecmp(ctx->filter->intype, f->r->content_type)) {
- /* wrong IMT for us; don't mess with the output */
- ctx->noop = 1;
- }
- else {
- rv = init_ext_filter_process(f);
- if (rv != APR_SUCCESS) {
- return rv;
- }
- if (ctx->filter->outtype &&
- ctx->filter->outtype != OUTTYPE_UNCHANGED) {
- f->r->content_type = ctx->filter->outtype;
- }
- if (ctx->filter->preserves_content_length != 1) {
- /* nasty, but needed to avoid confusing the browser
- */
- apr_table_unset(f->r->headers_out, "Content-Length");
- }
- }
-
- if (dc->debug >= DBGLVL_SHOWOPTIONS) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, f->r,
- "%sfiltering `%s' through `%s', cfg %s",
- ctx->noop ? "skipping: " : "",
- f->r->uri ? f->r->uri : f->r->filename,
- ctx->filter->command,
- get_cfg_string(dc, ctx->filter, f->r->pool));
- }
-
- return APR_SUCCESS;
-}
-
-/* drain_available_output():
- *
- * if any data is available from the filter, read it and pass it
- * to the next filter
- */
-static apr_status_t drain_available_output(ap_filter_t *f)
-{
- ef_ctx_t *ctx = f->ctx;
- ef_dir_t *dc = ctx->dc;
- apr_size_t len;
- char buf[4096];
- apr_status_t rv;
- apr_bucket_brigade *bb;
- apr_bucket *b;
-
- while (1) {
- len = sizeof(buf);
- rv = apr_file_read(ctx->proc->out,
- buf,
- &len);
- if ((rv && !APR_STATUS_IS_EAGAIN(rv)) ||
- dc->debug >= DBGLVL_GORY) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, f->r,
- "apr_file_read(child output), len %" APR_SIZE_T_FMT,
- !rv ? len : -1);
- }
- if (rv != APR_SUCCESS) {
- return rv;
- }
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_transient_create(buf, len);
- APR_BRIGADE_INSERT_TAIL(bb, b);
- if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r,
- "ap_pass_brigade()");
- return rv;
- }
- }
- /* we should never get here; if we do, a bogus error message would be
- * the least of our problems
- */
- return APR_ANONYMOUS;
-}
-
-static apr_status_t pass_data_to_filter(ap_filter_t *f, const char *data,
- apr_ssize_t len)
-{
- ef_ctx_t *ctx = f->ctx;
- ef_dir_t *dc = ctx->dc;
- apr_status_t rv;
- apr_size_t bytes_written = 0;
- apr_size_t tmplen;
-
- do {
- tmplen = len - bytes_written;
- rv = apr_file_write(ctx->proc->in,
- (const char *)data + bytes_written,
- &tmplen);
- bytes_written += tmplen;
- if (rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv)) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r,
- "apr_file_write(child input), len %" APR_SIZE_T_FMT,
- tmplen);
- return rv;
- }
- if (APR_STATUS_IS_EAGAIN(rv)) {
- /* XXX handle blocking conditions here... if we block, we need
- * to read data from the child process and pass it down to the
- * next filter!
- */
- rv = drain_available_output(f);
- if (APR_STATUS_IS_EAGAIN(rv)) {
-#if APR_FILES_AS_SOCKETS
- int num_events;
-
- rv = apr_poll(ctx->pollset,
- &num_events,
- f->r->server->timeout * APR_USEC_PER_SEC);
- if (rv || dc->debug >= DBGLVL_GORY) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG,
- rv, f->r, "apr_poll()");
- }
- if (rv != APR_SUCCESS && !APR_STATUS_IS_EINTR(rv)) {
- /* some error such as APR_TIMEUP */
- return rv;
- }
-#else /* APR_FILES_AS_SOCKETS */
- /* Yuck... I'd really like to wait until I can read
- * or write, but instead I have to sleep and try again
- */
- apr_sleep(100000); /* 100 milliseconds */
- if (dc->debug >= DBGLVL_GORY) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO,
- 0, f->r, "apr_sleep()");
- }
-#endif /* APR_FILES_AS_SOCKETS */
- }
- else if (rv != APR_SUCCESS) {
- return rv;
- }
- }
- } while (bytes_written < len);
- return rv;
-}
-
-static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
-{
- ef_ctx_t *ctx = f->ctx;
- apr_bucket *b;
- ef_dir_t *dc;
- apr_size_t len;
- const char *data;
- apr_status_t rv;
- char buf[4096];
- apr_bucket *eos = NULL;
-
- if (!ctx) {
- if ((rv = init_filter_instance(f)) != APR_SUCCESS) {
- return rv;
- }
- ctx = f->ctx;
- }
- if (ctx->noop) {
- ap_remove_output_filter(f);
- return ap_pass_brigade(f->next, bb);
- }
- dc = ctx->dc;
-
- APR_BRIGADE_FOREACH(b, bb) {
-
- if (APR_BUCKET_IS_EOS(b)) {
- eos = b;
- break;
- }
-
- rv = apr_bucket_read(b, &data, &len, APR_BLOCK_READ);
- if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, "apr_bucket_read()");
- return rv;
- }
-
- if (len > 0 &&
- (rv = pass_data_to_filter(f, data, len)) != APR_SUCCESS) {
- return rv;
- }
- }
-
- apr_brigade_destroy(bb);
-
- /* XXX What we *really* need to do once we've hit eos is create a pipe bucket
- * from the child output pipe and pass down the pipe bucket + eos.
- */
- if (eos) {
- /* close the child's stdin to signal that no more data is coming;
- * that will cause the child to finish generating output
- */
- if ((rv = apr_file_close(ctx->proc->in)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r,
- "apr_file_close(child input)");
- return rv;
- }
- /* since we've seen eos and closed the child's stdin, set the proper pipe
- * timeout; we don't care if we don't return from apr_file_read() for a while...
- */
- rv = apr_file_pipe_timeout_set(ctx->proc->out,
- f->r->server->timeout * APR_USEC_PER_SEC);
- if (rv) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r,
- "apr_file_pipe_timeout_set(child output)");
- return rv;
- }
- }
-
- do {
- len = sizeof(buf);
- rv = apr_file_read(ctx->proc->out,
- buf,
- &len);
- if ((rv && !APR_STATUS_IS_EOF(rv) && !APR_STATUS_IS_EAGAIN(rv)) ||
- dc->debug >= DBGLVL_GORY) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, f->r,
- "apr_file_read(child output), len %" APR_SIZE_T_FMT,
- !rv ? len : -1);
- }
- if (APR_STATUS_IS_EAGAIN(rv)) {
- if (eos) {
- /* should not occur, because we have an APR timeout in place */
- AP_DEBUG_ASSERT(1 != 1);
- }
- return APR_SUCCESS;
- }
-
- if (rv == APR_SUCCESS) {
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_transient_create(buf, len);
- APR_BRIGADE_INSERT_TAIL(bb, b);
- if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r,
- "ap_pass_brigade(filtered buffer) failed");
- return rv;
- }
- }
- } while (rv == APR_SUCCESS);
-
- if (!APR_STATUS_IS_EOF(rv)) {
- return rv;
- }
-
- if (eos) {
- /* pass down eos */
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_eos_create();
- APR_BRIGADE_INSERT_TAIL(bb, b);
- if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r,
- "ap_pass_brigade(eos) failed");
- return rv;
- }
- }
-
- return APR_SUCCESS;
-}
-
-#if 0
-static int ef_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
- ap_input_mode_t mode, apr_size_t *readbytes)
-{
- apr_status_t rv;
- apr_bucket *b;
- char *buf;
- apr_ssize_t len;
- char *zero;
-
- rv = ap_get_brigade(f->next, bb, mode, readbytes);
- if (rv != APR_SUCCESS) {
- return rv;
- }
-
- APR_BRIGADE_FOREACH(b, bb) {
- if (!APR_BUCKET_IS_EOS(b)) {
- if ((rv = apr_bucket_read(b, (const char **)&buf, &len, APR_BLOCK_READ)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, "apr_bucket_read() failed");
- return rv;
- }
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, "apr_bucket_read -> %d bytes",
- len);
- while ((zero = memchr(buf, '0', len))) {
- *zero = 'a';
- }
- }
- else
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, "got eos bucket");
- }
-
- return rv;
-}
-#endif
-
-module ext_filter_module =
-{
- STANDARD20_MODULE_STUFF,
- create_ef_dir_conf,
- merge_ef_dir_conf,
- create_ef_server_conf,
- NULL,
- cmds,
-};
diff --git a/modules/experimental/mod_generic_hook_export.c b/modules/experimental/mod_generic_hook_export.c
deleted file mode 100644
index 38ee86815d..0000000000
--- a/modules/experimental/mod_generic_hook_export.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "mod_generic_hook_export.h"
-#include "http_protocol.h"
-
-APR_IMPLEMENT_GENERIC_HOOK_RUN_ALL(ap,AP_MODULE,int,generic_hook_test,(const char *szStr),
- (szStr),OK,DECLINED)
-
-static int ExportLogTransaction(request_rec *r)
-{
- return ap_run_generic_hook_test(r->the_request);
-}
-
-static void ExportRegisterHooks(apr_pool_t *p)
-{
- ap_hook_log_transaction(ExportLogTransaction,NULL,NULL,APR_HOOK_MIDDLE);
-}
-
-module generic_hook_export_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- ExportRegisterHooks
-};
diff --git a/modules/experimental/mod_generic_hook_export.dsp b/modules/experimental/mod_generic_hook_export.dsp
deleted file mode 100644
index 711a041565..0000000000
--- a/modules/experimental/mod_generic_hook_export.dsp
+++ /dev/null
@@ -1,95 +0,0 @@
-# Microsoft Developer Studio Project File - Name="mod_generic_hook_export" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=mod_generic_hook_export - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "mod_generic_hook_export.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "mod_generic_hook_export.mak" CFG="mod_generic_hook_export - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "mod_generic_hook_export - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mod_generic_hook_export - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "mod_generic_hook_export - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /I "..\..\os\win32" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release\mod_generic_hook_export" /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /map /out:"Release/mod_generic_hook_export.so" /machine:I386
-# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /map /out:"Release/mod_generic_hook_export.so" /machine:I386
-
-!ELSEIF "$(CFG)" == "mod_generic_hook_export - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\..\include" /I "..\..\os\win32" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug\mod_generic_hook_export" /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /map /debug /out:"Debug/mod_generic_hook_export.so" /machine:I386
-# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /map/debug /out:"Debug/mod_generic_hook_export.so" /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "mod_generic_hook_export - Win32 Release"
-# Name "mod_generic_hook_export - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\mod_generic_hook_export.c
-# End Source File
-# End Target
-# End Project
diff --git a/modules/experimental/mod_generic_hook_export.h b/modules/experimental/mod_generic_hook_export.h
deleted file mode 100644
index a55d2f227c..0000000000
--- a/modules/experimental/mod_generic_hook_export.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#ifndef MOD_GENERIC_HOOK_EXPORT_H
-#define MOD_GENERIC_HOOK_EXPORT_H
-
-#include "apr_generic_hook.h"
-
-APR_DECLARE_EXTERNAL_HOOK(ap,AP_MODULE,int,generic_hook_test,(const char *))
-
-#endif /* def MOD_GENERIC_HOOK_EXPORT_H */
diff --git a/modules/experimental/mod_generic_hook_import.c b/modules/experimental/mod_generic_hook_import.c
deleted file mode 100644
index f46fa44df5..0000000000
--- a/modules/experimental/mod_generic_hook_import.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "mod_generic_hook_export.h"
-
-static int ImportGenericHookTestHook(const char *szStr)
-{
- ap_log_error(APLOG_MARK,APLOG_ERR,OK,NULL,"Generic hook test said: %s",
- szStr);
-
- return OK;
-}
-
-static void ImportRegisterHooks(apr_pool_t *p)
-{
- APR_HOOK_GENERIC(ap,generic_hook_test,ImportGenericHookTestHook,NULL,NULL,
- APR_HOOK_MIDDLE);
-}
-
-module generic_hook_import_module=
-{
- STANDARD20_MODULE_STUFF,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- ImportRegisterHooks
-};
diff --git a/modules/experimental/mod_generic_hook_import.dsp b/modules/experimental/mod_generic_hook_import.dsp
deleted file mode 100644
index 78068294ab..0000000000
--- a/modules/experimental/mod_generic_hook_import.dsp
+++ /dev/null
@@ -1,95 +0,0 @@
-# Microsoft Developer Studio Project File - Name="mod_generic_hook_import" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=mod_generic_hook_import - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "mod_generic_hook_import.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "mod_generic_hook_import.mak" CFG="mod_generic_hook_import - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "mod_generic_hook_import - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mod_generic_hook_import - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "mod_generic_hook_import - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /I "..\..\os\win32" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release\mod_generic_hook_import" /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /map /out:"Release/mod_generic_hook_import.so" /machine:I386
-# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /map /out:"Release/mod_generic_hook_import.so" /machine:I386
-
-!ELSEIF "$(CFG)" == "mod_generic_hook_import - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\..\include" /I "..\..\os\win32" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug\mod_generic_hook_import" /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /map /debug /out:"Debug/mod_generic_hook_import.so" /machine:I386
-# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /map/debug /out:"Debug/mod_generic_hook_import.so" /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "mod_generic_hook_import - Win32 Release"
-# Name "mod_generic_hook_import - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\mod_generic_hook_import.c
-# End Source File
-# End Target
-# End Project
diff --git a/modules/experimental/mod_optional_fn_export.c b/modules/experimental/mod_optional_fn_export.c
deleted file mode 100644
index b214a36621..0000000000
--- a/modules/experimental/mod_optional_fn_export.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "mod_optional_fn_export.h"
-
-/* The alert will note a strange mirror-image style resemblance to
- * mod_generic_hook_import.c. Yes, I _did_ mean import. Think about it.
- */
-
-static int TestOptionalFn(const char *szStr)
-{
- ap_log_error(APLOG_MARK,APLOG_ERR,OK,NULL,
- "Optional function test said: %s",szStr);
-
- return OK;
-}
-
-static void ExportRegisterHooks(apr_pool_t *p)
-{
- APR_REGISTER_OPTIONAL_FN(TestOptionalFn);
-}
-
-module optional_fn_export_module=
-{
- STANDARD20_MODULE_STUFF,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- ExportRegisterHooks
-};
diff --git a/modules/experimental/mod_optional_fn_export.h b/modules/experimental/mod_optional_fn_export.h
deleted file mode 100644
index a1950f373b..0000000000
--- a/modules/experimental/mod_optional_fn_export.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "apr_optional.h"
-
-APR_DECLARE_OPTIONAL_FN(int,TestOptionalFn,(const char *));
diff --git a/modules/experimental/mod_optional_fn_import.c b/modules/experimental/mod_optional_fn_import.c
deleted file mode 100644
index 3be3b6be6d..0000000000
--- a/modules/experimental/mod_optional_fn_import.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "mod_optional_fn_export.h"
-#include "http_protocol.h"
-
-/* The alert will note a strange mirror-image style resemblance to
- * mod_generic_hook_export.c. Yes, I _did_ mean export. Think about it.
- */
-
-static APR_OPTIONAL_FN_TYPE(TestOptionalFn) *pfn;
-
-static int ImportLogTransaction(request_rec *r)
-{
- if(pfn)
- return pfn(r->the_request);
- return DECLINED;
-}
-
-static void ImportFnRetrieve(void)
-{
- pfn=APR_RETRIEVE_OPTIONAL_FN(TestOptionalFn);
-}
-
-static void ImportRegisterHooks(apr_pool_t *p)
-{
- ap_hook_log_transaction(ImportLogTransaction,NULL,NULL,APR_HOOK_MIDDLE);
- ap_hook_optional_fn_retrieve(ImportFnRetrieve,NULL,NULL,APR_HOOK_MIDDLE);
-}
-
-module optional_fn_import_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- ImportRegisterHooks
-};