httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dumindu Perera" <pallew...@gmail.com>
Subject Re: load data at server startup - is ap_hook_post_config() the right place?
Date Thu, 22 Mar 2007 17:18:09 GMT
Hi Daniel,


> the server_rec doesnt have a pool field. which field can I use to store
> the
> data?



AFAIK, server config is not the same as server_rec.

You create server configuration as in the following:

<code>
typedef struct {
    /*
     what ever data you need in server config
     .
     .
    */
} my_cfg;

static void *my_server_config_create(apr_pool_t *p, server_rec *s) {
    my_cfg *cfg = (my_cfg *)apr_palloc(p, sizeof(my_cfg));
    /*
    Set your configuration in cfg struct
    .
    .
    */
    return (void *)cfg;
}

module AP_MODULE_DECLARE_DATA my_module = {
    STANDARD20_MODULE_STUFF,
    NULL, /*per-dir create,*/
    NULL, /*per-dir merge,*/
    my_server_config_create, /*per-sever create*/
    NULL, /*per-sever merge*/
    cmds,
    reg_hooks
};
</code>

now you can retrieve your server configuration as follows, when you have a
pointer to a request, 'r':

<code>
my_cfg *svr_cfg = (my_cfg *)ap_get_module_config(r->server->module_config,
&my_module);
</code>

Regards,
Dumindu.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message