src/config.c
author Tero Marttila <terom@fixme.fi>
Fri, 27 Mar 2009 17:22:43 +0200
changeset 83 c8e2dac08207
child 100 cfb7776bd6f0
permissions -rw-r--r--
add config module and modify irc_log/nexus to use it
83
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
#include "config.h"
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
#include <string.h>
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
err_t config_apply (struct config_option *options, void *ctx, const char *name, char *value, struct error_info *err)
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
{
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
    struct config_option *option;
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
    // find the matching config opt
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
    for (option = options; option->name && option->type; option++) {
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
        if (strcmp(option->name, name) == 0)
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
            break;
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
    }
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
    // no matching option found?
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
    if (!option)
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
        RETURN_SET_ERROR_STR(err, ERR_CONFIG_NAME, name);
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
    // call the handler
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
    return option->func(ctx, value, err);
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
}