4 /* Include this before everything else, for various large-file definitions */
9 * We don't use input, so don't generate code for it.
14 * We don't use unput, so don't generate code for it.
19 * We don't read interactively from the terminal.
21 %option never-interactive
24 * We want to stop processing when we get to the end of the input.
29 * Prefix scanner routines with "text2pcap_" rather than "yy" to avoid a
30 * "redefined macro" warning with flex 2.6.3.
32 %option prefix="text2pcap_"
36 /********************************************************************************
40 * Utility to convert an ASCII hexdump into a libpcap-format capture file
42 * (c) Copyright 2001 Ashok Narayanan <ashokn@cisco.com>
44 * Wireshark - Network traffic analyzer
45 * By Gerald Combs <gerald@wireshark.org>
46 * Copyright 1998 Gerald Combs
48 * This program is free software; you can redistribute it and/or
49 * modify it under the terms of the GNU General Public License
50 * as published by the Free Software Foundation; either version 2
51 * of the License, or (at your option) any later version.
53 * This program is distributed in the hope that it will be useful,
54 * but WITHOUT ANY WARRANTY; without even the implied warranty of
55 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56 * GNU General Public License for more details.
58 * You should have received a copy of the GNU General Public License
59 * along with this program; if not, write to the Free Software
60 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
62 *******************************************************************************/
67 #include "text2pcap.h"
70 * Disable diagnostics in the code generated by Flex.
75 * Flex (v 2.5.35) uses this symbol to "exclude" unistd.h
78 #define YY_NO_UNISTD_H
84 directive ^#TEXT2PCAP.*\r?\n
85 comment ^[\t ]*#.*\r?\n
86 byte [0-9A-Fa-f][0-9A-Fa-f][ \t]
87 byte_eol [0-9A-Fa-f][0-9A-Fa-f]\r?\n
88 offset [0-9A-Fa-f]+[: \t]
89 offset_eol [0-9A-Fa-f]+\r?\n
96 {byte} { if (parse_token(T_BYTE, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }
97 {byte_eol} { if (parse_token(T_BYTE, yytext) != EXIT_SUCCESS) return EXIT_FAILURE;
98 if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
99 {offset} { if (parse_token(T_OFFSET, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }
100 {offset_eol} { if (parse_token(T_OFFSET, yytext) != EXIT_SUCCESS) return EXIT_FAILURE;
101 if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
102 {mailfwd}{offset} { if (parse_token(T_OFFSET, yytext+1) != EXIT_SUCCESS) return EXIT_FAILURE; }
103 {eol} { if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
104 [ \t] ; /* ignore whitespace */
105 {directive} { if (parse_token(T_DIRECTIVE, yytext) != EXIT_SUCCESS) return EXIT_FAILURE;
106 if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
107 {comment} { if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
108 {text} { if (parse_token(T_TEXT, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }
113 * Turn diagnostics back on, so we check the code that we've written.
122 ret = text2pcap_lex();
123 text2pcap_lex_destroy();