aboutsummaryrefslogtreecommitdiff
path: root/src/rc-gram.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/rc-gram.y')
-rw-r--r--src/rc-gram.y94
1 files changed, 47 insertions, 47 deletions
diff --git a/src/rc-gram.y b/src/rc-gram.y
index d2aa080..1768eb1 100644
--- a/src/rc-gram.y
+++ b/src/rc-gram.y
@@ -1,12 +1,12 @@
%{
/*
rc-gram.y
This file is part of GNU Anubis.
- Copyright (C) 2003-2014 The Anubis Team.
+ Copyright (C) 2003-2024 The Anubis Team.
GNU Anubis is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
@@ -334,29 +334,29 @@ cond : expr
{
$$ = $2;
}
| cond AND cond
{
$$ = rc_node_create (rc_node_bool, &@2.beg);
- $$->v.bool.op = bool_and;
- $$->v.bool.left = $1;
- $$->v.bool.right = $3;
+ $$->v.vbool.op = bool_and;
+ $$->v.vbool.left = $1;
+ $$->v.vbool.right = $3;
}
| cond OR cond
{
$$ = rc_node_create (rc_node_bool, &@2.beg);
- $$->v.bool.op = bool_or;
- $$->v.bool.left = $1;
- $$->v.bool.right = $3;
+ $$->v.vbool.op = bool_or;
+ $$->v.vbool.left = $1;
+ $$->v.vbool.right = $3;
}
| NOT cond
{
$$ = rc_node_create (rc_node_bool, &@1.beg);
- $$->v.bool.op = bool_not;
- $$->v.bool.left = $2;
- $$->v.bool.right = NULL;
+ $$->v.vbool.op = bool_not;
+ $$->v.vbool.left = $2;
+ $$->v.vbool.right = NULL;
}
;
meq : /* empty */
{
$$ = 1;
@@ -455,25 +455,25 @@ string_key: /* empty */
}
;
expr : s_msgpart opt_sep meq opt_modlist string
{
RC_NODE *node = rc_node_create (rc_node_expr, &@1.beg);
- node->v.expr.part = $1.part;
- node->v.expr.key = $1.string;
- node->v.expr.sep = $2;
- node->v.expr.re = anubis_regex_compile ($5, $4);
+ node->v.vexpr.part = $1.part;
+ node->v.vexpr.key = $1.string;
+ node->v.vexpr.sep = $2;
+ node->v.vexpr.re = anubis_regex_compile ($5, $4);
free ($5);
if ($3)
$$ = node;
else
{
$$ = rc_node_create (rc_node_bool, &@1.beg);
- $$->v.bool.op = bool_not;
- $$->v.bool.left = node;
- $$->v.bool.right = NULL;
+ $$->v.vbool.op = bool_not;
+ $$->v.vbool.left = node;
+ $$->v.vbool.right = NULL;
}
}
;
modlist : modifier
{
@@ -517,15 +517,15 @@ rule_stmt: rule_start EOL stmtlist DONE
}
;
rule_start: rule opt_modlist string
{
$$ = rc_node_create (rc_node_expr, &@1.beg);
- $$->v.expr.part = HEADER;
- $$->v.expr.key = strdup (X_ANUBIS_RULE_HEADER);
- $$->v.expr.re = anubis_regex_compile ($3, $2);
+ $$->v.vexpr.part = HEADER;
+ $$->v.vexpr.key = strdup (X_ANUBIS_RULE_HEADER);
+ $$->v.vexpr.re = anubis_regex_compile ($3, $2);
free ($3);
}
;
rule : RULE
{
@@ -953,16 +953,16 @@ rc_asgn_destroy (RC_ASGN *asgn)
list_destroy (&asgn->rhs, anubis_free_list_item, NULL);
}
/* Bools */
void
-rc_bool_destroy (RC_BOOL *bool)
+rc_bool_destroy (RC_BOOL *b)
{
- rc_node_destroy (bool->left);
- rc_node_destroy (bool->right);
+ rc_node_destroy (b->left);
+ rc_node_destroy (b->right);
}
/* Nodes */
/* FIXME: 2nd should better be struct rc_yyltype */
RC_NODE *
@@ -980,18 +980,18 @@ rc_node_destroy (RC_NODE *node)
{
if (!node)
return;
switch (node->type)
{
case rc_node_bool:
- rc_bool_destroy (&node->v.bool);
+ rc_bool_destroy (&node->v.vbool);
break;
case rc_node_expr:
- free (node->v.expr.key);
- anubis_regex_free (&node->v.expr.re);
+ free (node->v.vexpr.key);
+ anubis_regex_free (&node->v.vexpr.re);
}
rc_destroy_loc (&node->loc);
xfree (node);
}
static char *
@@ -1015,43 +1015,43 @@ part_string (int part)
void
rc_node_print (RC_NODE *node)
{
switch (node->type)
{
case rc_node_expr:
- printf ("%s", part_string (node->v.expr.part));
- if (node->v.expr.key && node->v.expr.key[0] != '\n')
- printf ("[%s]",node->v.expr.key);
- if (node->v.expr.sep)
- printf ("(%s)", node->v.expr.sep);
+ printf ("%s", part_string (node->v.vexpr.part));
+ if (node->v.vexpr.key && node->v.vexpr.key[0] != '\n')
+ printf ("[%s]",node->v.vexpr.key);
+ if (node->v.vexpr.sep)
+ printf ("(%s)", node->v.vexpr.sep);
printf (" ");
- anubis_regex_print (node->v.expr.re);
+ anubis_regex_print (node->v.vexpr.re);
break;
case rc_node_bool:
- switch (node->v.bool.op)
+ switch (node->v.vbool.op)
{
case bool_not:
printf ("NOT (");
- rc_node_print (node->v.bool.left);
+ rc_node_print (node->v.vbool.left);
printf (")");
break;
case bool_and:
printf ("AND (");
- rc_node_print (node->v.bool.left);
+ rc_node_print (node->v.vbool.left);
printf (",");
- rc_node_print (node->v.bool.right);
+ rc_node_print (node->v.vbool.right);
printf (")");
break;
case bool_or:
printf ("OR (");
- rc_node_print (node->v.bool.left);
+ rc_node_print (node->v.vbool.left);
printf (",");
- rc_node_print (node->v.bool.right);
+ rc_node_print (node->v.vbool.right);
printf (")");
break;
}
}
}
@@ -1468,13 +1468,13 @@ eval_warning (struct eval_env *env, const char *fmt, ...)
fmt, ap);
va_end(ap);
}
static void asgn_eval (struct eval_env *env, RC_ASGN *asgn);
static int node_eval (struct eval_env *env, RC_NODE *node);
-static int bool_eval (struct eval_env *env, RC_BOOL *bool);
+static int bool_eval (struct eval_env *env, RC_BOOL *b);
static void cond_eval (struct eval_env *env, RC_COND *cond);
static void rule_eval (struct eval_env *env, RC_RULE *rule);
static void stmt_list_eval (struct eval_env *env, RC_STMT *stmt);
static void inst_eval (struct eval_env *env, RC_INST *inst);
#define VALID_STR(s) ((s)?(s):"NULL")
@@ -1660,13 +1660,13 @@ int
expr_eval (struct eval_env *env, RC_EXPR *expr)
{
int rc;
if (env->refstr && anubis_regex_refcnt (expr->re))
{
- argcv_free (-1, env->refstr);
+ argv_free (env->refstr);
env->refcnt = 0;
env->refstr = NULL;
}
switch (expr->part)
{
@@ -1710,32 +1710,32 @@ node_eval (struct eval_env *env, RC_NODE *node)
Note default: branch below */
env->loc = node->loc;
switch (node->type)
{
case rc_node_bool:
- rc = bool_eval (env, &node->v.bool);
+ rc = bool_eval (env, &node->v.vbool);
break;
case rc_node_expr:
- rc = expr_eval (env, &node->v.expr);
+ rc = expr_eval (env, &node->v.vexpr);
break;
default:
abort ();
}
return rc;
}
int
-bool_eval (struct eval_env *env, RC_BOOL *bool)
+bool_eval (struct eval_env *env, RC_BOOL *bv)
{
- int rc = node_eval (env, bool->left);
+ int rc = node_eval (env, bv->left);
- switch (bool->op)
+ switch (bv->op)
{
case bool_not:
return !rc;
case bool_and:
if (!rc)
@@ -1744,13 +1744,13 @@ bool_eval (struct eval_env *env, RC_BOOL *bool)
case bool_or:
if (rc)
return 1;
break;
}
- return node_eval (env, bool->right);
+ return node_eval (env, bv->right);
}
void
cond_eval (struct eval_env *env, RC_COND *cond)
{
if (node_eval (env, cond->node))
@@ -1811,13 +1811,13 @@ eval_section (int method, RC_SECTION *sec, struct rc_secdef *secdef,
tracefile (&sec->loc, _("Section %s"), sec->name);
if (setjmp (env.jmp) == 0)
stmt_list_eval (&env, sec->stmt);
if (env.refstr)
- argcv_free (-1, env.refstr);
+ argv_free (env.refstr);
}
void
rc_run_section (int method, RC_SECTION *sec, struct rc_secdef *secdef,
const char *class_name,
void *data, MESSAGE msg)

Return to:

Send suggestions and report system problems to the System administrator.