6 #include <sys/socket.h>
8 #include <netinet/in.h>
33 enum filter_action action;
39 static size_t parsed_lines;
47 %token ACTION IN OUT FROM QUICK LOG SOCKET
51 %token <string> WORD SOCKET
52 %token <number> NUMBER
53 %type <number> ACTION DIR QUICK LOG
54 %type <string> from topic
64 mqttrule : ACTION DIR topic from
68 memset(&r, 0, sizeof(r));
72 strlcpy(r.topic, $3, sizeof r.topic);
74 strlcpy(r.from, $4, sizeof r.from);
76 printf("%s %s <from> %s.\n", r.action == GTW_DROP ? "Drop" : "pass", r.topic[0]!=0 ? r.topic :"*", r.from[0]!=0 ? r.from : "<all>");
79 topic : ANY {$$=NULL;}
83 from : /* empty */ {$$=NULL;}
84 | FROM SOCKET {$$ = $2;}
92 fprintf(stderr, "while parsing \"%s\"\n",
98 int main( int argc, char **argv )
100 ++argv, --argc; /* skip over program name */
102 yyin = fopen( argv[0], "r" );
107 printf("\n#%zu.\n", parsed_lines);