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