2 * We don't read 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"
18 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License
22 * as published by the Free Software Foundation; either version 2
23 * of the License, or (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
42 #include <io.h> /* for isatty() on win32 */
46 #include "ascendtext.h"
48 #include "ascend-int.h"
49 #include "file_wrappers.h"
50 #include "ascend_scanner_lex.h"
53 extern char *ascend_ra_ptr;
54 extern char *ascend_ra_last;
55 #define YY_INPUT(buf,result,max_size) { int c = file_getc(yy_fh); \
56 result = (c==EOF) ? YY_NULL : (buf[0] = c, 1); }
61 #define NO_USER "<none>"
64 #define YY_NO_UNISTD_H
83 WDD_CAUSE "Cause an attempt to place call to "
84 WDD_CALLNUM [^\n\r\t ]+
85 WDD_CHUNK "WD_DIALOUT_DISP: chunk"
86 WDD_TYPE "type "[^\n\r\t ]+
114 %s sc_ether_direction
118 <INITIAL,sc_gen_byte>{ETHER_PFX} {
119 BEGIN(sc_ether_direction);
120 ascendlval.d = ASCEND_PFX_ETHER;
124 <INITIAL,sc_gen_byte>{ISDN_XPFX} {
126 ascendlval.d = ASCEND_PFX_ISDN_X;
130 <INITIAL,sc_gen_byte>{ISDN_RPFX} {
132 ascendlval.d = ASCEND_PFX_ISDN_R;
136 <INITIAL,sc_gen_byte>{WAN_XPFX} {
138 ascendlval.d = ASCEND_PFX_WDS_X;
142 <INITIAL,sc_gen_byte>{WAN_RPFX} {
144 ascendlval.d = ASCEND_PFX_WDS_R;
148 <INITIAL,sc_gen_byte>{PPP_XPFX} {
150 ascendlval.d = ASCEND_PFX_WDS_X;
154 <INITIAL,sc_gen_byte>{PPP_RPFX} {
156 ascendlval.d = ASCEND_PFX_WDS_R;
160 <sc_ether_direction>[^\(]{2,20} {
165 <sc_isdn_call>[^\/\(:]{2,20} {
170 <sc_wds_user>[^:]{2,20} {
171 char *atcopy = g_strdup(ascendtext);
172 char colon = input();
173 char after = input();
176 unput(after); unput(colon);
178 if (after != '(' && after != ' ') {
180 if (pseudo_header != NULL) {
181 g_strlcpy(pseudo_header->user, atcopy, ASCEND_MAX_STR_LEN);
183 } else { /* We have a version 7 file */
185 if (pseudo_header != NULL) {
186 g_strlcpy(pseudo_header->user, NO_USER, ASCEND_MAX_STR_LEN);
188 ascendlval.d = strtol(ascendtext, NULL, 10);
197 ascendlval.d = strtol(ascendtext, NULL, 10);
201 <sc_gen_task>(0x|0X)?{H}{2,8} {
202 BEGIN(sc_gen_time_s);
203 ascendlval.d = strtoul(ascendtext, NULL, 16);
207 <sc_gen_task>\"[A-Za-z0-9_ ]+\" {
211 <sc_gen_time_s>{D}{1,10} {
212 BEGIN(sc_gen_time_u);
213 ascendlval.d = strtol(ascendtext, NULL, 10);
217 <sc_gen_time_u>{D}{1,6} {
218 char *atcopy = g_strdup(ascendtext);
219 BEGIN(sc_gen_octets);
220 /* only want the most significant 2 digits. convert to usecs */
221 if (strlen(atcopy) > 2)
223 ascendlval.d = strtol(atcopy, NULL, 10) * 10000;
228 <sc_gen_octets>{D}{1,10} {
229 BEGIN(sc_gen_counter);
230 ascendlval.d = strtol(ascendtext, NULL, 10);
234 <sc_gen_counter,sc_gen_byte>"["{H}{4}"]:" {
239 <sc_gen_byte>{H}{2} {
240 ascendlval.b = (guint8)strtol(ascendtext, NULL, 16);
244 <sc_gen_byte>" "{4} {
252 <INITIAL,sc_gen_byte>{WDD_DATE} {
253 BEGIN(sc_wdd_date_d);
257 <sc_wdd_date_d>{D}{2} {
258 BEGIN(sc_wdd_date_m);
259 ascendlval.d = strtol(ascendtext, NULL, 10);
263 <sc_wdd_date_m>{D}{2} {
264 BEGIN(sc_wdd_date_y);
265 ascendlval.d = strtol(ascendtext, NULL, 10);
269 <sc_wdd_date_y>{D}{4} {
271 ascendlval.d = strtol(ascendtext, NULL, 10);
275 <sc_wdd_time>{WDD_TIME} {
276 BEGIN(sc_wdd_time_h);
280 <sc_wdd_time_h>{D}{2} {
281 BEGIN(sc_wdd_time_m);
282 ascendlval.d = strtol(ascendtext, NULL, 10);
286 <sc_wdd_time_m>{D}{2} {
287 BEGIN(sc_wdd_time_s);
288 ascendlval.d = strtol(ascendtext, NULL, 10);
292 <sc_wdd_time_s>{D}{2} {
294 ascendlval.d = strtol(ascendtext, NULL, 10);
298 <sc_wdd_cause>{WDD_CAUSE} {
299 BEGIN(sc_wdd_callnum);
303 <sc_wdd_callnum>{WDD_CALLNUM} {
305 if (pseudo_header != NULL) {
306 g_strlcpy(pseudo_header->call_num, ascendtext, ASCEND_MAX_STR_LEN);
311 <INITIAL,sc_wdd_chunk,sc_gen_byte>{WDD_CHUNK} {
312 BEGIN(sc_wdd_chunknum);
316 <sc_wdd_chunknum>{H}{1,8} {
318 ascendlval.d = strtoul(ascendtext, NULL, 16);
322 <sc_wdd_type>{WDD_TYPE} {
327 <sc_gen_task>\/{D}+ {
331 (0x|0X)?{H}+ { return HEXNUM; }
333 task:|task|at|time:|octets { return KEYWORD; }
335 <<EOF>> { at_eof++; yyterminate(); }
341 void ascend_init_lexer(FILE_T fh)
349 * We want to stop processing when we get to the end of the input.
350 * (%option noyywrap is not used because if used then
351 * some flex versions (eg: 2.5.35) generate code which causes
352 * warnings by the Windows VC compiler).