nfs: fix real/effective id mismatch in nfs_access
[dragonfly.git] / libexec / dma / aliases_parse.y
blobdd8b88a8104239e957abaed6958fe9cd8e6c5f73
1 %{
3 #include <err.h>
4 #include <string.h>
5 #include "dma.h"
7 extern int yylineno;
8 static void yyerror(const char *);
9 int yywrap(void);
10 int yylex(void);
12 static void
13 yyerror(const char *msg)
15 warnx("aliases line %d: %s", yylineno, msg);
18 int
19 yywrap(void)
21 return (1);
26 %union {
27 char *ident;
28 struct stritem *strit;
29 struct alias *alias;
32 %token <ident> T_IDENT
33 %token T_ERROR
34 %token T_EOF 0
36 %type <strit> dests
37 %type <alias> alias aliases
41 start : aliases T_EOF
43 LIST_FIRST(&aliases) = $1;
46 aliases : /* EMPTY */
48 $$ = NULL;
50 | alias aliases
52 if ($2 != NULL && $1 != NULL)
53 LIST_INSERT_AFTER($2, $1, next);
54 else if ($2 == NULL)
55 $2 = $1;
56 $$ = $2;
60 alias : T_IDENT ':' dests '\n'
62 struct alias *al;
64 if ($1 == NULL)
65 YYABORT;
66 al = calloc(1, sizeof(*al));
67 if (al == NULL)
68 YYABORT;
69 al->alias = $1;
70 SLIST_FIRST(&al->dests) = $3;
71 $$ = al;
73 | error '\n'
75 yyerrok;
76 $$ = NULL;
80 dests : T_IDENT
82 struct stritem *it;
84 if ($1 == NULL)
85 YYABORT;
86 it = calloc(1, sizeof(*it));
87 if (it == NULL)
88 YYABORT;
89 it->str = $1;
90 $$ = it;
92 | T_IDENT ',' dests
94 struct stritem *it;
96 if ($1 == NULL)
97 YYABORT;
98 it = calloc(1, sizeof(*it));
99 if (it == NULL)
100 YYABORT;
101 it->str = $1;
102 SLIST_NEXT(it, next) = $3;
103 $$ = it;