165532Snectar%{ 265532Snectar/* $NetBSD: nslexer.l,v 1.3 1999/01/25 00:16:17 lukem Exp $ */ 365532Snectar 465532Snectar/*- 565532Snectar * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. 665532Snectar * All rights reserved. 765532Snectar * 865532Snectar * This code is derived from software contributed to The NetBSD Foundation 965532Snectar * by Luke Mewburn. 1065532Snectar * 1165532Snectar * Redistribution and use in source and binary forms, with or without 1265532Snectar * modification, are permitted provided that the following conditions 1365532Snectar * are met: 1465532Snectar * 1. Redistributions of source code must retain the above copyright 1565532Snectar * notice, this list of conditions and the following disclaimer. 1665532Snectar * 2. Redistributions in binary form must reproduce the above copyright 1765532Snectar * notice, this list of conditions and the following disclaimer in the 1865532Snectar * documentation and/or other materials provided with the distribution. 1965532Snectar * 2065532Snectar * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2165532Snectar * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2265532Snectar * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2365532Snectar * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2465532Snectar * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2565532Snectar * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2665532Snectar * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2765532Snectar * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2865532Snectar * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2965532Snectar * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3065532Snectar * POSSIBILITY OF SUCH DAMAGE. 3165532Snectar */ 3265532Snectar 3365532Snectar#include <sys/cdefs.h> 3465532Snectar#if defined(LIBC_SCCS) && !defined(lint) 3565532Snectarstatic char *rcsid = 3665532Snectar "$FreeBSD$"; 3765532Snectar#endif /* LIBC_SCCS and not lint */ 3865532Snectar 39111618Snectar#include "namespace.h" 4065532Snectar#include <ctype.h> 4165532Snectar#define _NS_PRIVATE 4265532Snectar#include <nsswitch.h> 4365532Snectar#include <string.h> 44113595Snectar#include <syslog.h> 45111618Snectar#include "un-namespace.h" 4665532Snectar 4765532Snectar#include "nsparser.h" 4865532Snectar 4965532Snectar%} 5065532Snectar 51250227Sjkim%option noinput 52250227Sjkim%option nounput 5365532Snectar%option yylineno 5465532Snectar 5565532SnectarBLANK [ \t] 5665532SnectarCR \n 5765532SnectarSTRING [a-zA-Z][a-zA-Z0-9_]* 5865532Snectar 5965532Snectar%% 6065532Snectar 6165532Snectar{BLANK}+ ; /* skip whitespace */ 6265532Snectar 6365532Snectar#.* ; /* skip comments */ 6465532Snectar 6565532Snectar\\{CR} ; /* allow continuation */ 6665532Snectar 6765532Snectar{CR} return NL; 6865532Snectar 6965532Snectar[sS][uU][cC][cC][eE][sS][sS] return SUCCESS; 7065532Snectar[uU][nN][aA][vV][aA][iI][lL] return UNAVAIL; 7165532Snectar[nN][oO][tT][fF][oO][uU][nN][dD] return NOTFOUND; 7265532Snectar[tT][rR][yY][aA][gG][aA][iI][nN] return TRYAGAIN; 7365532Snectar 7465532Snectar[rR][eE][tT][uU][rR][nN] return RETURN; 7565532Snectar[cC][oO][nN][tT][iI][nN][uU][eE] return CONTINUE; 7665532Snectar 7765532Snectar{STRING} { 7865532Snectar char *p; 7965532Snectar int i; 8065532Snectar 81113595Snectar if ((p = strdup(yytext)) == NULL) { 82113595Snectar syslog(LOG_ERR, 83113595Snectar "NSSWITCH(nslexer): memory allocation failure"); 84113595Snectar return ERRORTOKEN; 85113595Snectar } 8665532Snectar for (i = 0; i < strlen(p); i++) { 8765532Snectar if (isupper((unsigned char)p[i])) 8865532Snectar p[i] = tolower((unsigned char)p[i]); 8965532Snectar } 9065532Snectar _nsyylval.str = p; 9165532Snectar return STRING; 9265532Snectar } 9365532Snectar 9486162Sfenner. return yytext[0]; 9565532Snectar 9665532Snectar%% 9765532Snectar 9865532Snectar#undef _nsyywrap 9965532Snectarint 10065532Snectar_nsyywrap() 10165532Snectar{ 10265532Snectar return 1; 10365532Snectar} /* _nsyywrap */ 10465532Snectar 10565532Snectarvoid 10665532Snectar_nsyyerror(msg) 10765532Snectar const char *msg; 10865532Snectar{ 10965532Snectar 110113595Snectar syslog(LOG_ERR, "NSSWITCH(nslexer): %s line %d: %s at '%s'", 111113595Snectar _PATH_NS_CONF, yylineno, msg, yytext); 11265532Snectar} /* _nsyyerror */ 113