Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.sbin / i4b / isdnd / rc_scan.l
1 /*
2  *   Copyright (c) 1997 Joerg Wunsch. All rights reserved.
3  *
4  *   Copyright (c) 1997, 2001 Hellmuth Michaelis. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *   1. Redistributions of source code must retain the above copyright
11  *      notice, this list of conditions and the following disclaimer.
12  *   2. Redistributions in binary form must reproduce the above copyright
13  *      notice, this list of conditions and the following disclaimer in the
14  *      documentation and/or other materials provided with the distribution.
15  *   
16  *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  *   SUCH DAMAGE.
27  *
28  *---------------------------------------------------------------------------
29  *
30  *      i4b daemon - runtime configuration lexical analyzer
31  *      ---------------------------------------------------
32  *
33  * $FreeBSD: src/usr.sbin/i4b/isdnd/rc_scan.l,v 1.6.2.2 2001/08/10 23:17:32 obrien Exp $
34  *
35  *      last edit-date: [Fri Jul 20 19:14:55 2001]
36  *
37  *---------------------------------------------------------------------------*/
38
39 %{
40
41 #include <err.h>
42 #include <stdlib.h>
43 #include <stdio.h>
44 #include <string.h>
45 #include <ctype.h>
46 #include <sysexits.h>
47
48 #include "y.tab.h"
49
50 int lineno;
51
52 %}
53
54 %option noyywrap
55 %option nounput
56
57 %%
58
59 #.*$                            { /*
60                                    * Drop comment.  NB: this prevents a hash
61                                    * sign from appearing inside a quoted string.
62                                    */
63                                 }
64
65 ["][^"]*["]                     {
66                                 char *str;
67                                 if ((str = malloc(yyleng - 1)) == 0)
68                                         errx(EX_OSERR, "Out of virtual memory");
69                                 memcpy(str, yytext + 1, yyleng - 2);
70                                 str[yyleng - 2] = 0;
71                                 yylval.str = str;
72                                 return STRING;
73                                 }
74
75 (-*[0-9]+)|\*                   {
76                                 char *str;
77                                 char *p = yytext;
78                                 int i = 0;
79                                 if ((str = malloc(128)) == 0)
80                                         errx(EX_OSERR, "Out of virtual memory");
81                                 while(*p == '-' || isdigit(*p) || *p == '*')
82                                         str[i++] = *p++;
83                                 str[i] = '\0';
84                                 yylval.str = str;
85                                 return NUMBERSTR;
86                                 }
87
88 acctall                         { return ACCTALL; }
89 acctfile                        { return ACCTFILE; }
90 alert                           { return ALERT; }
91 aliasing                        { return ALIASING; }
92 aliasfile                       { return ALIASFNAME; }
93 answerprog                      { return ANSWERPROG; }
94 b1protocol                      { return B1PROTOCOL; }
95 beepconnect                     { return BEEPCONNECT; }
96 budget-callbackperiod           { return BUDGETCALLBACKPERIOD; }
97 budget-callbackncalls           { return BUDGETCALLBACKNCALLS; }
98 budget-callbacksfile            { return BUDGETCALLBACKSFILE; }
99 budget-callbacksfile-rotate     { return BUDGETCALLBACKSFILEROTATE; }
100 budget-calloutperiod            { return BUDGETCALLOUTPERIOD; }
101 budget-calloutncalls            { return BUDGETCALLOUTNCALLS; }
102 budget-calloutsfile             { return BUDGETCALLOUTSFILE; }
103 budget-calloutsfile-rotate      { return BUDGETCALLOUTSFILEROTATE; }
104 callbackwait                    { return CALLBACKWAIT; }
105 calledbackwait                  { return CALLEDBACKWAIT; }
106 clone                           { return CLONE; }
107 connectprog                     { return CONNECTPROG; }
108 controller                      { return CONTROLLER; }
109 dialin-reaction                 { return REACTION; }
110 dialout-type                    { return DIALOUTTYPE; }
111 dialrandincr                    { return DIALRANDINCR; }
112 dialretries                     { return DIALRETRIES; }
113 direction                       { return DIRECTION; }
114 disconnectprog                  { return DISCONNECTPROG; }
115 downtries                       { return DOWNTRIES; }
116 downtime                        { return DOWNTIME; }
117 earlyhangup                     { return EARLYHANGUP; }
118 entry                           { return ENTRY; }
119 extcallattr                     { return EXTCALLATTR; }
120 firmware                        { return FIRMWARE; }
121 holidayfile                     { return HOLIDAYFILE; }
122 idletime-incoming               { return IDLETIME_IN; }
123 idletime-outgoing               { return IDLETIME_OUT; }
124 idle-algorithm-outgoing         { return IDLE_ALG_OUT; }
125 isdncontroller                  { return ISDNCONTROLLER; }
126 isdnchannel                     { return ISDNCHANNEL; }
127 isdntime                        { return ISDNTIME; }
128 isdntxdel-incoming              { return ISDNTXDELIN; }
129 isdntxdel-outgoing              { return ISDNTXDELOUT; }
130 local-phone-dialout             { return LOCAL_PHONE_DIALOUT; }
131 local-phone-incoming            { return LOCAL_PHONE_INCOMING; }
132 mailer                          { return MAILER; }
133 mailto                          { return MAILTO; }
134 maxconnecttime                  { return MAXCONNECTTIME; }
135 monitor-allowed                 { return MONITORSW; }
136 monitor-port                    { return MONITORPORT; }
137 monitor                         { return MONITOR; }
138 monitor-access                  { return MONITORACCESS; }
139 fullcmd                         { return FULLCMD; }
140 restrictedcmd                   { return RESTRICTEDCMD; }
141 channelstate                    { return CHANNELSTATE; }
142 callin                          { return CALLIN; }
143 callout                         { return CALLOUT; }
144 logevents                       { return LOGEVENTS; }
145 name                            { return NAME; }
146 no                              { return NO; }
147 off                             { return OFF; }
148 on                              { return ON; }
149 ppp-auth-rechallenge            { return PPP_AUTH_RECHALLENGE; }
150 ppp-auth-paranoid               { return PPP_AUTH_PARANOID; }
151 ppp-expect-auth                 { return PPP_EXPECT_AUTH; }
152 ppp-expect-name                 { return PPP_EXPECT_NAME; }
153 ppp-expect-password             { return PPP_EXPECT_PASSWORD; }
154 ppp-send-auth                   { return PPP_SEND_AUTH; }
155 ppp-send-name                   { return PPP_SEND_NAME; }
156 ppp-send-password               { return PPP_SEND_PASSWORD; }
157 protocol                        { return PROTOCOL; }
158 ratesfile                       { return RATESFILE; }
159 ratetype                        { return RATETYPE; }
160 recoverytime                    { return RECOVERYTIME; }
161 regexpr                         { return REGEXPR; }
162 regprog                         { return REGPROG; }
163 remdial-handling                { return REMOTE_NUMBERS_HANDLING; }
164 remote-phone-dialout            { return REMOTE_PHONE_DIALOUT; }
165 remote-phone-incoming           { return REMOTE_PHONE_INCOMING; }
166 rotatesuffix                    { return ROTATESUFFIX; }
167 rtprio                          { return RTPRIO; }
168 system                          { return SYSTEM; }
169 tinainitprog                    { return TINAINITPROG; }
170 unitlength                      { return UNITLENGTH; }
171 unitlengthsrc                   { return UNITLENGTHSRC; }
172 useacctfile                     { return USEACCTFILE; }
173 usrdevicename                   { return USRDEVICENAME; }
174 usrdeviceunit                   { return USRDEVICEUNIT; }
175 usedown                         { return USEDOWN; }
176 valid                           { return VALID; }
177 yes                             { return YES; }
178
179 \n                              { lineno++; return '\n'; }
180
181 [A-Za-z/.][-A-Za-z0-9_/.]*      {
182                                 char *str;
183                                 if ((str = strdup(yytext)) == 0)
184                                         err(EX_OSERR, "Out of virtual memory");
185                                 yylval.str = str;
186                                 return STRING;
187                                 }
188
189 [ \t]                           { /* drop white space */ }
190
191 .                               { return yytext[0]; }
192
193 %%
194
195 void
196 reset_scanner(FILE *infile)
197 {
198         yyrestart(infile);
199         lineno = 1;
200 }