[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modules
Subject:    Re: [apache-modules] How to read the config data ?
From:       Christian Parpart <cparpart () surakware ! net>
Date:       2003-06-29 2:05:16
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 27 June 2003 3:09 am, Ajit Chourasia wrote:
> Which API should I use to read data from the httpd.conf file.
> I want to add a new configuration parameter for my module.

You have to specify your own commands you wanna fread from the config file.
That is, why the struct command_rec lies around the http_config.h (IMHO).

For an example, here's how my looks like:
static command_rec cmds[] = {
#ifndef STANDARD20_MODULE_STUFF
    // Apache 1.3.x Module
    { "YaCSServer", (CMD_HAND_TYPE)cmdYaCSServer, 0, OR_FILEINFO, TAKE2,
      "Specifies location of the YaCS server, and port as second argument." },
    { 0 }
#else
    // Apache 2.0.x Module
    AP_INIT_TAKE2("YaCSServer", (CMD_HAND_TYPE)cmdYaCSServer, 0, OR_FILEINFO,
        "Specifies location of the YaCS server, and port as second 
argument."),
    { 0 }
#endif
};

Here you even see, the obive #if'ed code is for Apache 1.3 and the #else'd 
code below is for Apache 2.x. cmdYaCSServer shall then be implemented like 
this:

onst char *cmdYaCSServer(cmd_parms *cmd, TModYaCSConfig *config, const char 
*AHost, const char *APort) {
    // syntax: YaCSServer [HOST] [PORT]

    config->FHost = AHost;
    config->FPort = Strings::lexicalConvert<unsigned>(APort);

    return 0;
}

Now, you should register your command_rec structure (cmds) somewhere in your 
module struct, as follows:
* in Apache 1.3: it is the record-member before the handlers-member.
* in Apache 2.0: it is the record-member before teh hooks-member.

As you can see, readon apache config files is more than easy ;)

I hope this helps you getting started, more info may be found on http_config.h 
and co.

Cheers,
Christian.

- -- 
 03:39:57 up 39 days, 18:54,  1 user,  load average: 0.00, 0.00, 0.00
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+/klfPpa2GmDVhK0RAjQXAJ4wLj4FXiZFQzey0MrHSeVOH/GC0ACfW5dy
mGdk7+DueClhySfsNrckz2U=
=gpSv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
For additional commands, e-mail: apache-modules-help@covalent.net


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic