/* A lexical scanner generated by flex */ /* Scanner skeleton version: * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #include #include /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #ifdef __cplusplus #include #ifndef _WIN32 #include #endif /* Use prototypes in function declarations. */ #define YY_USE_PROTOS /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ #if __STDC__ #define YY_USE_PROTOS #define YY_USE_CONST #endif /* __STDC__ */ #endif /* ! __cplusplus */ #ifdef __TURBOC__ #pragma warn -rch #pragma warn -use #include #include #define YY_USE_CONST #define YY_USE_PROTOS #endif #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif #ifdef YY_USE_PROTOS #define YY_PROTO(proto) proto #else #define YY_PROTO(proto) () #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #define YY_BUF_SIZE 16384 typedef struct yy_buffer_state *YY_BUFFER_STATE; extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* The funky do-while in the following #define is used to turn the definition * int a single C statement (which needs a semi-colon terminator). This * avoids problems with code like: * * if ( condition_holds ) * yyless( 5 ); * else * do_something_else(); * * Prior to using the do-while the compiler would get upset at the * "else" because it interpreted the "if" statement as being all * done when it reached the ';' after the yyless() call. */ /* Return all but the first 'n' matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ *yy_cp = yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, yytext_ptr ) /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). */ typedef unsigned int yy_size_t; struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; static YY_BUFFER_STATE yy_current_buffer = 0; /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". */ #define YY_CURRENT_BUFFER yy_current_buffer /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; void yyrestart YY_PROTO(( FILE *input_file )); void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); void yy_load_buffer_state YY_PROTO(( void )); YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) #define yywrap() 1 #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern char *yytext; #define yytext_ptr yytext static yy_state_type yy_get_previous_state YY_PROTO(( void )); static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); static int yy_get_next_buffer YY_PROTO(( void )); static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yytext_ptr = yy_bp; \ yyleng = (int) (yy_cp - yy_bp); \ yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; #define YY_NUM_RULES 30 #define YY_END_OF_BUFFER 31 static yyconst short int yy_accept[323] = { 0, 0, 0, 22, 22, 0, 0, 31, 26, 27, 26, 26, 22, 23, 24, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 28, 29, 26, 27, 26, 26, 22, 0, 0, 0, 21, 0, 23, 24, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 28, 29, 26, 26, 22, 22, 11, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 10, 22, 22, 22, 22, 25, 26, 26, 12, 11, 0, 0, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 10, 0, 0, 22, 22, 22, 22, 26, 12, 0, 0, 0, 22, 7, 9, 22, 22, 22, 22, 22, 22, 22, 0, 22, 22, 22, 22, 26, 0, 11, 22, 7, 0, 0, 9, 0, 0, 22, 22, 22, 22, 22, 22, 22, 10, 22, 22, 22, 22, 26, 12, 22, 0, 0, 22, 22, 22, 22, 22, 17, 22, 22, 22, 22, 22, 26, 22, 7, 9, 22, 22, 22, 22, 22, 17, 0, 0, 8, 22, 22, 22, 22, 26, 22, 22, 22, 22, 19, 22, 16, 0, 8, 0, 0, 22, 22, 3, 18, 26, 22, 22, 22, 22, 22, 19, 0, 0, 22, 16, 0, 0, 17, 0, 22, 22, 3, 0, 0, 18, 0, 0, 26, 22, 22, 22, 22, 13, 0, 15, 16, 16, 0, 8, 2, 22, 0, 0, 26, 22, 22, 22, 14, 13, 0, 0, 19, 15, 0, 0, 16, 2, 0, 0, 20, 3, 18, 26, 22, 22, 4, 14, 0, 0, 0, 0, 0, 20, 0, 0, 26, 22, 22, 4, 0, 0, 0, 13, 15, 2, 0, 26, 22, 22, 0, 14, 20, 26, 26, 22, 22, 4, 26, 26, 22, 22, 26, 22, 22, 26, 22, 22, 26, 5, 22, 26, 5, 0, 0, 22, 26, 0, 22, 26, 5, 22, 26, 22, 26, 22, 26, 6, 26, 6, 0, 0, 26, 0, 26, 6, 1, 0 } ; static yyconst int yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 1, 1, 1, 1, 1, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 16, 19, 20, 21, 22, 23, 16, 24, 25, 26, 27, 28, 16, 29, 30, 16, 1, 1, 1, 1, 1, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 16, 19, 20, 21, 22, 23, 16, 24, 25, 26, 27, 28, 16, 29, 30, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst int yy_meta[31] = { 0, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst short int yy_base[377] = { 0, 0, 1, 5, 13, 765, 762, 759, 0, 741, 710, 683, 7, 16, 9, 25, 40, 43, 31, 28, 50, 53, 55, 57, 61, 64, 0, 698, 0, 685, 0, 653, 68, 0, 664, 0, 851, 662, 71, 648, 74, 80, 86, 88, 90, 92, 96, 119, 99, 101, 112, 106, 140, 0, 629, 114, 598, 121, 123, 125, 131, 133, 135, 137, 144, 146, 159, 148, 167, 170, 172, 174, 176, 178, 180, 851, 182, 594, 186, 188, 43, 588, 196, 193, 199, 201, 207, 209, 214, 216, 218, 220, 224, 227, 584, 231, 227, 236, 239, 239, 246, 249, 538, 0, 252, 254, 256, 258, 260, 262, 264, 266, 275, 280, 0, 283, 285, 290, 292, 269, 0, 294, 298, 300, 280, 530, 302, 306, 528, 309, 312, 316, 318, 323, 327, 329, 333, 337, 339, 343, 347, 374, 350, 354, 0, 0, 358, 360, 365, 380, 367, 369, 382, 389, 391, 393, 395, 420, 397, 400, 402, 404, 415, 426, 432, 434, 408, 312, 521, 410, 436, 440, 443, 445, 460, 452, 455, 467, 469, 471, 473, 479, 0, 483, 486, 519, 486, 491, 493, 496, 515, 498, 500, 502, 504, 507, 510, 514, 489, 524, 526, 516, 481, 532, 0, 534, 536, 540, 543, 477, 543, 547, 475, 559, 547, 550, 565, 554, 552, 0, 569, 571, 573, 0, 576, 578, 580, 0, 0, 588, 582, 594, 597, 599, 603, 606, 460, 606, 609, 612, 451, 612, 617, 620, 449, 620, 623, 625, 629, 635, 637, 639, 641, 644, 447, 0, 0, 0, 644, 648, 438, 428, 651, 653, 655, 659, 428, 0, 659, 666, 668, 0, 149, 670, 673, 0, 675, 677, 408, 159, 681, 683, 679, 380, 362, 687, 689, 358, 691, 696, 351, 700, 702, 341, 707, 711, 337, 715, 718, 335, 718, 326, 0, 721, 316, 723, 725, 303, 728, 294, 731, 273, 733, 269, 737, 740, 249, 229, 0, 218, 744, 0, 851, 748, 751, 754, 757, 760, 763, 766, 214, 769, 772, 775, 778, 207, 781, 784, 193, 167, 787, 157, 144, 790, 793, 796, 799, 802, 805, 131, 808, 811, 814, 112, 817, 820, 105, 823, 100, 826, 96, 86, 829, 832, 835, 838, 841, 79, 68, 49, 40, 25, 21, 844, 13, 847, 0 } ; static yyconst short int yy_def[377] = { 0, 323, 323, 324, 324, 325, 325, 322, 326, 322, 326, 326, 327, 322, 322, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 328, 322, 326, 322, 329, 326, 327, 322, 322, 330, 322, 322, 322, 322, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 328, 322, 329, 326, 330, 327, 331, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 332, 327, 327, 327, 327, 322, 329, 326, 333, 331, 322, 322, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 332, 322, 322, 327, 327, 327, 327, 334, 333, 322, 322, 335, 327, 336, 337, 327, 327, 327, 327, 327, 327, 327, 338, 327, 327, 327, 327, 334, 339, 335, 327, 336, 322, 322, 337, 322, 322, 327, 327, 327, 327, 327, 327, 327, 338, 327, 327, 327, 327, 340, 339, 327, 341, 342, 327, 327, 327, 327, 327, 343, 327, 327, 327, 327, 327, 344, 327, 341, 342, 327, 327, 327, 327, 327, 343, 322, 322, 345, 327, 327, 327, 327, 346, 327, 327, 327, 327, 347, 327, 348, 349, 345, 322, 322, 327, 327, 350, 351, 326, 327, 327, 327, 327, 327, 347, 322, 322, 327, 352, 322, 322, 349, 353, 327, 327, 350, 322, 322, 351, 322, 322, 354, 327, 327, 327, 327, 355, 356, 357, 352, 348, 358, 353, 359, 327, 360, 361, 362, 327, 327, 327, 363, 355, 322, 322, 356, 357, 322, 322, 358, 359, 322, 322, 364, 360, 361, 365, 327, 327, 366, 363, 322, 322, 367, 368, 369, 364, 322, 322, 326, 327, 327, 366, 322, 322, 370, 367, 368, 369, 371, 326, 327, 327, 372, 370, 371, 326, 326, 327, 327, 372, 326, 326, 327, 327, 326, 327, 327, 326, 327, 327, 326, 373, 327, 326, 373, 322, 322, 327, 326, 374, 327, 326, 374, 327, 326, 327, 326, 327, 326, 375, 326, 375, 322, 322, 326, 376, 326, 376, 326, 0, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322 } ; static yyconst short int yy_nxt[882] = { 0, 320, 35, 9, 9, 35, 10, 10, 13, 14, 33, 34, 38, 39, 305, 11, 13, 14, 35, 36, 37, 35, 282, 15, 16, 17, 277, 18, 33, 34, 19, 33, 34, 20, 33, 34, 40, 21, 22, 23, 24, 276, 25, 33, 34, 103, 33, 34, 103, 45, 270, 41, 43, 33, 34, 44, 33, 34, 33, 34, 33, 34, 42, 46, 33, 34, 47, 33, 34, 269, 52, 33, 34, 35, 36, 37, 35, 33, 34, 50, 268, 48, 49, 33, 34, 58, 51, 247, 59, 33, 34, 33, 34, 33, 34, 33, 34, 246, 63, 33, 34, 241, 33, 34, 33, 34, 237, 60, 68, 33, 34, 69, 62, 224, 61, 33, 34, 75, 76, 71, 70, 64, 33, 34, 33, 34, 33, 34, 80, 81, 65, 78, 203, 66, 33, 34, 33, 34, 33, 34, 33, 34, 67, 33, 34, 160, 83, 33, 34, 33, 34, 33, 34, 72, 278, 84, 279, 82, 159, 87, 73, 85, 33, 34, 283, 74, 284, 89, 142, 86, 33, 34, 88, 33, 34, 93, 94, 33, 34, 33, 34, 33, 34, 33, 34, 75, 76, 97, 91, 101, 102, 80, 81, 90, 136, 96, 33, 34, 95, 33, 34, 105, 33, 34, 33, 34, 98, 106, 121, 104, 33, 34, 33, 34, 107, 57, 108, 33, 34, 33, 34, 33, 34, 33, 34, 321, 109, 93, 94, 114, 33, 34, 114, 113, 33, 34, 319, 115, 110, 33, 34, 28, 33, 34, 28, 112, 111, 116, 118, 101, 102, 120, 315, 117, 120, 33, 34, 124, 125, 127, 128, 33, 34, 33, 34, 33, 34, 33, 34, 33, 34, 28, 133, 122, 141, 130, 317, 132, 33, 34, 313, 129, 144, 33, 34, 144, 33, 34, 33, 34, 131, 135, 137, 33, 34, 33, 34, 80, 81, 311, 134, 33, 34, 124, 125, 127, 128, 138, 145, 139, 309, 145, 33, 34, 182, 33, 34, 182, 140, 33, 34, 33, 34, 307, 143, 147, 33, 34, 146, 148, 33, 34, 33, 34, 304, 151, 93, 94, 298, 149, 33, 34, 33, 34, 301, 154, 33, 34, 296, 150, 33, 34, 153, 101, 102, 152, 155, 33, 34, 293, 158, 33, 34, 33, 34, 290, 162, 283, 33, 34, 33, 34, 167, 168, 156, 28, 28, 163, 28, 141, 28, 28, 28, 33, 34, 33, 34, 287, 161, 165, 169, 164, 33, 34, 33, 34, 33, 34, 33, 34, 33, 34, 170, 124, 125, 127, 128, 33, 34, 175, 177, 167, 168, 184, 185, 279, 171, 172, 33, 34, 173, 28, 28, 176, 28, 28, 28, 28, 28, 33, 34, 265, 178, 272, 179, 33, 34, 33, 34, 33, 34, 259, 181, 33, 34, 180, 33, 34, 33, 34, 253, 188, 243, 189, 239, 33, 34, 186, 33, 34, 187, 28, 28, 235, 28, 28, 28, 28, 28, 191, 33, 34, 33, 34, 197, 198, 33, 34, 211, 192, 208, 195, 201, 202, 201, 193, 184, 185, 204, 33, 34, 204, 197, 194, 33, 34, 208, 209, 199, 211, 212, 33, 34, 33, 34, 33, 34, 33, 34, 215, 33, 34, 205, 197, 198, 218, 219, 206, 223, 219, 213, 223, 184, 214, 167, 216, 217, 33, 34, 201, 202, 127, 220, 124, 222, 167, 168, 33, 34, 33, 34, 101, 225, 208, 209, 227, 211, 212, 227, 228, 33, 34, 228, 33, 34, 235, 236, 33, 34, 226, 28, 28, 233, 28, 28, 28, 28, 28, 33, 34, 230, 231, 239, 240, 201, 202, 201, 202, 232, 184, 185, 243, 244, 33, 34, 33, 34, 93, 245, 28, 28, 80, 28, 28, 28, 28, 28, 33, 34, 99, 33, 34, 253, 254, 249, 251, 235, 236, 255, 197, 198, 255, 239, 240, 256, 201, 202, 256, 77, 250, 243, 244, 257, 259, 260, 257, 208, 209, 211, 212, 28, 28, 54, 28, 28, 28, 28, 28, 33, 34, 33, 34, 265, 266, 253, 254, 267, 259, 260, 267, 271, 263, 39, 271, 33, 34, 33, 34, 265, 266, 262, 275, 235, 236, 275, 36, 274, 33, 273, 239, 240, 243, 244, 33, 34, 56, 33, 34, 253, 254, 259, 260, 265, 266, 33, 34, 33, 34, 29, 286, 33, 34, 33, 34, 33, 34, 280, 281, 285, 33, 34, 54, 289, 33, 34, 33, 34, 31, 294, 288, 298, 299, 291, 295, 33, 34, 30, 292, 298, 299, 302, 33, 34, 302, 33, 34, 298, 299, 33, 34, 303, 33, 34, 300, 33, 34, 315, 316, 306, 312, 315, 316, 318, 310, 29, 318, 308, 315, 316, 8, 8, 8, 12, 12, 12, 26, 26, 26, 28, 322, 28, 32, 32, 32, 53, 27, 53, 55, 27, 55, 79, 79, 79, 92, 92, 92, 100, 100, 100, 119, 322, 119, 123, 123, 123, 126, 126, 126, 157, 322, 157, 166, 166, 166, 174, 322, 174, 183, 183, 183, 190, 322, 190, 196, 196, 196, 200, 200, 200, 207, 207, 207, 210, 210, 210, 221, 221, 221, 229, 322, 229, 234, 234, 234, 238, 238, 238, 242, 242, 242, 248, 322, 248, 252, 252, 252, 258, 258, 258, 261, 322, 261, 264, 264, 264, 297, 297, 297, 314, 314, 314, 7, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322 } ; static yyconst short int yy_chk[882] = { 0, 376, 33, 1, 2, 33, 1, 2, 3, 3, 12, 12, 14, 14, 374, 2, 4, 4, 13, 13, 13, 13, 372, 4, 4, 4, 371, 4, 15, 15, 4, 19, 19, 4, 18, 18, 15, 4, 4, 4, 4, 370, 4, 16, 16, 80, 17, 17, 80, 19, 369, 16, 17, 20, 20, 18, 21, 21, 22, 22, 23, 23, 16, 20, 24, 24, 21, 25, 25, 368, 25, 32, 32, 38, 38, 38, 38, 40, 40, 23, 367, 22, 22, 41, 41, 40, 24, 361, 41, 42, 42, 43, 43, 44, 44, 45, 45, 360, 45, 46, 46, 358, 48, 48, 49, 49, 356, 42, 48, 51, 51, 49, 44, 353, 43, 50, 50, 55, 55, 51, 50, 46, 47, 47, 57, 57, 58, 58, 59, 59, 47, 58, 349, 47, 60, 60, 61, 61, 62, 62, 63, 63, 47, 52, 52, 342, 61, 64, 64, 65, 65, 67, 67, 52, 272, 62, 272, 60, 341, 65, 52, 63, 66, 66, 279, 52, 279, 67, 339, 64, 68, 68, 66, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 74, 76, 76, 73, 69, 78, 78, 79, 79, 68, 338, 72, 83, 83, 71, 82, 82, 83, 84, 84, 85, 85, 74, 84, 335, 82, 86, 86, 87, 87, 85, 330, 86, 88, 88, 89, 89, 90, 90, 91, 91, 319, 87, 92, 92, 93, 96, 96, 93, 91, 95, 95, 317, 95, 88, 97, 97, 99, 98, 98, 99, 90, 89, 96, 98, 100, 100, 101, 316, 97, 101, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 119, 111, 104, 119, 108, 313, 110, 112, 112, 311, 107, 124, 113, 113, 124, 115, 115, 116, 116, 109, 113, 115, 117, 117, 118, 118, 121, 121, 309, 112, 122, 122, 123, 123, 126, 126, 116, 127, 117, 307, 127, 129, 129, 167, 130, 130, 167, 118, 131, 131, 132, 132, 304, 122, 130, 133, 133, 129, 131, 134, 134, 135, 135, 301, 134, 136, 136, 299, 132, 137, 137, 138, 138, 296, 138, 139, 139, 293, 133, 140, 140, 137, 142, 142, 135, 139, 143, 143, 290, 143, 146, 146, 147, 147, 287, 147, 284, 148, 148, 150, 150, 151, 151, 140, 141, 141, 148, 141, 141, 141, 141, 141, 149, 149, 152, 152, 283, 146, 150, 152, 149, 153, 153, 154, 154, 155, 155, 156, 156, 158, 158, 153, 159, 159, 160, 160, 161, 161, 158, 161, 166, 166, 169, 169, 278, 154, 155, 162, 162, 156, 157, 157, 158, 157, 157, 157, 157, 157, 163, 163, 266, 162, 261, 163, 164, 164, 165, 165, 170, 170, 260, 165, 171, 171, 164, 172, 172, 173, 173, 254, 172, 244, 173, 240, 175, 175, 170, 176, 176, 171, 174, 174, 236, 174, 174, 174, 174, 174, 175, 177, 177, 178, 178, 179, 179, 180, 180, 212, 176, 209, 178, 181, 181, 202, 176, 183, 183, 184, 186, 186, 184, 198, 177, 187, 187, 188, 188, 180, 189, 189, 191, 191, 192, 192, 193, 193, 194, 194, 192, 195, 195, 186, 196, 196, 195, 197, 187, 201, 197, 190, 201, 185, 191, 168, 193, 194, 199, 199, 200, 200, 128, 199, 125, 200, 203, 203, 205, 205, 206, 206, 102, 205, 207, 207, 208, 210, 210, 208, 211, 214, 214, 211, 215, 215, 218, 218, 217, 217, 206, 213, 213, 217, 213, 213, 213, 213, 213, 216, 216, 214, 215, 220, 220, 221, 221, 222, 222, 216, 224, 224, 225, 225, 226, 226, 230, 230, 94, 226, 229, 229, 81, 229, 229, 229, 229, 229, 231, 231, 77, 232, 232, 233, 233, 230, 232, 234, 234, 235, 237, 237, 235, 238, 238, 239, 241, 241, 239, 56, 231, 242, 242, 243, 245, 245, 243, 246, 246, 247, 247, 248, 248, 54, 248, 248, 248, 248, 248, 249, 249, 250, 250, 251, 251, 252, 252, 253, 258, 258, 253, 259, 250, 39, 259, 262, 262, 263, 263, 264, 264, 249, 265, 268, 268, 265, 37, 263, 34, 262, 269, 269, 270, 270, 273, 273, 31, 274, 274, 276, 276, 277, 277, 282, 282, 280, 280, 281, 281, 29, 281, 285, 285, 286, 286, 288, 288, 273, 274, 280, 289, 289, 27, 286, 291, 291, 292, 292, 11, 291, 285, 294, 294, 288, 292, 295, 295, 10, 289, 297, 297, 298, 300, 300, 298, 303, 303, 305, 305, 306, 306, 300, 308, 308, 295, 310, 310, 312, 312, 303, 310, 314, 314, 315, 308, 9, 315, 306, 320, 320, 323, 323, 323, 324, 324, 324, 325, 325, 325, 326, 7, 326, 327, 327, 327, 328, 6, 328, 329, 5, 329, 331, 331, 331, 332, 332, 332, 333, 333, 333, 334, 0, 334, 336, 336, 336, 337, 337, 337, 340, 0, 340, 343, 343, 343, 344, 0, 344, 345, 345, 345, 346, 0, 346, 347, 347, 347, 348, 348, 348, 350, 350, 350, 351, 351, 351, 352, 352, 352, 354, 0, 354, 355, 355, 355, 357, 357, 357, 359, 359, 359, 362, 0, 362, 363, 363, 363, 364, 364, 364, 365, 0, 365, 366, 366, 366, 373, 373, 373, 375, 375, 375, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, 322 } ; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "mlex.l" #define INITIAL 0 /* -*- c -*- elmo - ELectronic Mail Operator Copyright (C) 2002, 2003, 2004 rzyjontko This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ------------------------------------------------------------ */ #line 24 "mlex.l" #define __USE_XOPEN #define _GNU_SOURCE /**************************************************************************** * IMPLEMENTATION HEADERS ****************************************************************************/ #include #include #include #include #include #include #include #ifdef HAVE_CONFIG_H # include #endif #ifdef HAVE_LOCALE_H # include #endif #include "xmalloc.h" #include "mlex.h" #include "mail.h" #include "mbox.h" #include "hash.h" #include "elmo.h" #include "address.h" #include "raddress.h" #include "error.h" #include "rstring.h" #include "mime.h" #include "rmime.h" #include "compose.h" #include "misc.h" #include "gettext.h" /**************************************************************************** * IMPLEMENTATION PRIVATE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS ****************************************************************************/ #define EXECUTE(fun) ((fun) ? fun (), 0 : 0) #define YY_DECL int mlex_scan YY_PROTO ((void)) #define YY_BREAK offset += yyleng; break; /* this means currently processed message, that is going to be added */ #define a_mail (mail + mail_index) #define ATEXT "([[:alpha:][:digit:]!#\\$%&\\\\\\'\\*\\+\\/\\=\\?\\^_\\`" \ "\\{\\}\\~\\|\\-])" #define DOT_ATOM_TEXT "(" ATEXT "+(\\." ATEXT "+)*)" #define DOT_ATOM "(" DOT_ATOM_TEXT ")" #define EMAIL_RE "(" DOT_ATOM "@" DOT_ATOM ")" #define FOR_EMAIL_RE "for <" EMAIL_RE ">;" #define WITH_SMTP_RE "with E?SMTP" #define MAX_BOUNDARY_LEN 80 /**************************************************************************** * IMPLEMENTATION PRIVATE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES ****************************************************************************/ /**************************************************************************** * IMPLEMENTATION PRIVATE STRUCTURES / UTILITY CLASSES ****************************************************************************/ struct bound { char boundary[MAX_BOUNDARY_LEN]; int boundary_len; mime_t *mime; }; /**************************************************************************** * IMPLEMENTATION REQUIRED EXTERNAL REFERENCES (AVOID) ****************************************************************************/ /**************************************************************************** * IMPLEMENTATION PRIVATE DATA ****************************************************************************/ /* offset means how many bytes we have already read mail[] is where we write info about letter currently being read the one pointed by newmail (see below) is for reading the second one is for writing mail_index may be 0 or 1, says which mail[] is for writing */ static unsigned offset = 0; static mail_t mail[2]; static int mail_index = 0; /* We use stack to push, and pop all necessary data each time we encounter multipart mime type. It has a constant size for the sake of simplicity. */ static struct bound stack[5]; static int top; /* A regular expression used to get the boundary from the header. */ static int re_compiled = 0; static regex_t bound_re_1; static regex_t bound_re_2; /** * This shows if we are going to get EXACTLY ONE mail. It is possible * that a mail in maildir has line beginning with "From_", just like * in mbox. We must reject the rule then. */ static int only_one = 0; /* This is how I determine if custom headers should be saved in headers rstring. */ static int collect_custom_headers = 0; /** * This holds a pointer to function which should be called after \n\n, * which ends header. It may reset this variable, not to be called * once for each mime-header. */ static void (*after_header_action)(void) = NULL; /**************************************************************************** * INTERFACE DATA ****************************************************************************/ mail_t *newmail = mail + 0; /**************************************************************************** * IMPLEMENTATION PRIVATE FUNCTION PROTOTYPES ****************************************************************************/ static char *unfold_content (char *content); static void clear_mail (time_t tm); static void write_headers (void); static mime_t *parent_mime (void); static mime_t *top_mime (void); static mime_t *top_or_parent_mime (void); static char *top_boundary (void); static int top_boundary_len (void); static void pop (void); static void push (char *boundary, int len); static void replace_top_mime (mime_t *mime); /**************************************************************************** * INTERFACE FUNCTIONS ****************************************************************************/ #define HEADER 1 #define FINISH 2 #line 858 "mlex.c" /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap YY_PROTO(( void )); #else extern int yywrap YY_PROTO(( void )); #endif #endif #ifndef YY_NO_UNPUT static void yyunput YY_PROTO(( int c, char *buf_ptr )); #endif #ifndef yytext_ptr static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen YY_PROTO(( yyconst char * )); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput YY_PROTO(( void )); #else static int input YY_PROTO(( void )); #endif #endif #if YY_STACK_USED static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = 0; #ifndef YY_NO_PUSH_STATE static void yy_push_state YY_PROTO(( int new_state )); #endif #ifndef YY_NO_POP_STATE static void yy_pop_state YY_PROTO(( void )); #endif #ifndef YY_NO_TOP_STATE static int yy_top_state YY_PROTO(( void )); #endif #else #define YY_NO_PUSH_STATE 1 #define YY_NO_POP_STATE 1 #define YY_NO_TOP_STATE 1 #endif #ifdef YY_MALLOC_DECL YY_MALLOC_DECL #else #if __STDC__ #ifndef __cplusplus #include #endif #else /* Just try to get by without declaring the routines. This will fail * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) * or sizeof(void*) != sizeof(int). */ #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( yy_current_buffer->yy_is_interactive ) \ { \ int c = '*', n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(yyin); \ } \ } #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL int yylex YY_PROTO(( void )) #endif /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ if ( yyleng > 0 ) \ yy_current_buffer->yy_at_bol = \ (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 191 "mlex.l" #line 1026 "mlex.c" if ( yy_init ) { yy_init = 0; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! yy_start ) yy_start = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_load_buffer_state(); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = yy_c_buf_p; /* Support of yytext. */ *yy_cp = yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = yy_start; yy_current_state += YY_AT_BOL(); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 323 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 851 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yy_hold_char; yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; goto yy_find_action; case 1: YY_RULE_SETUP #line 193 "mlex.l" { struct tm tm; char *begin; char *tmp; mime_t *mime; if (only_one){ YY_BREAK; } newmail = mail + mail_index; mail_index = 1 - mail_index; /* finish last mail */ if (!newmail->reply_to) newmail->reply_to = newmail->from; mime = top_mime (); if (mime){ mime->off_bound = offset; mime->off_end = offset; } /* this rule ends with return, so it does not reach YY_BREAK */ offset += yyleng; /* begin new mail */ begin = strchr (yytext, ' '); begin = strchr (begin + 1, ' '); while (*(begin + 1) == ' ') begin++; tmp = strptime (begin + 5, "%b %e %T %Y", &tm); if (!tmp){ error_ (0, "wrong time string"); return BROKEN_MAIL; } if (*tmp){ error_ (0, "not all parsed"); return BROKEN_MAIL; } else { offset++; /* to workaround \n that doesn't match */ clear_mail (mktime (&tm)); offset--; } BEGIN (HEADER); return NEXT_MAIL; } YY_BREAK case 2: YY_RULE_SETUP #line 252 "mlex.l" { char *tmp = yytext + 11; while (isspace (*tmp)) tmp++; if (a_mail->mua == NULL){ a_mail->mua = unfold_content (tmp); } } YY_BREAK case 3: YY_RULE_SETUP #line 264 "mlex.l" { char *tmp = yytext + 10; while (isspace (*tmp)) tmp++; if (a_mail->mua == NULL){ a_mail->mua = unfold_content (tmp); } } YY_BREAK case 4: YY_RULE_SETUP #line 276 "mlex.l" { int ret; int len = 0; regmatch_t matches[2]; mime_t *mime = top_mime (); char *str = yytext + 12; mime_set_from_header (mime, str); ret = regexec (& bound_re_1, str, 2, matches, 0); if (ret == REG_NOMATCH) ret = regexec (& bound_re_2, str, 2, matches, 0); if (ret == 0){ len = matches[1].rm_eo - matches[1].rm_so; push (str + matches[1].rm_so, len); } else if (ret != 0 && ret != REG_NOMATCH) error_regex (ret, NULL, "Boundary regexp failure."); } YY_BREAK case 5: YY_RULE_SETUP #line 299 "mlex.l" { mime_t *mime = top_or_parent_mime (); if (mime) mime_complete_file_name (mime, yytext + 20); } YY_BREAK case 6: YY_RULE_SETUP #line 307 "mlex.l" { mime_t *mime = top_mime (); if (mime){ mime->encoding = MENC_NONE; if (strstr (yytext + 26, "uoted") || strstr (yytext + 26, "UOTED")) mime->encoding = MENC_QP; else if (strstr (yytext + 26, "ase64") || strstr (yytext + 26, "ASE64")) mime->encoding = MENC_BASE64; else if (strstr (yytext + 26, "uencode") || strstr (yytext + 26, "UENCODE")) mime->encoding = MENC_UUENCODE; else if (strstr (yytext + 26, "7bit") || strstr (yytext + 26, "7BIT")) mime->encoding = MENC_7BIT; else if (strstr (yytext + 26, "8bit") || strstr (yytext + 26, "8BIT")) mime->encoding = MENC_8BIT; } } YY_BREAK case 7: YY_RULE_SETUP #line 332 "mlex.l" { char *tmp = yytext + 6; char *date; static struct tm tm; if (a_mail->date_str == NULL){ date = unfold_content (tmp); a_mail->date_str = date; while (*date && ! isdigit (*date)) date++; #ifdef HAVE_LOCALE_H setlocale (LC_ALL, "C"); #endif /** * here is a hack that makes it possible to parse a date with * obsolete year notation (2 - digits), we have to try the * obsolete one first, and check if it was possible to get * the date */ tmp = strptime (date, "%d %b %y %H:%M:%S", &tm); if (tmp == NULL) tmp = strptime (date, "%d %b %Y %H:%M:%S", &tm); #ifdef HAVE_LOCALE_H setlocale (LC_ALL, ""); #endif a_mail->date = mktime (&tm); } } YY_BREAK case 8: YY_RULE_SETUP #line 368 "mlex.l" { char *tmp = yytext + 9; if (a_mail->subject == NULL) a_mail->subject = unfold_content (tmp); } YY_BREAK case 9: YY_RULE_SETUP #line 376 "mlex.l" { char *tmp = yytext + 6; char *from; if (a_mail->from == NULL){ from = unfold_content (tmp); a_mail->from = address_from_string (from); xfree (from); } } YY_BREAK case 10: YY_RULE_SETUP #line 388 "mlex.l" { char *tmp = yytext + 4; char *to; if (a_mail->to == NULL){ to = unfold_content (tmp); a_mail->to = raddress_get_from_header (to); xfree (to); } } YY_BREAK case 11: YY_RULE_SETUP #line 400 "mlex.l" { char *tmp = yytext + 4; char *cc; if (a_mail->cc == NULL){ cc = unfold_content (tmp); a_mail->cc = raddress_get_from_header (cc); xfree (cc); } } YY_BREAK case 12: YY_RULE_SETUP #line 412 "mlex.l" { char *tmp = yytext + 4; char *bcc; if (a_mail->bcc == NULL){ bcc = unfold_content (tmp); a_mail->bcc = raddress_get_from_header (bcc); xfree (bcc); } } YY_BREAK case 13: YY_RULE_SETUP #line 424 "mlex.l" { char c; char *pine; char *tmp = yytext + 12; if (a_mail->msg_id == NULL){ a_mail->msg_id = unfold_content (tmp); } if (a_mail->mua == NULL){ tmp = strstr (a_mail->msg_id, "Pine"); if (tmp){ pine = tmp + 13; while (*pine != '.') pine--; c = *pine; *pine = '\0'; a_mail->mua = xstrdup (tmp); *pine = c; } } } YY_BREAK case 14: YY_RULE_SETUP #line 448 "mlex.l" { char *tmp = yytext + 13; char *irt; rstring_t *result; if (a_mail->in_reply_to == NULL){ irt = unfold_content (tmp); result = rstring_create_size (2); result->allocated_first = 1; rstring_add (result, irt); rstring_shrink (result); a_mail->in_reply_to = result; } } YY_BREAK case 15: YY_RULE_SETUP #line 465 "mlex.l" { char *tmp = yytext + 12; if (a_mail->in_reply_to){ rstring_delete (a_mail->in_reply_to); a_mail->in_reply_to = rstring_split_re (unfold_content (tmp), "[ \t\r\n]+"); a_mail->in_reply_to->allocated_first = 1; rstring_shrink (a_mail->in_reply_to); } } YY_BREAK case 16: YY_RULE_SETUP #line 478 "mlex.l" { char *tmp = yytext + 10; char *reply_to; if (a_mail->reply_to == NULL){ reply_to = unfold_content (tmp); a_mail->reply_to = address_from_string (reply_to); xfree (reply_to); } } YY_BREAK case 17: YY_RULE_SETUP #line 490 "mlex.l" { char *i; char *tmp = yytext + 8; if (! only_one){ tmp = unfold_content (tmp); for (i = tmp; *i; i++){ switch (*i){ case 'R': a_mail->flags |= FLAG_READ; break; case 'O': a_mail->flags |= FLAG_OLD; break; default: break; } } xfree (tmp); } } YY_BREAK case 18: YY_RULE_SETUP #line 518 "mlex.l" { char *i; char *tmp = yytext + 10; if (! only_one){ tmp = unfold_content (tmp); for (i = tmp; *i; i++){ switch (*i){ case 'A': a_mail->flags |= FLAG_ANSWERED; break; default: break; } } xfree (tmp); } } YY_BREAK case 19: YY_RULE_SETUP #line 542 "mlex.l" { int len; char *tmp; char *recv_for; regmatch_t matches[1]; if (a_mail->recv_for == NULL){ tmp = yytext + 9; recv_for = unfold_content (tmp); if (misc_regex (WITH_SMTP_RE, recv_for, matches) && misc_regex (FOR_EMAIL_RE, recv_for, matches)){ len = matches[0].rm_eo - matches[0].rm_so - 7 + 1; tmp = xmalloc (len); memcpy (tmp, recv_for + matches[0].rm_so + 5, len - 1); tmp[len - 1] = '\0'; a_mail->recv_for = address_from_string (tmp); xfree (tmp); } xfree (recv_for); } } YY_BREAK case 20: YY_RULE_SETUP #line 566 "mlex.l" { if (a_mail->smtp == NULL) a_mail->smtp = unfold_content (yytext + 12); } YY_BREAK case 21: YY_RULE_SETUP #line 572 "mlex.l" { mime_t *mime = top_or_parent_mime (); BEGIN (INITIAL); EXECUTE (after_header_action); if (mime){ mime->off_start = offset + yyleng; } } YY_BREAK case 22: YY_RULE_SETUP #line 584 "mlex.l" { char *header; if (collect_custom_headers){ header = unfold_content (yytext); if (a_mail->headers == NULL){ a_mail->headers = rstring_create (); a_mail->headers->allocated_all = 1; } rstring_add (a_mail->headers, header); } } YY_BREAK case 23: YY_RULE_SETUP #line 601 "mlex.l" YY_BREAK case 24: YY_RULE_SETUP #line 604 "mlex.l" YY_BREAK case 25: YY_RULE_SETUP #line 607 "mlex.l" { int len; char *boundary; char *seek; mime_t *mime; mime_t *parent; if (top == 0){ YY_BREAK; } boundary = top_boundary (); len = top_boundary_len (); if (boundary == NULL){ YY_BREAK; } seek = strstr (yytext + 2, boundary); if (seek == NULL){ seek = strstr (yytext, boundary); } if (seek == NULL){ YY_BREAK; } if (seek[len] == '-' && seek[len + 1] == '-'){ mime = top_or_parent_mime (); mime->off_bound = offset + yyleng; mime->off_end = offset; pop (); YY_BREAK; } mime = top_or_parent_mime (); mime->off_bound = offset; mime->off_end = offset - 1; parent = parent_mime (); if (parent->parts == NULL) parent->parts = rmime_create_size (4); mime = mime_create (); mime->off_header = offset + yyleng; rmime_add (parent->parts, mime); replace_top_mime (mime); BEGIN (HEADER); } YY_BREAK case 26: YY_RULE_SETUP #line 659 "mlex.l" YY_BREAK case 27: YY_RULE_SETUP #line 662 "mlex.l" YY_BREAK case YY_STATE_EOF(HEADER): #line 665 "mlex.l" { mime_t *mime; mime = top_or_parent_mime (); if (mime != NULL){ mime->off_bound = offset; mime->off_end = offset; } if (! a_mail->reply_to) a_mail->reply_to = a_mail->from; only_one = 0; offset = 0; BEGIN (INITIAL); return EOF_AT_HEADER; } YY_BREAK case 28: YY_RULE_SETUP #line 686 "mlex.l" YY_BREAK case 29: YY_RULE_SETUP #line 689 "mlex.l" YY_BREAK case YY_STATE_EOF(FINISH): #line 692 "mlex.l" { BEGIN (INITIAL); return END_OF_FILE; /** * this is to get rid of warnings */ yyunput (0, NULL); yy_flex_realloc (0, 0); } YY_BREAK case YY_STATE_EOF(INITIAL): #line 705 "mlex.l" { mime_t *mime; mime = top_or_parent_mime (); if (mime == NULL) return END_OF_FILE; mime->off_bound = offset; mime->off_end = offset; if (! a_mail->reply_to) a_mail->reply_to = a_mail->from; BEGIN (FINISH); newmail = mail + mail_index; only_one = 0; offset = 0; return NEXT_MAIL; } YY_BREAK case 30: YY_RULE_SETUP #line 727 "mlex.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK #line 1708 "mlex.c" case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between yy_current_buffer and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ yy_n_chars = yy_current_buffer->yy_n_chars; yy_current_buffer->yy_input_file = yyin; yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = yy_c_buf_p; goto yy_find_action; } } else switch ( yy_get_next_buffer() ) { case EOB_ACT_END_OF_FILE: { yy_did_buffer_switch_on_eof = 0; if ( yywrap() ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: yy_c_buf_p = &yy_current_buffer->yy_ch_buf[yy_n_chars]; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer() { register char *dest = yy_current_buffer->yy_ch_buf; register char *source = yytext_ptr; register int number_to_move, i; int ret_val; if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( yy_current_buffer->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ yy_current_buffer->yy_n_chars = yy_n_chars = 0; else { int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ #ifdef YY_USES_REJECT YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); #else /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = yy_current_buffer; int yy_c_buf_p_offset = (int) (yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yy_flex_realloc( (void *) b->yy_ch_buf, b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; #endif } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), yy_n_chars, num_to_read ); yy_current_buffer->yy_n_chars = yy_n_chars; } if ( yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; yy_current_buffer->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; yy_n_chars += number_to_move; yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state() { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = yy_start; yy_current_state += YY_AT_BOL(); for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 323 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ #ifdef YY_USE_PROTOS static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) #else static yy_state_type yy_try_NUL_trans( yy_current_state ) yy_state_type yy_current_state; #endif { register int yy_is_jam; register char *yy_cp = yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 323 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 322); return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_UNPUT #ifdef YY_USE_PROTOS static void yyunput( int c, register char *yy_bp ) #else static void yyunput( c, yy_bp ) int c; register char *yy_bp; #endif { register char *yy_cp = yy_c_buf_p; /* undo effects of setting up yytext */ *yy_cp = yy_hold_char; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = yy_n_chars + 2; register char *dest = &yy_current_buffer->yy_ch_buf[ yy_current_buffer->yy_buf_size + 2]; register char *source = &yy_current_buffer->yy_ch_buf[number_to_move]; while ( source > yy_current_buffer->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); yy_current_buffer->yy_n_chars = yy_n_chars = yy_current_buffer->yy_buf_size; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; yytext_ptr = yy_bp; yy_hold_char = *yy_cp; yy_c_buf_p = yy_cp; } #endif /* ifndef YY_NO_UNPUT */ #ifdef __cplusplus static int yyinput() #else static int input() #endif { int c; *yy_c_buf_p = yy_hold_char; if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) /* This was really a NUL. */ *yy_c_buf_p = '\0'; else { /* need more input */ int offset = yy_c_buf_p - yytext_ptr; ++yy_c_buf_p; switch ( yy_get_next_buffer() ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart( yyin ); /* fall through */ case EOB_ACT_END_OF_FILE: { if ( yywrap() ) return EOF; if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + offset; break; } } } c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ *yy_c_buf_p = '\0'; /* preserve yytext */ yy_hold_char = *++yy_c_buf_p; yy_current_buffer->yy_at_bol = (c == '\n'); return c; } #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) #else void yyrestart( input_file ) FILE *input_file; #endif { if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_init_buffer( yy_current_buffer, input_file ); yy_load_buffer_state(); } #ifdef YY_USE_PROTOS void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) #else void yy_switch_to_buffer( new_buffer ) YY_BUFFER_STATE new_buffer; #endif { if ( yy_current_buffer == new_buffer ) return; if ( yy_current_buffer ) { /* Flush out information for old buffer. */ *yy_c_buf_p = yy_hold_char; yy_current_buffer->yy_buf_pos = yy_c_buf_p; yy_current_buffer->yy_n_chars = yy_n_chars; } yy_current_buffer = new_buffer; yy_load_buffer_state(); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yy_did_buffer_switch_on_eof = 1; } #ifdef YY_USE_PROTOS void yy_load_buffer_state( void ) #else void yy_load_buffer_state() #endif { yy_n_chars = yy_current_buffer->yy_n_chars; yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; yyin = yy_current_buffer->yy_input_file; yy_hold_char = *yy_c_buf_p; } #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) #else YY_BUFFER_STATE yy_create_buffer( file, size ) FILE *file; int size; #endif { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer( b, file ); return b; } #ifdef YY_USE_PROTOS void yy_delete_buffer( YY_BUFFER_STATE b ) #else void yy_delete_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; if ( b == yy_current_buffer ) yy_current_buffer = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yy_flex_free( (void *) b->yy_ch_buf ); yy_flex_free( (void *) b ); } #ifndef _WIN32 #include #else #ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE extern int isatty YY_PROTO(( int )); #endif #endif #endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) #else void yy_init_buffer( b, file ) YY_BUFFER_STATE b; FILE *file; #endif { yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; #if YY_ALWAYS_INTERACTIVE b->yy_is_interactive = 1; #else #if YY_NEVER_INTERACTIVE b->yy_is_interactive = 0; #else b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif #endif } #ifdef YY_USE_PROTOS void yy_flush_buffer( YY_BUFFER_STATE b ) #else void yy_flush_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == yy_current_buffer ) yy_load_buffer_state(); } #ifndef YY_NO_SCAN_BUFFER #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) #else YY_BUFFER_STATE yy_scan_buffer( base, size ) char *base; yy_size_t size; #endif { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer( b ); return b; } #endif #ifndef YY_NO_SCAN_STRING #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) #else YY_BUFFER_STATE yy_scan_string( yy_str ) yyconst char *yy_str; #endif { int len; for ( len = 0; yy_str[len]; ++len ) ; return yy_scan_bytes( yy_str, len ); } #endif #ifndef YY_NO_SCAN_BYTES #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) #else YY_BUFFER_STATE yy_scan_bytes( bytes, len ) yyconst char *bytes; int len; #endif { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) yy_flex_alloc( n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < len; ++i ) buf[i] = bytes[i]; buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer( buf, n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #endif #ifndef YY_NO_PUSH_STATE #ifdef YY_USE_PROTOS static void yy_push_state( int new_state ) #else static void yy_push_state( new_state ) int new_state; #endif { if ( yy_start_stack_ptr >= yy_start_stack_depth ) { yy_size_t new_size; yy_start_stack_depth += YY_START_STACK_INCR; new_size = yy_start_stack_depth * sizeof( int ); if ( ! yy_start_stack ) yy_start_stack = (int *) yy_flex_alloc( new_size ); else yy_start_stack = (int *) yy_flex_realloc( (void *) yy_start_stack, new_size ); if ( ! yy_start_stack ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } yy_start_stack[yy_start_stack_ptr++] = YY_START; BEGIN(new_state); } #endif #ifndef YY_NO_POP_STATE static void yy_pop_state() { if ( --yy_start_stack_ptr < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN(yy_start_stack[yy_start_stack_ptr]); } #endif #ifndef YY_NO_TOP_STATE static int yy_top_state() { return yy_start_stack[yy_start_stack_ptr - 1]; } #endif #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif #ifdef YY_USE_PROTOS static void yy_fatal_error( yyconst char msg[] ) #else static void yy_fatal_error( msg ) char msg[]; #endif { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ yytext[yyleng] = yy_hold_char; \ yy_c_buf_p = yytext + n; \ yy_hold_char = *yy_c_buf_p; \ *yy_c_buf_p = '\0'; \ yyleng = n; \ } \ while ( 0 ) /* Internal utility routines. */ #ifndef yytext_ptr #ifdef YY_USE_PROTOS static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) #else static void yy_flex_strncpy( s1, s2, n ) char *s1; yyconst char *s2; int n; #endif { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN #ifdef YY_USE_PROTOS static int yy_flex_strlen( yyconst char *s ) #else static int yy_flex_strlen( s ) yyconst char *s; #endif { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif #ifdef YY_USE_PROTOS static void *yy_flex_alloc( yy_size_t size ) #else static void *yy_flex_alloc( size ) yy_size_t size; #endif { return (void *) malloc( size ); } #ifdef YY_USE_PROTOS static void *yy_flex_realloc( void *ptr, yy_size_t size ) #else static void *yy_flex_realloc( ptr, size ) void *ptr; yy_size_t size; #endif { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } #ifdef YY_USE_PROTOS static void yy_flex_free( void *ptr ) #else static void yy_flex_free( ptr ) void *ptr; #endif { free( ptr ); } #if YY_MAIN int main() { yylex(); return 0; } #endif #line 727 "mlex.l" void mlex_init (void) { int ret; ret = regcomp (& bound_re_1, "multipart.*boundary=[ \t\n]*\"([^\"]+)\"", REG_ICASE | REG_EXTENDED); if (ret) error_critical (1, 0, _("Internal error.")); ret = regcomp (& bound_re_2, "multipart.*boundary=[ \t\n]*([^; \n]*);?", REG_ICASE | REG_EXTENDED); if (ret) error_critical (1, 0, _("Internal error.")); re_compiled = 1; } void mlex_free_resources (void) { if (re_compiled){ regfree (& bound_re_1); regfree (& bound_re_2); } re_compiled = 0; } int mlex_scan_file (time_t tm, int collect_headers) { int ret; YY_BUFFER_STATE buffer = yy_create_buffer (yyin, YY_BUF_SIZE); collect_custom_headers = collect_headers; only_one = 1; after_header_action = NULL; clear_mail (tm); BEGIN (HEADER); yy_switch_to_buffer (buffer); ret = mlex_scan (); yy_delete_buffer (buffer); BEGIN (INITIAL); return ret; } int mlex_scan_buffer (char *buf) { int ret; YY_BUFFER_STATE state; YY_BUFFER_STATE old_state = YY_CURRENT_BUFFER; collect_custom_headers = 0; only_one = 1; after_header_action = NULL; clear_mail (0); BEGIN (HEADER); state = yy_scan_string (buf); ret = mlex_scan (); yy_delete_buffer (state); yy_switch_to_buffer (old_state); if (ret == EOF_AT_HEADER || ret == NEXT_MAIL) return NEXT_MAIL; return BROKEN_MAIL; } int mlex_outmail_scan (void) { int ret; time_t tm = time (NULL); YY_BUFFER_STATE buffer = yy_create_buffer (yyin, YY_BUF_SIZE); only_one = 1; collect_custom_headers = 1; after_header_action = write_headers; clear_mail (tm); BEGIN (HEADER); yy_switch_to_buffer (buffer); ret = mlex_scan (); yy_delete_buffer (buffer); BEGIN (INITIAL); return ret; } int mlex_mbox_scan_start (void) { YY_BUFFER_STATE buffer = yy_create_buffer (yyin, YY_BUF_SIZE); collect_custom_headers = 0; only_one = 0; after_header_action = NULL; memset (mail, '\0', sizeof (mail)); BEGIN (INITIAL); yy_switch_to_buffer (buffer); return mlex_scan (); } /**************************************************************************** * STACK OPERATIONS ****************************************************************************/ static void pop (void) { stack[top].mime = NULL; if (top == 0){ return; } top--; } static void push (char *boundary, int len) { if (len >= MAX_BOUNDARY_LEN) len = MAX_BOUNDARY_LEN - 1; memcpy (stack[top].boundary, boundary, len); stack[top].boundary[len] = '\0'; stack[top].boundary_len = len; top++; stack[top].mime = NULL; } static void replace_top_mime (mime_t *mime) { stack[top].mime = mime; } static mime_t * parent_mime (void) { if (top <= 0) return NULL; return stack[top - 1].mime; } static mime_t * top_mime (void) { if (top < 0) return NULL; return stack[top].mime; } static mime_t * top_or_parent_mime (void) { mime_t *result = top_mime (); if (result) return result; if (top <= 0) return NULL; return stack[top - 1].mime; } static char * top_boundary (void) { if (top <= 0) return NULL; return stack[top - 1].boundary; } static int top_boundary_len (void) { if (top <= 0) return -1; return stack[top - 1].boundary_len; } /**************************************************************************** * IMPLEMENTATION PRIVATE FUNCTIONS ****************************************************************************/ /* This function unfolds header content and returns a string containing just one line of plain text. It allocates memory for string, so it should be freed, after use. */ static char * unfold_content (char *content) { char *result = xmalloc (strlen (content) + 1); char *result_ptr = result; char *ptr; while (*content && isspace (*content)) content++; for (ptr = content; *ptr; ptr++){ switch (*ptr){ case '\r': break; default: *result_ptr = *ptr; result_ptr++; break; } } *result_ptr = '\0'; result = mime_decode_header (result, result_ptr - result, 1); return result; } static void clear_mail (time_t tm) { mail_clear (a_mail); a_mail->mime = mime_info_create (); a_mail->mime->mime->off_header = offset; a_mail->place.offset_header = offset; a_mail->date = tm; top = 0; stack[0].mime = a_mail->mime->mime; } static void write_headers (void) { char *msg_id = compose_msg_id (); rstring_t *in_reply_to = compose_in_reply_to (); char *date; if (a_mail->msg_id) xfree (a_mail->msg_id); if (a_mail->in_reply_to) rstring_delete (a_mail->in_reply_to); if (a_mail->date_str) date = a_mail->date_str; else date = compose_date (); a_mail->msg_id = msg_id; a_mail->date_str = date; a_mail->in_reply_to = in_reply_to; after_header_action = NULL; } /**************************************************************************** * INTERFACE CLASS BODIES ****************************************************************************/ /**************************************************************************** * * END MODULE mlex.l * ****************************************************************************/