Fix installation of desktop files.
[metze/wireshark/wip.git] / text2pcap-scanner.l
1 /* -*-mode: flex-*- */
2
3 /*
4  * We don't use input, so don't generate code for it.
5  */
6 %option noinput
7
8 /*
9  * We don't use unput, so don't generate code for it.
10  */
11 %option nounput
12
13 /*
14  * We don't read interactively from the terminal.
15  */
16 %option never-interactive
17
18 %{
19
20 /********************************************************************************
21  *
22  * text2pcap-scanner.l
23  *
24  * Utility to convert an ASCII hexdump into a libpcap-format capture file
25  *
26  * (c) Copyright 2001 Ashok Narayanan <ashokn@cisco.com>
27  *
28  * Wireshark - Network traffic analyzer
29  * By Gerald Combs <gerald@wireshark.org>
30  * Copyright 1998 Gerald Combs
31  *
32  * This program is free software; you can redistribute it and/or
33  * modify it under the terms of the GNU General Public License
34  * as published by the Free Software Foundation; either version 2
35  * of the License, or (at your option) any later version.
36  *
37  * This program is distributed in the hope that it will be useful,
38  * but WITHOUT ANY WARRANTY; without even the implied warranty of
39  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40  * GNU General Public License for more details.
41  *
42  * You should have received a copy of the GNU General Public License
43  * along with this program; if not, write to the Free Software
44  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
45  *
46  *******************************************************************************/
47
48 #include <stdio.h>
49 #include <stdlib.h>
50
51 #include "text2pcap.h"
52
53 /*
54  * Flex (v 2.5.35) uses this symbol to "exclude" unistd.h
55  */
56 #ifdef _WIN32
57 #define YY_NO_UNISTD_H
58 #endif
59
60 #ifdef _WIN32
61 /* disable Windows VC compiler warning "signed/unsigned mismatch" associated  */
62 /* with YY_INPUT code generated by flex versions such as 2.5.35.              */
63 #pragma warning (disable:4018)
64 #endif
65
66 %}
67
68 hexdigit [0-9A-Fa-f]
69 directive #TEXT2PCAP.*
70 comment #[^W].*
71 byte [0-9A-Fa-f][0-9A-Fa-f][ \t]
72 byte_eol [0-9A-Fa-f][0-9A-Fa-f]\r?\n
73 offset [0-9A-Fa-f]+[: \t]
74 offset_eol [0-9A-Fa-f]+\r?\n
75 text [^ \n\t]+
76 mailfwd >
77 eol \r?\n\r?
78
79 %%
80
81 {byte}            { parse_token(T_BYTE, yytext); }
82 {byte_eol}        { parse_token(T_BYTE, yytext); parse_token(T_EOL, NULL); }
83 {offset}          { parse_token(T_OFFSET, yytext); }
84 {offset_eol}      { parse_token(T_OFFSET, yytext); parse_token(T_EOL, NULL); }
85 {mailfwd}{offset} { parse_token(T_OFFSET, yytext+1); }
86 {eol}             { parse_token(T_EOL, NULL); }
87 [ \t]             ; /* ignore whitespace */
88 {directive}       { parse_token(T_DIRECTIVE, yytext); }
89 {comment}         ; /* ignore comments */
90 {text}            { parse_token(T_TEXT, yytext); }
91
92 %%
93
94 int yywrap(void)
95 {
96     return 1;
97 }