summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-06-06 04:21:43 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-06-06 05:24:28 (GMT)
commitb220b5a367469c571358c34ea0df813522e99485 (patch) (side-by-side diff)
tree600e8f26555a359b9d5297b1d566717a1ec78182
parent44efb0cda486e2614603e6dd78b0c93407f63c3b (diff)
downloadpies-b220b5a367469c571358c34ea0df813522e99485.tar.gz
pies-b220b5a367469c571358c34ea0df813522e99485.tar.bz2
Update the grecs submodule
* configure.ac (GRECS_SETUP): Request the tree-api * grecs: Pull a0c096190f * lib/envop.c (environ_set): Call wordsplit_free unconditionally. * lib/grecsasrt.c (assert_grecs_value_type) (assert_scalar_stmt): Remove. (conf_callback_url): Switch to tree-api. * lib/grecsasrt.h: Likewise. * src/acl.c: Rewrite grecs callbacks in the tree API style. Use grecs assertions. * src/acl.h: Likewise. * src/meta1parse.c: Likewise. * src/pies.c: Likewise. * src/piesctl.c: Likewise. * src/comp.c (component_finish): Check whether the "command" statement was used.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--configure.ac2
m---------grecs0
-rw-r--r--lib/envop.c3
-rw-r--r--lib/grecsasrt.c40
-rw-r--r--lib/grecsasrt.h7
-rw-r--r--src/acl.c38
-rw-r--r--src/acl.h12
-rw-r--r--src/comp.c7
-rw-r--r--src/meta1parse.c2
-rw-r--r--src/pies.c183
-rw-r--r--src/piesctl.c16
11 files changed, 157 insertions, 153 deletions
diff --git a/configure.ac b/configure.ac
index ccfd9fc..814ac00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,7 +74,7 @@ AC_CHECK_FUNCS([alarm dup2 gethostbyname memmove memset select setenv socket str
gl_INIT
# Grecs
-GRECS_SETUP([grecs],[tests git2chg getopt json sockaddr-list parser-meta1])
+GRECS_SETUP([grecs],[tree-api tests git2chg getopt json sockaddr-list parser-meta1])
GRECS_HOST_PROJECT_INCLUDES='-I$(top_srcdir)/gnu -I$(top_builddir)/gnu'
# Test for setproctitle
diff --git a/grecs b/grecs
-Subproject 1fa2dd2c6587822ff682581643499c3c3b78c9e
+Subproject a0c096190fa57b12b9b95ada70f51cab402c74c
diff --git a/lib/envop.c b/lib/envop.c
index 80a8b6c..ce24b92 100644
--- a/lib/envop.c
+++ b/lib/envop.c
@@ -186,8 +186,7 @@ environ_set (environ_t *env, char const *name, char const *value)
| WRDSF_PATHEXPAND))
{
int ec = errno;
- if (ws.ws_errno != WRDSE_USAGE) /* FIXME */
- wordsplit_free (&ws);
+ wordsplit_free (&ws);
errno = ec;
return -1;
}
diff --git a/lib/grecsasrt.c b/lib/grecsasrt.c
index 8ebd581..c217cec 100644
--- a/lib/grecsasrt.c
+++ b/lib/grecsasrt.c
@@ -23,45 +23,15 @@
#include "grecsasrt.h"
int
-assert_grecs_value_type (grecs_locus_t *locus,
- const grecs_value_t *value, int type)
-{
- if (GRECS_VALUE_EMPTY_P (value))
- {
- grecs_error (locus, 0, _("expected %s"),
- grecs_data_type_string (type));
- return 1;
- }
- if (value->type != type)
- {
- grecs_error (locus, 0, _("expected %s, but found %s"),
- grecs_data_type_string (type),
- grecs_data_type_string (value->type));
- return 1;
- }
- return 0;
-}
-
-int
-assert_scalar_stmt (grecs_locus_t *locus, enum grecs_callback_command cmd)
-{
- if (cmd != grecs_callback_set_value)
- {
- grecs_error (locus, 0, _("unexpected block statement"));
- return 1;
- }
- return 0;
-}
-
-int
conf_callback_url (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
struct pies_url *url;
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
if (pies_url_create (&url, value->v.string))
{
diff --git a/lib/grecsasrt.h b/lib/grecsasrt.h
index 4b3d2d6..f9fe432 100644
--- a/lib/grecsasrt.h
+++ b/lib/grecsasrt.h
@@ -14,9 +14,6 @@
You should have received a copy of the GNU General Public License
along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. */
-int assert_grecs_value_type (grecs_locus_t *locus,
- const grecs_value_t *value, int type);
-int assert_scalar_stmt (grecs_locus_t *locus, enum grecs_callback_command cmd);
int conf_callback_url (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data);
+ grecs_node_t *node,
+ void *varptr, void *cb_data);
diff --git a/src/acl.c b/src/acl.c
index 098edf4..84263e7 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -183,7 +183,7 @@ _parse_sockaddr (struct acl_entry *entry, const grecs_value_t *value)
struct pies_sockaddr *sptr;
const char *string;
- if (assert_grecs_value_type (&entry->locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_value_type (value, GRECS_TYPE_STRING, &entry->locus))
return 1;
string = value->v.string;
@@ -431,7 +431,7 @@ _parse_group (struct acl_entry *entry, size_t argc, grecs_value_t **argv)
static int
_parse_acl (struct acl_entry *entry, size_t argc, grecs_value_t **argv)
{
- if (assert_grecs_value_type (&entry->locus, argv[0], GRECS_TYPE_STRING))
+ if (grecs_assert_value_type (argv[0], GRECS_TYPE_STRING, &entry->locus))
return 1;
else if (_parse_token (entry, argv[0]) == 0)
return _parse_sub_acl (entry, argc - 1, argv + 1);
@@ -570,7 +570,7 @@ _acl_common_section_parser (enum grecs_callback_command cmd,
break;
case grecs_callback_set_value:
- if (assert_grecs_value_type (&value->locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_value_type (value, GRECS_TYPE_STRING, &value->locus))
return 0;
acl = pies_acl_lookup (value->v.string);
if (!acl)
@@ -592,11 +592,11 @@ _acl_common_section_parser (enum grecs_callback_command cmd,
int
acl_section_parser (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr,
- grecs_value_t *value,
- void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
int rc = _acl_common_section_parser (cmd, locus, value, varptr,
ACL_TAG_NONE);
if (rc == 0)
@@ -606,22 +606,22 @@ acl_section_parser (enum grecs_callback_command cmd,
int
defacl_section_parser (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr,
- grecs_value_t *value,
- void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
return _acl_common_section_parser (cmd, locus, value, cb_data,
ACL_TAG_REQUIRED);
}
static int
allow_cb (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr,
- grecs_value_t *value,
- void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
pies_acl_t acl = varptr;
if (cmd != grecs_callback_set_value)
@@ -635,11 +635,11 @@ allow_cb (enum grecs_callback_command cmd,
static int
deny_cb (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr,
- grecs_value_t *value,
- void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
pies_acl_t acl = varptr;
if (cmd != grecs_callback_set_value)
{
diff --git a/src/acl.h b/src/acl.h
index 6a68421..ca31491 100644
--- a/src/acl.h
+++ b/src/acl.h
@@ -40,12 +40,8 @@ int assert_grecs_value_type (grecs_locus_t *locus,
extern struct grecs_keyword acl_keywords[];
extern int acl_section_parser (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr,
- grecs_value_t *value,
- void *cb_data);
+ grecs_node_t *node,
+ void *varptr, void *cb_data);
extern int defacl_section_parser (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr,
- grecs_value_t *value,
- void *cb_data);
+ grecs_node_t *node,
+ void *varptr, void *cb_data);
diff --git a/src/comp.c b/src/comp.c
index d030979..d9e7966 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -736,6 +736,13 @@ component_verify (struct component *comp, grecs_locus_t *locus)
void
component_finish (struct component *comp, grecs_locus_t *locus)
{
+ if (!comp->command)
+ {
+ grecs_error (locus, 0, "%s", _("no 'command' statement"));
+ component_free (comp);
+ return;
+ }
+
if (comp->flags & CF_SHELL)
{
comp->argc = 3;
diff --git a/src/meta1parse.c b/src/meta1parse.c
index 6cf97ca..a8a16ee 100644
--- a/src/meta1parse.c
+++ b/src/meta1parse.c
@@ -110,7 +110,7 @@ substatement_find (struct grecs_node *node, char const *name, int type,
return substatement_error;
}
- if (assert_grecs_value_type (&np->v.value->locus, np->v.value, type))
+ if (grecs_assert_value_type (np->v.value, type, &np->v.value->locus))
return substatement_error;
*ret = np->v.value;
diff --git a/src/pies.c b/src/pies.c
index fe8d9b4..f8525da 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -179,10 +179,12 @@ stderr_closed_p (void)
}
static int
-_cb_action (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+_cb_action (enum grecs_callback_command cmd, grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
+
enum return_action *pact = varptr;
static struct tokendef actab[] = {
{"disable", action_disable},
@@ -191,8 +193,7 @@ _cb_action (enum grecs_callback_command cmd,
};
int res;
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
if (strtotok (actab, value->v.string, &res))
{
@@ -434,8 +435,8 @@ _get_array_arg (grecs_value_t *val, int num, grecs_locus_t *locus)
{
if (num < val->v.arg.c)
{
- if (assert_grecs_value_type (locus, val->v.arg.v[num],
- GRECS_TYPE_STRING) == 0)
+ if (grecs_assert_value_type (val->v.arg.v[num], GRECS_TYPE_STRING,
+ locus) == 0)
return val->v.arg.v[num]->v.string;
}
return NULL;
@@ -449,17 +450,19 @@ _get_list_arg (grecs_value_t *val, int num, grecs_locus_t *locus)
{
grecs_error (locus, 0, _("cannot get list item"));
}
- else if (assert_grecs_value_type (locus, elt, GRECS_TYPE_STRING) == 0)
+ else if (grecs_assert_value_type (elt, GRECS_TYPE_STRING, locus) == 0)
return elt->v.string;
return NULL;
}
static int
return_code_section_parser (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr,
- grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
+
struct component *comp = varptr;
size_t count;
struct action *act;
@@ -513,7 +516,7 @@ config_array_to_argv (grecs_value_t *val, grecs_locus_t *locus, size_t *pargc)
argv = grecs_calloc (argc + 1, sizeof (argv[0]));
for (i = j = 0; i < argc; i++)
{
- if (assert_grecs_value_type (locus, val->v.arg.v[i], GRECS_TYPE_STRING)
+ if (grecs_assert_value_type (val->v.arg.v[i], GRECS_TYPE_STRING, locus)
== 0)
argv[j++] = grecs_strdup (val->v.arg.v[i]->v.string);
}
@@ -525,15 +528,17 @@ config_array_to_argv (grecs_value_t *val, grecs_locus_t *locus, size_t *pargc)
static int
_cb_umask (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
+
mode_t *pmode = varptr;
char *p;
unsigned long n;
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
n = strtoul (value->v.string, &p, 8);
if (*p)
@@ -695,21 +700,20 @@ _cb_env (envop_t **envop, grecs_value_t *value, grecs_locus_t *locus)
static int
cb_env_section_parser (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr,
- grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
struct component *comp = varptr;
switch (cmd)
{
case grecs_callback_section_begin:
- //FIXME
*(struct component **) cb_data = comp;
break;
case grecs_callback_section_end:
- //FIXME
break;
case grecs_callback_set_value:
@@ -720,14 +724,15 @@ cb_env_section_parser (enum grecs_callback_command cmd,
static int
_cb_env_clear (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
struct component *comp = varptr;
int clear;
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
if (grecs_string_convert(&clear, grecs_type_bool, value->v.string, locus))
return 1;
@@ -741,14 +746,15 @@ _cb_env_clear (enum grecs_callback_command cmd,
static int
_cb_env_keep (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
struct component *comp = varptr;
char *p;
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
p = strchr (value->v.string, '=');
if (p)
@@ -762,14 +768,15 @@ _cb_env_keep (enum grecs_callback_command cmd,
static int
_cb_env_set (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
struct component *comp = varptr;
char *p;
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
p = strchr (value->v.string, '=');
if (p)
@@ -781,14 +788,15 @@ _cb_env_set (enum grecs_callback_command cmd,
static int
_cb_env_unset (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
struct component *comp = varptr;
char *p;
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
p = strchr (value->v.string, '=');
if (p)
@@ -882,12 +890,14 @@ string_to_syslog_facility (const char *key, int *pres)
static int
cb_syslog_facility (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
const char *str;
- if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
str = value->v.string;
if (c_isdigit (str[0]))
@@ -907,9 +917,11 @@ cb_syslog_facility (enum grecs_callback_command cmd,
static int
_cb_redir (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
struct redirector *rp = varptr;
static struct tokendef redirtab[] = {
{"null", redir_null},
@@ -937,8 +949,8 @@ _cb_redir (enum grecs_callback_command cmd,
break;
case GRECS_TYPE_ARRAY:
- if (assert_grecs_value_type (locus, value->v.arg.v[0],
- GRECS_TYPE_STRING))
+ if (grecs_assert_value_type (value->v.arg.v[0], GRECS_TYPE_STRING,
+ locus))
return 1;
if (strtotok (redirtab, value->v.arg.v[0]->v.string, &res))
grecs_error (locus, 0, _("%s: unrecognised redirector type"),
@@ -952,8 +964,8 @@ _cb_redir (enum grecs_callback_command cmd,
grecs_error (locus, 0, _("wrong number of arguments"));
return 1;
}
- if (assert_grecs_value_type (locus, value->v.arg.v[1],
- GRECS_TYPE_STRING))
+ if (grecs_assert_value_type (value->v.arg.v[1],
+ GRECS_TYPE_STRING, locus))
return 1;
switch (res)
@@ -1014,11 +1026,13 @@ socket_type_to_str (int socket_type, const char **pres)
static int
_cb_socket_type (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
+
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
if (str_to_socket_type (value->v.string, varptr))
@@ -1054,13 +1068,14 @@ static struct tokendef modetab[] = {
static int
_cb_mode (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
int res;
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
if (strtotok (modetab, value->v.string, &res))
grecs_error (locus, 0, _("%s: unrecognised mode"), value->v.string);
@@ -1071,14 +1086,15 @@ _cb_mode (enum grecs_callback_command cmd,
static int
_cb_limits (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
limits_record_t *plrec = varptr;
char *p;
- if (assert_scalar_stmt (locus, cmd)
- || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
if (parse_limits (plrec, (char *) value->v.string, &p))
grecs_error (locus, 0, _("invalid limit string (near %s)"), p);
@@ -1125,9 +1141,11 @@ str_to_cf (const char *string, int *flags)
static int
_cb_flags (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
int *flags = varptr;
switch (value->type)
@@ -1147,7 +1165,7 @@ _cb_flags (enum grecs_callback_command cmd,
for (ep = value->v.list->head; ep; ep = ep->next)
{
const grecs_value_t *vp = ep->data;
- if (assert_grecs_value_type (locus, vp, GRECS_TYPE_STRING))
+ if (grecs_assert_value_type (vp, GRECS_TYPE_STRING, locus))
return 1;
if (str_to_cf (vp->v.string, flags))
{
@@ -1168,12 +1186,14 @@ _cb_flags (enum grecs_callback_command cmd,
static int
_cb_initdefault (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
int *val = varptr;
- if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
if (strlen (value->v.string) != 1)
{
@@ -1191,12 +1211,14 @@ _cb_initdefault (enum grecs_callback_command cmd,
static int
_cb_runlevels (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
char **sptr = varptr, *p;
- if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
for (p = value->v.string; *p; p++)
{
@@ -1463,16 +1485,23 @@ find_component_keyword (const char *ident)
static int
component_section_parser (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
struct component *comp;
void **section_data = cb_data;
switch (cmd)
{
case grecs_callback_section_begin:
- if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ if (GRECS_VALUE_EMPTY_P (value))
+ {
+ grecs_error (locus, 0, _("missing tag"));
+ return 1;
+ }
+ if (grecs_assert_value_type (value, GRECS_TYPE_STRING, locus))
return 1;
comp = component_create (value->v.string);
*section_data = comp;
@@ -1557,10 +1586,11 @@ struct component default_component;
static int
_cb_include_meta1 (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
- if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ grecs_value_t *value = node->v.value;
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
meta1_config_parse (value->v.string);
return 0;
@@ -1568,10 +1598,11 @@ _cb_include_meta1 (enum grecs_callback_command cmd,
static int
_cb_include_inetd (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr, grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
- if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
+ grecs_value_t *value = node->v.value;
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
return 1;
return inetd_config_parse (value->v.string);
}
diff --git a/src/piesctl.c b/src/piesctl.c
index 4c777d7..390ccfc 100644
--- a/src/piesctl.c
+++ b/src/piesctl.c
@@ -80,10 +80,12 @@ static struct grecs_keyword instance_keywords[] = {
static int
callback_instance (enum grecs_callback_command cmd,
- grecs_locus_t *locus,
- void *varptr,
- grecs_value_t *value, void *cb_data)
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
+
switch (cmd)
{
case grecs_callback_section_begin:
@@ -92,7 +94,7 @@ callback_instance (enum grecs_callback_command cmd,
grecs_error (locus, 0, _("missing tag"));
return 1;
}
- if (assert_grecs_value_type (&value->locus, value, GRECS_TYPE_STRING))
+ if (grecs_assert_value_type (value, GRECS_TYPE_STRING, locus))
return 1;
if (strcmp (value->v.string, instance) == 0)
*(struct client_conn **) cb_data = &client;
@@ -184,8 +186,10 @@ parse_config (void)
node = grecs_find_node (tree, "/control/socket");
if (node)
{
- assert_grecs_value_type (&node->locus,
- node->v.value, GRECS_TYPE_STRING);
+ if (grecs_assert_value_type (node->v.value, GRECS_TYPE_STRING,
+ &node->locus))
+ exit (EX_CONFIG);
+
if (pies_url_create (&client.url, node->v.value->v.string))
{
grecs_error (&node->locus, 0, _("%s: cannot create URL: %s"),

Return to:

Send suggestions and report system problems to the System administrator.