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