aboutsummaryrefslogtreecommitdiff
path: root/src/pies.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-06-06 07:21:43 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-06-06 08:24:28 +0300
commitb220b5a367469c571358c34ea0df813522e99485 (patch)
tree600e8f26555a359b9d5297b1d566717a1ec78182 /src/pies.c
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 (limited to 'src/pies.c')
-rw-r--r--src/pies.c183
1 files changed, 107 insertions, 76 deletions
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);
}

Return to:

Send suggestions and report system problems to the System administrator.