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