Markus Rechberger / Dot Conf
 
StartSeite | MarkusRechberger/ | Neues | TestSeite | ForumSeite | Teilnehmer | Kategorien | Index | Hilfe | Einstellungen | Ändern

Veränderung (letzte Änderung) (keine anderen Diffs, Normalansicht)

Verändert: 3c3
bitte nach MarkusRechberger/DotConf verschieben, ich verwende die Einträge ab und zu gerne als Referenzliste
Ich verwende die Einträge ab und zu gerne als Referenzliste.

Verändert: 5,6c5

dotconf ist ein einfaches library welches man zum config files parsen verwenden kann...
/DotConf ist eine einfache Bibliothek zum Parsen von Konfigurationsdateien.

Verändert: 22,25c21,24
{"{MP FS OPTION}?", {ARG STR}?, cb_str, NULL, {CTX ALL}? },
{"{MP PROXY}?", {ARG LIST}?, cb_list, NULL, {CTX ALL}?},
{"{MP OUTPUT}?", {ARG STR}?, cb_str, NULL, {CTX ALL}?},
{LAST OPTION}?
{"{MP FS OPTION}?", {ARG STR}?, cb_str, NULL, {CTX ALL}? },
{"{MP PROXY}?", {ARG LIST}?, cb_list, NULL, {CTX ALL}?},
{"{MP OUTPUT}?", {ARG STR}?, cb_str, NULL, {CTX ALL}?},
{LAST OPTION}?

Verändert: 30c29
configfile_t *configfile;
configfile_t *configfile;

Verändert: 32,37c31,36
configfile = dotconf_create("simple.conf", options, NULL, {CASE INSENSITIVE}?);
if (!configfile)
{
fprintf(stderr, "Error opening config file\n");
return 1;
}
configfile = dotconf_create("simple.conf", options, NULL, {CASE INSENSITIVE}?);
if (!configfile)
{
fprintf(stderr, "Error opening config file\n");
return 1;
}

Verändert: 39,40c38,39
if (dotconf_command_loop(configfile) == 0)
fprintf(stderr, "Error reading config file\n");
if (dotconf_command_loop(configfile) == 0)
fprintf(stderr, "Error reading config file\n");

Verändert: 42c41
dotconf_cleanup(configfile);
dotconf_cleanup(configfile);

Verändert: 44c43
return 0;
return 0;

Verändert: 49,55c48,54
int i;
printf("%s:%ld: %s: [ ",
cmd->configfile->filename, cmd->configfile->line, cmd->name);
for (i = 0; i < cmd->arg_count; i++)
printf("(%d) %s ", i, cmd->data.list[i]);
printf("]\n");
return NULL;
int i;
printf("%s:%ld: %s: [ ",
cmd->configfile->filename, cmd->configfile->line, cmd->name);
for (i = 0; i < cmd->arg_count; i++)
printf("(%d) %s ", i, cmd->data.list[i]);
printf("]\n");
return NULL;

Verändert: 60,63c59,62
printf("%s:%ld: %s: [%s]\n",
cmd->configfile->filename, cmd->configfile->line,
cmd->name, cmd->data.str);
return NULL;
printf("%s:%ld: %s: [%s]\n",
cmd->configfile->filename, cmd->configfile->line,
cmd->name, cmd->data.str);
return NULL;

libdotconf

Ich verwende die Einträge ab und zu gerne als Referenzliste.

/DotConf ist eine einfache Bibliothek zum Parsen von Konfigurationsdateien.

#include <stdio.h>
#include <string.h>
#include <dotconf.h>

/*
  vim:set ts=4:
  vim:set shiftwidth=4:
*/

static DOTCONF_CB(cb_list);
static DOTCONF_CB(cb_str);

static const configoption_t options[] = {
    {"MP_FS_OPTION", ARG_STR, cb_str, NULL, CTX_ALL },
    {"MP_PROXY", ARG_LIST, cb_list, NULL, CTX_ALL},
    {"MP_OUTPUT", ARG_STR, cb_str, NULL, CTX_ALL},
    LAST_OPTION
};

int main(int argc, char **argv)
{
    configfile_t *configfile;

    configfile = dotconf_create("simple.conf", options, NULL, CASE_INSENSITIVE);
    if (!configfile)
    {
        fprintf(stderr, "Error opening config file\n");
        return 1;
    }

    if (dotconf_command_loop(configfile) == 0)
        fprintf(stderr, "Error reading config file\n");

    dotconf_cleanup(configfile);

    return 0;
}

DOTCONF_CB(cb_list)
{
    int i;
    printf("%s:%ld: %s: [  ",
        cmd->configfile->filename, cmd->configfile->line, cmd->name);
    for (i = 0; i < cmd->arg_count; i++)
        printf("(%d) %s  ", i, cmd->data.list[i]);
    printf("]\n");
    return NULL;
}

DOTCONF_CB(cb_str)
{
    printf("%s:%ld: %s: [%s]\n",
    cmd->configfile->filename, cmd->configfile->line,
    cmd->name, cmd->data.str);
    return NULL;
}


StartSeite | MarkusRechberger/ | Neues | TestSeite | ForumSeite | Teilnehmer | Kategorien | Index | Hilfe | Einstellungen | Ändern
Text dieser Seite ändern (zuletzt geändert: 13. Oktober 2004 9:10 (diff))
Suchbegriff: gesucht wird
im Titel
im Text