Name
Create Per-Server Config Structure
Synopsis
void *module_create_svr_config(pool *pPool, server_rec *pServer)
This
structure creates the per-server
configuration structure for the module. It is called once for the
main server and once per virtual host. It allocates and initializes
the memory for the per-server configuration and returns a pointer to
it. pServer
points to the
server_rec
for the current server. See Example 21-1 (1.3) for an excerpt from
mod_cgi.c.
Example
#define DEFAULT_LOGBYTES 10385760 #define DEFAULT_BUFBYTES 1024 typedef struct { char *logname; long logbytes; int bufbytes; } cgi_server_conf; static void *create_cgi_config(pool *p, server_rec *s) { cgi_server_conf *c = (cgi_server_conf *) ap_pcalloc(p, sizeof(cgi_server_conf)); c->logname = NULL; c->logbytes = DEFAULT_LOGBYTES; c->bufbytes = DEFAULT_BUFBYTES; return c; }
All this code does is allocate and initialize a copy of
cgi_server_conf
, which gets filled in during
configuration.
The only changes for 2.0 in this are that pool
becomes apr_pool_t
and ap_pcalloc(
)
becomes apr_pcalloc()
.
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.