Revert "HACK setup decryption keys for kerberos session setups smbclient..."
[metze/wireshark/wip.git] / text2pcap-scanner.l
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 don't use input, so don't generate code for it.
10  */
11 %option noinput
12
13 /*
14  * We don't use unput, so don't generate code for it.
15  */
16 %option nounput
17
18 /*
19  * We don't read interactively from the terminal.
20  */
21 %option never-interactive
22
23 /*
24  * We want to stop processing when we get to the end of the input.
25  */
26 %option noyywrap
27
28 /*
29  * Prefix scanner routines with "text2pcap_" rather than "yy" to avoid a
30  * "redefined macro" warning with flex 2.6.3.
31  */
32 %option prefix="text2pcap_"
33
34 %{
35
36 /********************************************************************************
37  *
38  * text2pcap-scanner.l
39  *
40  * Utility to convert an ASCII hexdump into a libpcap-format capture file
41  *
42  * (c) Copyright 2001 Ashok Narayanan <ashokn@cisco.com>
43  *
44  * Wireshark - Network traffic analyzer
45  * By Gerald Combs <gerald@wireshark.org>
46  * Copyright 1998 Gerald Combs
47  *
48  * SPDX-License-Identifier: GPL-2.0-or-later
49  *
50  *******************************************************************************/
51
52 #include <stdio.h>
53 #include <stdlib.h>
54
55 #include "text2pcap.h"
56
57 /*
58  * Disable diagnostics in the code generated by Flex.
59  */
60 DIAG_OFF_FLEX
61
62 /*
63  * Flex (v 2.5.35) uses this symbol to "exclude" unistd.h
64  */
65 #ifdef _WIN32
66 #define YY_NO_UNISTD_H
67 #endif
68
69 %}
70
71 directive ^#TEXT2PCAP.*\r?\n
72 comment ^[\t ]*#.*\r?\n
73 byte [0-9A-Fa-f][0-9A-Fa-f][ \t]?
74 byte_eol [0-9A-Fa-f][0-9A-Fa-f]\r?\n
75 offset [0-9A-Fa-f]+[: \t]
76 offset_eol [0-9A-Fa-f]+\r?\n
77 text [^ \n\t]+
78 mailfwd >
79 eol \r?\n\r?
80
81 %%
82
83 {byte}            { if (parse_token(T_BYTE, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }
84 {byte_eol}        { if (parse_token(T_BYTE, yytext) != EXIT_SUCCESS) return EXIT_FAILURE;
85         if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
86 {offset}          { if (parse_token(T_OFFSET, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }
87 {offset_eol}      { if (parse_token(T_OFFSET, yytext) != EXIT_SUCCESS) return EXIT_FAILURE;
88         if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
89 {mailfwd}{offset} { if (parse_token(T_OFFSET, yytext+1) != EXIT_SUCCESS) return EXIT_FAILURE; }
90 {eol}             { if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
91 [ \t]             ; /* ignore whitespace */
92 {directive}       { if (parse_token(T_DIRECTIVE, yytext) != EXIT_SUCCESS) return EXIT_FAILURE;
93         if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
94 {comment}         { if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
95 {text}            { if (parse_token(T_TEXT, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }
96
97 %%
98
99 /*
100  * Turn diagnostics back on, so we check the code that we've written.
101  */
102 DIAG_ON_FLEX
103
104 int
105 text2pcap_scan(void)
106 {
107     int ret;
108
109     ret = text2pcap_lex();
110     text2pcap_lex_destroy();
111     return ret;
112 }