0

No, I am NOT asking where to find httpd.conf


I have been given code for a module that I need to tinker with and since I can't find any good documentation on the subject I am asking you.

const char* receiver_set_config_path(cmd_parms* cmd, void* cfg, const char* arg)
{
    receiver_config_path = arg;
    return NULL;
}

In this code there is a cfg passed in. I want to determine the name of this specific cfg file being passed in so I can log the name. How would I go about doing this? This function is setup in my receiver_directives[].

static const command_rec        receiver_directives[] =
{
    AP_INIT_TAKE1("ReceiverPath", receiver_set_config_path, NULL, RSRC_CONF, "The path the receiver will put files"),
    { NULL }
};

Your help is greatly appreciated!

alk
  • 69,737
  • 10
  • 105
  • 255
thaweatherman
  • 1,467
  • 4
  • 20
  • 32

1 Answers1

0

What about doing so:

const char* receiver_set_config_path(cmd_parms* cmd, void* cfg, const char* arg)
{
#ifdef DEBUG
  fprintf(stderr, "DEBUG %s, %d: %s(..., arg='%s')\n", __FILE__, __LINE__, __FUNCTION__, arg);
#endif   
  receiver_config_path = arg;
  return NULL;
}

Compile using the additional option -DDEBUG and you'll be getting something printed to stderr like this:

DEBUG mymodule.c, 42: receiver_set_config_path(..., arg='mypath')
alk
  • 69,737
  • 10
  • 105
  • 255
  • But cfg is the one I want to know the name of. – thaweatherman May 19 '13 at 03:25
  • @thaweatherman: `cfg` mostly like does not point to a config file name but to a structure specific to the module containing configuration settings for the latter. – alk May 19 '13 at 16:09
  • I have looked all over on the Apache websites and have been unable to find good documentation of functions, etc. for writing modules. Do you know of a place to look? Or should I just start guessing at names of things in a struct? – thaweatherman May 19 '13 at 19:58
  • @thaweatherman: You might like to read here on how to build modules: http://httpd.apache.org/docs/2.4/developer/modguide.html and for configuration of modules in particular here http://httpd.apache.org/docs/2.4/developer/modguide.html#configuration – alk May 20 '13 at 09:26
  • I've been using that page as a reference throughout the process of adding functionality. I couldn't find an example using the void* cfg at all though – thaweatherman May 21 '13 at 14:43
  • 1
    @thaweatherman: `void * cfg` is used in Context Aware Configurations as described here: http://httpd.apache.org/docs/2.4/developer/modguide.html#context – alk May 21 '13 at 14:56
  • Thanks! Not sure how I missed that – thaweatherman May 21 '13 at 15:36