2 * We don't read interactively from the terminal.
4 %option never-interactive
7 * Prefix scanner routines with "ascend" rather than "yy", so this scanner
8 * can coexist with other scanners.
10 %option prefix="ascend"
16 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version 2
21 * of the License, or (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
39 #include "ascendtext.h"
41 #include "ascend-int.h"
42 #include "file_wrappers.h"
43 #include "ascend_scanner_lex.h"
46 extern char *ascend_ra_ptr;
47 extern char *ascend_ra_last;
48 #define YY_INPUT(buf,result,max_size) { int c = file_getc(yy_fh); \
49 result = (c==EOF) ? YY_NULL : (buf[0] = c, 1); }
54 #define NO_USER "<none>"
57 #define YY_NO_UNISTD_H
76 WDD_CAUSE "Cause an attempt to place call to "
77 WDD_CALLNUM [^\n\r\t ]+
78 WDD_CHUNK "WD_DIALOUT_DISP: chunk"
79 WDD_TYPE "type "[^\n\r\t ]+
107 %s sc_ether_direction
111 <INITIAL,sc_gen_byte>{ETHER_PFX} {
112 BEGIN(sc_ether_direction);
113 ascendlval.d = ASCEND_PFX_ETHER;
117 <INITIAL,sc_gen_byte>{ISDN_XPFX} {
119 ascendlval.d = ASCEND_PFX_ISDN_X;
123 <INITIAL,sc_gen_byte>{ISDN_RPFX} {
125 ascendlval.d = ASCEND_PFX_ISDN_R;
129 <INITIAL,sc_gen_byte>{WAN_XPFX} {
131 ascendlval.d = ASCEND_PFX_WDS_X;
135 <INITIAL,sc_gen_byte>{WAN_RPFX} {
137 ascendlval.d = ASCEND_PFX_WDS_R;
141 <INITIAL,sc_gen_byte>{PPP_XPFX} {
143 ascendlval.d = ASCEND_PFX_WDS_X;
147 <INITIAL,sc_gen_byte>{PPP_RPFX} {
149 ascendlval.d = ASCEND_PFX_WDS_R;
153 <sc_ether_direction>[^\(]{2,20} {
158 <sc_isdn_call>[^\/\(:]{2,20} {
163 <sc_wds_user>[^:]{2,20} {
164 char *atcopy = g_strdup(ascendtext);
165 char colon = input();
166 char after = input();
169 unput(after); unput(colon);
171 if (after != '(' && after != ' ') {
173 if (pseudo_header != NULL) {
174 g_strlcpy(pseudo_header->user, atcopy, ASCEND_MAX_STR_LEN);
176 } else { /* We have a version 7 file */
178 if (pseudo_header != NULL) {
179 g_strlcpy(pseudo_header->user, NO_USER, ASCEND_MAX_STR_LEN);
181 /* Are valid values ever > 2^32? If so we need to adjust YYSTYPE and a lot of */
182 /* upstream code accordingly. */
183 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
192 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
196 <sc_gen_task>(0x|0X)?{H}{2,8} {
197 BEGIN(sc_gen_time_s);
198 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 16);
202 <sc_gen_task>\"[A-Za-z0-9_ ]+\" {
206 <sc_gen_time_s>{D}{1,10} {
207 BEGIN(sc_gen_time_u);
208 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
212 <sc_gen_time_u>{D}{1,6} {
213 char *atcopy = g_strdup(ascendtext);
214 BEGIN(sc_gen_octets);
215 /* only want the most significant 2 digits. convert to usecs */
216 if (strlen(atcopy) > 2)
218 ascendlval.d = (guint32) strtoul(atcopy, NULL, 10) * 10000;
223 <sc_gen_octets>{D}{1,10} {
224 BEGIN(sc_gen_counter);
225 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
229 <sc_gen_counter,sc_gen_byte>"["{H}{4}"]:" {
234 <sc_gen_byte>{H}{2} {
235 ascendlval.b = (guint8)(guint32) strtoul(ascendtext, NULL, 16);
239 <sc_gen_byte>" "{4} {
247 <INITIAL,sc_gen_byte>{WDD_DATE} {
248 BEGIN(sc_wdd_date_d);
252 <sc_wdd_date_d>{D}{2} {
253 BEGIN(sc_wdd_date_m);
254 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
258 <sc_wdd_date_m>{D}{2} {
259 BEGIN(sc_wdd_date_y);
260 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
264 <sc_wdd_date_y>{D}{4} {
266 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
270 <sc_wdd_time>{WDD_TIME} {
271 BEGIN(sc_wdd_time_h);
275 <sc_wdd_time_h>{D}{2} {
276 BEGIN(sc_wdd_time_m);
277 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
281 <sc_wdd_time_m>{D}{2} {
282 BEGIN(sc_wdd_time_s);
283 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
287 <sc_wdd_time_s>{D}{2} {
289 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 10);
293 <sc_wdd_cause>{WDD_CAUSE} {
294 BEGIN(sc_wdd_callnum);
298 <sc_wdd_callnum>{WDD_CALLNUM} {
300 if (pseudo_header != NULL) {
301 g_strlcpy(pseudo_header->call_num, ascendtext, ASCEND_MAX_STR_LEN);
306 <INITIAL,sc_wdd_chunk,sc_gen_byte>{WDD_CHUNK} {
307 BEGIN(sc_wdd_chunknum);
311 <sc_wdd_chunknum>{H}{1,8} {
313 ascendlval.d = (guint32) strtoul(ascendtext, NULL, 16);
317 <sc_wdd_type>{WDD_TYPE} {
322 <sc_gen_task>\/{D}+ {
326 (0x|0X)?{H}+ { return HEXNUM; }
328 task:|task|at|time:|octets { return KEYWORD; }
330 <<EOF>> { at_eof++; yyterminate(); }
336 void ascend_init_lexer(FILE_T fh)
344 * We want to stop processing when we get to the end of the input.
345 * (%option noyywrap is not used because if used then
346 * some flex versions (eg: 2.5.35) generate code which causes
347 * warnings by the Windows VC compiler).