inet6: require RTF_ANNOUNCE to proxy NS
[dragonfly.git] / libexec / dma / aliases_parse.y
blob10f4b71617c29797c52dab738820fa2ec6cf5f39
1 %{
3 #include <err.h>
4 #include <string.h>
5 #include <syslog.h>
6 #include "dma.h"
8 extern int yylineno;
9 static void yyerror(const char *);
10 int yywrap(void);
11 #if YYPATCH < 20180510
12 int yylex(void);
13 #endif
15 static void
16 yyerror(const char *msg)
18 /**
19 * Because we do error '\n' below, we need to report the error
20 * one line above of what yylineno points to.
22 syslog(LOG_CRIT, "aliases line %d: %s", yylineno - 1, msg);
23 fprintf(stderr, "aliases line %d: %s\n", yylineno - 1, msg);
26 int
27 yywrap(void)
29 return (1);
34 %union {
35 char *ident;
36 struct stritem *strit;
37 struct alias *alias;
40 %token <ident> T_IDENT
41 %token T_ERROR
42 %token T_EOF 0
44 %type <strit> dests
45 %type <alias> alias aliases
49 start : aliases T_EOF
51 LIST_FIRST(&aliases) = $1;
54 aliases : /* EMPTY */
56 $$ = NULL;
58 | alias aliases
60 if ($2 != NULL && $1 != NULL)
61 LIST_INSERT_AFTER($2, $1, next);
62 else if ($2 == NULL)
63 $2 = $1;
64 $$ = $2;
68 alias : T_IDENT ':' dests '\n'
70 struct alias *al;
72 if ($1 == NULL)
73 YYABORT;
74 al = calloc(1, sizeof(*al));
75 if (al == NULL)
76 YYABORT;
77 al->alias = $1;
78 SLIST_FIRST(&al->dests) = $3;
79 $$ = al;
81 | error '\n'
83 YYABORT;
87 dests : T_IDENT
89 struct stritem *it;
91 if ($1 == NULL)
92 YYABORT;
93 it = calloc(1, sizeof(*it));
94 if (it == NULL)
95 YYABORT;
96 it->str = $1;
97 $$ = it;
99 | T_IDENT ',' dests
101 struct stritem *it;
103 if ($1 == NULL)
104 YYABORT;
105 it = calloc(1, sizeof(*it));
106 if (it == NULL)
107 YYABORT;
108 it->str = $1;
109 SLIST_NEXT(it, next) = $3;
110 $$ = it;