src/config.h
author Tero Marttila <terom@fixme.fi>
Tue, 31 Mar 2009 22:09:53 +0300
changeset 98 f357f835f0d5
parent 87 f0db6ebf18b9
child 100 cfb7776bd6f0
permissions -rw-r--r--
add irc_client_defaults to apply default values for irc_client_add_net irc_net_info, implement --defaults cmd opt and lua_client_connect
#ifndef CONFIG_H
#define CONFIG_H

/**
 * @file
 *
 * Support for module configuration parameters
 */
#include "error.h"

/** 
 * Different types of configuration parameters
 */
enum config_type {
    CONFIG_INVALID,

    /** A plain NUL-terminated string */
    CONFIG_STRING,
};

/**
 * A single configuration option, with a name, type, handler function, etc.
 */
struct config_option {
    /** The name of the config option */
    const char *name;

    /** The type of the value, XXX: unused */
    enum config_type type;
    
    /** The value handler func */
    err_t (*func) (void *ctx, char *value, struct error_info *err);

    /** The value description */
    const char *description;

    /** Help text */
    const char *help;
};

/**
 * Apply a configuration name/value to an array of config_option's.
 *
 * This finds the appropriate config_option and calls its func.
 */
err_t config_apply (struct config_option *options, void *ctx, const char *name, char *value, struct error_info *err);

#endif