1 #line 2 "IPFilterScanner.cpp"
3 #line 4 "IPFilterScanner.cpp"
5 #define YY_INT_ALIGNED short int
7 /* A lexical scanner generated by flex */
9 #define yy_create_buffer yyip_create_buffer
10 #define yy_delete_buffer yyip_delete_buffer
11 #define yy_flex_debug yyip_flex_debug
12 #define yy_init_buffer yyip_init_buffer
13 #define yy_flush_buffer yyip_flush_buffer
14 #define yy_load_buffer_state yyip_load_buffer_state
15 #define yy_switch_to_buffer yyip_switch_to_buffer
17 #define yyleng yyipleng
19 #define yylineno yyiplineno
21 #define yyrestart yyiprestart
22 #define yytext yyiptext
23 #define yywrap yyipwrap
24 #define yyalloc yyipalloc
25 #define yyrealloc yyiprealloc
26 #define yyfree yyipfree
29 #define YY_FLEX_MAJOR_VERSION 2
30 #define YY_FLEX_MINOR_VERSION 5
31 #define YY_FLEX_SUBMINOR_VERSION 39
32 #if YY_FLEX_SUBMINOR_VERSION > 0
36 /* First, we deal with platform-specific or compiler-specific issues. */
38 /* begin standard C headers. */
44 /* end standard C headers. */
46 /* flex integer type definitions */
51 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
53 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
55 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
56 * if you want the limit (max/min) macros for int types.
58 #ifndef __STDC_LIMIT_MACROS
59 #define __STDC_LIMIT_MACROS 1
63 typedef int8_t flex_int8_t
;
64 typedef uint8_t flex_uint8_t
;
65 typedef int16_t flex_int16_t
;
66 typedef uint16_t flex_uint16_t
;
67 typedef int32_t flex_int32_t
;
68 typedef uint32_t flex_uint32_t
;
70 typedef signed char flex_int8_t
;
71 typedef short int flex_int16_t
;
72 typedef int flex_int32_t
;
73 typedef unsigned char flex_uint8_t
;
74 typedef unsigned short int flex_uint16_t
;
75 typedef unsigned int flex_uint32_t
;
77 /* Limits of integral types. */
79 #define INT8_MIN (-128)
82 #define INT16_MIN (-32767-1)
85 #define INT32_MIN (-2147483647-1)
88 #define INT8_MAX (127)
91 #define INT16_MAX (32767)
94 #define INT32_MAX (2147483647)
97 #define UINT8_MAX (255U)
100 #define UINT16_MAX (65535U)
103 #define UINT32_MAX (4294967295U)
108 #endif /* ! FLEXINT_H */
112 /* The "const" storage-class-modifier is valid. */
115 #else /* ! __cplusplus */
117 /* C99 requires __STDC__ to be defined as 1. */
118 #if defined (__STDC__)
122 #endif /* defined (__STDC__) */
123 #endif /* ! __cplusplus */
126 #define yyconst const
131 /* Returned upon end-of-file. */
134 /* Promotes a possibly negative, possibly signed char to an unsigned
135 * integer for use as an array index. If the signed char is negative,
136 * we want to instead treat it as an 8-bit unsigned char, hence the
139 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
141 /* Enter a start condition. This macro really ought to take a parameter,
142 * but we do it the disgusting crufty way forced on us by the ()-less
143 * definition of BEGIN.
145 #define BEGIN (yy_start) = 1 + 2 *
147 /* Translate the current start state into a value that can be later handed
148 * to BEGIN to return to the state. The YYSTATE alias is for lex
151 #define YY_START (((yy_start) - 1) / 2)
152 #define YYSTATE YY_START
154 /* Action number for EOF rule of a given start state. */
155 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
157 /* Special action meaning "start processing a new file". */
158 #define YY_NEW_FILE yyiprestart(yyipin )
160 #define YY_END_OF_BUFFER_CHAR 0
162 /* Size of default input buffer. */
164 #define YY_BUF_SIZE 16384
167 /* The state buf must be large enough to hold one state per character in the main buffer.
169 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
171 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
172 #define YY_TYPEDEF_YY_BUFFER_STATE
173 typedef struct yy_buffer_state
*YY_BUFFER_STATE
;
176 #ifndef YY_TYPEDEF_YY_SIZE_T
177 #define YY_TYPEDEF_YY_SIZE_T
178 typedef size_t yy_size_t
;
181 extern yy_size_t yyipleng
;
183 extern FILE *yyipin
, *yyipout
;
185 #define EOB_ACT_CONTINUE_SCAN 0
186 #define EOB_ACT_END_OF_FILE 1
187 #define EOB_ACT_LAST_MATCH 2
189 #define YY_LESS_LINENO(n)
190 #define YY_LINENO_REWIND_TO(ptr)
192 /* Return all but the first "n" matched characters back to the input stream. */
196 /* Undo effects of setting up yyiptext. */ \
197 int yyless_macro_arg = (n); \
198 YY_LESS_LINENO(yyless_macro_arg);\
199 *yy_cp = (yy_hold_char); \
200 YY_RESTORE_YY_MORE_OFFSET \
201 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
202 YY_DO_BEFORE_ACTION; /* set up yyiptext again */ \
206 #define unput(c) yyunput( c, (yytext_ptr) )
208 #ifndef YY_STRUCT_YY_BUFFER_STATE
209 #define YY_STRUCT_YY_BUFFER_STATE
210 struct yy_buffer_state
214 char *yy_ch_buf
; /* input buffer */
215 char *yy_buf_pos
; /* current position in input buffer */
217 /* Size of input buffer in bytes, not including room for EOB
220 yy_size_t yy_buf_size
;
222 /* Number of characters read into yy_ch_buf, not including EOB
225 yy_size_t yy_n_chars
;
227 /* Whether we "own" the buffer - i.e., we know we created it,
228 * and can realloc() it to grow it, and should free() it to
231 int yy_is_our_buffer
;
233 /* Whether this is an "interactive" input source; if so, and
234 * if we're using stdio for input, then we want to use getc()
235 * instead of fread(), to make sure we stop fetching input after
238 int yy_is_interactive
;
240 /* Whether we're considered to be at the beginning of a line.
241 * If so, '^' rules will be active on the next match, otherwise
246 int yy_bs_lineno
; /**< The line count. */
247 int yy_bs_column
; /**< The column count. */
249 /* Whether to try to fill the input buffer when we reach the
254 int yy_buffer_status
;
256 #define YY_BUFFER_NEW 0
257 #define YY_BUFFER_NORMAL 1
258 /* When an EOF's been seen but there's still some text to process
259 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
260 * shouldn't try reading from the input source any more. We might
261 * still have a bunch of tokens to match, though, because of
262 * possible backing-up.
264 * When we actually see the EOF, we change the status to "new"
265 * (via yyiprestart()), so that the user can continue scanning by
266 * just pointing yyipin at a new input file.
268 #define YY_BUFFER_EOF_PENDING 2
271 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
273 /* Stack of input buffers. */
274 static size_t yy_buffer_stack_top
= 0; /**< index of top of stack. */
275 static size_t yy_buffer_stack_max
= 0; /**< capacity of stack. */
276 static YY_BUFFER_STATE
* yy_buffer_stack
= 0; /**< Stack as an array. */
278 /* We provide macros for accessing buffer states in case in the
279 * future we want to put the buffer states in a more general
282 * Returns the top of the stack, or NULL.
284 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
285 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
288 /* Same as previous macro, but useful when we know that the buffer stack is not
289 * NULL or when we need an lvalue. For internal use only.
291 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
293 /* yy_hold_char holds the character lost when yyiptext is formed. */
294 static char yy_hold_char
;
295 static yy_size_t yy_n_chars
; /* number of characters read into yy_ch_buf */
298 /* Points to current character in buffer. */
299 static char *yy_c_buf_p
= (char *) 0;
300 static int yy_init
= 0; /* whether we need to initialize */
301 static int yy_start
= 0; /* start state number */
303 /* Flag which is used to allow yyipwrap()'s to do buffer switches
304 * instead of setting up a fresh yyipin. A bit of a hack ...
306 static int yy_did_buffer_switch_on_eof
;
308 void yyiprestart (FILE *input_file
);
309 void yyip_switch_to_buffer (YY_BUFFER_STATE new_buffer
);
310 YY_BUFFER_STATE
yyip_create_buffer (FILE *file
,int size
);
311 void yyip_delete_buffer (YY_BUFFER_STATE b
);
312 void yyip_flush_buffer (YY_BUFFER_STATE b
);
313 void yyippush_buffer_state (YY_BUFFER_STATE new_buffer
);
314 void yyippop_buffer_state (void );
316 static void yyipensure_buffer_stack (void );
317 static void yyip_load_buffer_state (void );
318 static void yyip_init_buffer (YY_BUFFER_STATE b
,FILE *file
);
320 #define YY_FLUSH_BUFFER yyip_flush_buffer(YY_CURRENT_BUFFER )
322 YY_BUFFER_STATE
yyip_scan_buffer (char *base
,yy_size_t size
);
323 YY_BUFFER_STATE
yyip_scan_string (yyconst
char *yy_str
);
324 YY_BUFFER_STATE
yyip_scan_bytes (yyconst
char *bytes
,yy_size_t len
);
326 void *yyipalloc (yy_size_t
);
327 void *yyiprealloc (void *,yy_size_t
);
328 void yyipfree (void * );
330 #define yy_new_buffer yyip_create_buffer
332 #define yy_set_interactive(is_interactive) \
334 if ( ! YY_CURRENT_BUFFER ){ \
335 yyipensure_buffer_stack (); \
336 YY_CURRENT_BUFFER_LVALUE = \
337 yyip_create_buffer(yyipin,YY_BUF_SIZE ); \
339 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
342 #define yy_set_bol(at_bol) \
344 if ( ! YY_CURRENT_BUFFER ){\
345 yyipensure_buffer_stack (); \
346 YY_CURRENT_BUFFER_LVALUE = \
347 yyip_create_buffer(yyipin,YY_BUF_SIZE ); \
349 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
352 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
354 /* Begin user sect3 */
357 #define YY_SKIP_YYWRAP
359 typedef unsigned char YY_CHAR
;
361 FILE *yyipin
= (FILE *) 0, *yyipout
= (FILE *) 0;
363 typedef int yy_state_type
;
365 extern int yyiplineno
;
369 extern char *yyiptext
;
370 #define yytext_ptr yyiptext
372 static yy_state_type
yy_get_previous_state (void );
373 static yy_state_type
yy_try_NUL_trans (yy_state_type current_state
);
374 static int yy_get_next_buffer (void );
375 static void yy_fatal_error (yyconst
char msg
[] );
377 /* Done after the current pattern has been matched and before the
378 * corresponding action - sets up yyiptext.
380 #define YY_DO_BEFORE_ACTION \
381 (yytext_ptr) = yy_bp; \
382 yyipleng = (size_t) (yy_cp - yy_bp); \
383 (yy_hold_char) = *yy_cp; \
385 (yy_c_buf_p) = yy_cp;
387 #define YY_NUM_RULES 6
388 #define YY_END_OF_BUFFER 7
389 /* This struct is not used in this scanner,
390 but its presence is necessary. */
393 flex_int32_t yy_verify
;
396 static yyconst flex_int16_t yy_accept
[169] =
398 0, 0, 7, 6, 6, 4, 5, 5, 2, 5,
399 5, 0, 4, 0, 0, 0, 2, 0, 2, 2,
400 0, 0, 0, 0, 2, 2, 0, 0, 0, 0,
401 2, 2, 0, 0, 0, 0, 2, 2, 0, 0,
402 0, 0, 2, 2, 0, 0, 0, 0, 2, 2,
403 0, 0, 0, 0, 2, 2, 0, 0, 0, 0,
404 0, 2, 2, 0, 0, 0, 0, 0, 0, 2,
405 2, 2, 0, 0, 0, 0, 0, 2, 2, 2,
406 0, 0, 0, 0, 2, 2, 0, 0, 0, 0,
407 2, 2, 0, 0, 0, 0, 2, 2, 0, 0,
409 0, 0, 2, 2, 0, 0, 0, 0, 2, 2,
410 0, 0, 0, 3, 0, 2, 2, 0, 0, 0,
411 3, 3, 2, 2, 0, 1, 0, 3, 2, 1,
412 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415 1, 1, 1, 1, 1, 1, 1, 0
418 static yyconst flex_int32_t yy_ec
[256] =
420 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
421 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 2, 1, 1, 4, 1, 1, 1, 1, 1,
424 1, 1, 1, 5, 6, 7, 1, 8, 8, 8,
425 8, 8, 8, 8, 8, 8, 8, 9, 1, 1,
426 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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,
431 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
432 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
433 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
434 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
435 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
436 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
437 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
438 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
439 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
440 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
442 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
443 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
444 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
445 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
446 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
450 static yyconst flex_int32_t yy_meta
[10] =
452 1, 1, 2, 1, 1, 1, 1, 1, 1
455 static yyconst flex_int16_t yy_base
[173] =
457 0, 3, 231, 232, 11, 232, 221, 14, 220, 17,
458 25, 0, 232, 219, 0, 0, 218, 0, 217, 33,
459 36, 217, 0, 38, 0, 45, 47, 216, 215, 211,
460 54, 210, 209, 208, 56, 207, 58, 198, 60, 197,
461 196, 195, 194, 191, 189, 188, 62, 187, 64, 180,
462 71, 179, 178, 177, 176, 172, 171, 78, 170, 85,
463 169, 92, 165, 0, 94, 164, 163, 101, 162, 161,
464 108, 158, 157, 155, 0, 110, 154, 0, 112, 151,
465 114, 150, 149, 148, 147, 144, 143, 142, 116, 141,
466 118, 140, 120, 137, 136, 135, 134, 133, 130, 129,
468 122, 127, 124, 126, 131, 107, 106, 105, 104, 103,
469 100, 138, 99, 145, 98, 152, 97, 0, 159, 96,
470 91, 89, 88, 87, 84, 81, 81, 80, 77, 75,
471 166, 75, 0, 174, 181, 74, 183, 73, 70, 68,
472 185, 67, 66, 53, 192, 52, 51, 199, 50, 0,
473 201, 49, 43, 42, 203, 41, 40, 32, 205, 31,
474 30, 29, 212, 28, 24, 23, 22, 232, 220, 28,
478 static yyconst flex_int16_t yy_def
[173] =
480 169, 168, 168, 168, 168, 168, 170, 168, 171, 170,
481 170, 5, 168, 170, 11, 8, 171, 10, 171, 171,
482 10, 10, 11, 10, 20, 20, 10, 10, 21, 24,
483 20, 26, 21, 27, 27, 24, 26, 26, 24, 27,
484 21, 35, 31, 37, 21, 39, 39, 35, 37, 37,
485 21, 39, 21, 47, 31, 49, 51, 21, 51, 51,
486 47, 31, 49, 58, 47, 51, 60, 58, 60, 62,
487 31, 62, 21, 65, 68, 65, 60, 71, 31, 62,
488 65, 65, 21, 76, 31, 79, 21, 81, 81, 76,
489 79, 79, 76, 81, 21, 89, 31, 91, 21, 93,
491 93, 89, 91, 91, 21, 93, 21, 101, 31, 103,
492 105, 21, 105, 21, 101, 31, 103, 112, 112, 105,
493 114, 114, 116, 116, 119, 172, 119, 114, 116, 172,
494 172, 119, 131, 131, 131, 134, 134, 134, 135, 137,
495 137, 137, 135, 141, 135, 141, 145, 135, 145, 148,
496 135, 145, 135, 151, 151, 151, 135, 155, 155, 155,
497 135, 159, 135, 159, 163, 163, 163, 0, 168, 168,
501 static yyconst flex_int16_t yy_nxt
[242] =
503 130, 5, 6, 7, 8, 6, 9, 7, 7, 7,
504 10, 11, 12, 13, 14, 16, 13, 17, 14, 14,
505 14, 18, 15, 21, 22, 15, 23, 19, 14, 130,
506 167, 130, 24, 15, 25, 130, 164, 163, 130, 160,
507 26, 20, 14, 27, 29, 30, 19, 159, 130, 156,
508 155, 31, 32, 33, 34, 19, 130, 152, 130, 130,
509 146, 37, 41, 42, 43, 44, 45, 46, 53, 54,
510 55, 56, 57, 145, 130, 142, 58, 141, 59, 64,
511 130, 138, 14, 131, 19, 65, 67, 14, 132, 131,
512 68, 14, 69, 70, 129, 19, 128, 71, 14, 72,
514 73, 74, 75, 14, 19, 14, 120, 14, 76, 78,
515 117, 116, 115, 114, 14, 79, 83, 84, 85, 86,
516 87, 88, 95, 96, 97, 98, 99, 100, 107, 108,
517 109, 110, 111, 19, 14, 112, 106, 105, 113, 118,
518 104, 103, 102, 101, 14, 119, 121, 19, 14, 94,
519 93, 92, 122, 123, 91, 90, 89, 14, 19, 124,
520 125, 14, 82, 126, 81, 80, 127, 133, 19, 77,
521 14, 14, 19, 134, 131, 130, 14, 66, 14, 63,
522 135, 136, 130, 62, 61, 60, 14, 19, 137, 139,
523 140, 143, 144, 147, 14, 52, 51, 148, 50, 149,
525 150, 49, 48, 47, 14, 19, 151, 153, 154, 157,
526 158, 161, 162, 165, 14, 40, 39, 38, 36, 166,
527 4, 4, 35, 14, 28, 20, 20, 15, 20, 15,
528 168, 3, 168, 168, 168, 168, 168, 168, 168, 168,
532 static yyconst flex_int16_t yy_chk
[242] =
534 172, 1, 1, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 5, 5, 8, 8, 8, 8, 8, 8,
536 8, 8, 8, 10, 10, 10, 11, 171, 170, 167,
537 166, 165, 11, 11, 20, 164, 162, 161, 160, 158,
538 20, 20, 21, 21, 24, 24, 26, 157, 156, 154,
539 153, 26, 26, 27, 27, 31, 152, 149, 147, 146,
540 144, 31, 35, 35, 37, 37, 39, 39, 47, 47,
541 49, 49, 51, 143, 142, 140, 51, 139, 51, 58,
542 138, 136, 132, 130, 129, 58, 60, 128, 127, 126,
543 60, 125, 60, 62, 124, 123, 122, 62, 121, 62,
545 65, 65, 68, 120, 117, 115, 113, 111, 68, 71,
546 110, 109, 108, 107, 106, 71, 76, 76, 79, 79,
547 81, 81, 89, 89, 91, 91, 93, 93, 101, 101,
548 103, 103, 105, 104, 102, 105, 100, 99, 105, 112,
549 98, 97, 96, 95, 94, 112, 114, 92, 90, 88,
550 87, 86, 114, 116, 85, 84, 83, 82, 80, 116,
551 119, 77, 74, 119, 73, 72, 119, 131, 70, 69,
552 67, 66, 63, 131, 131, 134, 61, 59, 57, 56,
553 134, 134, 135, 55, 54, 53, 52, 50, 135, 137,
554 137, 141, 141, 145, 48, 46, 45, 145, 44, 145,
556 148, 43, 42, 41, 40, 38, 148, 151, 151, 155,
557 155, 159, 159, 163, 36, 34, 33, 32, 30, 163,
558 169, 169, 29, 28, 22, 19, 17, 14, 9, 7,
559 3, 168, 168, 168, 168, 168, 168, 168, 168, 168,
563 static yy_state_type yy_last_accepting_state
;
564 static char *yy_last_accepting_cpos
;
566 extern int yyip_flex_debug
;
567 int yyip_flex_debug
= 0;
569 /* The intent behind this definition is that it'll catch
570 * any uses of REJECT which flex missed.
572 #define REJECT reject_used_but_not_detected
573 #define yymore() yymore_used_but_not_detected
574 #define YY_MORE_ADJ 0
575 #define YY_RESTORE_YY_MORE_OFFSET
577 #line 1 "./IPFilterScanner.l"
578 #line 2 "./IPFilterScanner.l"
580 // This file is part of the aMule Project.
582 // Copyright (c) 2009-2011 aMule Team ( admin@amule.org / http://www.amule.org )
583 // Copyright (c) 2009-2011 Stu Redman ( sturedman@amule.org )
585 // Any parts of this program derived from the xMule, lMule or eMule project,
586 // or contributed by third-party developers are copyrighted by their
587 // respective authors.
589 // This program is free software; you can redistribute it and/or modify
590 // it under the terms of the GNU General Public License as published by
591 // the Free Software Foundation; either version 2 of the License, or
592 // (at your option) any later version.
594 // This program is distributed in the hope that it will be useful,
595 // but WITHOUT ANY WARRANTY; without even the implied warranty of
596 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
597 // GNU General Public License for more details.
599 // You should have received a copy of the GNU General Public License
600 // along with this program; if not, write to the Free Software
601 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
607 // These have a silly "grammar". For example:
608 // 1.2.3.4-1.2.3.5,100,Duh:2.3.4.5-2.3.4.6
609 // Now - which format is it, and what range should it take?
611 // So just use the lexer to read the file and assure the line format.
612 // The actual IP reading is done with the ScanIP() function.
619 #include "IPFilterScanner.h"
620 #include <common/Format.h>
621 #include <common/StringFunctions.h>
624 #define isatty(DUMMY) 0
625 #define YY_NO_UNISTD_H
626 #pragma warning(disable:4003)
629 #define YY_NEVER_INTERACTIVE 1
631 // When we get here the IP has been lexed nicely,
632 // so we can blaze through without any checks.
633 // The total lexing time is more than twice as fast
634 // with this than when using sscanf.
635 static bool ScanIP(const char * buf
, uint32
& ip
)
638 buf
++; // skip whitespace
642 for (int i
= 0; i
< 4; buf
++) {
643 if (*buf
< '0' || *buf
> '9') {
644 // finished a number, check it and add to the ip
653 a
= a
* 10 + *buf
- '0';
659 static bool ScanInt(const char * buf
, uint32
& a
)
662 buf
++; // skip whitespace
665 while (*buf
>= '0' && *buf
<= '9') {
666 a
= a
* 10 + *buf
- '0';
675 #line 676 "IPFilterScanner.cpp"
679 #ifndef YY_NO_UNISTD_H
680 /* Special case for "unistd.h", since it is non-ANSI. We include it way
681 * down here because we want the user's section 1 to have been scanned first.
682 * The user has a chance to override it with an option.
687 #ifndef YY_EXTRA_TYPE
688 #define YY_EXTRA_TYPE void *
691 static int yy_init_globals (void );
693 /* Accessor methods to globals.
694 These are made visible to non-reentrant scanners for convenience. */
696 int yyiplex_destroy (void );
698 int yyipget_debug (void );
700 void yyipset_debug (int debug_flag
);
702 YY_EXTRA_TYPE
yyipget_extra (void );
704 void yyipset_extra (YY_EXTRA_TYPE user_defined
);
706 FILE *yyipget_in (void );
708 void yyipset_in (FILE * in_str
);
710 FILE *yyipget_out (void );
712 void yyipset_out (FILE * out_str
);
714 yy_size_t
yyipget_leng (void );
716 char *yyipget_text (void );
718 int yyipget_lineno (void );
720 void yyipset_lineno (int line_number
);
722 /* Macros after this point can all be overridden by user definitions in
726 #ifndef YY_SKIP_YYWRAP
728 extern "C" int yyipwrap (void );
730 extern int yyipwrap (void );
735 static void yy_flex_strncpy (char *,yyconst
char *,int );
738 #ifdef YY_NEED_STRLEN
739 static int yy_flex_strlen (yyconst
char * );
745 static int yyinput (void );
747 static int input (void );
752 /* Amount of stuff to slurp up with each read. */
753 #ifndef YY_READ_BUF_SIZE
754 #define YY_READ_BUF_SIZE 8192
757 /* Copy whatever the last rule matched to the standard output. */
759 /* This used to be an fputs(), but since the string might contain NUL's,
760 * we now use fwrite().
762 #define ECHO do { if (fwrite( yyiptext, yyipleng, 1, yyipout )) {} } while (0)
765 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
766 * is returned in "result".
769 #define YY_INPUT(buf,result,max_size) \
770 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
774 for ( n = 0; n < max_size && \
775 (c = getc( yyipin )) != EOF && c != '\n'; ++n ) \
778 buf[n++] = (char) c; \
779 if ( c == EOF && ferror( yyipin ) ) \
780 YY_FATAL_ERROR( "input in flex scanner failed" ); \
786 while ( (result = fread(buf, 1, max_size, yyipin))==0 && ferror(yyipin)) \
788 if( errno != EINTR) \
790 YY_FATAL_ERROR( "input in flex scanner failed" ); \
801 /* No semi-colon after return; correct usage is to write "yyterminate();" -
802 * we don't want an extra ';' after the "return" because that will cause
803 * some compilers to complain about unreachable statements.
806 #define yyterminate() return YY_NULL
809 /* Number of entries by which start-condition stack grows. */
810 #ifndef YY_START_STACK_INCR
811 #define YY_START_STACK_INCR 25
814 /* Report a fatal error. */
815 #ifndef YY_FATAL_ERROR
816 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
819 /* end tables serialization structures and prototypes */
821 /* Default declaration of generated scanner - a define so the user can
822 * easily add parameters.
825 #define YY_DECL_IS_OURS 1
827 extern int yyiplex (void);
829 #define YY_DECL int yyiplex (void)
830 #endif /* !YY_DECL */
832 /* Code executed at the beginning of each rule, after yyiptext and yyipleng
835 #ifndef YY_USER_ACTION
836 #define YY_USER_ACTION
839 /* Code executed at the end of each rule. */
841 #define YY_BREAK break;
844 #define YY_RULE_SETUP \
845 if ( yyipleng > 0 ) \
846 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
847 (yyiptext[yyipleng - 1] == '\n'); \
850 /** The main scanner function which does all the work.
854 register yy_state_type yy_current_state
;
855 register char *yy_cp
, *yy_bp
;
867 (yy_start
) = 1; /* first start state */
875 if ( ! YY_CURRENT_BUFFER
) {
876 yyipensure_buffer_stack ();
877 YY_CURRENT_BUFFER_LVALUE
=
878 yyip_create_buffer(yyipin
,YY_BUF_SIZE
);
881 yyip_load_buffer_state( );
885 #line 106 "./IPFilterScanner.l"
888 #line 889 "IPFilterScanner.cpp"
890 while ( 1 ) /* loops until end-of-file is reached */
892 yy_cp
= (yy_c_buf_p
);
894 /* Support of yyiptext. */
895 *yy_cp
= (yy_hold_char
);
897 /* yy_bp points to the position in yy_ch_buf of the start of
902 yy_current_state
= (yy_start
);
903 yy_current_state
+= YY_AT_BOL();
907 register YY_CHAR yy_c
= yy_ec
[YY_SC_TO_UI(*yy_cp
)] ;
908 if ( yy_accept
[yy_current_state
] )
910 (yy_last_accepting_state
) = yy_current_state
;
911 (yy_last_accepting_cpos
) = yy_cp
;
913 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
915 yy_current_state
= (int) yy_def
[yy_current_state
];
916 if ( yy_current_state
>= 169 )
917 yy_c
= yy_meta
[(unsigned int) yy_c
];
919 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
922 while ( yy_base
[yy_current_state
] != 232 );
925 yy_act
= yy_accept
[yy_current_state
];
927 { /* have to back up */
928 yy_cp
= (yy_last_accepting_cpos
);
929 yy_current_state
= (yy_last_accepting_state
);
930 yy_act
= yy_accept
[yy_current_state
];
935 do_action
: /* This label is used only to access EOF actions. */
938 { /* beginning of action switch */
939 case 0: /* must back up */
940 /* undo the effects of YY_DO_BEFORE_ACTION */
941 *yy_cp
= (yy_hold_char
);
942 yy_cp
= (yy_last_accepting_cpos
);
943 yy_current_state
= (yy_last_accepting_state
);
948 #line 108 "./IPFilterScanner.l"
950 /* PeerGuardian filter line
951 <IPStart> - <IPEnd> , <AccessLevel> , <Description>
953 char * ip1
= yyiptext
;
954 char * ip2
= strchr(ip1
+ 7, '-') + 1;
955 char * acc
= strchr(ip2
+ 7, ',') + 1;
956 char * dsc
= strchr(acc
+ 1, ',') + 1;
957 if (!ScanIP(ip1
, IPStart
) || !ScanIP(ip2
, IPEnd
)
958 || !ScanInt(acc
, IPLevel
)) {
968 #line 125 "./IPFilterScanner.l"
975 #line 129 "./IPFilterScanner.l"
977 /* AntiP2P filter line
978 <Description> : <IPStart> - <IPEnd>
980 char * ip1
= strrchr(yyiptext
, ':');
981 *ip1
++ = 0; // remove : and terminate comment
982 char * ip2
= strchr(ip1
+ 7, '-') + 1;
983 if (!ScanIP(ip1
, IPStart
) || !ScanIP(ip2
, IPEnd
)) {
987 IPDescription
= yyiptext
;
993 /* rule 4 can match eol */
995 #line 145 "./IPFilterScanner.l"
1002 #line 149 "./IPFilterScanner.l"
1006 AddDebugLogLineN(logIPFilter
, CFormat(wxT("error in line %d: %s")) % yyip_Line
% wxString(char2unicode(yyiptext
)));
1011 #line 155 "./IPFilterScanner.l"
1014 #line 1015 "IPFilterScanner.cpp"
1015 case YY_STATE_EOF(INITIAL
):
1018 case YY_END_OF_BUFFER
:
1020 /* Amount of text matched not including the EOB char. */
1021 int yy_amount_of_matched_text
= (int) (yy_cp
- (yytext_ptr
)) - 1;
1023 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1024 *yy_cp
= (yy_hold_char
);
1025 YY_RESTORE_YY_MORE_OFFSET
1027 if ( YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
== YY_BUFFER_NEW
)
1029 /* We're scanning a new file or input source. It's
1030 * possible that this happened because the user
1031 * just pointed yyipin at a new source and called
1032 * yyiplex(). If so, then we have to assure
1033 * consistency between YY_CURRENT_BUFFER and our
1034 * globals. Here is the right place to do so, because
1035 * this is the first action (other than possibly a
1036 * back-up) that will match for the new input source.
1038 (yy_n_chars
) = YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
;
1039 YY_CURRENT_BUFFER_LVALUE
->yy_input_file
= yyipin
;
1040 YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
= YY_BUFFER_NORMAL
;
1043 /* Note that here we test for yy_c_buf_p "<=" to the position
1044 * of the first EOB in the buffer, since yy_c_buf_p will
1045 * already have been incremented past the NUL character
1046 * (since all states make transitions on EOB to the
1047 * end-of-buffer state). Contrast this with the test
1050 if ( (yy_c_buf_p
) <= &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
)] )
1051 { /* This was really a NUL. */
1052 yy_state_type yy_next_state
;
1054 (yy_c_buf_p
) = (yytext_ptr
) + yy_amount_of_matched_text
;
1056 yy_current_state
= yy_get_previous_state( );
1058 /* Okay, we're now positioned to make the NUL
1059 * transition. We couldn't have
1060 * yy_get_previous_state() go ahead and do it
1061 * for us because it doesn't know how to deal
1062 * with the possibility of jamming (and we don't
1063 * want to build jamming into it because then it
1064 * will run more slowly).
1067 yy_next_state
= yy_try_NUL_trans( yy_current_state
);
1069 yy_bp
= (yytext_ptr
) + YY_MORE_ADJ
;
1071 if ( yy_next_state
)
1073 /* Consume the NUL. */
1074 yy_cp
= ++(yy_c_buf_p
);
1075 yy_current_state
= yy_next_state
;
1081 yy_cp
= (yy_c_buf_p
);
1082 goto yy_find_action
;
1086 else switch ( yy_get_next_buffer( ) )
1088 case EOB_ACT_END_OF_FILE
:
1090 (yy_did_buffer_switch_on_eof
) = 0;
1094 /* Note: because we've taken care in
1095 * yy_get_next_buffer() to have set up
1096 * yyiptext, we can now set up
1097 * yy_c_buf_p so that if some total
1098 * hoser (like flex itself) wants to
1099 * call the scanner after we return the
1100 * YY_NULL, it'll still work - another
1101 * YY_NULL will get returned.
1103 (yy_c_buf_p
) = (yytext_ptr
) + YY_MORE_ADJ
;
1105 yy_act
= YY_STATE_EOF(YY_START
);
1111 if ( ! (yy_did_buffer_switch_on_eof
) )
1117 case EOB_ACT_CONTINUE_SCAN
:
1119 (yytext_ptr
) + yy_amount_of_matched_text
;
1121 yy_current_state
= yy_get_previous_state( );
1123 yy_cp
= (yy_c_buf_p
);
1124 yy_bp
= (yytext_ptr
) + YY_MORE_ADJ
;
1127 case EOB_ACT_LAST_MATCH
:
1129 &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
)];
1131 yy_current_state
= yy_get_previous_state( );
1133 yy_cp
= (yy_c_buf_p
);
1134 yy_bp
= (yytext_ptr
) + YY_MORE_ADJ
;
1135 goto yy_find_action
;
1142 "fatal flex scanner internal error--no action found" );
1143 } /* end of action switch */
1144 } /* end of scanning one token */
1145 } /* end of user's declarations */
1146 } /* end of yyiplex */
1148 /* yy_get_next_buffer - try to read in a new buffer
1150 * Returns a code representing an action:
1151 * EOB_ACT_LAST_MATCH -
1152 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1153 * EOB_ACT_END_OF_FILE - end of file
1155 static int yy_get_next_buffer (void)
1157 register char *dest
= YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
;
1158 register char *source
= (yytext_ptr
);
1159 register int number_to_move
, i
;
1162 if ( (yy_c_buf_p
) > &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
) + 1] )
1164 "fatal flex scanner internal error--end of buffer missed" );
1166 if ( YY_CURRENT_BUFFER_LVALUE
->yy_fill_buffer
== 0 )
1167 { /* Don't try to fill the buffer, so this is an EOF. */
1168 if ( (yy_c_buf_p
) - (yytext_ptr
) - YY_MORE_ADJ
== 1 )
1170 /* We matched a single character, the EOB, so
1171 * treat this as a final EOF.
1173 return EOB_ACT_END_OF_FILE
;
1178 /* We matched some text prior to the EOB, first
1181 return EOB_ACT_LAST_MATCH
;
1185 /* Try to read more data. */
1187 /* First move last chars to start of buffer. */
1188 number_to_move
= (int) ((yy_c_buf_p
) - (yytext_ptr
)) - 1;
1190 for ( i
= 0; i
< number_to_move
; ++i
)
1191 *(dest
++) = *(source
++);
1193 if ( YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
== YY_BUFFER_EOF_PENDING
)
1194 /* don't do the read, it's not guaranteed to return an EOF,
1197 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= (yy_n_chars
) = 0;
1201 yy_size_t num_to_read
=
1202 YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
- number_to_move
- 1;
1204 while ( num_to_read
<= 0 )
1205 { /* Not enough room in the buffer - grow it. */
1207 /* just a shorter name for the current buffer */
1208 YY_BUFFER_STATE b
= YY_CURRENT_BUFFER_LVALUE
;
1210 int yy_c_buf_p_offset
=
1211 (int) ((yy_c_buf_p
) - b
->yy_ch_buf
);
1213 if ( b
->yy_is_our_buffer
)
1215 yy_size_t new_size
= b
->yy_buf_size
* 2;
1217 if ( new_size
<= 0 )
1218 b
->yy_buf_size
+= b
->yy_buf_size
/ 8;
1220 b
->yy_buf_size
*= 2;
1222 b
->yy_ch_buf
= (char *)
1223 /* Include room in for 2 EOB chars. */
1224 yyiprealloc((void *) b
->yy_ch_buf
,b
->yy_buf_size
+ 2 );
1227 /* Can't grow it, we don't own it. */
1230 if ( ! b
->yy_ch_buf
)
1232 "fatal error - scanner input buffer overflow" );
1234 (yy_c_buf_p
) = &b
->yy_ch_buf
[yy_c_buf_p_offset
];
1236 num_to_read
= YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
-
1241 if ( num_to_read
> YY_READ_BUF_SIZE
)
1242 num_to_read
= YY_READ_BUF_SIZE
;
1244 /* Read in more data. */
1245 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[number_to_move
]),
1246 (yy_n_chars
), num_to_read
);
1248 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= (yy_n_chars
);
1251 if ( (yy_n_chars
) == 0 )
1253 if ( number_to_move
== YY_MORE_ADJ
)
1255 ret_val
= EOB_ACT_END_OF_FILE
;
1256 yyiprestart(yyipin
);
1261 ret_val
= EOB_ACT_LAST_MATCH
;
1262 YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
=
1263 YY_BUFFER_EOF_PENDING
;
1268 ret_val
= EOB_ACT_CONTINUE_SCAN
;
1270 if ((yy_size_t
) ((yy_n_chars
) + number_to_move
) > YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
) {
1271 /* Extend the array by 50%, plus the number we really need. */
1272 yy_size_t new_size
= (yy_n_chars
) + number_to_move
+ ((yy_n_chars
) >> 1);
1273 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
= (char *) yyiprealloc((void *) YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
,new_size
);
1274 if ( ! YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
)
1275 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1278 (yy_n_chars
) += number_to_move
;
1279 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
)] = YY_END_OF_BUFFER_CHAR
;
1280 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
) + 1] = YY_END_OF_BUFFER_CHAR
;
1282 (yytext_ptr
) = &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[0];
1287 /* yy_get_previous_state - get the state just before the EOB char was reached */
1289 static yy_state_type
yy_get_previous_state (void)
1291 register yy_state_type yy_current_state
;
1292 register char *yy_cp
;
1294 yy_current_state
= (yy_start
);
1295 yy_current_state
+= YY_AT_BOL();
1297 for ( yy_cp
= (yytext_ptr
) + YY_MORE_ADJ
; yy_cp
< (yy_c_buf_p
); ++yy_cp
)
1299 register YY_CHAR yy_c
= (*yy_cp
? yy_ec
[YY_SC_TO_UI(*yy_cp
)] : 1);
1300 if ( yy_accept
[yy_current_state
] )
1302 (yy_last_accepting_state
) = yy_current_state
;
1303 (yy_last_accepting_cpos
) = yy_cp
;
1305 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1307 yy_current_state
= (int) yy_def
[yy_current_state
];
1308 if ( yy_current_state
>= 169 )
1309 yy_c
= yy_meta
[(unsigned int) yy_c
];
1311 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1314 return yy_current_state
;
1317 /* yy_try_NUL_trans - try to make a transition on the NUL character
1320 * next_state = yy_try_NUL_trans( current_state );
1322 static yy_state_type
yy_try_NUL_trans (yy_state_type yy_current_state
)
1324 register int yy_is_jam
;
1325 register char *yy_cp
= (yy_c_buf_p
);
1327 register YY_CHAR yy_c
= 1;
1328 if ( yy_accept
[yy_current_state
] )
1330 (yy_last_accepting_state
) = yy_current_state
;
1331 (yy_last_accepting_cpos
) = yy_cp
;
1333 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1335 yy_current_state
= (int) yy_def
[yy_current_state
];
1336 if ( yy_current_state
>= 169 )
1337 yy_c
= yy_meta
[(unsigned int) yy_c
];
1339 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1340 yy_is_jam
= (yy_current_state
== 168);
1342 return yy_is_jam
? 0 : yy_current_state
;
1347 static int yyinput (void)
1349 static int input (void)
1355 *(yy_c_buf_p
) = (yy_hold_char
);
1357 if ( *(yy_c_buf_p
) == YY_END_OF_BUFFER_CHAR
)
1359 /* yy_c_buf_p now points to the character we want to return.
1360 * If this occurs *before* the EOB characters, then it's a
1361 * valid NUL; if not, then we've hit the end of the buffer.
1363 if ( (yy_c_buf_p
) < &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
)] )
1364 /* This was really a NUL. */
1365 *(yy_c_buf_p
) = '\0';
1368 { /* need more input */
1369 yy_size_t offset
= (yy_c_buf_p
) - (yytext_ptr
);
1372 switch ( yy_get_next_buffer( ) )
1374 case EOB_ACT_LAST_MATCH
:
1375 /* This happens because yy_g_n_b()
1376 * sees that we've accumulated a
1377 * token and flags that we need to
1378 * try matching the token before
1379 * proceeding. But for input(),
1380 * there's no matching to consider.
1381 * So convert the EOB_ACT_LAST_MATCH
1382 * to EOB_ACT_END_OF_FILE.
1385 /* Reset buffer status. */
1386 yyiprestart(yyipin
);
1390 case EOB_ACT_END_OF_FILE
:
1395 if ( ! (yy_did_buffer_switch_on_eof
) )
1404 case EOB_ACT_CONTINUE_SCAN
:
1405 (yy_c_buf_p
) = (yytext_ptr
) + offset
;
1411 c
= *(unsigned char *) (yy_c_buf_p
); /* cast for 8-bit char's */
1412 *(yy_c_buf_p
) = '\0'; /* preserve yyiptext */
1413 (yy_hold_char
) = *++(yy_c_buf_p
);
1415 YY_CURRENT_BUFFER_LVALUE
->yy_at_bol
= (c
== '\n');
1419 #endif /* ifndef YY_NO_INPUT */
1421 /** Immediately switch to a different input stream.
1422 * @param input_file A readable stream.
1424 * @note This function does not reset the start condition to @c INITIAL .
1426 void yyiprestart (FILE * input_file
)
1429 if ( ! YY_CURRENT_BUFFER
){
1430 yyipensure_buffer_stack ();
1431 YY_CURRENT_BUFFER_LVALUE
=
1432 yyip_create_buffer(yyipin
,YY_BUF_SIZE
);
1435 yyip_init_buffer(YY_CURRENT_BUFFER
,input_file
);
1436 yyip_load_buffer_state( );
1439 /** Switch to a different input buffer.
1440 * @param new_buffer The new input buffer.
1443 void yyip_switch_to_buffer (YY_BUFFER_STATE new_buffer
)
1446 /* TODO. We should be able to replace this entire function body
1448 * yyippop_buffer_state();
1449 * yyippush_buffer_state(new_buffer);
1451 yyipensure_buffer_stack ();
1452 if ( YY_CURRENT_BUFFER
== new_buffer
)
1455 if ( YY_CURRENT_BUFFER
)
1457 /* Flush out information for old buffer. */
1458 *(yy_c_buf_p
) = (yy_hold_char
);
1459 YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
= (yy_c_buf_p
);
1460 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= (yy_n_chars
);
1463 YY_CURRENT_BUFFER_LVALUE
= new_buffer
;
1464 yyip_load_buffer_state( );
1466 /* We don't actually know whether we did this switch during
1467 * EOF (yyipwrap()) processing, but the only time this flag
1468 * is looked at is after yyipwrap() is called, so it's safe
1469 * to go ahead and always set it.
1471 (yy_did_buffer_switch_on_eof
) = 1;
1474 static void yyip_load_buffer_state (void)
1476 (yy_n_chars
) = YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
;
1477 (yytext_ptr
) = (yy_c_buf_p
) = YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
;
1478 yyipin
= YY_CURRENT_BUFFER_LVALUE
->yy_input_file
;
1479 (yy_hold_char
) = *(yy_c_buf_p
);
1482 /** Allocate and initialize an input buffer state.
1483 * @param file A readable stream.
1484 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1486 * @return the allocated buffer state.
1488 YY_BUFFER_STATE
yyip_create_buffer (FILE * file
, int size
)
1492 b
= (YY_BUFFER_STATE
) yyipalloc(sizeof( struct yy_buffer_state
) );
1494 YY_FATAL_ERROR( "out of dynamic memory in yyip_create_buffer()" );
1496 b
->yy_buf_size
= size
;
1498 /* yy_ch_buf has to be 2 characters longer than the size given because
1499 * we need to put in 2 end-of-buffer characters.
1501 b
->yy_ch_buf
= (char *) yyipalloc(b
->yy_buf_size
+ 2 );
1502 if ( ! b
->yy_ch_buf
)
1503 YY_FATAL_ERROR( "out of dynamic memory in yyip_create_buffer()" );
1505 b
->yy_is_our_buffer
= 1;
1507 yyip_init_buffer(b
,file
);
1512 /** Destroy the buffer.
1513 * @param b a buffer created with yyip_create_buffer()
1516 void yyip_delete_buffer (YY_BUFFER_STATE b
)
1522 if ( b
== YY_CURRENT_BUFFER
) /* Not sure if we should pop here. */
1523 YY_CURRENT_BUFFER_LVALUE
= (YY_BUFFER_STATE
) 0;
1525 if ( b
->yy_is_our_buffer
)
1526 yyipfree((void *) b
->yy_ch_buf
);
1528 yyipfree((void *) b
);
1531 /* Initializes or reinitializes a buffer.
1532 * This function is sometimes called more than once on the same buffer,
1533 * such as during a yyiprestart() or at EOF.
1535 static void yyip_init_buffer (YY_BUFFER_STATE b
, FILE * file
)
1540 yyip_flush_buffer(b
);
1542 b
->yy_input_file
= file
;
1543 b
->yy_fill_buffer
= 1;
1545 /* If b is the current buffer, then yyip_init_buffer was _probably_
1546 * called from yyiprestart() or through yy_get_next_buffer.
1547 * In that case, we don't want to reset the lineno or column.
1549 if (b
!= YY_CURRENT_BUFFER
){
1550 b
->yy_bs_lineno
= 1;
1551 b
->yy_bs_column
= 0;
1554 b
->yy_is_interactive
= file
? (isatty( fileno(file
) ) > 0) : 0;
1559 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1560 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1563 void yyip_flush_buffer (YY_BUFFER_STATE b
)
1570 /* We always need two end-of-buffer characters. The first causes
1571 * a transition to the end-of-buffer state. The second causes
1572 * a jam in that state.
1574 b
->yy_ch_buf
[0] = YY_END_OF_BUFFER_CHAR
;
1575 b
->yy_ch_buf
[1] = YY_END_OF_BUFFER_CHAR
;
1577 b
->yy_buf_pos
= &b
->yy_ch_buf
[0];
1580 b
->yy_buffer_status
= YY_BUFFER_NEW
;
1582 if ( b
== YY_CURRENT_BUFFER
)
1583 yyip_load_buffer_state( );
1586 /** Pushes the new state onto the stack. The new state becomes
1587 * the current state. This function will allocate the stack
1589 * @param new_buffer The new state.
1592 void yyippush_buffer_state (YY_BUFFER_STATE new_buffer
)
1594 if (new_buffer
== NULL
)
1597 yyipensure_buffer_stack();
1599 /* This block is copied from yyip_switch_to_buffer. */
1600 if ( YY_CURRENT_BUFFER
)
1602 /* Flush out information for old buffer. */
1603 *(yy_c_buf_p
) = (yy_hold_char
);
1604 YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
= (yy_c_buf_p
);
1605 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= (yy_n_chars
);
1608 /* Only push if top exists. Otherwise, replace top. */
1609 if (YY_CURRENT_BUFFER
)
1610 (yy_buffer_stack_top
)++;
1611 YY_CURRENT_BUFFER_LVALUE
= new_buffer
;
1613 /* copied from yyip_switch_to_buffer. */
1614 yyip_load_buffer_state( );
1615 (yy_did_buffer_switch_on_eof
) = 1;
1618 /** Removes and deletes the top of the stack, if present.
1619 * The next element becomes the new top.
1622 void yyippop_buffer_state (void)
1624 if (!YY_CURRENT_BUFFER
)
1627 yyip_delete_buffer(YY_CURRENT_BUFFER
);
1628 YY_CURRENT_BUFFER_LVALUE
= NULL
;
1629 if ((yy_buffer_stack_top
) > 0)
1630 --(yy_buffer_stack_top
);
1632 if (YY_CURRENT_BUFFER
) {
1633 yyip_load_buffer_state( );
1634 (yy_did_buffer_switch_on_eof
) = 1;
1638 /* Allocates the stack if it does not exist.
1639 * Guarantees space for at least one push.
1641 static void yyipensure_buffer_stack (void)
1643 yy_size_t num_to_alloc
;
1645 if (!(yy_buffer_stack
)) {
1647 /* First allocation is just for 2 elements, since we don't know if this
1648 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1649 * immediate realloc on the next call.
1652 (yy_buffer_stack
) = (struct yy_buffer_state
**)yyipalloc
1653 (num_to_alloc
* sizeof(struct yy_buffer_state
*)
1655 if ( ! (yy_buffer_stack
) )
1656 YY_FATAL_ERROR( "out of dynamic memory in yyipensure_buffer_stack()" );
1658 memset((yy_buffer_stack
), 0, num_to_alloc
* sizeof(struct yy_buffer_state
*));
1660 (yy_buffer_stack_max
) = num_to_alloc
;
1661 (yy_buffer_stack_top
) = 0;
1665 if ((yy_buffer_stack_top
) >= ((yy_buffer_stack_max
)) - 1){
1667 /* Increase the buffer to prepare for a possible push. */
1668 int grow_size
= 8 /* arbitrary grow size */;
1670 num_to_alloc
= (yy_buffer_stack_max
) + grow_size
;
1671 (yy_buffer_stack
) = (struct yy_buffer_state
**)yyiprealloc
1673 num_to_alloc
* sizeof(struct yy_buffer_state
*)
1675 if ( ! (yy_buffer_stack
) )
1676 YY_FATAL_ERROR( "out of dynamic memory in yyipensure_buffer_stack()" );
1678 /* zero only the new slots.*/
1679 memset((yy_buffer_stack
) + (yy_buffer_stack_max
), 0, grow_size
* sizeof(struct yy_buffer_state
*));
1680 (yy_buffer_stack_max
) = num_to_alloc
;
1684 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1685 * @param base the character buffer
1686 * @param size the size in bytes of the character buffer
1688 * @return the newly allocated buffer state object.
1690 YY_BUFFER_STATE
yyip_scan_buffer (char * base
, yy_size_t size
)
1695 base
[size
-2] != YY_END_OF_BUFFER_CHAR
||
1696 base
[size
-1] != YY_END_OF_BUFFER_CHAR
)
1697 /* They forgot to leave room for the EOB's. */
1700 b
= (YY_BUFFER_STATE
) yyipalloc(sizeof( struct yy_buffer_state
) );
1702 YY_FATAL_ERROR( "out of dynamic memory in yyip_scan_buffer()" );
1704 b
->yy_buf_size
= size
- 2; /* "- 2" to take care of EOB's */
1705 b
->yy_buf_pos
= b
->yy_ch_buf
= base
;
1706 b
->yy_is_our_buffer
= 0;
1707 b
->yy_input_file
= 0;
1708 b
->yy_n_chars
= b
->yy_buf_size
;
1709 b
->yy_is_interactive
= 0;
1711 b
->yy_fill_buffer
= 0;
1712 b
->yy_buffer_status
= YY_BUFFER_NEW
;
1714 yyip_switch_to_buffer(b
);
1719 /** Setup the input buffer state to scan a string. The next call to yyiplex() will
1720 * scan from a @e copy of @a str.
1721 * @param yystr a NUL-terminated string to scan
1723 * @return the newly allocated buffer state object.
1724 * @note If you want to scan bytes that may contain NUL values, then use
1725 * yyip_scan_bytes() instead.
1727 YY_BUFFER_STATE
yyip_scan_string (yyconst
char * yystr
)
1730 return yyip_scan_bytes(yystr
,strlen(yystr
) );
1733 /** Setup the input buffer state to scan the given bytes. The next call to yyiplex() will
1734 * scan from a @e copy of @a bytes.
1735 * @param yybytes the byte buffer to scan
1736 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1738 * @return the newly allocated buffer state object.
1740 YY_BUFFER_STATE
yyip_scan_bytes (yyconst
char * yybytes
, yy_size_t _yybytes_len
)
1747 /* Get memory for full buffer, including space for trailing EOB's. */
1748 n
= _yybytes_len
+ 2;
1749 buf
= (char *) yyipalloc(n
);
1751 YY_FATAL_ERROR( "out of dynamic memory in yyip_scan_bytes()" );
1753 for ( i
= 0; i
< _yybytes_len
; ++i
)
1754 buf
[i
] = yybytes
[i
];
1756 buf
[_yybytes_len
] = buf
[_yybytes_len
+1] = YY_END_OF_BUFFER_CHAR
;
1758 b
= yyip_scan_buffer(buf
,n
);
1760 YY_FATAL_ERROR( "bad buffer in yyip_scan_bytes()" );
1762 /* It's okay to grow etc. this buffer, and we should throw it
1763 * away when we're done.
1765 b
->yy_is_our_buffer
= 1;
1770 #ifndef YY_EXIT_FAILURE
1771 #define YY_EXIT_FAILURE 2
1774 static void yy_fatal_error (yyconst
char* msg
)
1776 (void) fprintf( stderr
, "%s\n", msg
);
1777 exit( YY_EXIT_FAILURE
);
1780 /* Redefine yyless() so it works in section 3 code. */
1786 /* Undo effects of setting up yyiptext. */ \
1787 int yyless_macro_arg = (n); \
1788 YY_LESS_LINENO(yyless_macro_arg);\
1789 yyiptext[yyipleng] = (yy_hold_char); \
1790 (yy_c_buf_p) = yyiptext + yyless_macro_arg; \
1791 (yy_hold_char) = *(yy_c_buf_p); \
1792 *(yy_c_buf_p) = '\0'; \
1793 yyipleng = yyless_macro_arg; \
1797 /* Accessor methods (get/set functions) to struct members. */
1799 /** Get the current line number.
1802 int yyipget_lineno (void)
1808 /** Get the input stream.
1811 FILE *yyipget_in (void)
1816 /** Get the output stream.
1819 FILE *yyipget_out (void)
1824 /** Get the length of the current token.
1827 yy_size_t
yyipget_leng (void)
1832 /** Get the current token.
1836 char *yyipget_text (void)
1841 /** Set the current line number.
1842 * @param line_number
1845 void yyipset_lineno (int line_number
)
1848 yyiplineno
= line_number
;
1851 /** Set the input stream. This does not discard the current
1853 * @param in_str A readable stream.
1855 * @see yyip_switch_to_buffer
1857 void yyipset_in (FILE * in_str
)
1862 void yyipset_out (FILE * out_str
)
1867 int yyipget_debug (void)
1869 return yyip_flex_debug
;
1872 void yyipset_debug (int bdebug
)
1874 yyip_flex_debug
= bdebug
;
1877 static int yy_init_globals (void)
1879 /* Initialization is the same as for the non-reentrant scanner.
1880 * This function is called from yyiplex_destroy(), so don't allocate here.
1883 (yy_buffer_stack
) = 0;
1884 (yy_buffer_stack_top
) = 0;
1885 (yy_buffer_stack_max
) = 0;
1886 (yy_c_buf_p
) = (char *) 0;
1890 /* Defined in main.c */
1895 yyipin
= (FILE *) 0;
1896 yyipout
= (FILE *) 0;
1899 /* For future reference: Set errno on error, since we are called by
1905 /* yyiplex_destroy is for both reentrant and non-reentrant scanners. */
1906 int yyiplex_destroy (void)
1909 /* Pop the buffer stack, destroying each element. */
1910 while(YY_CURRENT_BUFFER
){
1911 yyip_delete_buffer(YY_CURRENT_BUFFER
);
1912 YY_CURRENT_BUFFER_LVALUE
= NULL
;
1913 yyippop_buffer_state();
1916 /* Destroy the stack itself. */
1917 yyipfree((yy_buffer_stack
) );
1918 (yy_buffer_stack
) = NULL
;
1920 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1921 * yyiplex() is called, initialization will occur. */
1928 * Internal utility routines.
1932 static void yy_flex_strncpy (char* s1
, yyconst
char * s2
, int n
)
1935 for ( i
= 0; i
< n
; ++i
)
1940 #ifdef YY_NEED_STRLEN
1941 static int yy_flex_strlen (yyconst
char * s
)
1944 for ( n
= 0; s
[n
]; ++n
)
1951 void *yyipalloc (yy_size_t size
)
1953 return (void *) malloc( size
);
1956 void *yyiprealloc (void * ptr
, yy_size_t size
)
1958 /* The cast to (char *) in the following accommodates both
1959 * implementations that use char* generic pointers, and those
1960 * that use void* generic pointers. It works with the latter
1961 * because both ANSI C and C++ allow castless assignment from
1962 * any pointer type to void*, and deal with argument conversions
1963 * as though doing an assignment.
1965 return (void *) realloc( (char *) ptr
, size
);
1968 void yyipfree (void * ptr
)
1970 free( (char *) ptr
); /* see yyiprealloc() for (char *) cast */
1973 #define YYTABLES_NAME "yytables"
1975 #line 155 "./IPFilterScanner.l"