add initial support for the crisarchitecture used on foxboards to openwrt
[openwrt/svn-archive/archive.git] / target / linux / etrax-2.6 / image / e100boot / src / libpcap-0.4 / scanner.c
1
2 #line 3 "<stdout>"
3
4 #define YY_INT_ALIGNED short int
5
6 /* A lexical scanner generated by flex */
7
8 #define FLEX_SCANNER
9 #define YY_FLEX_MAJOR_VERSION 2
10 #define YY_FLEX_MINOR_VERSION 5
11 #define YY_FLEX_SUBMINOR_VERSION 33
12 #if YY_FLEX_SUBMINOR_VERSION > 0
13 #define FLEX_BETA
14 #endif
15
16 /* First, we deal with platform-specific or compiler-specific issues. */
17
18 /* begin standard C headers. */
19 #include <stdio.h>
20 #include <string.h>
21 #include <errno.h>
22 #include <stdlib.h>
23
24 /* end standard C headers. */
25
26 /* flex integer type definitions */
27
28 #ifndef FLEXINT_H
29 #define FLEXINT_H
30
31 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
32
33 #if __STDC_VERSION__ >= 199901L
34
35 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
36 * if you want the limit (max/min) macros for int types.
37 */
38 #ifndef __STDC_LIMIT_MACROS
39 #define __STDC_LIMIT_MACROS 1
40 #endif
41
42 #include <inttypes.h>
43 typedef int8_t flex_int8_t;
44 typedef uint8_t flex_uint8_t;
45 typedef int16_t flex_int16_t;
46 typedef uint16_t flex_uint16_t;
47 typedef int32_t flex_int32_t;
48 typedef uint32_t flex_uint32_t;
49 #else
50 typedef signed char flex_int8_t;
51 typedef short int flex_int16_t;
52 typedef int flex_int32_t;
53 typedef unsigned char flex_uint8_t;
54 typedef unsigned short int flex_uint16_t;
55 typedef unsigned int flex_uint32_t;
56 #endif /* ! C99 */
57
58 /* Limits of integral types. */
59 #ifndef INT8_MIN
60 #define INT8_MIN (-128)
61 #endif
62 #ifndef INT16_MIN
63 #define INT16_MIN (-32767-1)
64 #endif
65 #ifndef INT32_MIN
66 #define INT32_MIN (-2147483647-1)
67 #endif
68 #ifndef INT8_MAX
69 #define INT8_MAX (127)
70 #endif
71 #ifndef INT16_MAX
72 #define INT16_MAX (32767)
73 #endif
74 #ifndef INT32_MAX
75 #define INT32_MAX (2147483647)
76 #endif
77 #ifndef UINT8_MAX
78 #define UINT8_MAX (255U)
79 #endif
80 #ifndef UINT16_MAX
81 #define UINT16_MAX (65535U)
82 #endif
83 #ifndef UINT32_MAX
84 #define UINT32_MAX (4294967295U)
85 #endif
86
87 #endif /* ! FLEXINT_H */
88
89 #ifdef __cplusplus
90
91 /* The "const" storage-class-modifier is valid. */
92 #define YY_USE_CONST
93
94 #else /* ! __cplusplus */
95
96 #if __STDC__
97
98 #define YY_USE_CONST
99
100 #endif /* __STDC__ */
101 #endif /* ! __cplusplus */
102
103 #ifdef YY_USE_CONST
104 #define yyconst const
105 #else
106 #define yyconst
107 #endif
108
109 /* Returned upon end-of-file. */
110 #define YY_NULL 0
111
112 /* Promotes a possibly negative, possibly signed char to an unsigned
113 * integer for use as an array index. If the signed char is negative,
114 * we want to instead treat it as an 8-bit unsigned char, hence the
115 * double cast.
116 */
117 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
118
119 /* Enter a start condition. This macro really ought to take a parameter,
120 * but we do it the disgusting crufty way forced on us by the ()-less
121 * definition of BEGIN.
122 */
123 #define BEGIN (yy_start) = 1 + 2 *
124
125 /* Translate the current start state into a value that can be later handed
126 * to BEGIN to return to the state. The YYSTATE alias is for lex
127 * compatibility.
128 */
129 #define YY_START (((yy_start) - 1) / 2)
130 #define YYSTATE YY_START
131
132 /* Action number for EOF rule of a given start state. */
133 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
134
135 /* Special action meaning "start processing a new file". */
136 #define YY_NEW_FILE pcap_restart(pcap_in )
137
138 #define YY_END_OF_BUFFER_CHAR 0
139
140 /* Size of default input buffer. */
141 #ifndef YY_BUF_SIZE
142 #define YY_BUF_SIZE 16384
143 #endif
144
145 /* The state buf must be large enough to hold one state per character in the main buffer.
146 */
147 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
148
149 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
150 #define YY_TYPEDEF_YY_BUFFER_STATE
151 typedef struct yy_buffer_state *YY_BUFFER_STATE;
152 #endif
153
154 extern int pcap_leng;
155
156 extern FILE *pcap_in, *pcap_out;
157
158 #define EOB_ACT_CONTINUE_SCAN 0
159 #define EOB_ACT_END_OF_FILE 1
160 #define EOB_ACT_LAST_MATCH 2
161
162 #define YY_LESS_LINENO(n)
163
164 /* Return all but the first "n" matched characters back to the input stream. */
165 #define yyless(n) \
166 do \
167 { \
168 /* Undo effects of setting up pcap_text. */ \
169 int yyless_macro_arg = (n); \
170 YY_LESS_LINENO(yyless_macro_arg);\
171 *yy_cp = (yy_hold_char); \
172 YY_RESTORE_YY_MORE_OFFSET \
173 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
174 YY_DO_BEFORE_ACTION; /* set up pcap_text again */ \
175 } \
176 while ( 0 )
177
178 #define unput(c) yyunput( c, (yytext_ptr) )
179
180 /* The following is because we cannot portably get our hands on size_t
181 * (without autoconf's help, which isn't available because we want
182 * flex-generated scanners to compile on their own).
183 */
184
185 #ifndef YY_TYPEDEF_YY_SIZE_T
186 #define YY_TYPEDEF_YY_SIZE_T
187 typedef unsigned int yy_size_t;
188 #endif
189
190 #ifndef YY_STRUCT_YY_BUFFER_STATE
191 #define YY_STRUCT_YY_BUFFER_STATE
192 struct yy_buffer_state
193 {
194 FILE *yy_input_file;
195
196 char *yy_ch_buf; /* input buffer */
197 char *yy_buf_pos; /* current position in input buffer */
198
199 /* Size of input buffer in bytes, not including room for EOB
200 * characters.
201 */
202 yy_size_t yy_buf_size;
203
204 /* Number of characters read into yy_ch_buf, not including EOB
205 * characters.
206 */
207 int yy_n_chars;
208
209 /* Whether we "own" the buffer - i.e., we know we created it,
210 * and can realloc() it to grow it, and should free() it to
211 * delete it.
212 */
213 int yy_is_our_buffer;
214
215 /* Whether this is an "interactive" input source; if so, and
216 * if we're using stdio for input, then we want to use getc()
217 * instead of fread(), to make sure we stop fetching input after
218 * each newline.
219 */
220 int yy_is_interactive;
221
222 /* Whether we're considered to be at the beginning of a line.
223 * If so, '^' rules will be active on the next match, otherwise
224 * not.
225 */
226 int yy_at_bol;
227
228 int yy_bs_lineno; /**< The line count. */
229 int yy_bs_column; /**< The column count. */
230
231 /* Whether to try to fill the input buffer when we reach the
232 * end of it.
233 */
234 int yy_fill_buffer;
235
236 int yy_buffer_status;
237
238 #define YY_BUFFER_NEW 0
239 #define YY_BUFFER_NORMAL 1
240 /* When an EOF's been seen but there's still some text to process
241 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
242 * shouldn't try reading from the input source any more. We might
243 * still have a bunch of tokens to match, though, because of
244 * possible backing-up.
245 *
246 * When we actually see the EOF, we change the status to "new"
247 * (via pcap_restart()), so that the user can continue scanning by
248 * just pointing pcap_in at a new input file.
249 */
250 #define YY_BUFFER_EOF_PENDING 2
251
252 };
253 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
254
255 /* Stack of input buffers. */
256 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
257 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
258 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
259
260 /* We provide macros for accessing buffer states in case in the
261 * future we want to put the buffer states in a more general
262 * "scanner state".
263 *
264 * Returns the top of the stack, or NULL.
265 */
266 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
267 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
268 : NULL)
269
270 /* Same as previous macro, but useful when we know that the buffer stack is not
271 * NULL or when we need an lvalue. For internal use only.
272 */
273 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
274
275 /* yy_hold_char holds the character lost when pcap_text is formed. */
276 static char yy_hold_char;
277 static int yy_n_chars; /* number of characters read into yy_ch_buf */
278 int pcap_leng;
279
280 /* Points to current character in buffer. */
281 static char *yy_c_buf_p = (char *) 0;
282 static int yy_init = 0; /* whether we need to initialize */
283 static int yy_start = 0; /* start state number */
284
285 /* Flag which is used to allow pcap_wrap()'s to do buffer switches
286 * instead of setting up a fresh pcap_in. A bit of a hack ...
287 */
288 static int yy_did_buffer_switch_on_eof;
289
290 void pcap_restart (FILE *input_file );
291 void pcap__switch_to_buffer (YY_BUFFER_STATE new_buffer );
292 YY_BUFFER_STATE pcap__create_buffer (FILE *file,int size );
293 void pcap__delete_buffer (YY_BUFFER_STATE b );
294 void pcap__flush_buffer (YY_BUFFER_STATE b );
295 void pcap_push_buffer_state (YY_BUFFER_STATE new_buffer );
296 void pcap_pop_buffer_state (void );
297
298 static void pcap_ensure_buffer_stack (void );
299 static void pcap__load_buffer_state (void );
300 static void pcap__init_buffer (YY_BUFFER_STATE b,FILE *file );
301
302 #define YY_FLUSH_BUFFER pcap__flush_buffer(YY_CURRENT_BUFFER )
303
304 YY_BUFFER_STATE pcap__scan_buffer (char *base,yy_size_t size );
305 YY_BUFFER_STATE pcap__scan_string (yyconst char *yy_str );
306 YY_BUFFER_STATE pcap__scan_bytes (yyconst char *bytes,int len );
307
308 void *pcap_alloc (yy_size_t );
309 void *pcap_realloc (void *,yy_size_t );
310 void pcap_free (void * );
311
312 #define yy_new_buffer pcap__create_buffer
313
314 #define yy_set_interactive(is_interactive) \
315 { \
316 if ( ! YY_CURRENT_BUFFER ){ \
317 pcap_ensure_buffer_stack (); \
318 YY_CURRENT_BUFFER_LVALUE = \
319 pcap__create_buffer(pcap_in,YY_BUF_SIZE ); \
320 } \
321 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
322 }
323
324 #define yy_set_bol(at_bol) \
325 { \
326 if ( ! YY_CURRENT_BUFFER ){\
327 pcap_ensure_buffer_stack (); \
328 YY_CURRENT_BUFFER_LVALUE = \
329 pcap__create_buffer(pcap_in,YY_BUF_SIZE ); \
330 } \
331 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
332 }
333
334 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
335
336 /* Begin user sect3 */
337
338 typedef unsigned char YY_CHAR;
339
340 FILE *pcap_in = (FILE *) 0, *pcap_out = (FILE *) 0;
341
342 typedef int yy_state_type;
343
344 extern int pcap_lineno;
345
346 int pcap_lineno = 1;
347
348 extern char *pcap_text;
349 #define yytext_ptr pcap_text
350
351 static yy_state_type yy_get_previous_state (void );
352 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
353 static int yy_get_next_buffer (void );
354 static void yy_fatal_error (yyconst char msg[] );
355
356 /* Done after the current pattern has been matched and before the
357 * corresponding action - sets up pcap_text.
358 */
359 #define YY_DO_BEFORE_ACTION \
360 (yytext_ptr) = yy_bp; \
361 pcap_leng = (size_t) (yy_cp - yy_bp); \
362 (yy_hold_char) = *yy_cp; \
363 *yy_cp = '\0'; \
364 (yy_c_buf_p) = yy_cp;
365
366 #define YY_NUM_RULES 52
367 #define YY_END_OF_BUFFER 53
368 /* This struct is not used in this scanner,
369 but its presence is necessary. */
370 struct yy_trans_info
371 {
372 flex_int32_t yy_verify;
373 flex_int32_t yy_nxt;
374 };
375 static yyconst flex_int16_t yy_accept[217] =
376 { 0,
377 0, 0, 53, 51, 36, 36, 37, 37, 37, 37,
378 51, 44, 44, 37, 37, 37, 51, 51, 51, 51,
379 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
380 51, 51, 51, 51, 51, 51, 37, 0, 50, 40,
381 30, 0, 48, 44, 0, 48, 48, 48, 42, 39,
382 41, 38, 43, 49, 49, 49, 48, 48, 48, 48,
383 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
384 48, 7, 48, 48, 48, 48, 48, 48, 48, 48,
385 31, 48, 48, 48, 48, 48, 48, 48, 48, 48,
386 48, 31, 45, 45, 44, 0, 0, 44, 30, 5,
387
388 48, 48, 48, 48, 1, 48, 48, 48, 48, 48,
389 48, 48, 48, 48, 15, 33, 48, 48, 48, 48,
390 48, 20, 32, 48, 48, 3, 48, 48, 16, 48,
391 2, 8, 9, 48, 48, 0, 47, 0, 48, 48,
392 27, 48, 48, 4, 48, 48, 19, 10, 11, 12,
393 48, 48, 25, 21, 48, 48, 48, 48, 22, 48,
394 6, 45, 45, 45, 0, 47, 0, 13, 48, 48,
395 48, 48, 48, 48, 18, 17, 48, 48, 23, 48,
396 48, 0, 47, 48, 14, 48, 48, 48, 33, 48,
397 48, 45, 45, 45, 0, 48, 24, 26, 34, 48,
398
399 48, 48, 0, 47, 48, 48, 35, 45, 0, 28,
400 29, 0, 47, 46, 46, 0
401 } ;
402
403 static yyconst flex_int32_t yy_ec[256] =
404 { 0,
405 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408 1, 2, 4, 1, 1, 1, 1, 5, 1, 6,
409 6, 7, 7, 1, 8, 9, 7, 10, 11, 11,
410 11, 11, 11, 11, 11, 11, 11, 12, 1, 13,
411 14, 15, 1, 1, 16, 16, 16, 16, 16, 16,
412 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
413 17, 17, 17, 17, 17, 17, 17, 18, 17, 17,
414 19, 20, 19, 1, 21, 1, 22, 23, 24, 25,
415
416 26, 27, 28, 29, 30, 17, 31, 32, 33, 34,
417 35, 36, 17, 37, 38, 39, 40, 17, 41, 42,
418 43, 17, 1, 44, 1, 1, 1, 1, 1, 1,
419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
424 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
425 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
426
427 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
432 1, 1, 1, 1, 1
433 } ;
434
435 static yyconst flex_int32_t yy_meta[45] =
436 { 0,
437 1, 2, 2, 2, 1, 2, 1, 1, 1, 3,
438 3, 3, 1, 1, 1, 3, 1, 1, 1, 1,
439 1, 3, 3, 3, 3, 3, 3, 1, 1, 1,
440 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
441 1, 1, 1, 1
442 } ;
443
444 static yyconst flex_int16_t yy_base[230] =
445 { 0,
446 0, 0, 381, 44, 382, 382, 366, 374, 382, 45,
447 382, 68, 29, 35, 364, 39, 103, 137, 121, 171,
448 24, 92, 86, 131, 33, 342, 108, 113, 47, 24,
449 79, 136, 354, 36, 351, 349, 329, 176, 382, 382,
450 382, 0, 127, 175, 360, 359, 0, 204, 382, 382,
451 382, 382, 382, 191, 0, 0, 345, 333, 346, 332,
452 327, 103, 326, 335, 142, 324, 336, 323, 327, 29,
453 336, 0, 319, 140, 323, 318, 319, 322, 314, 313,
454 0, 312, 313, 313, 313, 310, 324, 315, 320, 307,
455 306, 382, 191, 184, 207, 329, 328, 330, 0, 0,
456
457 306, 315, 310, 301, 0, 308, 303, 306, 309, 291,
458 293, 292, 291, 291, 0, 297, 286, 292, 291, 115,
459 282, 0, 0, 297, 280, 0, 279, 281, 0, 280,
460 0, 0, 0, 147, 224, 303, 302, 301, 281, 286,
461 0, 284, 272, 0, 267, 268, 0, 0, 0, 0,
462 266, 266, 0, 0, 272, 279, 272, 266, 0, 265,
463 0, 214, 227, 290, 286, 284, 276, 0, 263, 247,
464 263, 258, 248, 252, 0, 0, 256, 239, 0, 165,
465 247, 263, 256, 245, 0, 223, 228, 239, 0, 240,
466 227, 234, 180, 251, 247, 217, 0, 0, 0, 216,
467
468 228, 267, 231, 230, 202, 200, 0, 0, 210, 0,
469 0, 207, 200, 195, 192, 382, 294, 196, 194, 166,
470 163, 147, 131, 121, 114, 85, 80, 78, 69
471 } ;
472
473 static yyconst flex_int16_t yy_def[230] =
474 { 0,
475 216, 1, 216, 216, 216, 216, 216, 216, 216, 216,
476 216, 216, 12, 216, 216, 216, 12, 12, 217, 12,
477 20, 20, 20, 20, 18, 18, 18, 18, 18, 18,
478 18, 18, 18, 18, 18, 18, 216, 216, 216, 216,
479 216, 18, 18, 18, 218, 18, 18, 18, 216, 216,
480 216, 216, 216, 217, 217, 217, 18, 18, 18, 18,
481 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
482 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
483 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
484 18, 216, 18, 18, 18, 219, 220, 48, 18, 18,
485
486 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
487 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
488 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
489 18, 18, 18, 18, 18, 216, 221, 222, 18, 18,
490 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
491 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
492 18, 18, 18, 135, 223, 220, 216, 18, 18, 18,
493 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
494 18, 216, 224, 18, 18, 18, 18, 18, 18, 18,
495 18, 18, 18, 181, 225, 18, 18, 18, 18, 18,
496
497 18, 18, 216, 226, 18, 18, 18, 202, 227, 18,
498 18, 216, 228, 229, 216, 0, 216, 216, 216, 216,
499 216, 216, 216, 216, 216, 216, 216, 216, 216
500 } ;
501
502 static yyconst flex_int16_t yy_nxt[427] =
503 { 0,
504 4, 5, 6, 7, 8, 9, 10, 9, 11, 12,
505 13, 10, 14, 15, 16, 17, 18, 18, 9, 19,
506 11, 20, 21, 17, 22, 23, 24, 25, 26, 27,
507 18, 28, 29, 30, 31, 32, 33, 34, 35, 36,
508 18, 18, 18, 37, 38, 38, 47, 49, 50, 79,
509 38, 38, 52, 53, 66, 38, 38, 47, 80, 87,
510 60, 112, 47, 38, 38, 113, 61, 88, 76, 67,
511 47, 215, 89, 39, 39, 42, 43, 44, 44, 45,
512 214, 77, 212, 46, 47, 48, 78, 209, 42, 46,
513 46, 46, 46, 46, 46, 47, 47, 47, 47, 47,
514
515 47, 47, 47, 47, 47, 47, 47, 47, 47, 48,
516 47, 47, 46, 46, 45, 81, 203, 62, 82, 47,
517 47, 54, 47, 195, 64, 47, 104, 54, 47, 63,
518 47, 69, 54, 182, 73, 70, 93, 94, 74, 155,
519 54, 71, 75, 72, 47, 47, 47, 47, 216, 167,
520 56, 156, 47, 45, 47, 65, 162, 163, 47, 47,
521 47, 47, 47, 47, 47, 165, 107, 47, 138, 47,
522 83, 84, 85, 116, 192, 193, 38, 117, 47, 47,
523 46, 46, 38, 43, 95, 95, 45, 38, 47, 193,
524 193, 54, 134, 94, 94, 38, 136, 54, 96, 134,
525
526 94, 94, 54, 166, 57, 39, 166, 58, 135, 59,
527 54, 166, 47, 98, 98, 43, 95, 95, 213, 98,
528 56, 213, 180, 163, 163, 98, 98, 98, 98, 98,
529 98, 181, 135, 164, 164, 180, 163, 163, 211, 164,
530 210, 166, 204, 193, 193, 164, 164, 164, 164, 164,
531 164, 202, 207, 206, 205, 181, 194, 194, 204, 180,
532 201, 200, 194, 199, 198, 197, 196, 166, 194, 194,
533 194, 194, 194, 194, 183, 202, 208, 208, 191, 190,
534 189, 188, 208, 187, 186, 185, 184, 166, 208, 208,
535 208, 208, 208, 208, 55, 166, 55, 183, 134, 179,
536
537 178, 177, 176, 175, 174, 173, 172, 171, 126, 170,
538 169, 168, 166, 166, 137, 126, 161, 160, 159, 158,
539 157, 154, 126, 153, 152, 151, 150, 149, 148, 147,
540 146, 145, 144, 143, 142, 141, 140, 139, 43, 97,
541 137, 133, 132, 131, 130, 129, 128, 127, 126, 125,
542 124, 123, 122, 121, 120, 119, 118, 115, 114, 111,
543 110, 109, 108, 106, 105, 103, 102, 101, 100, 99,
544 45, 97, 92, 91, 90, 86, 68, 51, 41, 40,
545 216, 3, 216, 216, 216, 216, 216, 216, 216, 216,
546 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
547
548 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
549 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
550 216, 216, 216, 216, 216, 216
551 } ;
552
553 static yyconst flex_int16_t yy_chk[427] =
554 { 0,
555 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
556 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
557 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
558 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
559 1, 1, 1, 1, 4, 10, 13, 14, 14, 30,
560 4, 10, 16, 16, 25, 4, 10, 21, 30, 34,
561 21, 70, 21, 4, 10, 70, 21, 34, 29, 25,
562 13, 229, 34, 4, 10, 12, 12, 12, 12, 12,
563 228, 29, 227, 12, 12, 12, 29, 226, 12, 12,
564 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
565
566 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
567 12, 17, 17, 17, 62, 31, 225, 22, 31, 23,
568 17, 19, 23, 224, 23, 22, 62, 19, 22, 22,
569 22, 27, 19, 223, 28, 27, 43, 43, 28, 120,
570 19, 27, 28, 27, 17, 18, 18, 18, 18, 222,
571 19, 120, 18, 65, 18, 24, 134, 134, 18, 18,
572 18, 18, 18, 18, 24, 221, 65, 24, 220, 24,
573 32, 32, 32, 74, 180, 180, 38, 74, 18, 20,
574 20, 20, 38, 44, 44, 44, 44, 38, 20, 193,
575 193, 54, 94, 94, 94, 38, 219, 54, 218, 93,
576
577 93, 93, 54, 215, 20, 38, 214, 20, 93, 20,
578 54, 213, 20, 48, 48, 95, 95, 95, 212, 48,
579 54, 209, 162, 162, 162, 48, 48, 48, 48, 48,
580 48, 162, 93, 135, 135, 163, 163, 163, 206, 135,
581 205, 204, 203, 192, 192, 135, 135, 135, 135, 135,
582 135, 192, 201, 200, 196, 162, 181, 181, 195, 194,
583 191, 190, 181, 188, 187, 186, 184, 183, 181, 181,
584 181, 181, 181, 181, 182, 192, 202, 202, 178, 177,
585 174, 173, 202, 172, 171, 170, 169, 167, 202, 202,
586 202, 202, 202, 202, 217, 166, 217, 165, 164, 160,
587
588 158, 157, 156, 155, 152, 151, 146, 145, 143, 142,
589 140, 139, 138, 137, 136, 130, 128, 127, 125, 124,
590 121, 119, 118, 117, 116, 114, 113, 112, 111, 110,
591 109, 108, 107, 106, 104, 103, 102, 101, 98, 97,
592 96, 91, 90, 89, 88, 87, 86, 85, 84, 83,
593 82, 80, 79, 78, 77, 76, 75, 73, 71, 69,
594 68, 67, 66, 64, 63, 61, 60, 59, 58, 57,
595 46, 45, 37, 36, 35, 33, 26, 15, 8, 7,
596 3, 216, 216, 216, 216, 216, 216, 216, 216, 216,
597 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
598
599 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
600 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
601 216, 216, 216, 216, 216, 216
602 } ;
603
604 static yy_state_type yy_last_accepting_state;
605 static char *yy_last_accepting_cpos;
606
607 extern int pcap__flex_debug;
608 int pcap__flex_debug = 0;
609
610 /* The intent behind this definition is that it'll catch
611 * any uses of REJECT which flex missed.
612 */
613 #define REJECT reject_used_but_not_detected
614 #define yymore() yymore_used_but_not_detected
615 #define YY_MORE_ADJ 0
616 #define YY_RESTORE_YY_MORE_OFFSET
617 char *pcap_text;
618 #line 1 "scanner.l"
619 #line 2 "scanner.l"
620 /*
621 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
622 * The Regents of the University of California. All rights reserved.
623 *
624 * Redistribution and use in source and binary forms, with or without
625 * modification, are permitted provided that: (1) source code distributions
626 * retain the above copyright notice and this paragraph in its entirety, (2)
627 * distributions including binary code include the above copyright notice and
628 * this paragraph in its entirety in the documentation or other materials
629 * provided with the distribution, and (3) all advertising materials mentioning
630 * features or use of this software display the following acknowledgement:
631 * ``This product includes software developed by the University of California,
632 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
633 * the University nor the names of its contributors may be used to endorse
634 * or promote products derived from this software without specific prior
635 * written permission.
636 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
637 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
638 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
639 */
640
641 #ifndef lint
642 static const char rcsid[] =
643 "@(#) $Header: /usr/local/cvs/linux/tools/build/e100boot/libpcap-0.4/scanner.l,v 1.1 1999/08/26 10:05:27 johana Exp $ (LBL)";
644 #endif
645
646 #include <sys/types.h>
647 #include <sys/time.h>
648
649 #include <ctype.h>
650 #include <unistd.h>
651
652 #include "pcap-int.h"
653
654 #include "gencode.h"
655 #include <pcap-namedb.h>
656 #include "tokdefs.h"
657
658 #include "gnuc.h"
659 #ifdef HAVE_OS_PROTO_H
660 #include "os-proto.h"
661 #endif
662
663 static int stoi(char *);
664 static inline int xdtoi(int);
665
666 #ifdef FLEX_SCANNER
667 #define YY_NO_UNPUT
668 #undef YY_INPUT
669 #define YY_INPUT(buf, result, max)\
670 {\
671 char *src = in_buffer;\
672 int i;\
673 \
674 if (*src == 0)\
675 result = YY_NULL;\
676 else {\
677 for (i = 0; *src && i < max; ++i)\
678 buf[i] = *src++;\
679 in_buffer += i;\
680 result = i;\
681 }\
682 }
683 #else
684 #undef getc
685 #define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++)
686 #endif
687
688 #define yylval pcap_lval
689 extern YYSTYPE yylval;
690
691 static char *in_buffer;
692
693 #line 694 "<stdout>"
694
695 #define INITIAL 0
696
697 #ifndef YY_NO_UNISTD_H
698 /* Special case for "unistd.h", since it is non-ANSI. We include it way
699 * down here because we want the user's section 1 to have been scanned first.
700 * The user has a chance to override it with an option.
701 */
702 #include <unistd.h>
703 #endif
704
705 #ifndef YY_EXTRA_TYPE
706 #define YY_EXTRA_TYPE void *
707 #endif
708
709 static int yy_init_globals (void );
710
711 /* Macros after this point can all be overridden by user definitions in
712 * section 1.
713 */
714
715 #ifndef YY_SKIP_YYWRAP
716 #ifdef __cplusplus
717 extern "C" int pcap_wrap (void );
718 #else
719 extern int pcap_wrap (void );
720 #endif
721 #endif
722
723 static void yyunput (int c,char *buf_ptr );
724
725 #ifndef yytext_ptr
726 static void yy_flex_strncpy (char *,yyconst char *,int );
727 #endif
728
729 #ifdef YY_NEED_STRLEN
730 static int yy_flex_strlen (yyconst char * );
731 #endif
732
733 #ifndef YY_NO_INPUT
734
735 #ifdef __cplusplus
736 static int yyinput (void );
737 #else
738 static int input (void );
739 #endif
740
741 #endif
742
743 /* Amount of stuff to slurp up with each read. */
744 #ifndef YY_READ_BUF_SIZE
745 #define YY_READ_BUF_SIZE 8192
746 #endif
747
748 /* Copy whatever the last rule matched to the standard output. */
749 #ifndef ECHO
750 /* This used to be an fputs(), but since the string might contain NUL's,
751 * we now use fwrite().
752 */
753 #define ECHO (void) fwrite( pcap_text, pcap_leng, 1, pcap_out )
754 #endif
755
756 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
757 * is returned in "result".
758 */
759 #ifndef YY_INPUT
760 #define YY_INPUT(buf,result,max_size) \
761 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
762 { \
763 int c = '*'; \
764 size_t n; \
765 for ( n = 0; n < max_size && \
766 (c = getc( pcap_in )) != EOF && c != '\n'; ++n ) \
767 buf[n] = (char) c; \
768 if ( c == '\n' ) \
769 buf[n++] = (char) c; \
770 if ( c == EOF && ferror( pcap_in ) ) \
771 YY_FATAL_ERROR( "input in flex scanner failed" ); \
772 result = n; \
773 } \
774 else \
775 { \
776 errno=0; \
777 while ( (result = fread(buf, 1, max_size, pcap_in))==0 && ferror(pcap_in)) \
778 { \
779 if( errno != EINTR) \
780 { \
781 YY_FATAL_ERROR( "input in flex scanner failed" ); \
782 break; \
783 } \
784 errno=0; \
785 clearerr(pcap_in); \
786 } \
787 }\
788 \
789
790 #endif
791
792 /* No semi-colon after return; correct usage is to write "yyterminate();" -
793 * we don't want an extra ';' after the "return" because that will cause
794 * some compilers to complain about unreachable statements.
795 */
796 #ifndef yyterminate
797 #define yyterminate() return YY_NULL
798 #endif
799
800 /* Number of entries by which start-condition stack grows. */
801 #ifndef YY_START_STACK_INCR
802 #define YY_START_STACK_INCR 25
803 #endif
804
805 /* Report a fatal error. */
806 #ifndef YY_FATAL_ERROR
807 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
808 #endif
809
810 /* end tables serialization structures and prototypes */
811
812 /* Default declaration of generated scanner - a define so the user can
813 * easily add parameters.
814 */
815 #ifndef YY_DECL
816 #define YY_DECL_IS_OURS 1
817
818 extern int pcap_lex (void);
819
820 #define YY_DECL int pcap_lex (void)
821 #endif /* !YY_DECL */
822
823 /* Code executed at the beginning of each rule, after pcap_text and pcap_leng
824 * have been set up.
825 */
826 #ifndef YY_USER_ACTION
827 #define YY_USER_ACTION
828 #endif
829
830 /* Code executed at the end of each rule. */
831 #ifndef YY_BREAK
832 #define YY_BREAK break;
833 #endif
834
835 #define YY_RULE_SETUP \
836 YY_USER_ACTION
837
838 /** The main scanner function which does all the work.
839 */
840 YY_DECL
841 {
842 register yy_state_type yy_current_state;
843 register char *yy_cp, *yy_bp;
844 register int yy_act;
845
846 #line 82 "scanner.l"
847
848 #line 849 "<stdout>"
849
850 if ( !(yy_init) )
851 {
852 (yy_init) = 1;
853
854 #ifdef YY_USER_INIT
855 YY_USER_INIT;
856 #endif
857
858 if ( ! (yy_start) )
859 (yy_start) = 1; /* first start state */
860
861 if ( ! pcap_in )
862 pcap_in = stdin;
863
864 if ( ! pcap_out )
865 pcap_out = stdout;
866
867 if ( ! YY_CURRENT_BUFFER ) {
868 pcap_ensure_buffer_stack ();
869 YY_CURRENT_BUFFER_LVALUE =
870 pcap__create_buffer(pcap_in,YY_BUF_SIZE );
871 }
872
873 pcap__load_buffer_state( );
874 }
875
876 while ( 1 ) /* loops until end-of-file is reached */
877 {
878 yy_cp = (yy_c_buf_p);
879
880 /* Support of pcap_text. */
881 *yy_cp = (yy_hold_char);
882
883 /* yy_bp points to the position in yy_ch_buf of the start of
884 * the current run.
885 */
886 yy_bp = yy_cp;
887
888 yy_current_state = (yy_start);
889 yy_match:
890 do
891 {
892 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
893 if ( yy_accept[yy_current_state] )
894 {
895 (yy_last_accepting_state) = yy_current_state;
896 (yy_last_accepting_cpos) = yy_cp;
897 }
898 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
899 {
900 yy_current_state = (int) yy_def[yy_current_state];
901 if ( yy_current_state >= 217 )
902 yy_c = yy_meta[(unsigned int) yy_c];
903 }
904 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
905 ++yy_cp;
906 }
907 while ( yy_base[yy_current_state] != 382 );
908
909 yy_find_action:
910 yy_act = yy_accept[yy_current_state];
911 if ( yy_act == 0 )
912 { /* have to back up */
913 yy_cp = (yy_last_accepting_cpos);
914 yy_current_state = (yy_last_accepting_state);
915 yy_act = yy_accept[yy_current_state];
916 }
917
918 YY_DO_BEFORE_ACTION;
919
920 do_action: /* This label is used only to access EOF actions. */
921
922 switch ( yy_act )
923 { /* beginning of action switch */
924 case 0: /* must back up */
925 /* undo the effects of YY_DO_BEFORE_ACTION */
926 *yy_cp = (yy_hold_char);
927 yy_cp = (yy_last_accepting_cpos);
928 yy_current_state = (yy_last_accepting_state);
929 goto yy_find_action;
930
931 case 1:
932 YY_RULE_SETUP
933 #line 83 "scanner.l"
934 return DST;
935 YY_BREAK
936 case 2:
937 YY_RULE_SETUP
938 #line 84 "scanner.l"
939 return SRC;
940 YY_BREAK
941 case 3:
942 YY_RULE_SETUP
943 #line 86 "scanner.l"
944 return LINK;
945 YY_BREAK
946 case 4:
947 YY_RULE_SETUP
948 #line 87 "scanner.l"
949 return LINK;
950 YY_BREAK
951 case 5:
952 YY_RULE_SETUP
953 #line 88 "scanner.l"
954 return ARP;
955 YY_BREAK
956 case 6:
957 YY_RULE_SETUP
958 #line 89 "scanner.l"
959 return RARP;
960 YY_BREAK
961 case 7:
962 YY_RULE_SETUP
963 #line 90 "scanner.l"
964 return IP;
965 YY_BREAK
966 case 8:
967 YY_RULE_SETUP
968 #line 91 "scanner.l"
969 return TCP;
970 YY_BREAK
971 case 9:
972 YY_RULE_SETUP
973 #line 92 "scanner.l"
974 return UDP;
975 YY_BREAK
976 case 10:
977 YY_RULE_SETUP
978 #line 93 "scanner.l"
979 return ICMP;
980 YY_BREAK
981 case 11:
982 YY_RULE_SETUP
983 #line 94 "scanner.l"
984 return IGMP;
985 YY_BREAK
986 case 12:
987 YY_RULE_SETUP
988 #line 95 "scanner.l"
989 return IGRP;
990 YY_BREAK
991 case 13:
992 YY_RULE_SETUP
993 #line 97 "scanner.l"
994 return ATALK;
995 YY_BREAK
996 case 14:
997 YY_RULE_SETUP
998 #line 98 "scanner.l"
999 return DECNET;
1000 YY_BREAK
1001 case 15:
1002 YY_RULE_SETUP
1003 #line 99 "scanner.l"
1004 return LAT;
1005 YY_BREAK
1006 case 16:
1007 YY_RULE_SETUP
1008 #line 100 "scanner.l"
1009 return SCA;
1010 YY_BREAK
1011 case 17:
1012 YY_RULE_SETUP
1013 #line 101 "scanner.l"
1014 return MOPRC;
1015 YY_BREAK
1016 case 18:
1017 YY_RULE_SETUP
1018 #line 102 "scanner.l"
1019 return MOPDL;
1020 YY_BREAK
1021 case 19:
1022 YY_RULE_SETUP
1023 #line 104 "scanner.l"
1024 return HOST;
1025 YY_BREAK
1026 case 20:
1027 YY_RULE_SETUP
1028 #line 105 "scanner.l"
1029 return NET;
1030 YY_BREAK
1031 case 21:
1032 YY_RULE_SETUP
1033 #line 106 "scanner.l"
1034 return MASK;
1035 YY_BREAK
1036 case 22:
1037 YY_RULE_SETUP
1038 #line 107 "scanner.l"
1039 return PORT;
1040 YY_BREAK
1041 case 23:
1042 YY_RULE_SETUP
1043 #line 108 "scanner.l"
1044 return PROTO;
1045 YY_BREAK
1046 case 24:
1047 YY_RULE_SETUP
1048 #line 110 "scanner.l"
1049 return GATEWAY;
1050 YY_BREAK
1051 case 25:
1052 YY_RULE_SETUP
1053 #line 112 "scanner.l"
1054 return LESS;
1055 YY_BREAK
1056 case 26:
1057 YY_RULE_SETUP
1058 #line 113 "scanner.l"
1059 return GREATER;
1060 YY_BREAK
1061 case 27:
1062 YY_RULE_SETUP
1063 #line 114 "scanner.l"
1064 return BYTE;
1065 YY_BREAK
1066 case 28:
1067 YY_RULE_SETUP
1068 #line 115 "scanner.l"
1069 return TK_BROADCAST;
1070 YY_BREAK
1071 case 29:
1072 YY_RULE_SETUP
1073 #line 116 "scanner.l"
1074 return TK_MULTICAST;
1075 YY_BREAK
1076 case 30:
1077 YY_RULE_SETUP
1078 #line 118 "scanner.l"
1079 return AND;
1080 YY_BREAK
1081 case 31:
1082 YY_RULE_SETUP
1083 #line 119 "scanner.l"
1084 return OR;
1085 YY_BREAK
1086 case 32:
1087 YY_RULE_SETUP
1088 #line 120 "scanner.l"
1089 return '!';
1090 YY_BREAK
1091 case 33:
1092 YY_RULE_SETUP
1093 #line 122 "scanner.l"
1094 return LEN;
1095 YY_BREAK
1096 case 34:
1097 YY_RULE_SETUP
1098 #line 123 "scanner.l"
1099 return INBOUND;
1100 YY_BREAK
1101 case 35:
1102 YY_RULE_SETUP
1103 #line 124 "scanner.l"
1104 return OUTBOUND;
1105 YY_BREAK
1106 case 36:
1107 /* rule 36 can match eol */
1108 YY_RULE_SETUP
1109 #line 126 "scanner.l"
1110 ;
1111 YY_BREAK
1112 case 37:
1113 YY_RULE_SETUP
1114 #line 127 "scanner.l"
1115 return pcap_text[0];
1116 YY_BREAK
1117 case 38:
1118 YY_RULE_SETUP
1119 #line 128 "scanner.l"
1120 return GEQ;
1121 YY_BREAK
1122 case 39:
1123 YY_RULE_SETUP
1124 #line 129 "scanner.l"
1125 return LEQ;
1126 YY_BREAK
1127 case 40:
1128 YY_RULE_SETUP
1129 #line 130 "scanner.l"
1130 return NEQ;
1131 YY_BREAK
1132 case 41:
1133 YY_RULE_SETUP
1134 #line 131 "scanner.l"
1135 return '=';
1136 YY_BREAK
1137 case 42:
1138 YY_RULE_SETUP
1139 #line 132 "scanner.l"
1140 return LSH;
1141 YY_BREAK
1142 case 43:
1143 YY_RULE_SETUP
1144 #line 133 "scanner.l"
1145 return RSH;
1146 YY_BREAK
1147 case 44:
1148 YY_RULE_SETUP
1149 #line 134 "scanner.l"
1150 { yylval.i = stoi((char *)pcap_text); return NUM; }
1151 YY_BREAK
1152 case 45:
1153 YY_RULE_SETUP
1154 #line 135 "scanner.l"
1155 {
1156 yylval.s = sdup((char *)pcap_text); return HID; }
1157 YY_BREAK
1158 case 46:
1159 YY_RULE_SETUP
1160 #line 137 "scanner.l"
1161 { yylval.e = pcap_ether_aton((char *)pcap_text);
1162 return EID; }
1163 YY_BREAK
1164 case 47:
1165 YY_RULE_SETUP
1166 #line 139 "scanner.l"
1167 { bpf_error("bogus ethernet address %s", pcap_text); }
1168 YY_BREAK
1169 case 48:
1170 YY_RULE_SETUP
1171 #line 140 "scanner.l"
1172 {
1173 yylval.s = sdup((char *)pcap_text); return ID; }
1174 YY_BREAK
1175 case 49:
1176 YY_RULE_SETUP
1177 #line 142 "scanner.l"
1178 { yylval.s = sdup((char *)pcap_text + 1); return ID; }
1179 YY_BREAK
1180 case 50:
1181 YY_RULE_SETUP
1182 #line 143 "scanner.l"
1183 {
1184 bpf_error("illegal token: %s\n", pcap_text); }
1185 YY_BREAK
1186 case 51:
1187 YY_RULE_SETUP
1188 #line 145 "scanner.l"
1189 { bpf_error("illegal char '%c'", *pcap_text); }
1190 YY_BREAK
1191 case 52:
1192 YY_RULE_SETUP
1193 #line 146 "scanner.l"
1194 ECHO;
1195 YY_BREAK
1196 #line 1197 "<stdout>"
1197 case YY_STATE_EOF(INITIAL):
1198 yyterminate();
1199
1200 case YY_END_OF_BUFFER:
1201 {
1202 /* Amount of text matched not including the EOB char. */
1203 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1204
1205 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1206 *yy_cp = (yy_hold_char);
1207 YY_RESTORE_YY_MORE_OFFSET
1208
1209 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1210 {
1211 /* We're scanning a new file or input source. It's
1212 * possible that this happened because the user
1213 * just pointed pcap_in at a new source and called
1214 * pcap_lex(). If so, then we have to assure
1215 * consistency between YY_CURRENT_BUFFER and our
1216 * globals. Here is the right place to do so, because
1217 * this is the first action (other than possibly a
1218 * back-up) that will match for the new input source.
1219 */
1220 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1221 YY_CURRENT_BUFFER_LVALUE->yy_input_file = pcap_in;
1222 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1223 }
1224
1225 /* Note that here we test for yy_c_buf_p "<=" to the position
1226 * of the first EOB in the buffer, since yy_c_buf_p will
1227 * already have been incremented past the NUL character
1228 * (since all states make transitions on EOB to the
1229 * end-of-buffer state). Contrast this with the test
1230 * in input().
1231 */
1232 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1233 { /* This was really a NUL. */
1234 yy_state_type yy_next_state;
1235
1236 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1237
1238 yy_current_state = yy_get_previous_state( );
1239
1240 /* Okay, we're now positioned to make the NUL
1241 * transition. We couldn't have
1242 * yy_get_previous_state() go ahead and do it
1243 * for us because it doesn't know how to deal
1244 * with the possibility of jamming (and we don't
1245 * want to build jamming into it because then it
1246 * will run more slowly).
1247 */
1248
1249 yy_next_state = yy_try_NUL_trans( yy_current_state );
1250
1251 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1252
1253 if ( yy_next_state )
1254 {
1255 /* Consume the NUL. */
1256 yy_cp = ++(yy_c_buf_p);
1257 yy_current_state = yy_next_state;
1258 goto yy_match;
1259 }
1260
1261 else
1262 {
1263 yy_cp = (yy_c_buf_p);
1264 goto yy_find_action;
1265 }
1266 }
1267
1268 else switch ( yy_get_next_buffer( ) )
1269 {
1270 case EOB_ACT_END_OF_FILE:
1271 {
1272 (yy_did_buffer_switch_on_eof) = 0;
1273
1274 if ( pcap_wrap( ) )
1275 {
1276 /* Note: because we've taken care in
1277 * yy_get_next_buffer() to have set up
1278 * pcap_text, we can now set up
1279 * yy_c_buf_p so that if some total
1280 * hoser (like flex itself) wants to
1281 * call the scanner after we return the
1282 * YY_NULL, it'll still work - another
1283 * YY_NULL will get returned.
1284 */
1285 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1286
1287 yy_act = YY_STATE_EOF(YY_START);
1288 goto do_action;
1289 }
1290
1291 else
1292 {
1293 if ( ! (yy_did_buffer_switch_on_eof) )
1294 YY_NEW_FILE;
1295 }
1296 break;
1297 }
1298
1299 case EOB_ACT_CONTINUE_SCAN:
1300 (yy_c_buf_p) =
1301 (yytext_ptr) + yy_amount_of_matched_text;
1302
1303 yy_current_state = yy_get_previous_state( );
1304
1305 yy_cp = (yy_c_buf_p);
1306 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1307 goto yy_match;
1308
1309 case EOB_ACT_LAST_MATCH:
1310 (yy_c_buf_p) =
1311 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1312
1313 yy_current_state = yy_get_previous_state( );
1314
1315 yy_cp = (yy_c_buf_p);
1316 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1317 goto yy_find_action;
1318 }
1319 break;
1320 }
1321
1322 default:
1323 YY_FATAL_ERROR(
1324 "fatal flex scanner internal error--no action found" );
1325 } /* end of action switch */
1326 } /* end of scanning one token */
1327 } /* end of pcap_lex */
1328
1329 /* yy_get_next_buffer - try to read in a new buffer
1330 *
1331 * Returns a code representing an action:
1332 * EOB_ACT_LAST_MATCH -
1333 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1334 * EOB_ACT_END_OF_FILE - end of file
1335 */
1336 static int yy_get_next_buffer (void)
1337 {
1338 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1339 register char *source = (yytext_ptr);
1340 register int number_to_move, i;
1341 int ret_val;
1342
1343 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1344 YY_FATAL_ERROR(
1345 "fatal flex scanner internal error--end of buffer missed" );
1346
1347 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1348 { /* Don't try to fill the buffer, so this is an EOF. */
1349 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1350 {
1351 /* We matched a single character, the EOB, so
1352 * treat this as a final EOF.
1353 */
1354 return EOB_ACT_END_OF_FILE;
1355 }
1356
1357 else
1358 {
1359 /* We matched some text prior to the EOB, first
1360 * process it.
1361 */
1362 return EOB_ACT_LAST_MATCH;
1363 }
1364 }
1365
1366 /* Try to read more data. */
1367
1368 /* First move last chars to start of buffer. */
1369 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1370
1371 for ( i = 0; i < number_to_move; ++i )
1372 *(dest++) = *(source++);
1373
1374 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1375 /* don't do the read, it's not guaranteed to return an EOF,
1376 * just force an EOF
1377 */
1378 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1379
1380 else
1381 {
1382 int num_to_read =
1383 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1384
1385 while ( num_to_read <= 0 )
1386 { /* Not enough room in the buffer - grow it. */
1387
1388 /* just a shorter name for the current buffer */
1389 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1390
1391 int yy_c_buf_p_offset =
1392 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1393
1394 if ( b->yy_is_our_buffer )
1395 {
1396 int new_size = b->yy_buf_size * 2;
1397
1398 if ( new_size <= 0 )
1399 b->yy_buf_size += b->yy_buf_size / 8;
1400 else
1401 b->yy_buf_size *= 2;
1402
1403 b->yy_ch_buf = (char *)
1404 /* Include room in for 2 EOB chars. */
1405 pcap_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1406 }
1407 else
1408 /* Can't grow it, we don't own it. */
1409 b->yy_ch_buf = 0;
1410
1411 if ( ! b->yy_ch_buf )
1412 YY_FATAL_ERROR(
1413 "fatal error - scanner input buffer overflow" );
1414
1415 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1416
1417 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1418 number_to_move - 1;
1419
1420 }
1421
1422 if ( num_to_read > YY_READ_BUF_SIZE )
1423 num_to_read = YY_READ_BUF_SIZE;
1424
1425 /* Read in more data. */
1426 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1427 (yy_n_chars), (size_t) num_to_read );
1428
1429 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1430 }
1431
1432 if ( (yy_n_chars) == 0 )
1433 {
1434 if ( number_to_move == YY_MORE_ADJ )
1435 {
1436 ret_val = EOB_ACT_END_OF_FILE;
1437 pcap_restart(pcap_in );
1438 }
1439
1440 else
1441 {
1442 ret_val = EOB_ACT_LAST_MATCH;
1443 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1444 YY_BUFFER_EOF_PENDING;
1445 }
1446 }
1447
1448 else
1449 ret_val = EOB_ACT_CONTINUE_SCAN;
1450
1451 (yy_n_chars) += number_to_move;
1452 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1453 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1454
1455 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1456
1457 return ret_val;
1458 }
1459
1460 /* yy_get_previous_state - get the state just before the EOB char was reached */
1461
1462 static yy_state_type yy_get_previous_state (void)
1463 {
1464 register yy_state_type yy_current_state;
1465 register char *yy_cp;
1466
1467 yy_current_state = (yy_start);
1468
1469 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1470 {
1471 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1472 if ( yy_accept[yy_current_state] )
1473 {
1474 (yy_last_accepting_state) = yy_current_state;
1475 (yy_last_accepting_cpos) = yy_cp;
1476 }
1477 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1478 {
1479 yy_current_state = (int) yy_def[yy_current_state];
1480 if ( yy_current_state >= 217 )
1481 yy_c = yy_meta[(unsigned int) yy_c];
1482 }
1483 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1484 }
1485
1486 return yy_current_state;
1487 }
1488
1489 /* yy_try_NUL_trans - try to make a transition on the NUL character
1490 *
1491 * synopsis
1492 * next_state = yy_try_NUL_trans( current_state );
1493 */
1494 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1495 {
1496 register int yy_is_jam;
1497 register char *yy_cp = (yy_c_buf_p);
1498
1499 register YY_CHAR yy_c = 1;
1500 if ( yy_accept[yy_current_state] )
1501 {
1502 (yy_last_accepting_state) = yy_current_state;
1503 (yy_last_accepting_cpos) = yy_cp;
1504 }
1505 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1506 {
1507 yy_current_state = (int) yy_def[yy_current_state];
1508 if ( yy_current_state >= 217 )
1509 yy_c = yy_meta[(unsigned int) yy_c];
1510 }
1511 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1512 yy_is_jam = (yy_current_state == 216);
1513
1514 return yy_is_jam ? 0 : yy_current_state;
1515 }
1516
1517 static void yyunput (int c, register char * yy_bp )
1518 {
1519 register char *yy_cp;
1520
1521 yy_cp = (yy_c_buf_p);
1522
1523 /* undo effects of setting up pcap_text */
1524 *yy_cp = (yy_hold_char);
1525
1526 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1527 { /* need to shift things up to make room */
1528 /* +2 for EOB chars. */
1529 register int number_to_move = (yy_n_chars) + 2;
1530 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1531 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1532 register char *source =
1533 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1534
1535 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1536 *--dest = *--source;
1537
1538 yy_cp += (int) (dest - source);
1539 yy_bp += (int) (dest - source);
1540 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1541 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1542
1543 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1544 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1545 }
1546
1547 *--yy_cp = (char) c;
1548
1549 (yytext_ptr) = yy_bp;
1550 (yy_hold_char) = *yy_cp;
1551 (yy_c_buf_p) = yy_cp;
1552 }
1553
1554 #ifndef YY_NO_INPUT
1555 #ifdef __cplusplus
1556 static int yyinput (void)
1557 #else
1558 static int input (void)
1559 #endif
1560
1561 {
1562 int c;
1563
1564 *(yy_c_buf_p) = (yy_hold_char);
1565
1566 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1567 {
1568 /* yy_c_buf_p now points to the character we want to return.
1569 * If this occurs *before* the EOB characters, then it's a
1570 * valid NUL; if not, then we've hit the end of the buffer.
1571 */
1572 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1573 /* This was really a NUL. */
1574 *(yy_c_buf_p) = '\0';
1575
1576 else
1577 { /* need more input */
1578 int offset = (yy_c_buf_p) - (yytext_ptr);
1579 ++(yy_c_buf_p);
1580
1581 switch ( yy_get_next_buffer( ) )
1582 {
1583 case EOB_ACT_LAST_MATCH:
1584 /* This happens because yy_g_n_b()
1585 * sees that we've accumulated a
1586 * token and flags that we need to
1587 * try matching the token before
1588 * proceeding. But for input(),
1589 * there's no matching to consider.
1590 * So convert the EOB_ACT_LAST_MATCH
1591 * to EOB_ACT_END_OF_FILE.
1592 */
1593
1594 /* Reset buffer status. */
1595 pcap_restart(pcap_in );
1596
1597 /*FALLTHROUGH*/
1598
1599 case EOB_ACT_END_OF_FILE:
1600 {
1601 if ( pcap_wrap( ) )
1602 return EOF;
1603
1604 if ( ! (yy_did_buffer_switch_on_eof) )
1605 YY_NEW_FILE;
1606 #ifdef __cplusplus
1607 return yyinput();
1608 #else
1609 return input();
1610 #endif
1611 }
1612
1613 case EOB_ACT_CONTINUE_SCAN:
1614 (yy_c_buf_p) = (yytext_ptr) + offset;
1615 break;
1616 }
1617 }
1618 }
1619
1620 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1621 *(yy_c_buf_p) = '\0'; /* preserve pcap_text */
1622 (yy_hold_char) = *++(yy_c_buf_p);
1623
1624 return c;
1625 }
1626 #endif /* ifndef YY_NO_INPUT */
1627
1628 /** Immediately switch to a different input stream.
1629 * @param input_file A readable stream.
1630 *
1631 * @note This function does not reset the start condition to @c INITIAL .
1632 */
1633 void pcap_restart (FILE * input_file )
1634 {
1635
1636 if ( ! YY_CURRENT_BUFFER ){
1637 pcap_ensure_buffer_stack ();
1638 YY_CURRENT_BUFFER_LVALUE =
1639 pcap__create_buffer(pcap_in,YY_BUF_SIZE );
1640 }
1641
1642 pcap__init_buffer(YY_CURRENT_BUFFER,input_file );
1643 pcap__load_buffer_state( );
1644 }
1645
1646 /** Switch to a different input buffer.
1647 * @param new_buffer The new input buffer.
1648 *
1649 */
1650 void pcap__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1651 {
1652
1653 /* TODO. We should be able to replace this entire function body
1654 * with
1655 * pcap_pop_buffer_state();
1656 * pcap_push_buffer_state(new_buffer);
1657 */
1658 pcap_ensure_buffer_stack ();
1659 if ( YY_CURRENT_BUFFER == new_buffer )
1660 return;
1661
1662 if ( YY_CURRENT_BUFFER )
1663 {
1664 /* Flush out information for old buffer. */
1665 *(yy_c_buf_p) = (yy_hold_char);
1666 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1667 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1668 }
1669
1670 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1671 pcap__load_buffer_state( );
1672
1673 /* We don't actually know whether we did this switch during
1674 * EOF (pcap_wrap()) processing, but the only time this flag
1675 * is looked at is after pcap_wrap() is called, so it's safe
1676 * to go ahead and always set it.
1677 */
1678 (yy_did_buffer_switch_on_eof) = 1;
1679 }
1680
1681 static void pcap__load_buffer_state (void)
1682 {
1683 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1684 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1685 pcap_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1686 (yy_hold_char) = *(yy_c_buf_p);
1687 }
1688
1689 /** Allocate and initialize an input buffer state.
1690 * @param file A readable stream.
1691 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1692 *
1693 * @return the allocated buffer state.
1694 */
1695 YY_BUFFER_STATE pcap__create_buffer (FILE * file, int size )
1696 {
1697 YY_BUFFER_STATE b;
1698
1699 b = (YY_BUFFER_STATE) pcap_alloc(sizeof( struct yy_buffer_state ) );
1700 if ( ! b )
1701 YY_FATAL_ERROR( "out of dynamic memory in pcap__create_buffer()" );
1702
1703 b->yy_buf_size = size;
1704
1705 /* yy_ch_buf has to be 2 characters longer than the size given because
1706 * we need to put in 2 end-of-buffer characters.
1707 */
1708 b->yy_ch_buf = (char *) pcap_alloc(b->yy_buf_size + 2 );
1709 if ( ! b->yy_ch_buf )
1710 YY_FATAL_ERROR( "out of dynamic memory in pcap__create_buffer()" );
1711
1712 b->yy_is_our_buffer = 1;
1713
1714 pcap__init_buffer(b,file );
1715
1716 return b;
1717 }
1718
1719 /** Destroy the buffer.
1720 * @param b a buffer created with pcap__create_buffer()
1721 *
1722 */
1723 void pcap__delete_buffer (YY_BUFFER_STATE b )
1724 {
1725
1726 if ( ! b )
1727 return;
1728
1729 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1730 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1731
1732 if ( b->yy_is_our_buffer )
1733 pcap_free((void *) b->yy_ch_buf );
1734
1735 pcap_free((void *) b );
1736 }
1737
1738 #ifndef __cplusplus
1739 extern int isatty (int );
1740 #endif /* __cplusplus */
1741
1742 /* Initializes or reinitializes a buffer.
1743 * This function is sometimes called more than once on the same buffer,
1744 * such as during a pcap_restart() or at EOF.
1745 */
1746 static void pcap__init_buffer (YY_BUFFER_STATE b, FILE * file )
1747
1748 {
1749 int oerrno = errno;
1750
1751 pcap__flush_buffer(b );
1752
1753 b->yy_input_file = file;
1754 b->yy_fill_buffer = 1;
1755
1756 /* If b is the current buffer, then pcap__init_buffer was _probably_
1757 * called from pcap_restart() or through yy_get_next_buffer.
1758 * In that case, we don't want to reset the lineno or column.
1759 */
1760 if (b != YY_CURRENT_BUFFER){
1761 b->yy_bs_lineno = 1;
1762 b->yy_bs_column = 0;
1763 }
1764
1765 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1766
1767 errno = oerrno;
1768 }
1769
1770 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1771 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1772 *
1773 */
1774 void pcap__flush_buffer (YY_BUFFER_STATE b )
1775 {
1776 if ( ! b )
1777 return;
1778
1779 b->yy_n_chars = 0;
1780
1781 /* We always need two end-of-buffer characters. The first causes
1782 * a transition to the end-of-buffer state. The second causes
1783 * a jam in that state.
1784 */
1785 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1786 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1787
1788 b->yy_buf_pos = &b->yy_ch_buf[0];
1789
1790 b->yy_at_bol = 1;
1791 b->yy_buffer_status = YY_BUFFER_NEW;
1792
1793 if ( b == YY_CURRENT_BUFFER )
1794 pcap__load_buffer_state( );
1795 }
1796
1797 /** Pushes the new state onto the stack. The new state becomes
1798 * the current state. This function will allocate the stack
1799 * if necessary.
1800 * @param new_buffer The new state.
1801 *
1802 */
1803 void pcap_push_buffer_state (YY_BUFFER_STATE new_buffer )
1804 {
1805 if (new_buffer == NULL)
1806 return;
1807
1808 pcap_ensure_buffer_stack();
1809
1810 /* This block is copied from pcap__switch_to_buffer. */
1811 if ( YY_CURRENT_BUFFER )
1812 {
1813 /* Flush out information for old buffer. */
1814 *(yy_c_buf_p) = (yy_hold_char);
1815 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1816 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1817 }
1818
1819 /* Only push if top exists. Otherwise, replace top. */
1820 if (YY_CURRENT_BUFFER)
1821 (yy_buffer_stack_top)++;
1822 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1823
1824 /* copied from pcap__switch_to_buffer. */
1825 pcap__load_buffer_state( );
1826 (yy_did_buffer_switch_on_eof) = 1;
1827 }
1828
1829 /** Removes and deletes the top of the stack, if present.
1830 * The next element becomes the new top.
1831 *
1832 */
1833 void pcap_pop_buffer_state (void)
1834 {
1835 if (!YY_CURRENT_BUFFER)
1836 return;
1837
1838 pcap__delete_buffer(YY_CURRENT_BUFFER );
1839 YY_CURRENT_BUFFER_LVALUE = NULL;
1840 if ((yy_buffer_stack_top) > 0)
1841 --(yy_buffer_stack_top);
1842
1843 if (YY_CURRENT_BUFFER) {
1844 pcap__load_buffer_state( );
1845 (yy_did_buffer_switch_on_eof) = 1;
1846 }
1847 }
1848
1849 /* Allocates the stack if it does not exist.
1850 * Guarantees space for at least one push.
1851 */
1852 static void pcap_ensure_buffer_stack (void)
1853 {
1854 int num_to_alloc;
1855
1856 if (!(yy_buffer_stack)) {
1857
1858 /* First allocation is just for 2 elements, since we don't know if this
1859 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1860 * immediate realloc on the next call.
1861 */
1862 num_to_alloc = 1;
1863 (yy_buffer_stack) = (struct yy_buffer_state**)pcap_alloc
1864 (num_to_alloc * sizeof(struct yy_buffer_state*)
1865 );
1866
1867 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1868
1869 (yy_buffer_stack_max) = num_to_alloc;
1870 (yy_buffer_stack_top) = 0;
1871 return;
1872 }
1873
1874 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1875
1876 /* Increase the buffer to prepare for a possible push. */
1877 int grow_size = 8 /* arbitrary grow size */;
1878
1879 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1880 (yy_buffer_stack) = (struct yy_buffer_state**)pcap_realloc
1881 ((yy_buffer_stack),
1882 num_to_alloc * sizeof(struct yy_buffer_state*)
1883 );
1884
1885 /* zero only the new slots.*/
1886 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1887 (yy_buffer_stack_max) = num_to_alloc;
1888 }
1889 }
1890
1891 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1892 * @param base the character buffer
1893 * @param size the size in bytes of the character buffer
1894 *
1895 * @return the newly allocated buffer state object.
1896 */
1897 YY_BUFFER_STATE pcap__scan_buffer (char * base, yy_size_t size )
1898 {
1899 YY_BUFFER_STATE b;
1900
1901 if ( size < 2 ||
1902 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1903 base[size-1] != YY_END_OF_BUFFER_CHAR )
1904 /* They forgot to leave room for the EOB's. */
1905 return 0;
1906
1907 b = (YY_BUFFER_STATE) pcap_alloc(sizeof( struct yy_buffer_state ) );
1908 if ( ! b )
1909 YY_FATAL_ERROR( "out of dynamic memory in pcap__scan_buffer()" );
1910
1911 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1912 b->yy_buf_pos = b->yy_ch_buf = base;
1913 b->yy_is_our_buffer = 0;
1914 b->yy_input_file = 0;
1915 b->yy_n_chars = b->yy_buf_size;
1916 b->yy_is_interactive = 0;
1917 b->yy_at_bol = 1;
1918 b->yy_fill_buffer = 0;
1919 b->yy_buffer_status = YY_BUFFER_NEW;
1920
1921 pcap__switch_to_buffer(b );
1922
1923 return b;
1924 }
1925
1926 /** Setup the input buffer state to scan a string. The next call to pcap_lex() will
1927 * scan from a @e copy of @a str.
1928 * @param yystr a NUL-terminated string to scan
1929 *
1930 * @return the newly allocated buffer state object.
1931 * @note If you want to scan bytes that may contain NUL values, then use
1932 * pcap__scan_bytes() instead.
1933 */
1934 YY_BUFFER_STATE pcap__scan_string (yyconst char * yystr )
1935 {
1936
1937 return pcap__scan_bytes(yystr,strlen(yystr) );
1938 }
1939
1940 /** Setup the input buffer state to scan the given bytes. The next call to pcap_lex() will
1941 * scan from a @e copy of @a bytes.
1942 * @param bytes the byte buffer to scan
1943 * @param len the number of bytes in the buffer pointed to by @a bytes.
1944 *
1945 * @return the newly allocated buffer state object.
1946 */
1947 YY_BUFFER_STATE pcap__scan_bytes (yyconst char * yybytes, int _yybytes_len )
1948 {
1949 YY_BUFFER_STATE b;
1950 char *buf;
1951 yy_size_t n;
1952 int i;
1953
1954 /* Get memory for full buffer, including space for trailing EOB's. */
1955 n = _yybytes_len + 2;
1956 buf = (char *) pcap_alloc(n );
1957 if ( ! buf )
1958 YY_FATAL_ERROR( "out of dynamic memory in pcap__scan_bytes()" );
1959
1960 for ( i = 0; i < _yybytes_len; ++i )
1961 buf[i] = yybytes[i];
1962
1963 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1964
1965 b = pcap__scan_buffer(buf,n );
1966 if ( ! b )
1967 YY_FATAL_ERROR( "bad buffer in pcap__scan_bytes()" );
1968
1969 /* It's okay to grow etc. this buffer, and we should throw it
1970 * away when we're done.
1971 */
1972 b->yy_is_our_buffer = 1;
1973
1974 return b;
1975 }
1976
1977 #ifndef YY_EXIT_FAILURE
1978 #define YY_EXIT_FAILURE 2
1979 #endif
1980
1981 static void yy_fatal_error (yyconst char* msg )
1982 {
1983 (void) fprintf( stderr, "%s\n", msg );
1984 exit( YY_EXIT_FAILURE );
1985 }
1986
1987 /* Redefine yyless() so it works in section 3 code. */
1988
1989 #undef yyless
1990 #define yyless(n) \
1991 do \
1992 { \
1993 /* Undo effects of setting up pcap_text. */ \
1994 int yyless_macro_arg = (n); \
1995 YY_LESS_LINENO(yyless_macro_arg);\
1996 pcap_text[pcap_leng] = (yy_hold_char); \
1997 (yy_c_buf_p) = pcap_text + yyless_macro_arg; \
1998 (yy_hold_char) = *(yy_c_buf_p); \
1999 *(yy_c_buf_p) = '\0'; \
2000 pcap_leng = yyless_macro_arg; \
2001 } \
2002 while ( 0 )
2003
2004 /* Accessor methods (get/set functions) to struct members. */
2005
2006 /** Get the current line number.
2007 *
2008 */
2009 int pcap_get_lineno (void)
2010 {
2011
2012 return pcap_lineno;
2013 }
2014
2015 /** Get the input stream.
2016 *
2017 */
2018 FILE *pcap_get_in (void)
2019 {
2020 return pcap_in;
2021 }
2022
2023 /** Get the output stream.
2024 *
2025 */
2026 FILE *pcap_get_out (void)
2027 {
2028 return pcap_out;
2029 }
2030
2031 /** Get the length of the current token.
2032 *
2033 */
2034 int pcap_get_leng (void)
2035 {
2036 return pcap_leng;
2037 }
2038
2039 /** Get the current token.
2040 *
2041 */
2042
2043 char *pcap_get_text (void)
2044 {
2045 return pcap_text;
2046 }
2047
2048 /** Set the current line number.
2049 * @param line_number
2050 *
2051 */
2052 void pcap_set_lineno (int line_number )
2053 {
2054
2055 pcap_lineno = line_number;
2056 }
2057
2058 /** Set the input stream. This does not discard the current
2059 * input buffer.
2060 * @param in_str A readable stream.
2061 *
2062 * @see pcap__switch_to_buffer
2063 */
2064 void pcap_set_in (FILE * in_str )
2065 {
2066 pcap_in = in_str ;
2067 }
2068
2069 void pcap_set_out (FILE * out_str )
2070 {
2071 pcap_out = out_str ;
2072 }
2073
2074 int pcap_get_debug (void)
2075 {
2076 return pcap__flex_debug;
2077 }
2078
2079 void pcap_set_debug (int bdebug )
2080 {
2081 pcap__flex_debug = bdebug ;
2082 }
2083
2084 static int yy_init_globals (void)
2085 {
2086 /* Initialization is the same as for the non-reentrant scanner.
2087 * This function is called from pcap_lex_destroy(), so don't allocate here.
2088 */
2089
2090 (yy_buffer_stack) = 0;
2091 (yy_buffer_stack_top) = 0;
2092 (yy_buffer_stack_max) = 0;
2093 (yy_c_buf_p) = (char *) 0;
2094 (yy_init) = 0;
2095 (yy_start) = 0;
2096
2097 /* Defined in main.c */
2098 #ifdef YY_STDINIT
2099 pcap_in = stdin;
2100 pcap_out = stdout;
2101 #else
2102 pcap_in = (FILE *) 0;
2103 pcap_out = (FILE *) 0;
2104 #endif
2105
2106 /* For future reference: Set errno on error, since we are called by
2107 * pcap_lex_init()
2108 */
2109 return 0;
2110 }
2111
2112 /* pcap_lex_destroy is for both reentrant and non-reentrant scanners. */
2113 int pcap_lex_destroy (void)
2114 {
2115
2116 /* Pop the buffer stack, destroying each element. */
2117 while(YY_CURRENT_BUFFER){
2118 pcap__delete_buffer(YY_CURRENT_BUFFER );
2119 YY_CURRENT_BUFFER_LVALUE = NULL;
2120 pcap_pop_buffer_state();
2121 }
2122
2123 /* Destroy the stack itself. */
2124 pcap_free((yy_buffer_stack) );
2125 (yy_buffer_stack) = NULL;
2126
2127 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2128 * pcap_lex() is called, initialization will occur. */
2129 yy_init_globals( );
2130
2131 return 0;
2132 }
2133
2134 /*
2135 * Internal utility routines.
2136 */
2137
2138 #ifndef yytext_ptr
2139 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2140 {
2141 register int i;
2142 for ( i = 0; i < n; ++i )
2143 s1[i] = s2[i];
2144 }
2145 #endif
2146
2147 #ifdef YY_NEED_STRLEN
2148 static int yy_flex_strlen (yyconst char * s )
2149 {
2150 register int n;
2151 for ( n = 0; s[n]; ++n )
2152 ;
2153
2154 return n;
2155 }
2156 #endif
2157
2158 void *pcap_alloc (yy_size_t size )
2159 {
2160 return (void *) malloc( size );
2161 }
2162
2163 void *pcap_realloc (void * ptr, yy_size_t size )
2164 {
2165 /* The cast to (char *) in the following accommodates both
2166 * implementations that use char* generic pointers, and those
2167 * that use void* generic pointers. It works with the latter
2168 * because both ANSI C and C++ allow castless assignment from
2169 * any pointer type to void*, and deal with argument conversions
2170 * as though doing an assignment.
2171 */
2172 return (void *) realloc( (char *) ptr, size );
2173 }
2174
2175 void pcap_free (void * ptr )
2176 {
2177 free( (char *) ptr ); /* see pcap_realloc() for (char *) cast */
2178 }
2179
2180 #define YYTABLES_NAME "yytables"
2181
2182 #line 146 "scanner.l"
2183
2184
2185 void
2186 lex_init(buf)
2187 char *buf;
2188 {
2189 in_buffer = buf;
2190 }
2191
2192 /*
2193 * Also define a pcap_wrap. Note that if we're using flex, it will
2194 * define a macro to map this identifier to pcap_wrap.
2195 */
2196 int
2197 pcap_wrap()
2198 {
2199 return 1;
2200 }
2201
2202 /* Hex digit to integer. */
2203 static inline int
2204 xdtoi(c)
2205 register int c;
2206 {
2207 if (isdigit(c))
2208 return c - '0';
2209 else if (islower(c))
2210 return c - 'a' + 10;
2211 else
2212 return c - 'A' + 10;
2213 }
2214
2215 /*
2216 * Convert string to integer. Just like atoi(), but checks for
2217 * preceding 0x or 0 and uses hex or octal instead of decimal.
2218 */
2219 static int
2220 stoi(s)
2221 char *s;
2222 {
2223 int base = 10;
2224 int n = 0;
2225
2226 if (*s == '0') {
2227 if (s[1] == 'x' || s[1] == 'X') {
2228 s += 2;
2229 base = 16;
2230 }
2231 else {
2232 base = 8;
2233 s += 1;
2234 }
2235 }
2236 while (*s)
2237 n = n * base + xdtoi(*s++);
2238
2239 return n;
2240 }
2241
2242