Main Page | Modules | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

mod_ext_filter.c File Reference

#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
#include "http_protocol.h"
#include "http_core.h"
#include "apr_buckets.h"
#include "util_filter.h"
#include "util_script.h"
#include "util_time.h"
#include "apr_strings.h"
#include "apr_hash.h"
#include "apr_lib.h"
#include "apr_poll.h"
#include "apr_want.h"

Include dependency graph for mod_ext_filter.c:

Go to the source code of this file.

Defines

#define CORE_PRIVATE
#define APR_WANT_STRFUNC
#define INTYPE_ALL   (char *)1
#define OUTTYPE_UNCHANGED   (char *)1
#define DBGLVL_SHOWOPTIONS   1
#define DBGLVL_ERRORCHECK   2
#define DBGLVL_GORY   9
#define ERRFN_USERDATA_KEY   "EXTFILTCHILDERRFN"

Typedefs

typedef ef_server_t ef_server_t
typedef ef_filter_t ef_filter_t
typedef ef_dir_t ef_dir_t
typedef ef_ctx_t ef_ctx_t

Functions

static apr_status_t ef_output_filter (ap_filter_t *, apr_bucket_brigade *)
static void * create_ef_dir_conf (apr_pool_t *p, char *dummy)
static void * create_ef_server_conf (apr_pool_t *p, server_rec *s)
static void * merge_ef_dir_conf (apr_pool_t *p, void *basev, void *overridesv)
static const char * add_options (cmd_parms *cmd, void *in_dc, const char *arg)
static const char * parse_cmd (apr_pool_t *p, const char **args, ef_filter_t *filter)
static const char * define_filter (cmd_parms *cmd, void *dummy, const char *args)
static int ef_init (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *main_s)
static void register_hooks (apr_pool_t *p)
static apr_status_t set_resource_limits (request_rec *r, apr_procattr_t *procattr)
static apr_status_t ef_close_file (void *vfile)
static void child_errfn (apr_pool_t *pool, apr_status_t err, const char *description)
static apr_status_t init_ext_filter_process (ap_filter_t *f)
static const char * get_cfg_string (ef_dir_t *dc, ef_filter_t *filter, apr_pool_t *p)
static ef_filter_tfind_filter_def (const server_rec *s, const char *fname)
static apr_status_t init_filter_instance (ap_filter_t *f)
static apr_status_t drain_available_output (ap_filter_t *f)
static apr_status_t pass_data_to_filter (ap_filter_t *f, const char *data, apr_size_t len)

Variables

module AP_MODULE_DECLARE_DATA ext_filter_module
static const server_recmain_server
static const command_rec cmds []


Define Documentation

#define APR_WANT_STRFUNC
 

Definition at line 35 of file mod_ext_filter.c.

#define CORE_PRIVATE
 

Definition at line 25 of file mod_ext_filter.c.

#define DBGLVL_ERRORCHECK   2
 

Definition at line 81 of file mod_ext_filter.c.

Referenced by init_ext_filter_process().

#define DBGLVL_GORY   9
 

Definition at line 82 of file mod_ext_filter.c.

#define DBGLVL_SHOWOPTIONS   1
 

Definition at line 80 of file mod_ext_filter.c.

Referenced by init_filter_instance().

#define ERRFN_USERDATA_KEY   "EXTFILTCHILDERRFN"
 

Definition at line 84 of file mod_ext_filter.c.

Referenced by cgid_child_errfn(), cgid_server(), child_errfn(), and init_ext_filter_process().

#define INTYPE_ALL   (char *)1
 

Definition at line 52 of file mod_ext_filter.c.

Referenced by init_filter_instance().

#define OUTTYPE_UNCHANGED   (char *)1
 

Definition at line 54 of file mod_ext_filter.c.

Referenced by init_filter_instance().


Typedef Documentation

typedef struct ef_ctx_t ef_ctx_t
 

typedef struct ef_dir_t ef_dir_t
 

typedef struct ef_filter_t ef_filter_t
 

typedef struct ef_server_t ef_server_t
 


Function Documentation

static const char* add_options cmd_parms cmd,
void *  in_dc,
const char *  arg
[static]
 

Definition at line 128 of file mod_ext_filter.c.

References ef_dir_t::debug, ef_dir_t::log_stderr, NULL, strcasecmp(), strncasecmp(), and cmd_parms_struct::temp_pool.

Here is the call graph for this function:

static void child_errfn apr_pool_t pool,
apr_status_t  err,
const char *  description
[static]
 

Definition at line 385 of file mod_ext_filter.c.

References APR_CTIME_LEN, request_rec::connection, errbuf, ERRFN_USERDATA_KEY, r, conn_rec::remote_ip, and stderr_log.

Referenced by init_ext_filter_process().

static void* create_ef_dir_conf apr_pool_t p,
char *  dummy
[static]
 

Definition at line 86 of file mod_ext_filter.c.

References apr_pcalloc, ef_dir_t::debug, and ef_dir_t::log_stderr.

static void* create_ef_server_conf apr_pool_t p,
server_rec s
[static]
 

Definition at line 96 of file mod_ext_filter.c.

References apr_pcalloc, conf, ef_server_t::h, and ef_server_t::p.

static const char* define_filter cmd_parms cmd,
void *  dummy,
const char *  args
[static]
 

Definition at line 200 of file mod_ext_filter.c.

References ap_assert, AP_FTYPE_RESOURCE, ap_get_module_config, APR_HASH_KEY_STRING, apr_isspace, apr_pcalloc, conf, ef_filter_t::disable_env, ef_output_filter(), ef_filter_t::enable_env, ext_filter_module, ef_filter_t::ftype, ef_server_t::h, ef_filter_t::intype, ef_filter_t::mode, server_rec::module_config, ef_filter_t::name, name, NULL, ef_filter_t::outtype, ef_server_t::p, parse_cmd(), cmd_parms_struct::pool, ef_filter_t::preserves_content_length, cmd_parms_struct::server, strcasecmp(), and strncasecmp().

Here is the call graph for this function:

static apr_status_t drain_available_output ap_filter_t f  )  [static]
 

Definition at line 622 of file mod_ext_filter.c.

References APLOG_DEBUG, APLOG_ERR, APLOG_MARK, APR_ANONYMOUS, APR_BRIGADE_INSERT_TAIL, APR_STATUS_IS_EAGAIN, APR_SUCCESS, b, bb, conn_rec::bucket_alloc, buf, c, request_rec::connection, ap_filter_t::ctx, ctx, DBGLVL_GORY, ef_ctx_t::dc, ef_dir_t::debug, len, ap_filter_t::next, apr_proc_t::out, request_rec::pool, ef_ctx_t::proc, ap_filter_t::r, and r.

Referenced by pass_data_to_filter().

static apr_status_t ef_close_file void *  vfile  )  [static]
 

Definition at line 380 of file mod_ext_filter.c.

Referenced by init_ext_filter_process().

static int ef_init apr_pool_t p,
apr_pool_t plog,
apr_pool_t ptemp,
server_rec main_s
[static]
 

Definition at line 341 of file mod_ext_filter.c.

References OK.

Referenced by register_hooks().

static apr_status_t ef_output_filter ap_filter_t ,
apr_bucket_brigade
[static]
 

Definition at line 723 of file mod_ext_filter.c.

References AP_DEBUG_ASSERT, APLOG_DEBUG, APLOG_ERR, APLOG_MARK, APR_BLOCK_READ, APR_BRIGADE_FOREACH, APR_BRIGADE_INSERT_TAIL, APR_BUCKET_IS_EOS, apr_bucket_read, APR_STATUS_IS_EAGAIN, APR_STATUS_IS_EOF, APR_SUCCESS, b, conn_rec::bucket_alloc, buf, c, request_rec::connection, ctx, DBGLVL_GORY, ef_ctx_t::dc, ef_dir_t::debug, eos, apr_proc_t::in, init_filter_instance(), len, ef_ctx_t::noop, NULL, apr_proc_t::out, pass_data_to_filter(), request_rec::pool, ef_ctx_t::proc, r, request_rec::server, and server_rec::timeout.

Referenced by define_filter().

Here is the call graph for this function:

static ef_filter_t* find_filter_def const server_rec s,
const char *  fname
[static]
 

Definition at line 529 of file mod_ext_filter.c.

References ap_get_module_config, APR_HASH_KEY_STRING, ext_filter_module, f, ef_server_t::h, and server_rec::module_config.

Referenced by init_filter_instance().

static const char* get_cfg_string ef_dir_t dc,
ef_filter_t filter,
apr_pool_t p
[static]
 

Definition at line 509 of file mod_ext_filter.c.

References ef_dir_t::debug, ef_filter_t::intype, ef_dir_t::log_stderr, ef_filter_t::outtype, and ef_filter_t::preserves_content_length.

Referenced by init_filter_instance().

static apr_status_t init_ext_filter_process ap_filter_t f  )  [static]
 

Definition at line 409 of file mod_ext_filter.c.

References ap_assert, APLOG_ERR, APLOG_MARK, APR_CHILD_BLOCK, APR_KILL_AFTER_TIMEOUT, apr_pcalloc, APR_POLLIN, APR_POLLOUT, APR_SUCCESS, ef_filter_t::args, request_rec::args, child_errfn(), ef_filter_t::command, ap_filter_t::ctx, ctx, DBGLVL_ERRORCHECK, ef_ctx_t::dc, ef_dir_t::debug, ef_close_file(), env, ERRFN_USERDATA_KEY, server_rec::error_log, ef_ctx_t::filter, apr_proc_t::in, ef_dir_t::log_stderr, NULL, apr_proc_t::out, ef_ctx_t::p, request_rec::path_info, request_rec::pool, ef_ctx_t::proc, ef_ctx_t::procattr, ap_filter_t::r, request_rec::server, set_resource_limits(), request_rec::subprocess_env, and request_rec::uri.

Referenced by init_filter_instance().

Here is the call graph for this function:

static apr_status_t init_filter_instance ap_filter_t f  )  [static]
 

Definition at line 544 of file mod_ext_filter.c.

References ap_get_module_config, APLOG_DEBUG, APLOG_ERR, APLOG_MARK, APR_EINVAL, apr_pcalloc, APR_SUCCESS, ef_filter_t::command, request_rec::content_type, ap_filter_t::ctx, ctx, DBGLVL_SHOWOPTIONS, ef_ctx_t::dc, ef_dir_t::debug, ef_filter_t::disable_env, ef_filter_t::enable_env, ext_filter_module, request_rec::filename, ef_ctx_t::filter, find_filter_def(), ap_filter_t::frec, get_cfg_string(), request_rec::headers_out, init_ext_filter_process(), ef_filter_t::intype, INTYPE_ALL, ap_filter_rec_t::name, ef_ctx_t::noop, ef_filter_t::outtype, OUTTYPE_UNCHANGED, ef_ctx_t::p, request_rec::per_dir_config, request_rec::pool, ef_filter_t::preserves_content_length, ap_filter_t::r, request_rec::server, strcasecmp(), request_rec::subprocess_env, and request_rec::uri.

Referenced by ef_output_filter().

Here is the call graph for this function:

static void* merge_ef_dir_conf apr_pool_t p,
void *  basev,
void *  overridesv
[static]
 

Definition at line 106 of file mod_ext_filter.c.

References apr_pcalloc, base, ef_dir_t::debug, and ef_dir_t::log_stderr.

static const char* parse_cmd apr_pool_t p,
const char **  args,
ef_filter_t filter
[static]
 

Definition at line 152 of file mod_ext_filter.c.

References APR_SUCCESS, ef_filter_t::args, ef_filter_t::command, NULL, parms, and start.

Referenced by define_filter().

static apr_status_t pass_data_to_filter ap_filter_t f,
const char *  data,
apr_size_t  len
[static]
 

Definition at line 663 of file mod_ext_filter.c.

References APLOG_DEBUG, APLOG_ERR, APLOG_MARK, APR_STATUS_IS_EAGAIN, APR_STATUS_IS_EINTR, APR_SUCCESS, bytes_written, ap_filter_t::ctx, ctx, DBGLVL_GORY, ef_ctx_t::dc, ef_dir_t::debug, drain_available_output(), apr_proc_t::in, ef_ctx_t::proc, and ap_filter_t::r.

Referenced by ef_output_filter().

Here is the call graph for this function:

static void register_hooks apr_pool_t p  )  [static]
 

Definition at line 347 of file mod_ext_filter.c.

References APR_HOOK_MIDDLE, ef_init(), and NULL.

Here is the call graph for this function:

static apr_status_t set_resource_limits request_rec r,
apr_procattr_t procattr
[static]
 

Definition at line 352 of file mod_ext_filter.c.

References ap_assert, ap_get_module_config, APR_LIMIT_CPU, APR_LIMIT_MEM, APR_LIMIT_NPROC, APR_SUCCESS, conf, core_module, and request_rec::per_dir_config.

Referenced by init_ext_filter_process().


Variable Documentation

const command_rec cmds[] [static]
 

Initial value:

{
    AP_INIT_ITERATE("ExtFilterOptions",
                    add_options,
                    NULL,
                    ACCESS_CONF, 
                    "valid options: DebugLevel=n, LogStderr, NoLogStderr"),
    AP_INIT_RAW_ARGS("ExtFilterDefine",
                     define_filter,
                     NULL,
                     RSRC_CONF,
                     "Define an external filter"),
    {NULL}
}

Definition at line 326 of file mod_ext_filter.c.

module AP_MODULE_DECLARE_DATA ext_filter_module
 

Initial value:

Definition at line 881 of file mod_ext_filter.c.

Referenced by define_filter(), find_filter_def(), and init_filter_instance().

const server_rec* main_server [static]
 

Definition at line 76 of file mod_ext_filter.c.