Home | History | Annotate | Line # | Download | only in net
nslexer.l revision 1.5.2.1
      1      1.2   lukem %{
      2  1.5.2.1     jmc /*	$NetBSD: nslexer.l,v 1.5.2.1 2004/03/15 04:42:17 jmc Exp $	*/
      3      1.2   lukem 
      4      1.2   lukem /*-
      5      1.2   lukem  * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
      6      1.2   lukem  * All rights reserved.
      7      1.2   lukem  *
      8      1.2   lukem  * This code is derived from software contributed to The NetBSD Foundation
      9      1.2   lukem  * by Luke Mewburn.
     10      1.2   lukem  *
     11      1.2   lukem  * Redistribution and use in source and binary forms, with or without
     12      1.2   lukem  * modification, are permitted provided that the following conditions
     13      1.2   lukem  * are met:
     14      1.2   lukem  * 1. Redistributions of source code must retain the above copyright
     15      1.2   lukem  *    notice, this list of conditions and the following disclaimer.
     16      1.2   lukem  * 2. Redistributions in binary form must reproduce the above copyright
     17      1.2   lukem  *    notice, this list of conditions and the following disclaimer in the
     18      1.2   lukem  *    documentation and/or other materials provided with the distribution.
     19      1.2   lukem  * 3. All advertising materials mentioning features or use of this software
     20      1.2   lukem  *    must display the following acknowledgement:
     21      1.2   lukem  *        This product includes software developed by the NetBSD
     22      1.2   lukem  *        Foundation, Inc. and its contributors.
     23      1.2   lukem  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24      1.2   lukem  *    contributors may be used to endorse or promote products derived
     25      1.2   lukem  *    from this software without specific prior written permission.
     26      1.2   lukem  *
     27      1.2   lukem  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28      1.2   lukem  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29      1.2   lukem  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30      1.2   lukem  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31      1.2   lukem  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32      1.2   lukem  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33      1.2   lukem  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34      1.2   lukem  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35      1.2   lukem  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36      1.2   lukem  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37      1.2   lukem  * POSSIBILITY OF SUCH DAMAGE.
     38      1.2   lukem  */
     39      1.3   lukem 
     40      1.3   lukem #include <sys/cdefs.h>
     41      1.3   lukem #if defined(LIBC_SCCS) && !defined(lint)
     42  1.5.2.1     jmc __RCSID("$NetBSD: nslexer.l,v 1.5.2.1 2004/03/15 04:42:17 jmc Exp $");
     43      1.3   lukem #endif /* LIBC_SCCS and not lint */
     44      1.2   lukem 
     45      1.4  kleink #include "namespace.h"
     46      1.2   lukem #include <ctype.h>
     47      1.2   lukem #define _NS_PRIVATE
     48      1.2   lukem #include <nsswitch.h>
     49      1.2   lukem #include <string.h>
     50  1.5.2.1     jmc #include <syslog.h>
     51      1.2   lukem 
     52      1.2   lukem #include "nsparser.h"
     53      1.2   lukem 
     54      1.2   lukem #define YY_NO_UNPUT
     55      1.2   lukem 
     56      1.2   lukem %}
     57      1.2   lukem 
     58      1.2   lukem %option yylineno
     59  1.5.2.1     jmc %option never-interactive
     60      1.2   lukem 
     61      1.2   lukem BLANK		[ \t]
     62      1.2   lukem CR		\n
     63      1.2   lukem STRING		[a-zA-Z][a-zA-Z0-9_]*
     64      1.2   lukem 
     65      1.2   lukem %%
     66      1.2   lukem 
     67      1.2   lukem {BLANK}+	;			/* skip whitespace */
     68      1.2   lukem 
     69      1.2   lukem #.*		;			/* skip comments */
     70      1.2   lukem 
     71      1.2   lukem \\{CR}		;			/* allow continuation */
     72      1.2   lukem 
     73      1.2   lukem {CR}		return NL;
     74      1.2   lukem 
     75      1.2   lukem [sS][uU][cC][cC][eE][sS][sS]		return SUCCESS;
     76      1.2   lukem [uU][nN][aA][vV][aA][iI][lL]		return UNAVAIL;
     77      1.2   lukem [nN][oO][tT][fF][oO][uU][nN][dD]	return NOTFOUND;
     78      1.2   lukem [tT][rR][yY][aA][gG][aA][iI][nN]	return TRYAGAIN;
     79      1.2   lukem 
     80      1.2   lukem [rR][eE][tT][uU][rR][nN]		return RETURN;
     81      1.2   lukem [cC][oO][nN][tT][iI][nN][uU][eE]	return CONTINUE;
     82      1.2   lukem 
     83      1.2   lukem {STRING}	{
     84      1.2   lukem 			char *p;
     85      1.2   lukem 			int i;
     86      1.2   lukem 
     87  1.5.2.1     jmc 			if ((p = strdup(yytext)) == NULL) {
     88  1.5.2.1     jmc 				syslog(LOG_ERR, "libc nsdispatch: %m");
     89  1.5.2.1     jmc 				return NL;
     90  1.5.2.1     jmc 			}
     91      1.2   lukem 
     92      1.2   lukem 			for (i = 0; i < strlen(p); i++) {
     93      1.2   lukem 				if (isupper((unsigned char)p[i]))
     94      1.2   lukem 					p[i] = tolower((unsigned char)p[i]);
     95      1.2   lukem 			}
     96      1.2   lukem 			_nsyylval.str = p;
     97      1.2   lukem 			return STRING;
     98      1.2   lukem 		}
     99      1.2   lukem 
    100      1.5   lukem .		return yytext[0];
    101      1.2   lukem 
    102      1.2   lukem %%
    103      1.2   lukem 
    104      1.2   lukem #undef _nsyywrap
    105      1.2   lukem int
    106      1.2   lukem _nsyywrap()
    107      1.2   lukem {
    108      1.2   lukem 	return 1;
    109      1.2   lukem } /* _nsyywrap */
    110      1.2   lukem 
    111      1.2   lukem void
    112      1.2   lukem _nsyyerror(msg)
    113      1.2   lukem 	const char *msg;
    114      1.2   lukem {
    115      1.2   lukem 
    116  1.5.2.1     jmc 	 syslog(LOG_WARNING, "libc nsdispatch: %s line %d: %s at '%s'",
    117  1.5.2.1     jmc 	    _PATH_NS_CONF, yylineno, msg, yytext);
    118      1.2   lukem } /* _nsyyerror */
    119