diff options
Diffstat (limited to 'tests/gcfset.c')
-rw-r--r-- | tests/gcfset.c | 136 |
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 @@ | |||
1 | /* grecs - Gray's Extensible Configuration System | 1 | /* argot - Gray's Extensible Configuration System |
2 | Copyright (C) 2007-2016 Sergey Poznyakoff | 2 | Copyright (C) 2007-2016 Sergey Poznyakoff |
3 | 3 | ||
4 | Grecs is free software; you can redistribute it and/or modify it | 4 | Grecs is free software; you can redistribute it and/or modify it |
@@ -21,7 +21,7 @@ | |||
21 | #include <string.h> | 21 | #include <string.h> |
22 | #include <errno.h> | 22 | #include <errno.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include "grecs.h" | 24 | #include "argot.h" |
25 | 25 | ||
26 | struct logging_setup { | 26 | struct logging_setup { |
27 | int use_syslog; | 27 | int use_syslog; |
@@ -34,136 +34,136 @@ struct logging_setup logging_setup; | |||
34 | char *scalar_string; | 34 | char *scalar_string; |
35 | char *mailbox_pattern; | 35 | char *mailbox_pattern; |
36 | char *mailbox_type; | 36 | char *mailbox_type; |
37 | struct grecs_list *listvar; | 37 | struct argot_list *listvar; |
38 | 38 | ||
39 | struct program { | 39 | struct program { |
40 | char *name; | 40 | char *name; |
41 | struct logging_setup logging_setup; | 41 | struct logging_setup logging_setup; |
42 | char *scalar_string; | 42 | char *scalar_string; |
43 | grecs_locus_t locus; | 43 | argot_locus_t locus; |
44 | struct program *next; | 44 | struct program *next; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | struct grecs_list *proglist; | 47 | struct argot_list *proglist; |
48 | 48 | ||
49 | #if GRECS_TREE_API | 49 | #if ARGOT_TREE_API |
50 | # define GRECS_CB_ARGS \ | 50 | # define ARGOT_CB_ARGS \ |
51 | enum grecs_callback_command cmd,\ | 51 | enum argot_callback_command cmd,\ |
52 | grecs_node_t *node,\ | 52 | argot_node_t *node,\ |
53 | void *varptr,\ | 53 | void *varptr,\ |
54 | void *cb_data | 54 | void *cb_data |
55 | # define GRECS_CB_AUTO \ | 55 | # define ARGOT_CB_AUTO \ |
56 | grecs_locus_t *locus = &node->locus;\ | 56 | argot_locus_t *locus = &node->locus;\ |
57 | grecs_value_t *value = node->v.value; | 57 | argot_value_t *value = node->v.value; |
58 | #else | 58 | #else |
59 | # define GRECS_CB_ARGS \ | 59 | # define ARGOT_CB_ARGS \ |
60 | enum grecs_callback_command cmd,\ | 60 | enum argot_callback_command cmd,\ |
61 | grecs_locus_t *locus,\ | 61 | argot_locus_t *locus,\ |
62 | void *varptr,\ | 62 | void *varptr,\ |
63 | grecs_value_t *value,\ | 63 | argot_value_t *value,\ |
64 | void *cb_data | 64 | void *cb_data |
65 | # define GRECS_CB_AUTO | 65 | # define ARGOT_CB_AUTO |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | static int | 68 | static int |
69 | cb_logging_facility(GRECS_CB_ARGS) | 69 | cb_logging_facility(ARGOT_CB_ARGS) |
70 | { | 70 | { |
71 | GRECS_CB_AUTO | 71 | ARGOT_CB_AUTO |
72 | 72 | ||
73 | if (cmd != grecs_callback_set_value) { | 73 | if (cmd != argot_callback_set_value) { |
74 | grecs_error(locus, 0, "Unexpected block statement"); | 74 | argot_error(locus, 0, "Unexpected block statement"); |
75 | return 1; | 75 | return 1; |
76 | } | 76 | } |
77 | if (!value || value->type != GRECS_TYPE_STRING) { | 77 | if (!value || value->type != ARGOT_TYPE_STRING) { |
78 | grecs_error(locus, 0, "expected string argument"); | 78 | argot_error(locus, 0, "expected string argument"); |
79 | return 1; | 79 | return 1; |
80 | } | 80 | } |
81 | 81 | ||
82 | *(char**)varptr = grecs_strdup(value->v.string); | 82 | *(char**)varptr = argot_strdup(value->v.string); |
83 | return 0; | 83 | return 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | static struct grecs_keyword logging_kwtab[] = { | 86 | static struct argot_keyword logging_kwtab[] = { |
87 | { "syslog", NULL, "Send to syslog", | 87 | { "syslog", NULL, "Send to syslog", |
88 | grecs_type_bool, GRECS_DFLT, NULL, | 88 | argot_type_bool, ARGOT_DFLT, NULL, |
89 | offsetof(struct logging_setup, use_syslog) }, | 89 | offsetof(struct logging_setup, use_syslog) }, |
90 | { "facility", "name", "Set logging facility", | 90 | { "facility", "name", "Set logging facility", |
91 | grecs_type_string, GRECS_AGGR, NULL, | 91 | argot_type_string, ARGOT_AGGR, NULL, |
92 | offsetof(struct logging_setup, facility), cb_logging_facility }, | 92 | offsetof(struct logging_setup, facility), cb_logging_facility }, |
93 | { "tag", "label", "Tag logging messages with this string", | 93 | { "tag", "label", "Tag logging messages with this string", |
94 | grecs_type_string, GRECS_DFLT, NULL, | 94 | argot_type_string, ARGOT_DFLT, NULL, |
95 | offsetof(struct logging_setup, tag) }, | 95 | offsetof(struct logging_setup, tag) }, |
96 | { "print-priority", NULL, "Prefix each message with its priority", | 96 | { "print-priority", NULL, "Prefix each message with its priority", |
97 | grecs_type_bool, GRECS_DFLT, NULL, | 97 | argot_type_bool, ARGOT_DFLT, NULL, |
98 | offsetof(struct logging_setup, print_priority) }, | 98 | offsetof(struct logging_setup, print_priority) }, |
99 | { NULL }, | 99 | { NULL }, |
100 | }; | 100 | }; |
101 | 101 | ||
102 | static struct grecs_keyword mailbox_kwtab[] = { | 102 | static struct argot_keyword mailbox_kwtab[] = { |
103 | { "mailbox-pattern", NULL, "Default mailbox pattern", | 103 | { "mailbox-pattern", NULL, "Default mailbox pattern", |
104 | grecs_type_string, GRECS_DFLT, &mailbox_pattern }, | 104 | argot_type_string, ARGOT_DFLT, &mailbox_pattern }, |
105 | { "mailbox-type", NULL, "Default mailbox type", | 105 | { "mailbox-type", NULL, "Default mailbox type", |
106 | grecs_type_string, GRECS_DFLT, &mailbox_type }, | 106 | argot_type_string, ARGOT_DFLT, &mailbox_type }, |
107 | { NULL }, | 107 | { NULL }, |
108 | }; | 108 | }; |
109 | 109 | ||
110 | 110 | ||
111 | static struct grecs_keyword program_kwtab[] = { | 111 | static struct argot_keyword program_kwtab[] = { |
112 | { "scalar", "label", "Scalar string", | 112 | { "scalar", "label", "Scalar string", |
113 | grecs_type_string, GRECS_DFLT, | 113 | argot_type_string, ARGOT_DFLT, |
114 | NULL, offsetof(struct program,scalar_string) }, | 114 | NULL, offsetof(struct program,scalar_string) }, |
115 | { "logging", NULL, "Configure logging logging", | 115 | { "logging", NULL, "Configure logging logging", |
116 | grecs_type_section, GRECS_DFLT, | 116 | argot_type_section, ARGOT_DFLT, |
117 | NULL, offsetof(struct program,logging_setup), | 117 | NULL, offsetof(struct program,logging_setup), |
118 | NULL, NULL, logging_kwtab }, | 118 | NULL, NULL, logging_kwtab }, |
119 | { NULL } | 119 | { NULL } |
120 | }; | 120 | }; |
121 | 121 | ||
122 | static int | 122 | static int |
123 | cb_program(GRECS_CB_ARGS) | 123 | cb_program(ARGOT_CB_ARGS) |
124 | { | 124 | { |
125 | struct program *prog; | 125 | struct program *prog; |
126 | void **pdata = cb_data; | 126 | void **pdata = cb_data; |
127 | GRECS_CB_AUTO | 127 | ARGOT_CB_AUTO |
128 | 128 | ||
129 | switch (cmd) { | 129 | switch (cmd) { |
130 | case grecs_callback_section_begin: | 130 | case argot_callback_section_begin: |
131 | if (!value || value->type != GRECS_TYPE_STRING) { | 131 | if (!value || value->type != ARGOT_TYPE_STRING) { |
132 | grecs_error(locus, 0, "tag must be a string"); | 132 | argot_error(locus, 0, "tag must be a string"); |
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | prog = grecs_zalloc(sizeof(*prog)); | 135 | prog = argot_zalloc(sizeof(*prog)); |
136 | prog->name = grecs_strdup(value->v.string); | 136 | prog->name = argot_strdup(value->v.string); |
137 | prog->locus = *locus; | 137 | prog->locus = *locus; |
138 | *pdata = prog; | 138 | *pdata = prog; |
139 | break; | 139 | break; |
140 | 140 | ||
141 | case grecs_callback_section_end: | 141 | case argot_callback_section_end: |
142 | prog = *pdata; | 142 | prog = *pdata; |
143 | if (!proglist) | 143 | if (!proglist) |
144 | proglist = grecs_list_create(); | 144 | proglist = argot_list_create(); |
145 | grecs_list_append(proglist, prog); | 145 | argot_list_append(proglist, prog); |
146 | break; | 146 | break; |
147 | 147 | ||
148 | case grecs_callback_set_value: | 148 | case argot_callback_set_value: |
149 | grecs_error(locus, 0, "invalid use of block statement"); | 149 | argot_error(locus, 0, "invalid use of block statement"); |
150 | } | 150 | } |
151 | return 0; | 151 | return 0; |
152 | } | 152 | } |
153 | 153 | ||
154 | static struct grecs_keyword main_kwtab[] = { | 154 | static struct argot_keyword main_kwtab[] = { |
155 | { "scalar", "label", "Scalar string", | 155 | { "scalar", "label", "Scalar string", |
156 | grecs_type_string, GRECS_DFLT, &scalar_string }, | 156 | argot_type_string, ARGOT_DFLT, &scalar_string }, |
157 | { "logging", NULL, "Configure logging logging", | 157 | { "logging", NULL, "Configure logging logging", |
158 | grecs_type_section, GRECS_DFLT, &logging_setup, 0, NULL, | 158 | argot_type_section, ARGOT_DFLT, &logging_setup, 0, NULL, |
159 | NULL, logging_kwtab }, | 159 | NULL, logging_kwtab }, |
160 | { "mailbox", NULL, "Mailbox configuration", | 160 | { "mailbox", NULL, "Mailbox configuration", |
161 | grecs_type_section, GRECS_DFLT, NULL, 0, NULL, NULL, mailbox_kwtab }, | 161 | argot_type_section, ARGOT_DFLT, NULL, 0, NULL, NULL, mailbox_kwtab }, |
162 | { "program", "name: string", "Subprogram configuration", | 162 | { "program", "name: string", "Subprogram configuration", |
163 | grecs_type_section, GRECS_DFLT, | 163 |