aboutsummaryrefslogtreecommitdiff
path: root/tests/gcfset.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gcfset.c')
-rw-r--r--tests/gcfset.c136
1 files changed, 68 insertions, 68 deletions
diff --git a/tests/gcfset.c b/tests/gcfset.c
index f241738..6c2cb06 100644
--- a/tests/gcfset.c
+++ b/tests/gcfset.c
@@ -1,4 +1,4 @@
-/* grecs - Gray's Extensible Configuration System
+/* argot - Gray's Extensible Configuration System
Copyright (C) 2007-2016 Sergey Poznyakoff
Grecs is free software; you can redistribute it and/or modify it
@@ -21,7 +21,7 @@
#include <string.h>
#include <errno.h>
#include <stdlib.h>
-#include "grecs.h"
+#include "argot.h"
struct logging_setup {
int use_syslog;
@@ -34,136 +34,136 @@ struct logging_setup logging_setup;
char *scalar_string;
char *mailbox_pattern;
char *mailbox_type;
-struct grecs_list *listvar;
+struct argot_list *listvar;
struct program {
char *name;
struct logging_setup logging_setup;
char *scalar_string;
- grecs_locus_t locus;
+ argot_locus_t locus;
struct program *next;
};
-struct grecs_list *proglist;
+struct argot_list *proglist;
-#if GRECS_TREE_API
-# define GRECS_CB_ARGS \
- enum grecs_callback_command cmd,\
- grecs_node_t *node,\
+#if ARGOT_TREE_API
+# define ARGOT_CB_ARGS \
+ enum argot_callback_command cmd,\
+ argot_node_t *node,\
void *varptr,\
void *cb_data
-# define GRECS_CB_AUTO \
- grecs_locus_t *locus = &node->locus;\
- grecs_value_t *value = node->v.value;
+# define ARGOT_CB_AUTO \
+ argot_locus_t *locus = &node->locus;\
+ argot_value_t *value = node->v.value;
#else
-# define GRECS_CB_ARGS \
- enum grecs_callback_command cmd,\
- grecs_locus_t *locus,\
+# define ARGOT_CB_ARGS \
+ enum argot_callback_command cmd,\
+ argot_locus_t *locus,\
void *varptr,\
- grecs_value_t *value,\
+ argot_value_t *value,\
void *cb_data
-# define GRECS_CB_AUTO
+# define ARGOT_CB_AUTO
#endif
static int
-cb_logging_facility(GRECS_CB_ARGS)
+cb_logging_facility(ARGOT_CB_ARGS)
{
- GRECS_CB_AUTO
+ ARGOT_CB_AUTO
- if (cmd != grecs_callback_set_value) {
- grecs_error(locus, 0, "Unexpected block statement");
+ if (cmd != argot_callback_set_value) {
+ argot_error(locus, 0, "Unexpected block statement");
return 1;
}
- if (!value || value->type != GRECS_TYPE_STRING) {
- grecs_error(locus, 0, "expected string argument");
+ if (!value || value->type != ARGOT_TYPE_STRING) {
+ argot_error(locus, 0, "expected string argument");
return 1;
}
- *(char**)varptr = grecs_strdup(value->v.string);
+ *(char**)varptr = argot_strdup(value->v.string);
return 0;
}
-static struct grecs_keyword logging_kwtab[] = {
+static struct argot_keyword logging_kwtab[] = {
{ "syslog", NULL, "Send to syslog",
- grecs_type_bool, GRECS_DFLT, NULL,
+ argot_type_bool, ARGOT_DFLT, NULL,
offsetof(struct logging_setup, use_syslog) },
{ "facility", "name", "Set logging facility",
- grecs_type_string, GRECS_AGGR, NULL,
+ argot_type_string, ARGOT_AGGR, NULL,
offsetof(struct logging_setup, facility), cb_logging_facility },
{ "tag", "label", "Tag logging messages with this string",
- grecs_type_string, GRECS_DFLT, NULL,
+ argot_type_string, ARGOT_DFLT, NULL,
offsetof(struct logging_setup, tag) },
{ "print-priority", NULL, "Prefix each message with its priority",
- grecs_type_bool, GRECS_DFLT, NULL,
+ argot_type_bool, ARGOT_DFLT, NULL,
offsetof(struct logging_setup, print_priority) },
{ NULL },
};
-static struct grecs_keyword mailbox_kwtab[] = {
+static struct argot_keyword mailbox_kwtab[] = {
{ "mailbox-pattern", NULL, "Default mailbox pattern",
- grecs_type_string, GRECS_DFLT, &mailbox_pattern },
+ argot_type_string, ARGOT_DFLT, &mailbox_pattern },
{ "mailbox-type", NULL, "Default mailbox type",
- grecs_type_string, GRECS_DFLT, &mailbox_type },
+ argot_type_string, ARGOT_DFLT, &mailbox_type },
{ NULL },
};
-static struct grecs_keyword program_kwtab[] = {
+static struct argot_keyword program_kwtab[] = {
{ "scalar", "label", "Scalar string",
- grecs_type_string, GRECS_DFLT,
+ argot_type_string, ARGOT_DFLT,
NULL, offsetof(struct program,scalar_string) },
{ "logging", NULL, "Configure logging logging",
- grecs_type_section, GRECS_DFLT,
+ argot_type_section, ARGOT_DFLT,
NULL, offsetof(struct program,logging_setup),
NULL, NULL, logging_kwtab },
{ NULL }
};
static int
-cb_program(GRECS_CB_ARGS)
+cb_program(ARGOT_CB_ARGS)
{
struct program *prog;
void **pdata = cb_data;
- GRECS_CB_AUTO
+ ARGOT_CB_AUTO
switch (cmd) {
- case grecs_callback_section_begin:
- if (!value || value->type != GRECS_TYPE_STRING) {
- grecs_error(locus, 0, "tag must be a string");
+ case argot_callback_section_begin:
+ if (!value || value->type != ARGOT_TYPE_STRING) {
+ argot_error(locus, 0, "tag must be a string");
return 0;
}
- prog = grecs_zalloc(sizeof(*prog));
- prog->name = grecs_strdup(value->v.string);
+ prog = argot_zalloc(sizeof(*prog));
+ prog->name = argot_strdup(value->v.string);
prog->locus = *locus;
*pdata = prog;
break;
- case grecs_callback_section_end:
+ case argot_callback_section_end:
prog = *pdata;
if (!proglist)
- proglist = grecs_list_create();
- grecs_list_append(proglist, prog);
+ proglist = argot_list_create();
+ argot_list_append(proglist, prog);
break;
- case grecs_callback_set_value:
- grecs_error(locus, 0, "invalid use of block statement");
+ case argot_callback_set_value:
+ argot_error(locus, 0, "invalid use of block statement");
}
return 0;
}
-static struct grecs_keyword main_kwtab[] = {
+static struct argot_keyword main_kwtab[] = {
{ "scalar", "label", "Scalar string",
- grecs_type_string, GRECS_DFLT, &scalar_string },
+ argot_type_string, ARGOT_DFLT, &scalar_string },
{ "logging", NULL, "Configure logging logging",
- grecs_type_section, GRECS_DFLT, &logging_setup, 0, NULL,
+ argot_type_section, ARGOT_DFLT, &logging_setup, 0, NULL,
NULL, logging_kwtab },
{ "mailbox", NULL, "Mailbox configuration",
- grecs_type_section, GRECS_DFLT, NULL, 0, NULL, NULL, mailbox_kwtab },
+ argot_type_section, ARGOT_DFLT, NULL, 0, NULL, NULL, mailbox_kwtab },
{ "program", "name: string", "Subprogram configuration",
- grecs_type_section, GRECS_DFLT,
+ argot_type_section, ARGOT_DFLT,
NULL, 0, cb_program, NULL, program_kwtab },
{ "listvar", NULL, "list variable",
- grecs_type_string, GRECS_LIST, &listvar },
+ argot_type_string, ARGOT_LIST, &listvar },
{ NULL }
};
@@ -186,7 +186,7 @@ print_program(struct program *prog)
}
static int
-node_ident_cmp(struct grecs_node const *a, struct grecs_node const *b)
+node_ident_cmp(struct argot_node const *a, struct argot_node const *b)
{
return strcmp(a->ident, b->ident);
}
@@ -203,12 +203,12 @@ main(int argc, char **argv)
{
char *progname = argv[0];
const char *file = NULL;
- struct grecs_node *tree;
+ struct argot_node *tree;
int cfhelp = 0;
int reduce = 0;
int print = 0;
int sort = 0;
- int flags = GRECS_NODE_FLAG_DEFAULT;
+ int flags = ARGOT_NODE_FLAG_DEFAULT;
int dontset = 0;
while (--argc) {
@@ -222,7 +222,7 @@ main(int argc, char **argv)
else if (strcmp(arg, "-print") == 0)
print = 1;
else if (strcmp(arg, "-locus") == 0)
- flags |= GRECS_NODE_FLAG_LOCUS;
+ flags |= ARGOT_NODE_FLAG_LOCUS;
else if (strncmp(arg, "-delim=", 7) == 0)
flags |= arg[7];
else if (strcmp(arg, "-sort") == 0)
@@ -243,32 +243,32 @@ main(int argc, char **argv)
if (cfhelp) {
static char docstring[] =
"Sample configuration file structure.\n";
- grecs_print_docstring(docstring, 0, stdout);
- grecs_print_statement_array(main_kwtab, 1, 0, stdout);
+ argot_print_docstring(docstring, 0, stdout);
+ argot_print_statement_array(main_kwtab, 1, 0, stdout);
exit(0);
}
- tree = grecs_parse(file);
+ tree = argot_parse(file);
if (!tree)
exit(2);
if (reduce)
- grecs_tree_reduce(tree, main_kwtab, GRECS_AGGR);
+ argot_tree_reduce(tree, main_kwtab, ARGOT_AGGR);
if (sort)
- grecs_tree_sort(tree, node_ident_cmp);
+ argot_tree_sort(tree, node_ident_cmp);
if (print) {
- grecs_print_node(tree, flags, stdout);
+ argot_print_node(tree, flags, stdout);
fputc('\n', stdout);
}
if (dontset)
exit(0);
- if (grecs_tree_process(tree, main_kwtab))
+ if (argot_tree_process(tree, main_kwtab))
exit(2);
- grecs_tree_free(tree);
+ argot_tree_free(tree);
printf("Global settings:\n");
printf("scalar = %s\n", S(scalar_string));
if (listvar) {
- struct grecs_list_entry *ep;
+ struct argot_list_entry *ep;
printf("listvar =");
for (ep = listvar->head; ep; ep = ep->next)
printf(" \"%s\"", (char*)ep->data);
@@ -278,10 +278,10 @@ main(int argc, char **argv)
print_logging_setup(&logging_setup);
if (proglist) {
- struct grecs_list_entry *ep;
+ struct argot_list_entry *ep;
printf("Programs configured: %lu\n",
- (unsigned long) grecs_list_size(proglist));
+ (unsigned long) argot_list_size(proglist));
for (ep = proglist->head; ep; ep = ep->next)
print_program(ep->data);
}

Return to:

Send suggestions and report system problems to the System administrator.