chiark
/
gitweb
/
~mdw
/
become
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2e11036
)
Use rewritten class handler. Makes the expression parsers considerably
author
mdw
<mdw>
Wed, 17 Sep 1997 10:26:52 +0000
(10:26 +0000)
committer
mdw
<mdw>
Wed, 17 Sep 1997 10:26:52 +0000
(10:26 +0000)
simpler.
src/parser.y
patch
|
blob
|
blame
|
history
diff --git
a/src/parser.y
b/src/parser.y
index b36ecdb5271389d44fca30825318539ddd78623f..a3860b42d2c03afb95a104740bd36db82c4d94f8 100644
(file)
--- a/
src/parser.y
+++ b/
src/parser.y
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: parser.y,v 1.
3 1997/09/09 18:17:06
mdw Exp $
+ * $Id: parser.y,v 1.
4 1997/09/17 10:26:52
mdw Exp $
*
* Parser for `become.conf' files
*
*
* Parser for `become.conf' files
*
@@
-29,6
+29,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: parser.y,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: parser.y,v $
+ * Revision 1.4 1997/09/17 10:26:52 mdw
+ * Use rewritten class handler. Makes the expression parsers considerably
+ * simpler.
+ *
* Revision 1.3 1997/09/09 18:17:06 mdw
* Allow default port to be given as a service name or port number.
*
* Revision 1.3 1997/09/09 18:17:06 mdw
* Allow default port to be given as a service name or port number.
*
@@
-69,7
+73,6
@@
#include "lexer.h"
#include "name.h"
#include "rule.h"
#include "lexer.h"
#include "name.h"
#include "rule.h"
-#include "set.h"
#include "sym.h"
#include "userdb.h"
#include "utils.h"
#include "sym.h"
#include "userdb.h"
#include "utils.h"
@@
-81,7
+84,7
@@
long i;
char *s;
name *n;
long i;
char *s;
name *n;
- class
def
*c;
+ class
_node
*c;
}
/*----- Token and rule declarations ---------------------------------------*/
}
/*----- Token and rule declarations ---------------------------------------*/
@@
-251,90
+254,38
@@
name : WORD {
/* --- User class expressions --- */
user_class : user_class ',' user_class {
/* --- User class expressions --- */
user_class : user_class ',' user_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_union($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- if ($1 == class_all)
- $$ = class_all;
- else
- $$ = class_create($1->type,
- set_union($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
| user_class '-' user_class {
}
}
| user_class '-' user_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_diff($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- $$ = class_create($1->type,
- set_subtract($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
| user_class '&' user_class {
}
}
| user_class '&' user_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_isect($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- if ($1 == class_all)
- $$ = class_all;
- else
- $$ = class_create($1->type,
- set_intersect($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
| user_class '|' user_class {
}
}
| user_class '|' user_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_union($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- if ($1 == class_all)
- $$ = class_all;
- else
- $$ = class_create($1->type,
- set_union($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
}
}
- | INT {
- sym_table *t = xmalloc(sizeof(*t));
- int u = $1;
- sym_createTable(t);
- sym_find(t, (char *)&u, sizeof(u),
- sizeof(sym_base), 0);
- $$ = class_create(clType_user, t);
- }
+ | INT { $$ = class_fromUser(clType_user, $1); }
| STRING {
struct passwd *pw;
| STRING {
struct passwd *pw;
- sym_table *t;
- int u;
if ((pw = userdb_userByName($1)) == 0) {
moan("user `%s' not known at line %i",
$1, lex_line);
YYERROR;
if ((pw = userdb_userByName($1)) == 0) {
moan("user `%s' not known at line %i",
$1, lex_line);
YYERROR;
- } else {
- t = xmalloc(sizeof(*t));
- u = pw->pw_uid;
- sym_createTable(t);
- sym_find(t, (char *)&u, sizeof(u),
- sizeof(sym_base), 0);
- $$ = class_create(clType_user, t);
- }
+ } else
+ $$ = class_fromUser(clType_user, pw->pw_uid);
}
| WORD {
name *n = name_find($1, 0, 0);
}
| WORD {
name *n = name_find($1, 0, 0);
@@
-356,72
+307,30
@@
user_class : user_class ',' user_class {
/* --- Command class expressions --- */
command_class : command_class ',' command_class {
/* --- Command class expressions --- */
command_class : command_class ',' command_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_union($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- if ($1 == class_all)
- $$ = class_all;
- else
- $$ = class_create($1->type,
- set_union($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
| command_class '-' command_class {
}
}
| command_class '-' command_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_diff($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- $$ = class_create($1->type,
- set_subtract($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
| command_class '&' command_class {
}
}
| command_class '&' command_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_isect($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- if ($1 == class_all)
- $$ = class_all;
- else
- $$ = class_create($1->type,
- set_intersect($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
| command_class '|' command_class {
}
}
| command_class '|' command_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_union($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- if ($1 == class_all)
- $$ = class_all;
- else
- $$ = class_create($1->type,
- set_union($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
}
}
- | STRING {
- sym_table *t = xmalloc(sizeof(*t));
- sym_createTable(t);
- sym_find(t, $1, -1, sizeof(sym_base), 0);
- $$ = class_create(clType_command, t);
- }
+ | STRING { $$ = class_fromString(clType_command, $1); }
| WORD {
name *n = name_find($1, 0, 0);
if (!n || !n->c) {
| WORD {
name *n = name_find($1, 0, 0);
if (!n || !n->c) {
@@
-441,73
+350,31
@@
command_class : command_class ',' command_class {
/* --- Host class expressions --- */
/* --- Host class expressions --- */
-host_class : host_class ',' host_class {
- if (
$1->type != $3->type
) {
+host_class
: host_class ',' host_class {
+ if (
($$ = class_union($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- if ($1 == class_all)
- $$ = class_all;
- else
- $$ = class_create($1->type,
- set_union($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
| host_class '-' host_class {
}
}
| host_class '-' host_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_diff($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- $$ = class_create($1->type,
- set_subtract($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
| host_class '&' host_class {
}
}
| host_class '&' host_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_isect($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- if ($1 == class_all)
- $$ = class_all;
- else
- $$ = class_create($1->type,
- set_intersect($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
| host_class '|' host_class {
}
}
| host_class '|' host_class {
- if (
$1->type != $3->type
) {
+ if (
($$ = class_union($1, $3)) == 0
) {
yyerror("type mismatch");
yyerror("type mismatch");
- class_dec($1);
- class_dec($3);
YYERROR;
YYERROR;
- } else {
- if ($1 == class_all)
- $$ = class_all;
- else
- $$ = class_create($1->type,
- set_union($1->t, $3->t));
- class_dec($1);
- class_dec($3);
}
}
}
}
- | STRING {
- sym_table *t = xmalloc(sizeof(*t));
- sym_createTable(t);
- sym_find(t, $1, -1, sizeof(sym_base), 0);
- $$ = class_create(clType_host, t);
- }
+ | STRING { $$ = class_fromString(clType_host, $1); }
| WORD {
name *n = name_find($1, 0, 0);
if (!n || !n->c) {
| WORD {
name *n = name_find($1, 0, 0);
if (!n || !n->c) {