nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* -*-mode: flex-*- */ |
2 | |||
3 | %top { |
||
4 | /* Include this before everything else, for various large-file definitions */ |
||
5 | #include "config.h" |
||
6 | } |
||
7 | |||
8 | /* |
||
9 | * We want a reentrant scanner. |
||
10 | */ |
||
11 | %option reentrant |
||
12 | |||
13 | /* |
||
14 | * We don't use input, so don't generate code for it. |
||
15 | */ |
||
16 | %option noinput |
||
17 | |||
18 | /* |
||
19 | * We don't use unput, so don't generate code for it. |
||
20 | */ |
||
21 | %option nounput |
||
22 | |||
23 | /* |
||
24 | * We don't read interactively from the terminal. |
||
25 | */ |
||
26 | %option never-interactive |
||
27 | |||
28 | /* |
||
29 | * We want to stop processing when we get to the end of the input. |
||
30 | */ |
||
31 | %option noyywrap |
||
32 | |||
33 | /* |
||
34 | * Prefix scanner routines with "text_import_" rather than "yy", so this scanner |
||
35 | * can coexist with other scanners. |
||
36 | */ |
||
37 | %option prefix="text_import_" |
||
38 | |||
39 | /* |
||
40 | * We have to override the memory allocators so that we don't get |
||
41 | * "unused argument" warnings from the yyscanner argument (which |
||
42 | * we don't use, as we have a global memory allocator). |
||
43 | * |
||
44 | * We provide, as macros, our own versions of the routines generated by Flex, |
||
45 | * which just call malloc()/realloc()/free() (as the Flex versions do), |
||
46 | * discarding the extra argument. |
||
47 | */ |
||
48 | %option noyyalloc |
||
49 | %option noyyrealloc |
||
50 | %option noyyfree |
||
51 | |||
52 | %{ |
||
53 | |||
54 | /******************************************************************************** |
||
55 | * |
||
56 | * text_import_scanner.l |
||
57 | * Scanner for text import |
||
58 | * November 2010, Jaap Keuter <jaap.keuter@xs4all.nl> |
||
59 | * |
||
60 | * Wireshark - Network traffic analyzer |
||
61 | * By Gerald Combs <gerald@wireshark.org> |
||
62 | * Copyright 1998 Gerald Combs |
||
63 | * |
||
64 | * Based on text2pcap-scanner.l by Ashok Narayanan <ashokn@cisco.com> |
||
65 | * |
||
66 | * This program is free software; you can redistribute it and/or |
||
67 | * modify it under the terms of the GNU General Public License |
||
68 | * as published by the Free Software Foundation; either version 2 |
||
69 | * of the License, or (at your option) any later version. |
||
70 | * |
||
71 | * This program is distributed in the hope that it will be useful, |
||
72 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
73 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
74 | * GNU General Public License for more details. |
||
75 | * |
||
76 | * You should have received a copy of the GNU General Public License |
||
77 | * along with this program; if not, write to the Free Software |
||
78 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||
79 | * |
||
80 | *******************************************************************************/ |
||
81 | |||
82 | #include <stdio.h> |
||
83 | #include <stdlib.h> |
||
84 | |||
85 | #include "text_import_scanner.h" |
||
86 | |||
87 | /* |
||
88 | * Flex (v 2.5.35) uses this symbol to "exclude" unistd.h |
||
89 | */ |
||
90 | #ifdef _WIN32 |
||
91 | # define YY_NO_UNISTD_H |
||
92 | |||
93 | /* disable Windows VC compiler warning "signed/unsigned mismatch" associated */ |
||
94 | /* with YY_INPUT code generated by flex versions such as 2.5.35. */ |
||
95 | # pragma warning (disable:4018) |
||
96 | #endif |
||
97 | |||
98 | /* |
||
99 | * Sleazy hack to suppress compiler warnings in yy_fatal_error(). |
||
100 | */ |
||
101 | #define YY_EXIT_FAILURE ((void)yyscanner, 2) |
||
102 | |||
103 | /* |
||
104 | * Macros for the allocators, to discard the extra argument. |
||
105 | */ |
||
106 | #define text_import_alloc(size, yyscanner) (void *)malloc(size) |
||
107 | #define text_import_realloc(ptr, size, yyscanner) (void *)realloc((char *)(ptr), (size)) |
||
108 | #define text_import_free(ptr, yyscanner) free((char *)ptr) |
||
109 | |||
110 | %} |
||
111 | |||
112 | hexdigit [0-9A-Fa-f] |
||
113 | directive ^#TEXT2PCAP.*\r?\n |
||
114 | comment ^[\t ]*#.*\r?\n |
||
115 | byte [0-9A-Fa-f][0-9A-Fa-f][ \t] |
||
116 | byte_eol [0-9A-Fa-f][0-9A-Fa-f]\r?\n |
||
117 | offset [0-9A-Fa-f]+[: \t] |
||
118 | offset_eol [0-9A-Fa-f]+\r?\n |
||
119 | text [^ \n\t]+ |
||
120 | mailfwd > |
||
121 | eol \r?\n\r? |
||
122 | |||
123 | %% |
||
124 | |||
125 | {byte} { parse_token(T_BYTE, yytext); } |
||
126 | {byte_eol} { parse_token(T_BYTE, yytext); parse_token(T_EOL, NULL); } |
||
127 | {offset} { parse_token(T_OFFSET, yytext); } |
||
128 | {offset_eol} { parse_token(T_OFFSET, yytext); parse_token(T_EOL, NULL); } |
||
129 | {mailfwd}{offset} { parse_token(T_OFFSET, yytext+1); } |
||
130 | {eol} { parse_token(T_EOL, NULL); } |
||
131 | [ \t] ; /* ignore whitespace */ |
||
132 | {directive} { parse_token(T_DIRECTIVE, yytext); parse_token(T_EOL, NULL); } |
||
133 | {comment} { parse_token(T_EOL, NULL); } |
||
134 | {text} { parse_token(T_TEXT, yytext); } |
||
135 | |||
136 | <<EOF>> { write_current_packet(); yyterminate(); } |