2 * We want to stop processing when we get to the end of the input.
7 * We don't read from the terminal.
9 %option never-interactive
12 * Prefix scanner routines with "ascend" rather than "yy", so this scanner
13 * can coexist with other scanners.
15 %option prefix="ascend"
23 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
25 * This program is free software; you can redistribute it and/or
26 * modify it under the terms of the GNU General Public License
27 * as published by the Free Software Foundation; either version 2
28 * of the License, or (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
49 #include <io.h> /* for isatty() on win32 */
54 #include "ascend-grammar.h"
55 #include "ascend-int.h"
56 #include "file_wrappers.h"
57 #include "ascend-scanner_lex.h"
60 extern char *ascend_ra_ptr;
61 extern char *ascend_ra_last;
62 #define YY_INPUT(buf,result,max_size) { int c = file_getc(yy_fh); \
63 result = (c==EOF) ? YY_NULL : (buf[0] = c, 1); }
68 #define NO_USER "<none>"
71 #define YY_NO_UNISTD_H
90 WDD_CAUSE "Cause an attempt to place call to "
91 WDD_CALLNUM [^\n\r\t ]+
92 WDD_CHUNK "WD_DIALOUT_DISP: chunk"
93 WDD_TYPE "type "[^\n\r\t ]+
121 %s sc_ether_direction
125 <INITIAL,sc_gen_byte>{ETHER_PFX} {
126 BEGIN(sc_ether_direction);
127 ascendlval.d = ASCEND_PFX_ETHER;
131 <INITIAL,sc_gen_byte>{ISDN_XPFX} {
133 ascendlval.d = ASCEND_PFX_ISDN_X;
137 <INITIAL,sc_gen_byte>{ISDN_RPFX} {
139 ascendlval.d = ASCEND_PFX_ISDN_R;
143 <INITIAL,sc_gen_byte>{WAN_XPFX} {
145 ascendlval.d = ASCEND_PFX_WDS_X;
149 <INITIAL,sc_gen_byte>{WAN_RPFX} {
151 ascendlval.d = ASCEND_PFX_WDS_R;
155 <INITIAL,sc_gen_byte>{PPP_XPFX} {
157 ascendlval.d = ASCEND_PFX_WDS_X;
161 <INITIAL,sc_gen_byte>{PPP_RPFX} {
163 ascendlval.d = ASCEND_PFX_WDS_R;
167 <sc_ether_direction>[^\(]+ {
172 <sc_isdn_call>[^\/\(:]+ {
178 char *atcopy = strdup(ascendtext);
179 char colon = input();
180 char after = input();
183 unput(after); unput(colon);
185 if (after != '(' && after != ' ') {
187 if (pseudo_header != NULL) {
188 strncpy(pseudo_header->user, atcopy, ASCEND_MAX_STR_LEN);
189 pseudo_header->user[ASCEND_MAX_STR_LEN - 1] = '\0';
191 } else { /* We have a version 7 file */
193 if (pseudo_header != NULL) {
194 strncpy(pseudo_header->user, NO_USER, ASCEND_MAX_STR_LEN);
196 ascendlval.d = strtol(ascendtext, NULL, 10);
205 ascendlval.d = strtol(ascendtext, NULL, 10);
209 <sc_gen_task>(0x|0X)?{H}+ {
210 BEGIN(sc_gen_time_s);
211 ascendlval.d = strtoul(ascendtext, NULL, 16);
215 <sc_gen_task>\"[A-Za-z0-9_ ]+\" {
219 <sc_gen_time_s>{D}+ {
220 BEGIN(sc_gen_time_u);
221 ascendlval.d = strtol(ascendtext, NULL, 10);
225 <sc_gen_time_u>{D}+ {
226 char *atcopy = strdup(ascendtext);
227 BEGIN(sc_gen_octets);
228 /* only want the most significant 2 digits. convert to usecs */
229 if (strlen(atcopy) > 2)
231 ascendlval.d = strtol(atcopy, NULL, 10) * 10000;
236 <sc_gen_octets>{D}+ {
237 BEGIN(sc_gen_counter);
238 ascendlval.d = strtol(ascendtext, NULL, 10);
242 <sc_gen_counter,sc_gen_byte>"["{H}{4}"]:" {
247 <sc_gen_byte>{H}{2} {
248 ascendlval.b = (guint8)strtol(ascendtext, NULL, 16);
252 <sc_gen_byte>" "{4} {
260 <INITIAL,sc_gen_byte>{WDD_DATE} {
261 BEGIN(sc_wdd_date_d);
265 <sc_wdd_date_d>{D}{2} {
266 BEGIN(sc_wdd_date_m);
267 ascendlval.d = strtol(ascendtext, NULL, 10);
271 <sc_wdd_date_m>{D}{2} {
272 BEGIN(sc_wdd_date_y);
273 ascendlval.d = strtol(ascendtext, NULL, 10);
277 <sc_wdd_date_y>{D}{4} {
279 ascendlval.d = strtol(ascendtext, NULL, 10);
283 <sc_wdd_time>{WDD_TIME} {
284 BEGIN(sc_wdd_time_h);
288 <sc_wdd_time_h>{D}{2} {
289 BEGIN(sc_wdd_time_m);
290 ascendlval.d = strtol(ascendtext, NULL, 10);
294 <sc_wdd_time_m>{D}{2} {
295 BEGIN(sc_wdd_time_s);
296 ascendlval.d = strtol(ascendtext, NULL, 10);
300 <sc_wdd_time_s>{D}{2} {
302 ascendlval.d = strtol(ascendtext, NULL, 10);
306 <sc_wdd_cause>{WDD_CAUSE} {
307 BEGIN(sc_wdd_callnum);
311 <sc_wdd_callnum>{WDD_CALLNUM} {
313 if (pseudo_header != NULL) {
314 strncpy(pseudo_header->call_num, ascendtext, ASCEND_MAX_STR_LEN);
315 pseudo_header->call_num[ASCEND_MAX_STR_LEN - 1] = '\0';
320 <INITIAL,sc_wdd_chunk,sc_gen_byte>{WDD_CHUNK} {
321 BEGIN(sc_wdd_chunknum);
325 <sc_wdd_chunknum>{H}+ {
327 ascendlval.d = strtoul(ascendtext, NULL, 16);
331 <sc_wdd_type>{WDD_TYPE} {
336 <sc_gen_task>\/{D}+ {
340 (0x|0X)?{H}+ { return HEXNUM; }
342 task:|task|at|time:|octets { return KEYWORD; }
344 <<EOF>> { at_eof++; yyterminate(); }
350 void ascend_init_lexer(FILE_T fh)