Home | History | Annotate | Line # | Download | only in net
nslexer.l revision 1.1.4.1
      1 %{
      2 /*	$NetBSD: nslexer.l,v 1.1.4.1 1997/05/23 21:14:50 lukem Exp $	*/
      3 
      4 /*-
      5  * Copyright (c) 1997 Luke Mewburn <lukem (at) netbsd.org>
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  * 	This product includes software developed by Luke Mewburn.
     19  * 4. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
     28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     29  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
     30  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
     31  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 #include <ctype.h>
     35 #include <string.h>
     36 
     37 #include "nsswitch.h"
     38 #include "nsparser.tab.h"
     39 %}
     40 
     41 BLANK		[ \t]
     42 CR		\n
     43 DBNAME		[a-zA-Z][a-zA-Z0-9_]*
     44 
     45 %option yylineno
     46 
     47 %%
     48 
     49 {BLANK}+	;	/* skip whitespace */
     50 
     51 #.*		;	/* nuke comments */
     52 
     53 \\{CR}		;	/* allow continuation */
     54 
     55 {CR}		return NL;
     56 
     57 [sS][uU][cC][cC][eE][sS][sS]		return SUCCESS;
     58 [uU][nN][aA][vV][aA][iI][lL]		return UNAVAIL;
     59 [nN][oO][tT][fF][oO][uU][nN][dD]	return NOTFOUND;
     60 [tT][rR][yY][aA][gG][aA][iI][nN]	return TRYAGAIN;
     61 
     62 [rR][eE][tT][uU][rR][nN]		return RETURN;
     63 [cC][oO][nN][tT][iI][nN][uU][eE]	return CONTINUE;
     64 
     65 [fF][iI][lL][eE][sS]			return FILES;
     66 [dD][nN][sS]				return DNS;
     67 [nN][iI][sS]				return NIS;
     68 [nN][iI][sS][pP][lL][uU][sS]		return NISPLUS;
     69 [cC][oO][mM][pP][aA][tT]		return COMPAT;
     70 
     71 {DBNAME}	{
     72 			int i, c;
     73 
     74 			for (i = 0; i < NS_MAXDBLEN; i++) {
     75 				c = yytext[i];
     76 				if (isupper(c))
     77 					c = tolower(c);
     78 				_nsyylval.dbstr[i] = c;
     79 				if (! yytext[i])
     80 					break;
     81 			}
     82 			_nsyylval.dbstr[NS_MAXDBLEN - 1] = '\0';
     83 			return DATABASE;
     84 		}
     85 
     86 [:=\[\]]	return yytext[0];
     87 
     88 .		;	/* ignore all else */
     89 
     90 %%
     91 
     92 #undef _nsyywrap
     93 int
     94 _nsyywrap()
     95 {
     96 	return 1;
     97 } /* _nsyywrap */
     98 
     99 void
    100 _nsyyerror(msg)
    101 	char *msg;
    102 {
    103 
    104 		/* XXX: this should end up in syslog maybe? */
    105 	 fprintf(stderr, "line %d: %s at '%s'\n", yylineno, msg, yytext);
    106 } /* _nsyyerror */
    107