Configuration Functions
An essential component of every directive is the function implementing it.
Normally the function serves to set some data field(s) in one of the config
structs. The function prototype for AP_INIT_TAKE1 is the same, regardless
of whether we're setting per-server or per-directory config:
const char* my_first_cmd_func(cmd_parms* cmd, void* cfg, const char* arg)
cmd
is a cmd_parms_struct comprising a number
of fields used internally by Apache and available to modules. Fields
likely to be of interest in modules include:
- void* info - contains
my_ptr
from the
command declaration
- apr_pool_t* pool - pool
for permanent resource allocation
- apr_pool_t* temp_pool - pool for temporary resource
allocation
- server_rec* server - the server rec
cfg
is the directory config rec, and arg
is an argument to the directive set in the configuration file we are
processing.
Thus, if we are setting per-directory configuration, we just cast
the cfg argument, whereas if we are setting per-server configuration
we need to retrieve it from the server_rec: