John David Duncan wrote:
const char *config_server_thing(cmd_parms *cmd, void *m, char *arg) {
}
So far, so good. But here's the problem: In this function, I should be
able to cast the pointer, m, back to the struct srv that was
initialized earlier.
srv_conf = (struct srv *) m;
But after lots of debugging, I find that:
1) The pointer m is not equal to the pointer that was returned from
the initialization function.
2) m does not hold a copy of the data structure that was initialized.
3) And m is also not equal to the value of
ap_get_module_config(cmd->server->module_config, &my_module)
Finally, as a work-around, I decided to use:
srv_conf = (struct srv *)
ap_get_module_config(cmd->server->module_config, &my_module);
instead of:
srv_conf = (struct srv *) m;
The void *m parameter is only set if the function is being called in a
<Directory> block, in which case it will be assigned to that directory
block's configuration that you create, not the servers' configuration
structure. If it is a server directive (as yours is in the examples you
provided) this parameter should be NULL.
I have a few functions that are both directory specific and also server
specific (used in both circumstances), and to prevent a redesign of the
wheel, I typically check for NULL on that parameter, and if it is NULL,
I reassign it to the cmd->server->module_config option - giving me a
valid configuration structure as I created both. Then I am free to do
what I want with it.
Joe
--
Joseph Lewis <http://sharktooth.org/>
"Divide the fire, and you will sooner put it out." - Publius Syrus