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.
44 #include <io.h> /* for isatty() on win32 */
48 #include "ascendtext.h"
50 #include "ascend-int.h"
51 #include "file_wrappers.h"
52 #include "ascend_scanner_lex.h"
55 extern char *ascend_ra_ptr;
56 extern char *ascend_ra_last;
57 #define YY_INPUT(buf,result,max_size) { int c = file_getc(yy_fh); \
58 result = (c==EOF) ? YY_NULL : (buf[0] = c, 1); }
63 #define NO_USER "<none>"
66 #define YY_NO_UNISTD_H
85 WDD_CAUSE "Cause an attempt to place call to "
86 WDD_CALLNUM [^\n\r\t ]+
87 WDD_CHUNK "WD_DIALOUT_DISP: chunk"
88 WDD_TYPE "type "[^\n\r\t ]+
116 %s sc_ether_direction
120 <INITIAL,sc_gen_byte>{ETHER_PFX} {
121 BEGIN(sc_ether_direction);
122 ascendlval.d = ASCEND_PFX_ETHER;
126 <INITIAL,sc_gen_byte>{ISDN_XPFX} {
128 ascendlval.d = ASCEND_PFX_ISDN_X;
132 <INITIAL,sc_gen_byte>{ISDN_RPFX} {
134 ascendlval.d = ASCEND_PFX_ISDN_R;
138 <INITIAL,sc_gen_byte>{WAN_XPFX} {
140 ascendlval.d = ASCEND_PFX_WDS_X;
144 <INITIAL,sc_gen_byte>{WAN_RPFX} {
146 ascendlval.d = ASCEND_PFX_WDS_R;
150 <INITIAL,sc_gen_byte>{PPP_XPFX} {
152 ascendlval.d = ASCEND_PFX_WDS_X;
156 <INITIAL,sc_gen_byte>{PPP_RPFX} {
158 ascendlval.d = ASCEND_PFX_WDS_R;
162 <sc_ether_direction>[^\(]+ {
167 <sc_isdn_call>[^\/\(:]+ {
173 char *atcopy = g_strdup(ascendtext);
174 char colon = input();
175 char after = input();
178 unput(after); unput(colon);
180 if (after != '(' && after != ' ') {
182 if (pseudo_header != NULL) {
183 g_strlcpy(pseudo_header->user, atcopy, ASCEND_MAX_STR_LEN);
185 } else { /* We have a version 7 file */
187 if (pseudo_header != NULL) {
188 g_strlcpy(pseudo_header->user, NO_USER, ASCEND_MAX_STR_LEN);
190 ascendlval.d = strtol(ascendtext, NULL, 10);
199 ascendlval.d = strtol(ascendtext, NULL, 10);
203 <sc_gen_task>(0x|0X)?{H}+ {
204 BEGIN(sc_gen_time_s);
205 ascendlval.d = strtoul(ascendtext, NULL, 16);
209 <sc_gen_task>\"[A-Za-z0-9_ ]+\" {
213 <sc_gen_time_s>{D}+ {
214 BEGIN(sc_gen_time_u);
215 ascendlval.d = strtol(ascendtext, NULL, 10);
219 <sc_gen_time_u>{D}+ {
220 char *atcopy = g_strdup(ascendtext);
221 BEGIN(sc_gen_octets);
222 /* only want the most significant 2 digits. convert to usecs */
223 if (strlen(atcopy) > 2)
225 ascendlval.d = strtol(atcopy, NULL, 10) * 10000;
230 <sc_gen_octets>{D}+ {
231 BEGIN(sc_gen_counter);
232 ascendlval.d = strtol(ascendtext, NULL, 10);
236 <sc_gen_counter,sc_gen_byte>"["{H}{4}"]:" {
241 <sc_gen_byte>{H}{2} {
242 ascendlval.b = (guint8)strtol(ascendtext, NULL, 16);
246 <sc_gen_byte>" "{4} {
254 <INITIAL,sc_gen_byte>{WDD_DATE} {
255 BEGIN(sc_wdd_date_d);
259 <sc_wdd_date_d>{D}{2} {
260 BEGIN(sc_wdd_date_m);
261 ascendlval.d = strtol(ascendtext, NULL, 10);
265 <sc_wdd_date_m>{D}{2} {
266 BEGIN(sc_wdd_date_y);
267 ascendlval.d = strtol(ascendtext, NULL, 10);
271 <sc_wdd_date_y>{D}{4} {
273 ascendlval.d = strtol(ascendtext, NULL, 10);
277 <sc_wdd_time>{WDD_TIME} {
278 BEGIN(sc_wdd_time_h);
282 <sc_wdd_time_h>{D}{2} {
283 BEGIN(sc_wdd_time_m);
284 ascendlval.d = strtol(ascendtext, NULL, 10);
288 <sc_wdd_time_m>{D}{2} {
289 BEGIN(sc_wdd_time_s);
290 ascendlval.d = strtol(ascendtext, NULL, 10);
294 <sc_wdd_time_s>{D}{2} {
296 ascendlval.d = strtol(ascendtext, NULL, 10);
300 <sc_wdd_cause>{WDD_CAUSE} {
301 BEGIN(sc_wdd_callnum);
305 <sc_wdd_callnum>{WDD_CALLNUM} {
307 if (pseudo_header != NULL) {
308 g_strlcpy(pseudo_header->call_num, ascendtext, ASCEND_MAX_STR_LEN);
313 <INITIAL,sc_wdd_chunk,sc_gen_byte>{WDD_CHUNK} {
314 BEGIN(sc_wdd_chunknum);
318 <sc_wdd_chunknum>{H}+ {
320 ascendlval.d = strtoul(ascendtext, NULL, 16);
324 <sc_wdd_type>{WDD_TYPE} {
329 <sc_gen_task>\/{D}+ {
333 (0x|0X)?{H}+ { return HEXNUM; }
335 task:|task|at|time:|octets { return KEYWORD; }
337 <<EOF>> { at_eof++; yyterminate(); }
343 void ascend_init_lexer(FILE_T fh)
351 * We want to stop processing when we get to the end of the input.
352 * (%option noyywrap is not used because if used then
353 * some flex versions (eg: 2.5.35) generate code which causes
354 * warnings by the Windows VC compiler).