Modules:QuickList:Configuration
From Anope Wiki
Contents |
Configuration
Anope allows you to parse configuration directives in services.conf for use with your module.
struct Directive
Configuration directives are stored in a struct Directive, which looks like this:
typedef struct {
char *name;
struct {
int type;
int flags;
void *ptr;
} params[MAXPARAMS];
} Directive;
In params, type can be:
| Value | Param type | Type of ptr |
| PARAM_INT | Integer | int |
| PARAM_POSINT | Positive Integer | int |
| PARAM_PORT | Integer between 1-65535 | int |
| PARAM_STRING | String | char * |
| PARAM_TIME | Time paramenter (5m, 3d, etc) | int |
| PARAM_SET | No param - set ptr to 1 | int |
The flag field can be used to set various flags for the configuration directive, like PARAM_OPTIONAL to make the param optional, and PARAM_RELOAD to be able to reload the param. You can usually enter PARAM_RELOAD in this field.
The ptr is a pointer to the data type outlined in the table above. The variable stored here will be set to the value found in the directive if it has been parsed.
moduleGetConfigDirective
Parse the given configuration directive.
int moduleGetConfigDirective(Directive *d)
You pass a pointer to your configuration Directive as d. This function will parse the configuration file and fill your directive, if it has been found.
Example
#include <module.h>
int AnopeInit(int argc, char **argv)
{
char *my_services_root = NULL;
Directive confvalues[] = {
{ "ServicesRoot", { { PARAM_STRING, PARAM_RELOAD,

