Exported API for registering custom variables. See #120.

Simple example in api/mod_var_remote_host_port.c
This commit is contained in:
brectanus
2007-05-03 03:26:30 +00:00
parent b47059a5b3
commit 2aa6e61605
7 changed files with 174 additions and 1 deletions

View File

@@ -922,6 +922,22 @@ static void modsec_register_operator(const char *name, void *fn_init, void *fn_e
}
}
/**
* This function is exported for other Apache modules to
* register new variables.
*/
static void modsec_register_variable(const char *name, unsigned int type,
unsigned int argc_min, unsigned int argc_max,
void *fn_validate, void *fn_generate,
unsigned int is_cacheable, unsigned int availability) {
if (modsecurity != NULL) {
msre_engine_variable_register(modsecurity->msre, name, type, argc_min, argc_max, fn_validate, fn_generate, is_cacheable, availability);
}
else {
fprintf(stderr,"modsecurity is NULL\n");
}
}
/**
* Registers module hooks with Apache.
*/
@@ -948,6 +964,7 @@ static void register_hooks(apr_pool_t *mp) {
/* Export optional functions. */
APR_REGISTER_OPTIONAL_FN(modsec_register_tfn);
APR_REGISTER_OPTIONAL_FN(modsec_register_operator);
APR_REGISTER_OPTIONAL_FN(modsec_register_variable);
/* Main hooks */
ap_hook_pre_config(hook_pre_config, NULL, NULL, APR_HOOK_FIRST);