veriexecctl_conf.l revision 1.2.2.1 1 1.1 blymn %{
2 1.2.2.1 tron /* $NetBSD: veriexecctl_conf.l,v 1.2.2.1 2005/06/10 14:47:23 tron Exp $ */
3 1.2.2.1 tron
4 1.2.2.1 tron /*-
5 1.2.2.1 tron * Copyright 2005 Elad Efrat <elad (at) bsd.org.il>
6 1.2.2.1 tron * Copyright 2005 Brett Lymn <blymn (at) netbsd.org>
7 1.2.2.1 tron *
8 1.2.2.1 tron * All rights reserved.
9 1.2.2.1 tron *
10 1.2.2.1 tron * This code has been donated to The NetBSD Foundation by the Author.
11 1.2.2.1 tron *
12 1.2.2.1 tron * Redistribution and use in source and binary forms, with or without
13 1.2.2.1 tron * modification, are permitted provided that the following conditions
14 1.2.2.1 tron * are met:
15 1.2.2.1 tron * 1. Redistributions of source code must retain the above copyright
16 1.2.2.1 tron * notice, this list of conditions and the following disclaimer.
17 1.2.2.1 tron * 2. The name of the author may not be used to endorse or promote products
18 1.2.2.1 tron * derived from this software withough specific prior written permission
19 1.2.2.1 tron *
20 1.2.2.1 tron * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.2.2.1 tron * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.2.2.1 tron * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.2.2.1 tron * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.2.2.1 tron * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.2.2.1 tron * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.2.2.1 tron * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.2.2.1 tron * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.2.2.1 tron * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.2.2.1 tron * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 blymn *
31 1.1 blymn *
32 1.1 blymn */
33 1.1 blymn
34 1.2.2.1 tron #include <sys/param.h>
35 1.2.2.1 tron #include <sys/types.h>
36 1.2.2.1 tron #include <sys/queue.h>
37 1.2.2.1 tron #include <sys/verified_exec.h>
38 1.2.2.1 tron
39 1.1 blymn #include <stdio.h>
40 1.2.2.1 tron #include <stdlib.h>
41 1.1 blymn #include <string.h>
42 1.2.2.1 tron #include <unistd.h>
43 1.2.2.1 tron #include <err.h>
44 1.1 blymn
45 1.2.2.1 tron #include "veriexecctl_parse.h"
46 1.2.2.1 tron #include "veriexecctl.h"
47 1.1 blymn
48 1.2.2.1 tron u_int64_t entries;
49 1.2.2.1 tron char *filename;
50 1.1 blymn %}
51 1.1 blymn
52 1.2.2.1 tron STRING [0-9a-zA-Z]+
53 1.1 blymn
54 1.2.2.1 tron %%
55 1.1 blymn
56 1.2.2.1 tron /* path */
57 1.2.2.1 tron \/[^ \t]+ {
58 1.2.2.1 tron yylval.string = strdup(yytext);
59 1.2.2.1 tron return (PATH);
60 1.2.2.1 tron }
61 1.2.2.1 tron
62 1.2.2.1 tron /* string (fingerprint, type, options) */
63 1.2.2.1 tron {STRING} {
64 1.2.2.1 tron yylval.string = strdup(yytext);
65 1.2.2.1 tron if (!(yylval.string)) {
66 1.2.2.1 tron (void) fprintf(stderr, "WARNING: Out"
67 1.2.2.1 tron " of memory during run-time! "
68 1.2.2.1 tron "Attempting recover...\n");
69 1.2.2.1 tron
70 1.2.2.1 tron /*
71 1.2.2.1 tron * Sleep a little bit and let the
72 1.2.2.1 tron * machine calm down. ;)
73 1.2.2.1 tron */
74 1.2.2.1 tron usleep(60000);
75 1.2.2.1 tron
76 1.2.2.1 tron yylval.string = strdup(yytext);
77 1.2.2.1 tron if (!(yylval.string)) {
78 1.2.2.1 tron (void) fprintf(stderr, "ERROR:"
79 1.2.2.1 tron " No memory. Aborting.\n");
80 1.2.2.1 tron exit(1);
81 1.2.2.1 tron }
82 1.2.2.1 tron
83 1.2.2.1 tron (void) fprintf(stderr, "Recovered.\n");
84 1.2.2.1 tron }
85 1.2.2.1 tron
86 1.2.2.1 tron return (STRING);
87 1.2.2.1 tron }
88 1.2.2.1 tron
89 1.2.2.1 tron
90 1.2.2.1 tron /* comments, white-outs */
91 1.2.2.1 tron [ \t\r] |
92 1.2.2.1 tron #.* ;
93 1.2.2.1 tron #.*\n |
94 1.2.2.1 tron ^\n { line++; }
95 1.2.2.1 tron
96 1.2.2.1 tron /* eol on a line with data. need a call to ioctl, return eol */
97 1.2.2.1 tron \n {
98 1.2.2.1 tron line++;
99 1.2.2.1 tron return (EOL);
100 1.2.2.1 tron }
101 1.1 blymn
102 1.2.2.1 tron . { yyerror("Invalid character"); }
103 1.1 blymn
104 1.1 blymn %%
105 1.1 blymn
106 1.2.2.1 tron int yywrap(void) {
107 1.2.2.1 tron return (1);
108 1.2.2.1 tron }
109 1.2.2.1 tron
110 1.2.2.1 tron void yyerror(const char *string) {
111 1.2.2.1 tron fprintf(stderr, "%s at \"%s\", line %d\n", string, yytext, line);
112 1.1 blymn }
113