Fix language getting reset to system default on saving preferences
[amule.git] / src / IPFilterScanner.cpp
blob584ec447ba6826e25d1a33d3a1c53cada5591074
1 #line 2 "../../trunk/src/IPFilterScanner.cpp"
3 #line 4 "../../trunk/src/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
16 #define yyin yyipin
17 #define yyleng yyipleng
18 #define yylex yyiplex
19 #define yylineno yyiplineno
20 #define yyout yyipout
21 #define yyrestart yyiprestart
22 #define yytext yyiptext
23 #define yywrap yyipwrap
24 #define yyalloc yyipalloc
25 #define yyrealloc yyiprealloc
26 #define yyfree yyipfree
28 #define FLEX_SCANNER
29 #define YY_FLEX_MAJOR_VERSION 2
30 #define YY_FLEX_MINOR_VERSION 5
31 #define YY_FLEX_SUBMINOR_VERSION 35
32 #if YY_FLEX_SUBMINOR_VERSION > 0
33 #define FLEX_BETA
34 #endif
36 /* First, we deal with platform-specific or compiler-specific issues. */
38 /* begin standard C headers. */
39 #include <stdio.h>
40 #include <string.h>
41 #include <errno.h>
42 #include <stdlib.h>
44 /* end standard C headers. */
46 /* flex integer type definitions */
48 #ifndef FLEXINT_H
49 #define FLEXINT_H
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
60 #endif
62 #include <inttypes.h>
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;
69 #else
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;
76 #endif /* ! C99 */
78 /* Limits of integral types. */
79 #ifndef INT8_MIN
80 #define INT8_MIN (-128)
81 #endif
82 #ifndef INT16_MIN
83 #define INT16_MIN (-32767-1)
84 #endif
85 #ifndef INT32_MIN
86 #define INT32_MIN (-2147483647-1)
87 #endif
88 #ifndef INT8_MAX
89 #define INT8_MAX (127)
90 #endif
91 #ifndef INT16_MAX
92 #define INT16_MAX (32767)
93 #endif
94 #ifndef INT32_MAX
95 #define INT32_MAX (2147483647)
96 #endif
97 #ifndef UINT8_MAX
98 #define UINT8_MAX (255U)
99 #endif
100 #ifndef UINT16_MAX
101 #define UINT16_MAX (65535U)
102 #endif
103 #ifndef UINT32_MAX
104 #define UINT32_MAX (4294967295U)
105 #endif
107 #endif /* ! FLEXINT_H */
109 #ifdef __cplusplus
111 /* The "const" storage-class-modifier is valid. */
112 #define YY_USE_CONST
114 #else /* ! __cplusplus */
116 /* C99 requires __STDC__ to be defined as 1. */
117 #if defined (__STDC__)
119 #define YY_USE_CONST
121 #endif /* defined (__STDC__) */
122 #endif /* ! __cplusplus */
124 #ifdef YY_USE_CONST
125 #define yyconst const
126 #else
127 #define yyconst
128 #endif
130 /* Returned upon end-of-file. */
131 #define YY_NULL 0
133 /* Promotes a possibly negative, possibly signed char to an unsigned
134 * integer for use as an array index. If the signed char is negative,
135 * we want to instead treat it as an 8-bit unsigned char, hence the
136 * double cast.
138 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
140 /* Enter a start condition. This macro really ought to take a parameter,
141 * but we do it the disgusting crufty way forced on us by the ()-less
142 * definition of BEGIN.
144 #define BEGIN (yy_start) = 1 + 2 *
146 /* Translate the current start state into a value that can be later handed
147 * to BEGIN to return to the state. The YYSTATE alias is for lex
148 * compatibility.
150 #define YY_START (((yy_start) - 1) / 2)
151 #define YYSTATE YY_START
153 /* Action number for EOF rule of a given start state. */
154 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
156 /* Special action meaning "start processing a new file". */
157 #define YY_NEW_FILE yyiprestart(yyipin )
159 #define YY_END_OF_BUFFER_CHAR 0
161 /* Size of default input buffer. */
162 #ifndef YY_BUF_SIZE
163 #define YY_BUF_SIZE 16384
164 #endif
166 /* The state buf must be large enough to hold one state per character in the main buffer.
168 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
170 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
171 #define YY_TYPEDEF_YY_BUFFER_STATE
172 typedef struct yy_buffer_state *YY_BUFFER_STATE;
173 #endif
175 extern int yyipleng;
177 extern FILE *yyipin, *yyipout;
179 #define EOB_ACT_CONTINUE_SCAN 0
180 #define EOB_ACT_END_OF_FILE 1
181 #define EOB_ACT_LAST_MATCH 2
183 #define YY_LESS_LINENO(n)
185 /* Return all but the first "n" matched characters back to the input stream. */
186 #define yyless(n) \
187 do \
189 /* Undo effects of setting up yyiptext. */ \
190 int yyless_macro_arg = (n); \
191 YY_LESS_LINENO(yyless_macro_arg);\
192 *yy_cp = (yy_hold_char); \
193 YY_RESTORE_YY_MORE_OFFSET \
194 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
195 YY_DO_BEFORE_ACTION; /* set up yyiptext again */ \
197 while ( 0 )
199 #define unput(c) yyunput( c, (yytext_ptr) )
201 #ifndef YY_TYPEDEF_YY_SIZE_T
202 #define YY_TYPEDEF_YY_SIZE_T
203 typedef size_t yy_size_t;
204 #endif
206 #ifndef YY_STRUCT_YY_BUFFER_STATE
207 #define YY_STRUCT_YY_BUFFER_STATE
208 struct yy_buffer_state
210 FILE *yy_input_file;
212 char *yy_ch_buf; /* input buffer */
213 char *yy_buf_pos; /* current position in input buffer */
215 /* Size of input buffer in bytes, not including room for EOB
216 * characters.
218 yy_size_t yy_buf_size;
220 /* Number of characters read into yy_ch_buf, not including EOB
221 * characters.
223 int yy_n_chars;
225 /* Whether we "own" the buffer - i.e., we know we created it,
226 * and can realloc() it to grow it, and should free() it to
227 * delete it.
229 int yy_is_our_buffer;
231 /* Whether this is an "interactive" input source; if so, and
232 * if we're using stdio for input, then we want to use getc()
233 * instead of fread(), to make sure we stop fetching input after
234 * each newline.
236 int yy_is_interactive;
238 /* Whether we're considered to be at the beginning of a line.
239 * If so, '^' rules will be active on the next match, otherwise
240 * not.
242 int yy_at_bol;
244 int yy_bs_lineno; /**< The line count. */
245 int yy_bs_column; /**< The column count. */
247 /* Whether to try to fill the input buffer when we reach the
248 * end of it.
250 int yy_fill_buffer;
252 int yy_buffer_status;
254 #define YY_BUFFER_NEW 0
255 #define YY_BUFFER_NORMAL 1
256 /* When an EOF's been seen but there's still some text to process
257 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
258 * shouldn't try reading from the input source any more. We might
259 * still have a bunch of tokens to match, though, because of
260 * possible backing-up.
262 * When we actually see the EOF, we change the status to "new"
263 * (via yyiprestart()), so that the user can continue scanning by
264 * just pointing yyipin at a new input file.
266 #define YY_BUFFER_EOF_PENDING 2
269 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
271 /* Stack of input buffers. */
272 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
273 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
274 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
276 /* We provide macros for accessing buffer states in case in the
277 * future we want to put the buffer states in a more general
278 * "scanner state".
280 * Returns the top of the stack, or NULL.
282 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
283 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
284 : NULL)
286 /* Same as previous macro, but useful when we know that the buffer stack is not
287 * NULL or when we need an lvalue. For internal use only.
289 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
291 /* yy_hold_char holds the character lost when yyiptext is formed. */
292 static char yy_hold_char;
293 static int yy_n_chars; /* number of characters read into yy_ch_buf */
294 int yyipleng;
296 /* Points to current character in buffer. */
297 static char *yy_c_buf_p = (char *) 0;
298 static int yy_init = 0; /* whether we need to initialize */
299 static int yy_start = 0; /* start state number */
301 /* Flag which is used to allow yyipwrap()'s to do buffer switches
302 * instead of setting up a fresh yyipin. A bit of a hack ...
304 static int yy_did_buffer_switch_on_eof;
306 void yyiprestart (FILE *input_file );
307 void yyip_switch_to_buffer (YY_BUFFER_STATE new_buffer );
308 YY_BUFFER_STATE yyip_create_buffer (FILE *file,int size );
309 void yyip_delete_buffer (YY_BUFFER_STATE b );
310 void yyip_flush_buffer (YY_BUFFER_STATE b );
311 void yyippush_buffer_state (YY_BUFFER_STATE new_buffer );
312 void yyippop_buffer_state (void );
314 static void yyipensure_buffer_stack (void );
315 static void yyip_load_buffer_state (void );
316 static void yyip_init_buffer (YY_BUFFER_STATE b,FILE *file );
318 #define YY_FLUSH_BUFFER yyip_flush_buffer(YY_CURRENT_BUFFER )
320 YY_BUFFER_STATE yyip_scan_buffer (char *base,yy_size_t size );
321 YY_BUFFER_STATE yyip_scan_string (yyconst char *yy_str );
322 YY_BUFFER_STATE yyip_scan_bytes (yyconst char *bytes,int len );
324 void *yyipalloc (yy_size_t );
325 void *yyiprealloc (void *,yy_size_t );
326 void yyipfree (void * );
328 #define yy_new_buffer yyip_create_buffer
330 #define yy_set_interactive(is_interactive) \
332 if ( ! YY_CURRENT_BUFFER ){ \
333 yyipensure_buffer_stack (); \
334 YY_CURRENT_BUFFER_LVALUE = \
335 yyip_create_buffer(yyipin,YY_BUF_SIZE ); \
337 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
340 #define yy_set_bol(at_bol) \
342 if ( ! YY_CURRENT_BUFFER ){\
343 yyipensure_buffer_stack (); \
344 YY_CURRENT_BUFFER_LVALUE = \
345 yyip_create_buffer(yyipin,YY_BUF_SIZE ); \
347 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
350 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
352 /* Begin user sect3 */
354 #define yyipwrap(n) 1
355 #define YY_SKIP_YYWRAP
357 typedef unsigned char YY_CHAR;
359 FILE *yyipin = (FILE *) 0, *yyipout = (FILE *) 0;
361 typedef int yy_state_type;
363 extern int yyiplineno;
365 int yyiplineno = 1;
367 extern char *yyiptext;
368 #define yytext_ptr yyiptext
370 static yy_state_type yy_get_previous_state (void );
371 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
372 static int yy_get_next_buffer (void );
373 static void yy_fatal_error (yyconst char msg[] );
375 /* Done after the current pattern has been matched and before the
376 * corresponding action - sets up yyiptext.
378 #define YY_DO_BEFORE_ACTION \
379 (yytext_ptr) = yy_bp; \
380 yyipleng = (size_t) (yy_cp - yy_bp); \
381 (yy_hold_char) = *yy_cp; \
382 *yy_cp = '\0'; \
383 (yy_c_buf_p) = yy_cp;
385 #define YY_NUM_RULES 6
386 #define YY_END_OF_BUFFER 7
387 /* This struct is not used in this scanner,
388 but its presence is necessary. */
389 struct yy_trans_info
391 flex_int32_t yy_verify;
392 flex_int32_t yy_nxt;
394 static yyconst flex_int16_t yy_accept[169] =
395 { 0,
396 0, 0, 7, 6, 6, 4, 5, 5, 2, 5,
397 5, 0, 4, 0, 0, 0, 2, 0, 2, 2,
398 0, 0, 0, 0, 2, 2, 0, 0, 0, 0,
399 2, 2, 0, 0, 0, 0, 2, 2, 0, 0,
400 0, 0, 2, 2, 0, 0, 0, 0, 2, 2,
401 0, 0, 0, 0, 2, 2, 0, 0, 0, 0,
402 0, 2, 2, 0, 0, 0, 0, 0, 0, 2,
403 2, 2, 0, 0, 0, 0, 0, 2, 2, 2,
404 0, 0, 0, 0, 2, 2, 0, 0, 0, 0,
405 2, 2, 0, 0, 0, 0, 2, 2, 0, 0,
407 0, 0, 2, 2, 0, 0, 0, 0, 2, 2,
408 0, 0, 0, 3, 0, 2, 2, 0, 0, 0,
409 3, 3, 2, 2, 0, 1, 0, 3, 2, 1,
410 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 0
416 static yyconst flex_int32_t yy_ec[256] =
417 { 0,
418 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
419 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
421 1, 2, 1, 1, 4, 1, 1, 1, 1, 1,
422 1, 1, 1, 5, 6, 7, 1, 8, 8, 8,
423 8, 8, 8, 8, 8, 8, 8, 9, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
427 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, 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,
440 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
441 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
448 static yyconst flex_int32_t yy_meta[10] =
449 { 0,
450 1, 1, 2, 1, 1, 1, 1, 1, 1
453 static yyconst flex_int16_t yy_base[173] =
454 { 0,
455 0, 3, 231, 232, 11, 232, 221, 14, 220, 17,
456 25, 0, 232, 219, 0, 0, 218, 0, 217, 33,
457 36, 217, 0, 38, 0, 45, 47, 216, 215, 211,
458 54, 210, 209, 208, 56, 207, 58, 198, 60, 197,
459 196, 195, 194, 191, 189, 188, 62, 187, 64, 180,
460 71, 179, 178, 177, 176, 172, 171, 78, 170, 85,
461 169, 92, 165, 0, 94, 164, 163, 101, 162, 161,
462 108, 158, 157, 155, 0, 110, 154, 0, 112, 151,
463 114, 150, 149, 148, 147, 144, 143, 142, 116, 141,
464 118, 140, 120, 137, 136, 135, 134, 133, 130, 129,
466 122, 127, 124, 126, 131, 107, 106, 105, 104, 103,
467 100, 138, 99, 145, 98, 152, 97, 0, 159, 96,
468 91, 89, 88, 87, 84, 81, 81, 80, 77, 75,
469 166, 75, 0, 174, 181, 74, 183, 73, 70, 68,
470 185, 67, 66, 53, 192, 52, 51, 199, 50, 0,
471 201, 49, 43, 42, 203, 41, 40, 32, 205, 31,
472 30, 29, 212, 28, 24, 23, 22, 232, 220, 28,
473 27, 0
476 static yyconst flex_int16_t yy_def[173] =
477 { 0,
478 169, 168, 168, 168, 168, 168, 170, 168, 171, 170,
479 170, 5, 168, 170, 11, 8, 171, 10, 171, 171,
480 10, 10, 11, 10, 20, 20, 10, 10, 21, 24,
481 20, 26, 21, 27, 27, 24, 26, 26, 24, 27,
482 21, 35, 31, 37, 21, 39, 39, 35, 37, 37,
483 21, 39, 21, 47, 31, 49, 51, 21, 51, 51,
484 47, 31, 49, 58, 47, 51, 60, 58, 60, 62,
485 31, 62, 21, 65, 68, 65, 60, 71, 31, 62,
486 65, 65, 21, 76, 31, 79, 21, 81, 81, 76,
487 79, 79, 76, 81, 21, 89, 31, 91, 21, 93,
489 93, 89, 91, 91, 21, 93, 21, 101, 31, 103,
490 105, 21, 105, 21, 101, 31, 103, 112, 112, 105,
491 114, 114, 116, 116, 119, 172, 119, 114, 116, 172,
492 172, 119, 131, 131, 131, 134, 134, 134, 135, 137,
493 137, 137, 135, 141, 135, 141, 145, 135, 145, 148,
494 135, 145, 135, 151, 151, 151, 135, 155, 155, 155,
495 135, 159, 135, 159, 163, 163, 163, 0, 168, 168,
496 168, 168
499 static yyconst flex_int16_t yy_nxt[242] =
500 { 0,
501 130, 5, 6, 7, 8, 6, 9, 7, 7, 7,
502 10, 11, 12, 13, 14, 16, 13, 17, 14, 14,
503 14, 18, 15, 21, 22, 15, 23, 19, 14, 130,
504 167, 130, 24, 15, 25, 130, 164, 163, 130, 160,
505 26, 20, 14, 27, 29, 30, 19, 159, 130, 156,
506 155, 31, 32, 33, 34, 19, 130, 152, 130, 130,
507 146, 37, 41, 42, 43, 44, 45, 46, 53, 54,
508 55, 56, 57, 145, 130, 142, 58, 141, 59, 64,
509 130, 138, 14, 131, 19, 65, 67, 14, 132, 131,
510 68, 14, 69, 70, 129, 19, 128, 71, 14, 72,
512 73, 74, 75, 14, 19, 14, 120, 14, 76, 78,
513 117, 116, 115, 114, 14, 79, 83, 84, 85, 86,
514 87, 88, 95, 96, 97, 98, 99, 100, 107, 108,
515 109, 110, 111, 19, 14, 112, 106, 105, 113, 118,
516 104, 103, 102, 101, 14, 119, 121, 19, 14, 94,
517 93, 92, 122, 123, 91, 90, 89, 14, 19, 124,
518 125, 14, 82, 126, 81, 80, 127, 133, 19, 77,
519 14, 14, 19, 134, 131, 130, 14, 66, 14, 63,
520 135, 136, 130, 62, 61, 60, 14, 19, 137, 139,
521 140, 143, 144, 147, 14, 52, 51, 148, 50, 149,
523 150, 49, 48, 47, 14, 19, 151, 153, 154, 157,
524 158, 161, 162, 165, 14, 40, 39, 38, 36, 166,
525 4, 4, 35, 14, 28, 20, 20, 15, 20, 15,
526 168, 3, 168, 168, 168, 168, 168, 168, 168, 168,
530 static yyconst flex_int16_t yy_chk[242] =
531 { 0,
532 172, 1, 1, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 5, 5, 8, 8, 8, 8, 8, 8,
534 8, 8, 8, 10, 10, 10, 11, 171, 170, 167,
535 166, 165, 11, 11, 20, 164, 162, 161, 160, 158,
536 20, 20, 21, 21, 24, 24, 26, 157, 156, 154,
537 153, 26, 26, 27, 27, 31, 152, 149, 147, 146,
538 144, 31, 35, 35, 37, 37, 39, 39, 47, 47,
539 49, 49, 51, 143, 142, 140, 51, 139, 51, 58,
540 138, 136, 132, 130, 129, 58, 60, 128, 127, 126,
541 60, 125, 60, 62, 124, 123, 122, 62, 121, 62,
543 65, 65, 68, 120, 117, 115, 113, 111, 68, 71,
544 110, 109, 108, 107, 106, 71, 76, 76, 79, 79,
545 81, 81, 89, 89, 91, 91, 93, 93, 101, 101,
546 103, 103, 105, 104, 102, 105, 100, 99, 105, 112,
547 98, 97, 96, 95, 94, 112, 114, 92, 90, 88,
548 87, 86, 114, 116, 85, 84, 83, 82, 80, 116,
549 119, 77, 74, 119, 73, 72, 119, 131, 70, 69,
550 67, 66, 63, 131, 131, 134, 61, 59, 57, 56,
551 134, 134, 135, 55, 54, 53, 52, 50, 135, 137,
552 137, 141, 141, 145, 48, 46, 45, 145, 44, 145,
554 148, 43, 42, 41, 40, 38, 148, 151, 151, 155,
555 155, 159, 159, 163, 36, 34, 33, 32, 30, 163,
556 169, 169, 29, 28, 22, 19, 17, 14, 9, 7,
557 3, 168, 168, 168, 168, 168, 168, 168, 168, 168,
561 static yy_state_type yy_last_accepting_state;
562 static char *yy_last_accepting_cpos;
564 extern int yyip_flex_debug;
565 int yyip_flex_debug = 0;
567 /* The intent behind this definition is that it'll catch
568 * any uses of REJECT which flex missed.
570 #define REJECT reject_used_but_not_detected
571 #define yymore() yymore_used_but_not_detected
572 #define YY_MORE_ADJ 0
573 #define YY_RESTORE_YY_MORE_OFFSET
574 char *yyiptext;
575 #line 1 "../../trunk/src/IPFilterScanner.l"
576 #line 2 "../../trunk/src/IPFilterScanner.l"
578 // This file is part of the aMule Project.
580 // Copyright (c) 2009-2010 aMule Team ( admin@amule.org / http://www.amule.org )
581 // Copyright (c) 2009-2010 Stu Redman ( sturedman@amule.org )
583 // Any parts of this program derived from the xMule, lMule or eMule project,
584 // or contributed by third-party developers are copyrighted by their
585 // respective authors.
587 // This program is free software; you can redistribute it and/or modify
588 // it under the terms of the GNU General Public License as published by
589 // the Free Software Foundation; either version 2 of the License, or
590 // (at your option) any later version.
592 // This program is distributed in the hope that it will be useful,
593 // but WITHOUT ANY WARRANTY; without even the implied warranty of
594 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
595 // GNU General Public License for more details.
597 // You should have received a copy of the GNU General Public License
598 // along with this program; if not, write to the Free Software
599 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
603 // Read IP filters
605 // These have a silly "grammar". For example:
606 // 1.2.3.4-1.2.3.5,100,Duh:2.3.4.5-2.3.4.6
607 // Now - which format is it, and what range should it take?
609 // So just use the lexer to read the file and assure the line format.
610 // The actual IP reading is done with the ScanIP() function.
613 #include <stdio.h>
614 #include "Types.h"
615 #include "Logger.h"
616 #define IPFS_EXTERN
617 #include "IPFilterScanner.h"
618 #include <common/Format.h>
619 #include <common/StringFunctions.h>
621 #ifdef _MSC_VER
622 #define isatty(DUMMY) 0
623 #define YY_NO_UNISTD_H
624 #pragma warning(disable:4003)
625 #endif
627 #define YY_NEVER_INTERACTIVE 1
629 // When we get here the IP has been lexed nicely,
630 // so we can blaze through without any checks.
631 // The total lexing time is more than twice as fast
632 // with this than when using sscanf.
633 static bool ScanIP(const char * buf, uint32 & ip)
635 while (*buf < '0') {
636 buf++; // skip whitespace
638 ip = 0;
639 int a = 0;
640 for (int i = 0; i < 4; buf++) {
641 if (*buf < '0' || *buf > '9') {
642 // finished a number, check it and add to the ip
643 if (a > 255) {
644 return false;
646 ip = (ip << 8) | a;
647 a = 0;
648 i++;
649 } else {
650 // build number
651 a = a * 10 + *buf - '0';
654 return true;
657 static bool ScanInt(const char * buf, uint32 & a)
659 while (*buf < '0') {
660 buf++; // skip whitespace
662 a = 0;
663 while (*buf >= '0' && *buf <= '9') {
664 a = a * 10 + *buf - '0';
665 if (a > 255) {
666 return false;
668 buf++;
670 return true;
673 #line 674 "../../trunk/src/IPFilterScanner.cpp"
675 #define INITIAL 0
677 #ifndef YY_NO_UNISTD_H
678 /* Special case for "unistd.h", since it is non-ANSI. We include it way
679 * down here because we want the user's section 1 to have been scanned first.
680 * The user has a chance to override it with an option.
682 #include <unistd.h>
683 #endif
685 #ifndef YY_EXTRA_TYPE
686 #define YY_EXTRA_TYPE void *
687 #endif
689 static int yy_init_globals (void );
691 /* Accessor methods to globals.
692 These are made visible to non-reentrant scanners for convenience. */
694 int yyiplex_destroy (void );
696 int yyipget_debug (void );
698 void yyipset_debug (int debug_flag );
700 YY_EXTRA_TYPE yyipget_extra (void );
702 void yyipset_extra (YY_EXTRA_TYPE user_defined );
704 FILE *yyipget_in (void );
706 void yyipset_in (FILE * in_str );
708 FILE *yyipget_out (void );
710 void yyipset_out (FILE * out_str );
712 int yyipget_leng (void );
714 char *yyipget_text (void );
716 int yyipget_lineno (void );
718 void yyipset_lineno (int line_number );
720 /* Macros after this point can all be overridden by user definitions in
721 * section 1.
724 #ifndef YY_SKIP_YYWRAP
725 #ifdef __cplusplus
726 extern "C" int yyipwrap (void );
727 #else
728 extern int yyipwrap (void );
729 #endif
730 #endif
732 static void yyunput (int c,char *buf_ptr );
734 #ifndef yytext_ptr
735 static void yy_flex_strncpy (char *,yyconst char *,int );
736 #endif
738 #ifdef YY_NEED_STRLEN
739 static int yy_flex_strlen (yyconst char * );
740 #endif
742 #ifndef YY_NO_INPUT
744 #ifdef __cplusplus
745 static int yyinput (void );
746 #else
747 static int input (void );
748 #endif
750 #endif
752 /* Amount of stuff to slurp up with each read. */
753 #ifndef YY_READ_BUF_SIZE
754 #define YY_READ_BUF_SIZE 8192
755 #endif
757 /* Copy whatever the last rule matched to the standard output. */
758 #ifndef ECHO
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)
763 #endif
765 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
766 * is returned in "result".
768 #ifndef YY_INPUT
769 #define YY_INPUT(buf,result,max_size) \
770 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
772 int c = '*'; \
773 unsigned n; \
774 for ( n = 0; n < max_size && \
775 (c = getc( yyipin )) != EOF && c != '\n'; ++n ) \
776 buf[n] = (char) c; \
777 if ( c == '\n' ) \
778 buf[n++] = (char) c; \
779 if ( c == EOF && ferror( yyipin ) ) \
780 YY_FATAL_ERROR( "input in flex scanner failed" ); \
781 result = n; \
783 else \
785 errno=0; \
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" ); \
791 break; \
793 errno=0; \
794 clearerr(yyipin); \
799 #endif
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.
805 #ifndef yyterminate
806 #define yyterminate() return YY_NULL
807 #endif
809 /* Number of entries by which start-condition stack grows. */
810 #ifndef YY_START_STACK_INCR
811 #define YY_START_STACK_INCR 25
812 #endif
814 /* Report a fatal error. */
815 #ifndef YY_FATAL_ERROR
816 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
817 #endif
819 /* end tables serialization structures and prototypes */
821 /* Default declaration of generated scanner - a define so the user can
822 * easily add parameters.
824 #ifndef YY_DECL
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
833 * have been set up.
835 #ifndef YY_USER_ACTION
836 #define YY_USER_ACTION
837 #endif
839 /* Code executed at the end of each rule. */
840 #ifndef YY_BREAK
841 #define YY_BREAK break;
842 #endif
844 #define YY_RULE_SETUP \
845 if ( yyipleng > 0 ) \
846 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
847 (yyiptext[yyipleng - 1] == '\n'); \
848 YY_USER_ACTION
850 /** The main scanner function which does all the work.
852 YY_DECL
854 register yy_state_type yy_current_state;
855 register char *yy_cp, *yy_bp;
856 register int yy_act;
858 #line 106 "../../trunk/src/IPFilterScanner.l"
861 #line 862 "../../trunk/src/IPFilterScanner.cpp"
863 if ( !(yy_init) )
865 (yy_init) = 1;
867 #ifdef YY_USER_INIT
868 YY_USER_INIT;
869 #endif
871 if ( ! (yy_start) )
872 (yy_start) = 1; /* first start state */
874 if ( ! yyipin )
875 yyipin = stdin;
877 if ( ! yyipout )
878 yyipout = stdout;
880 if ( ! YY_CURRENT_BUFFER ) {
881 yyipensure_buffer_stack ();
882 YY_CURRENT_BUFFER_LVALUE =
883 yyip_create_buffer(yyipin,YY_BUF_SIZE );
886 yyip_load_buffer_state( );
889 while ( 1 ) /* loops until end-of-file is reached */
891 yy_cp = (yy_c_buf_p);
893 /* Support of yyiptext. */
894 *yy_cp = (yy_hold_char);
896 /* yy_bp points to the position in yy_ch_buf of the start of
897 * the current run.
899 yy_bp = yy_cp;
901 yy_current_state = (yy_start);
902 yy_current_state += YY_AT_BOL();
903 yy_match:
906 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
907 if ( yy_accept[yy_current_state] )
909 (yy_last_accepting_state) = yy_current_state;
910 (yy_last_accepting_cpos) = yy_cp;
912 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
914 yy_current_state = (int) yy_def[yy_current_state];
915 if ( yy_current_state >= 169 )
916 yy_c = yy_meta[(unsigned int) yy_c];
918 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
919 ++yy_cp;
921 while ( yy_base[yy_current_state] != 232 );
923 yy_find_action:
924 yy_act = yy_accept[yy_current_state];
925 if ( yy_act == 0 )
926 { /* have to back up */
927 yy_cp = (yy_last_accepting_cpos);
928 yy_current_state = (yy_last_accepting_state);
929 yy_act = yy_accept[yy_current_state];
932 YY_DO_BEFORE_ACTION;
934 do_action: /* This label is used only to access EOF actions. */
936 switch ( yy_act )
937 { /* beginning of action switch */
938 case 0: /* must back up */
939 /* undo the effects of YY_DO_BEFORE_ACTION */
940 *yy_cp = (yy_hold_char);
941 yy_cp = (yy_last_accepting_cpos);
942 yy_current_state = (yy_last_accepting_state);
943 goto yy_find_action;
945 case 1:
946 YY_RULE_SETUP
947 #line 108 "../../trunk/src/IPFilterScanner.l"
949 /* PeerGuardian filter line
950 <IPStart> - <IPEnd> , <AccessLevel> , <Description>
952 char * ip1 = yyiptext;
953 char * ip2 = strchr(ip1 + 7, '-') + 1;
954 char * acc = strchr(ip2 + 7, ',') + 1;
955 char * dsc = strchr(acc + 1, ',') + 1;
956 if (!ScanIP(ip1, IPStart) || !ScanIP(ip2, IPEnd)
957 || !ScanInt(acc, IPLevel)) {
958 yyip_Bad++;
959 } else {
960 IPDescription = dsc;
961 return 1;
964 YY_BREAK
965 case 2:
966 YY_RULE_SETUP
967 #line 125 "../../trunk/src/IPFilterScanner.l"
969 /* Comment */
971 YY_BREAK
972 case 3:
973 YY_RULE_SETUP
974 #line 129 "../../trunk/src/IPFilterScanner.l"
976 /* AntiP2P filter line
977 <Description> : <IPStart> - <IPEnd>
979 char * ip1 = strrchr(yyiptext, ':');
980 *ip1++ = 0; // remove : and terminate comment
981 char * ip2 = strchr(ip1 + 7, '-') + 1;
982 if (!ScanIP(ip1, IPStart) || !ScanIP(ip2, IPEnd)) {
983 yyip_Bad++;
984 } else {
985 IPLevel = 0;
986 IPDescription = yyiptext;
987 return 1;
990 YY_BREAK
991 case 4:
992 /* rule 4 can match eol */
993 YY_RULE_SETUP
994 #line 145 "../../trunk/src/IPFilterScanner.l"
996 yyip_Line++;
998 YY_BREAK
999 case 5:
1000 YY_RULE_SETUP
1001 #line 149 "../../trunk/src/IPFilterScanner.l"
1003 /* Bad line */
1004 yyip_Bad++;
1005 AddDebugLogLineN(logIPFilter, CFormat(wxT("error in line %d: %s")) % yyip_Line % wxString(char2unicode(yyiptext)));
1007 YY_BREAK
1008 case 6:
1009 YY_RULE_SETUP
1010 #line 155 "../../trunk/src/IPFilterScanner.l"
1011 ECHO;
1012 YY_BREAK
1013 #line 1014 "../../trunk/src/IPFilterScanner.cpp"
1014 case YY_STATE_EOF(INITIAL):
1015 yyterminate();
1017 case YY_END_OF_BUFFER:
1019 /* Amount of text matched not including the EOB char. */
1020 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1022 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1023 *yy_cp = (yy_hold_char);
1024 YY_RESTORE_YY_MORE_OFFSET
1026 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1028 /* We're scanning a new file or input source. It's
1029 * possible that this happened because the user
1030 * just pointed yyipin at a new source and called
1031 * yyiplex(). If so, then we have to assure
1032 * consistency between YY_CURRENT_BUFFER and our
1033 * globals. Here is the right place to do so, because
1034 * this is the first action (other than possibly a
1035 * back-up) that will match for the new input source.
1037 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1038 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyipin;
1039 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1042 /* Note that here we test for yy_c_buf_p "<=" to the position
1043 * of the first EOB in the buffer, since yy_c_buf_p will
1044 * already have been incremented past the NUL character
1045 * (since all states make transitions on EOB to the
1046 * end-of-buffer state). Contrast this with the test
1047 * in input().
1049 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1050 { /* This was really a NUL. */
1051 yy_state_type yy_next_state;
1053 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1055 yy_current_state = yy_get_previous_state( );
1057 /* Okay, we're now positioned to make the NUL
1058 * transition. We couldn't have
1059 * yy_get_previous_state() go ahead and do it
1060 * for us because it doesn't know how to deal
1061 * with the possibility of jamming (and we don't
1062 * want to build jamming into it because then it
1063 * will run more slowly).
1066 yy_next_state = yy_try_NUL_trans( yy_current_state );
1068 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1070 if ( yy_next_state )
1072 /* Consume the NUL. */
1073 yy_cp = ++(yy_c_buf_p);
1074 yy_current_state = yy_next_state;
1075 goto yy_match;
1078 else
1080 yy_cp = (yy_c_buf_p);
1081 goto yy_find_action;
1085 else switch ( yy_get_next_buffer( ) )
1087 case EOB_ACT_END_OF_FILE:
1089 (yy_did_buffer_switch_on_eof) = 0;
1091 if ( yyipwrap( ) )
1093 /* Note: because we've taken care in
1094 * yy_get_next_buffer() to have set up
1095 * yyiptext, we can now set up
1096 * yy_c_buf_p so that if some total
1097 * hoser (like flex itself) wants to
1098 * call the scanner after we return the
1099 * YY_NULL, it'll still work - another
1100 * YY_NULL will get returned.
1102 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1104 yy_act = YY_STATE_EOF(YY_START);
1105 goto do_action;
1108 else
1110 if ( ! (yy_did_buffer_switch_on_eof) )
1111 YY_NEW_FILE;
1113 break;
1116 case EOB_ACT_CONTINUE_SCAN:
1117 (yy_c_buf_p) =
1118 (yytext_ptr) + yy_amount_of_matched_text;
1120 yy_current_state = yy_get_previous_state( );
1122 yy_cp = (yy_c_buf_p);
1123 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1124 goto yy_match;
1126 case EOB_ACT_LAST_MATCH:
1127 (yy_c_buf_p) =
1128 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1130 yy_current_state = yy_get_previous_state( );
1132 yy_cp = (yy_c_buf_p);
1133 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1134 goto yy_find_action;
1136 break;
1139 default:
1140 YY_FATAL_ERROR(
1141 "fatal flex scanner internal error--no action found" );
1142 } /* end of action switch */
1143 } /* end of scanning one token */
1144 } /* end of yyiplex */
1146 /* yy_get_next_buffer - try to read in a new buffer
1148 * Returns a code representing an action:
1149 * EOB_ACT_LAST_MATCH -
1150 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1151 * EOB_ACT_END_OF_FILE - end of file
1153 static int yy_get_next_buffer (void)
1155 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1156 register char *source = (yytext_ptr);
1157 register int number_to_move, i;
1158 int ret_val;
1160 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1161 YY_FATAL_ERROR(
1162 "fatal flex scanner internal error--end of buffer missed" );
1164 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1165 { /* Don't try to fill the buffer, so this is an EOF. */
1166 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1168 /* We matched a single character, the EOB, so
1169 * treat this as a final EOF.
1171 return EOB_ACT_END_OF_FILE;
1174 else
1176 /* We matched some text prior to the EOB, first
1177 * process it.
1179 return EOB_ACT_LAST_MATCH;
1183 /* Try to read more data. */
1185 /* First move last chars to start of buffer. */
1186 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1188 for ( i = 0; i < number_to_move; ++i )
1189 *(dest++) = *(source++);
1191 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1192 /* don't do the read, it's not guaranteed to return an EOF,
1193 * just force an EOF
1195 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1197 else
1199 int num_to_read =
1200 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1202 while ( num_to_read <= 0 )
1203 { /* Not enough room in the buffer - grow it. */
1205 /* just a shorter name for the current buffer */
1206 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1208 int yy_c_buf_p_offset =
1209 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1211 if ( b->yy_is_our_buffer )
1213 int new_size = b->yy_buf_size * 2;
1215 if ( new_size <= 0 )
1216 b->yy_buf_size += b->yy_buf_size / 8;
1217 else
1218 b->yy_buf_size *= 2;
1220 b->yy_ch_buf = (char *)
1221 /* Include room in for 2 EOB chars. */
1222 yyiprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1224 else
1225 /* Can't grow it, we don't own it. */
1226 b->yy_ch_buf = 0;
1228 if ( ! b->yy_ch_buf )
1229 YY_FATAL_ERROR(
1230 "fatal error - scanner input buffer overflow" );
1232 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1234 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1235 number_to_move - 1;
1239 if ( num_to_read > YY_READ_BUF_SIZE )
1240 num_to_read = YY_READ_BUF_SIZE;
1242 /* Read in more data. */
1243 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1244 (yy_n_chars), (size_t) num_to_read );
1246 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1249 if ( (yy_n_chars) == 0 )
1251 if ( number_to_move == YY_MORE_ADJ )
1253 ret_val = EOB_ACT_END_OF_FILE;
1254 yyiprestart(yyipin );
1257 else
1259 ret_val = EOB_ACT_LAST_MATCH;
1260 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1261 YY_BUFFER_EOF_PENDING;
1265 else
1266 ret_val = EOB_ACT_CONTINUE_SCAN;
1268 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1269 /* Extend the array by 50%, plus the number we really need. */
1270 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1271 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyiprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1272 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1273 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1276 (yy_n_chars) += number_to_move;
1277 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1278 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1280 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1282 return ret_val;
1285 /* yy_get_previous_state - get the state just before the EOB char was reached */
1287 static yy_state_type yy_get_previous_state (void)
1289 register yy_state_type yy_current_state;
1290 register char *yy_cp;
1292 yy_current_state = (yy_start);
1293 yy_current_state += YY_AT_BOL();
1295 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1297 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1298 if ( yy_accept[yy_current_state] )
1300 (yy_last_accepting_state) = yy_current_state;
1301 (yy_last_accepting_cpos) = yy_cp;
1303 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1305 yy_current_state = (int) yy_def[yy_current_state];
1306 if ( yy_current_state >= 169 )
1307 yy_c = yy_meta[(unsigned int) yy_c];
1309 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1312 return yy_current_state;
1315 /* yy_try_NUL_trans - try to make a transition on the NUL character
1317 * synopsis
1318 * next_state = yy_try_NUL_trans( current_state );
1320 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1322 register int yy_is_jam;
1323 register char *yy_cp = (yy_c_buf_p);
1325 register YY_CHAR yy_c = 1;
1326 if ( yy_accept[yy_current_state] )
1328 (yy_last_accepting_state) = yy_current_state;
1329 (yy_last_accepting_cpos) = yy_cp;
1331 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1333 yy_current_state = (int) yy_def[yy_current_state];
1334 if ( yy_current_state >= 169 )
1335 yy_c = yy_meta[(unsigned int) yy_c];
1337 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1338 yy_is_jam = (yy_current_state == 168);
1340 return yy_is_jam ? 0 : yy_current_state;
1343 static void yyunput (int c, register char * yy_bp )
1345 register char *yy_cp;
1347 yy_cp = (yy_c_buf_p);
1349 /* undo effects of setting up yyiptext */
1350 *yy_cp = (yy_hold_char);
1352 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1353 { /* need to shift things up to make room */
1354 /* +2 for EOB chars. */
1355 register int number_to_move = (yy_n_chars) + 2;
1356 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1357 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1358 register char *source =
1359 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1361 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1362 *--dest = *--source;
1364 yy_cp += (int) (dest - source);
1365 yy_bp += (int) (dest - source);
1366 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1367 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1369 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1370 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1373 *--yy_cp = (char) c;
1375 (yytext_ptr) = yy_bp;
1376 (yy_hold_char) = *yy_cp;
1377 (yy_c_buf_p) = yy_cp;
1380 #ifndef YY_NO_INPUT
1381 #ifdef __cplusplus
1382 static int yyinput (void)
1383 #else
1384 static int input (void)
1385 #endif
1388 int c;
1390 *(yy_c_buf_p) = (yy_hold_char);
1392 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1394 /* yy_c_buf_p now points to the character we want to return.
1395 * If this occurs *before* the EOB characters, then it's a
1396 * valid NUL; if not, then we've hit the end of the buffer.
1398 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1399 /* This was really a NUL. */
1400 *(yy_c_buf_p) = '\0';
1402 else
1403 { /* need more input */
1404 int offset = (yy_c_buf_p) - (yytext_ptr);
1405 ++(yy_c_buf_p);
1407 switch ( yy_get_next_buffer( ) )
1409 case EOB_ACT_LAST_MATCH:
1410 /* This happens because yy_g_n_b()
1411 * sees that we've accumulated a
1412 * token and flags that we need to
1413 * try matching the token before
1414 * proceeding. But for input(),
1415 * there's no matching to consider.
1416 * So convert the EOB_ACT_LAST_MATCH
1417 * to EOB_ACT_END_OF_FILE.
1420 /* Reset buffer status. */
1421 yyiprestart(yyipin );
1423 /*FALLTHROUGH*/
1425 case EOB_ACT_END_OF_FILE:
1427 if ( yyipwrap( ) )
1428 return EOF;
1430 if ( ! (yy_did_buffer_switch_on_eof) )
1431 YY_NEW_FILE;
1432 #ifdef __cplusplus
1433 return yyinput();
1434 #else
1435 return input();
1436 #endif
1439 case EOB_ACT_CONTINUE_SCAN:
1440 (yy_c_buf_p) = (yytext_ptr) + offset;
1441 break;
1446 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1447 *(yy_c_buf_p) = '\0'; /* preserve yyiptext */
1448 (yy_hold_char) = *++(yy_c_buf_p);
1450 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
1452 return c;
1454 #endif /* ifndef YY_NO_INPUT */
1456 /** Immediately switch to a different input stream.
1457 * @param input_file A readable stream.
1459 * @note This function does not reset the start condition to @c INITIAL .
1461 void yyiprestart (FILE * input_file )
1464 if ( ! YY_CURRENT_BUFFER ){
1465 yyipensure_buffer_stack ();
1466 YY_CURRENT_BUFFER_LVALUE =
1467 yyip_create_buffer(yyipin,YY_BUF_SIZE );
1470 yyip_init_buffer(YY_CURRENT_BUFFER,input_file );
1471 yyip_load_buffer_state( );
1474 /** Switch to a different input buffer.
1475 * @param new_buffer The new input buffer.
1478 void yyip_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1481 /* TODO. We should be able to replace this entire function body
1482 * with
1483 * yyippop_buffer_state();
1484 * yyippush_buffer_state(new_buffer);
1486 yyipensure_buffer_stack ();
1487 if ( YY_CURRENT_BUFFER == new_buffer )
1488 return;
1490 if ( YY_CURRENT_BUFFER )
1492 /* Flush out information for old buffer. */
1493 *(yy_c_buf_p) = (yy_hold_char);
1494 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1495 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1498 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1499 yyip_load_buffer_state( );
1501 /* We don't actually know whether we did this switch during
1502 * EOF (yyipwrap()) processing, but the only time this flag
1503 * is looked at is after yyipwrap() is called, so it's safe
1504 * to go ahead and always set it.
1506 (yy_did_buffer_switch_on_eof) = 1;
1509 static void yyip_load_buffer_state (void)
1511 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1512 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1513 yyipin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1514 (yy_hold_char) = *(yy_c_buf_p);
1517 /** Allocate and initialize an input buffer state.
1518 * @param file A readable stream.
1519 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1521 * @return the allocated buffer state.
1523 YY_BUFFER_STATE yyip_create_buffer (FILE * file, int size )
1525 YY_BUFFER_STATE b;
1527 b = (YY_BUFFER_STATE) yyipalloc(sizeof( struct yy_buffer_state ) );
1528 if ( ! b )
1529 YY_FATAL_ERROR( "out of dynamic memory in yyip_create_buffer()" );
1531 b->yy_buf_size = size;
1533 /* yy_ch_buf has to be 2 characters longer than the size given because
1534 * we need to put in 2 end-of-buffer characters.
1536 b->yy_ch_buf = (char *) yyipalloc(b->yy_buf_size + 2 );
1537 if ( ! b->yy_ch_buf )
1538 YY_FATAL_ERROR( "out of dynamic memory in yyip_create_buffer()" );
1540 b->yy_is_our_buffer = 1;
1542 yyip_init_buffer(b,file );
1544 return b;
1547 /** Destroy the buffer.
1548 * @param b a buffer created with yyip_create_buffer()
1551 void yyip_delete_buffer (YY_BUFFER_STATE b )
1554 if ( ! b )
1555 return;
1557 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1558 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1560 if ( b->yy_is_our_buffer )
1561 yyipfree((void *) b->yy_ch_buf );
1563 yyipfree((void *) b );
1566 #ifndef __cplusplus
1567 extern int isatty (int );
1568 #endif /* __cplusplus */
1570 /* Initializes or reinitializes a buffer.
1571 * This function is sometimes called more than once on the same buffer,
1572 * such as during a yyiprestart() or at EOF.
1574 static void yyip_init_buffer (YY_BUFFER_STATE b, FILE * file )
1577 int oerrno = errno;
1579 yyip_flush_buffer(b );
1581 b->yy_input_file = file;
1582 b->yy_fill_buffer = 1;
1584 /* If b is the current buffer, then yyip_init_buffer was _probably_
1585 * called from yyiprestart() or through yy_get_next_buffer.
1586 * In that case, we don't want to reset the lineno or column.
1588 if (b != YY_CURRENT_BUFFER){
1589 b->yy_bs_lineno = 1;
1590 b->yy_bs_column = 0;
1593 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1595 errno = oerrno;
1598 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1599 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1602 void yyip_flush_buffer (YY_BUFFER_STATE b )
1604 if ( ! b )
1605 return;
1607 b->yy_n_chars = 0;
1609 /* We always need two end-of-buffer characters. The first causes
1610 * a transition to the end-of-buffer state. The second causes
1611 * a jam in that state.
1613 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1614 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1616 b->yy_buf_pos = &b->yy_ch_buf[0];
1618 b->yy_at_bol = 1;
1619 b->yy_buffer_status = YY_BUFFER_NEW;
1621 if ( b == YY_CURRENT_BUFFER )
1622 yyip_load_buffer_state( );
1625 /** Pushes the new state onto the stack. The new state becomes
1626 * the current state. This function will allocate the stack
1627 * if necessary.
1628 * @param new_buffer The new state.
1631 void yyippush_buffer_state (YY_BUFFER_STATE new_buffer )
1633 if (new_buffer == NULL)
1634 return;
1636 yyipensure_buffer_stack();
1638 /* This block is copied from yyip_switch_to_buffer. */
1639 if ( YY_CURRENT_BUFFER )
1641 /* Flush out information for old buffer. */
1642 *(yy_c_buf_p) = (yy_hold_char);
1643 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1644 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1647 /* Only push if top exists. Otherwise, replace top. */
1648 if (YY_CURRENT_BUFFER)
1649 (yy_buffer_stack_top)++;
1650 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1652 /* copied from yyip_switch_to_buffer. */
1653 yyip_load_buffer_state( );
1654 (yy_did_buffer_switch_on_eof) = 1;
1657 /** Removes and deletes the top of the stack, if present.
1658 * The next element becomes the new top.
1661 void yyippop_buffer_state (void)
1663 if (!YY_CURRENT_BUFFER)
1664 return;
1666 yyip_delete_buffer(YY_CURRENT_BUFFER );
1667 YY_CURRENT_BUFFER_LVALUE = NULL;
1668 if ((yy_buffer_stack_top) > 0)
1669 --(yy_buffer_stack_top);
1671 if (YY_CURRENT_BUFFER) {
1672 yyip_load_buffer_state( );
1673 (yy_did_buffer_switch_on_eof) = 1;
1677 /* Allocates the stack if it does not exist.
1678 * Guarantees space for at least one push.
1680 static void yyipensure_buffer_stack (void)
1682 int num_to_alloc;
1684 if (!(yy_buffer_stack)) {
1686 /* First allocation is just for 2 elements, since we don't know if this
1687 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1688 * immediate realloc on the next call.
1690 num_to_alloc = 1;
1691 (yy_buffer_stack) = (struct yy_buffer_state**)yyipalloc
1692 (num_to_alloc * sizeof(struct yy_buffer_state*)
1694 if ( ! (yy_buffer_stack) )
1695 YY_FATAL_ERROR( "out of dynamic memory in yyipensure_buffer_stack()" );
1697 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1699 (yy_buffer_stack_max) = num_to_alloc;
1700 (yy_buffer_stack_top) = 0;
1701 return;
1704 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1706 /* Increase the buffer to prepare for a possible push. */
1707 int grow_size = 8 /* arbitrary grow size */;
1709 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1710 (yy_buffer_stack) = (struct yy_buffer_state**)yyiprealloc
1711 ((yy_buffer_stack),
1712 num_to_alloc * sizeof(struct yy_buffer_state*)
1714 if ( ! (yy_buffer_stack) )
1715 YY_FATAL_ERROR( "out of dynamic memory in yyipensure_buffer_stack()" );
1717 /* zero only the new slots.*/
1718 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1719 (yy_buffer_stack_max) = num_to_alloc;
1723 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1724 * @param base the character buffer
1725 * @param size the size in bytes of the character buffer
1727 * @return the newly allocated buffer state object.
1729 YY_BUFFER_STATE yyip_scan_buffer (char * base, yy_size_t size )
1731 YY_BUFFER_STATE b;
1733 if ( size < 2 ||
1734 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1735 base[size-1] != YY_END_OF_BUFFER_CHAR )
1736 /* They forgot to leave room for the EOB's. */
1737 return 0;
1739 b = (YY_BUFFER_STATE) yyipalloc(sizeof( struct yy_buffer_state ) );
1740 if ( ! b )
1741 YY_FATAL_ERROR( "out of dynamic memory in yyip_scan_buffer()" );
1743 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1744 b->yy_buf_pos = b->yy_ch_buf = base;
1745 b->yy_is_our_buffer = 0;
1746 b->yy_input_file = 0;
1747 b->yy_n_chars = b->yy_buf_size;
1748 b->yy_is_interactive = 0;
1749 b->yy_at_bol = 1;
1750 b->yy_fill_buffer = 0;
1751 b->yy_buffer_status = YY_BUFFER_NEW;
1753 yyip_switch_to_buffer(b );
1755 return b;
1758 /** Setup the input buffer state to scan a string. The next call to yyiplex() will
1759 * scan from a @e copy of @a str.
1760 * @param yystr a NUL-terminated string to scan
1762 * @return the newly allocated buffer state object.
1763 * @note If you want to scan bytes that may contain NUL values, then use
1764 * yyip_scan_bytes() instead.
1766 YY_BUFFER_STATE yyip_scan_string (yyconst char * yystr )
1769 return yyip_scan_bytes(yystr,strlen(yystr) );
1772 /** Setup the input buffer state to scan the given bytes. The next call to yyiplex() will
1773 * scan from a @e copy of @a bytes.
1774 * @param bytes the byte buffer to scan
1775 * @param len the number of bytes in the buffer pointed to by @a bytes.
1777 * @return the newly allocated buffer state object.
1779 YY_BUFFER_STATE yyip_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1781 YY_BUFFER_STATE b;
1782 char *buf;
1783 yy_size_t n;
1784 int i;
1786 /* Get memory for full buffer, including space for trailing EOB's. */
1787 n = _yybytes_len + 2;
1788 buf = (char *) yyipalloc(n );
1789 if ( ! buf )
1790 YY_FATAL_ERROR( "out of dynamic memory in yyip_scan_bytes()" );
1792 for ( i = 0; i < _yybytes_len; ++i )
1793 buf[i] = yybytes[i];
1795 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1797 b = yyip_scan_buffer(buf,n );
1798 if ( ! b )
1799 YY_FATAL_ERROR( "bad buffer in yyip_scan_bytes()" );
1801 /* It's okay to grow etc. this buffer, and we should throw it
1802 * away when we're done.
1804 b->yy_is_our_buffer = 1;
1806 return b;
1809 #ifndef YY_EXIT_FAILURE
1810 #define YY_EXIT_FAILURE 2
1811 #endif
1813 static void yy_fatal_error (yyconst char* msg )
1815 (void) fprintf( stderr, "%s\n", msg );
1816 exit( YY_EXIT_FAILURE );
1819 /* Redefine yyless() so it works in section 3 code. */
1821 #undef yyless
1822 #define yyless(n) \
1823 do \
1825 /* Undo effects of setting up yyiptext. */ \
1826 int yyless_macro_arg = (n); \
1827 YY_LESS_LINENO(yyless_macro_arg);\
1828 yyiptext[yyipleng] = (yy_hold_char); \
1829 (yy_c_buf_p) = yyiptext + yyless_macro_arg; \
1830 (yy_hold_char) = *(yy_c_buf_p); \
1831 *(yy_c_buf_p) = '\0'; \
1832 yyipleng = yyless_macro_arg; \
1834 while ( 0 )
1836 /* Accessor methods (get/set functions) to struct members. */
1838 /** Get the current line number.
1841 int yyipget_lineno (void)
1844 return yyiplineno;
1847 /** Get the input stream.
1850 FILE *yyipget_in (void)
1852 return yyipin;
1855 /** Get the output stream.
1858 FILE *yyipget_out (void)
1860 return yyipout;
1863 /** Get the length of the current token.
1866 int yyipget_leng (void)
1868 return yyipleng;
1871 /** Get the current token.
1875 char *yyipget_text (void)
1877 return yyiptext;
1880 /** Set the current line number.
1881 * @param line_number
1884 void yyipset_lineno (int line_number )
1887 yyiplineno = line_number;
1890 /** Set the input stream. This does not discard the current
1891 * input buffer.
1892 * @param in_str A readable stream.
1894 * @see yyip_switch_to_buffer
1896 void yyipset_in (FILE * in_str )
1898 yyipin = in_str ;
1901 void yyipset_out (FILE * out_str )
1903 yyipout = out_str ;
1906 int yyipget_debug (void)
1908 return yyip_flex_debug;
1911 void yyipset_debug (int bdebug )
1913 yyip_flex_debug = bdebug ;
1916 static int yy_init_globals (void)
1918 /* Initialization is the same as for the non-reentrant scanner.
1919 * This function is called from yyiplex_destroy(), so don't allocate here.
1922 (yy_buffer_stack) = 0;
1923 (yy_buffer_stack_top) = 0;
1924 (yy_buffer_stack_max) = 0;
1925 (yy_c_buf_p) = (char *) 0;
1926 (yy_init) = 0;
1927 (yy_start) = 0;
1929 /* Defined in main.c */
1930 #ifdef YY_STDINIT
1931 yyipin = stdin;
1932 yyipout = stdout;
1933 #else
1934 yyipin = (FILE *) 0;
1935 yyipout = (FILE *) 0;
1936 #endif
1938 /* For future reference: Set errno on error, since we are called by
1939 * yyiplex_init()
1941 return 0;
1944 /* yyiplex_destroy is for both reentrant and non-reentrant scanners. */
1945 int yyiplex_destroy (void)
1948 /* Pop the buffer stack, destroying each element. */
1949 while(YY_CURRENT_BUFFER){
1950 yyip_delete_buffer(YY_CURRENT_BUFFER );
1951 YY_CURRENT_BUFFER_LVALUE = NULL;
1952 yyippop_buffer_state();
1955 /* Destroy the stack itself. */
1956 yyipfree((yy_buffer_stack) );
1957 (yy_buffer_stack) = NULL;
1959 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1960 * yyiplex() is called, initialization will occur. */
1961 yy_init_globals( );
1963 return 0;
1967 * Internal utility routines.
1970 #ifndef yytext_ptr
1971 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1973 register int i;
1974 for ( i = 0; i < n; ++i )
1975 s1[i] = s2[i];
1977 #endif
1979 #ifdef YY_NEED_STRLEN
1980 static int yy_flex_strlen (yyconst char * s )
1982 register int n;
1983 for ( n = 0; s[n]; ++n )
1986 return n;
1988 #endif
1990 void *yyipalloc (yy_size_t size )
1992 return (void *) malloc( size );
1995 void *yyiprealloc (void * ptr, yy_size_t size )
1997 /* The cast to (char *) in the following accommodates both
1998 * implementations that use char* generic pointers, and those
1999 * that use void* generic pointers. It works with the latter
2000 * because both ANSI C and C++ allow castless assignment from
2001 * any pointer type to void*, and deal with argument conversions
2002 * as though doing an assignment.
2004 return (void *) realloc( (char *) ptr, size );
2007 void yyipfree (void * ptr )
2009 free( (char *) ptr ); /* see yyiprealloc() for (char *) cast */
2012 #define YYTABLES_NAME "yytables"
2014 #line 155 "../../trunk/src/IPFilterScanner.l"