Commit Graph

29 Commits

Author SHA1 Message Date
João Valverde 1acae21bcd Windows: Fix warnings using flex
Fix some warnings complaining of macro redefinitions with stdint.h.
Include stdint.h via wireshark.h everywhere so it stays fixed.
2021-10-22 06:41:44 +00:00
João Valverde 59c082c046 Add new global header wireshark.h with guideline
Remove ws_diag_control.h from config.h because that was a workaround
for the lack of a public global header. Fix the resultant build errors.
2021-10-22 06:41:44 +00:00
Peter Wu 22cf80d30d text2pcap: gracefully handle hexdump without trailing LF
When copying hexdumps, the newline might be missing which would result
in a capture file missing one byte in its packet. Adjust the grammar to
recognize the two trailing hexadecimal characters as a "byte".

This is safe because Flex picks the rule that matches the longest input
string. So given "01 ", it will always match all three characters. If
something like "01x" is given, then the "text" rule will be matched (as
before). Only if no more characters are available (such as at the end of
a file), then the rule will match two hexdigits.

Remove the unnecessary hexdigit rule while at it.

Change-Id: I21dc37d684d1c410ce720cb27706a6e54f87f94d
Reviewed-on: https://code.wireshark.org/review/30190
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-13 05:16:22 +00:00
Dario Lombardo fe71e26af2 spdx: more licenses converted.
Change-Id: I3861061ec261e63b23621799e020e811ed78a343
Reviewed-on: https://code.wireshark.org/review/26333
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-03-07 15:56:44 +00:00
Guy Harris 4a69d10920 Squelch redundant declaration warnings.
Have the text-to-pcap scanners define a routine that the main code
calls, which both allocates and destroys the scanner.  Don't declare the
Lex-generated routines in a header file we create, declare that routine,
instead.

Change-Id: Icad6a83db1a0dea8ac390315af72383fc99f8513
Reviewed-on: https://code.wireshark.org/review/25822
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-16 22:40:26 +00:00
Guy Harris 72b57ac4ef Use DIAG_OFF_FLEX/DIAG_ON_FLEX more consistently.
Add warning C4267 (size_t to int conversion) with MSVC to DIAG_OFF_FLEX.

Addd -Wshorten-64-to-32 with Clang and GCC to DIAG_OFF_FLEX.

Don't explicitly use #pragma to turn off warnings; use DIAG_OFF_FLEX for
all of them.

If we use DIAG_OFF_FLEX, use DIAG_ON_FLEX, even if we have no section of
entirely included code at the end.

Change-Id: Ibfd44e8954704e9a8bcb1bd8e54f31d28357fffb
Reviewed-on: https://code.wireshark.org/review/25817
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-16 19:54:16 +00:00
Guy Harris 8bc1c6e3e8 Add DIAG_OFF_FLEX and DIAG_ON_FLEX for use in Flex scanners.
DIAG_OFF_FLEX turns off all warnings that we want to disable for
Flex-generated code due to some versions of Flex generating code that
triggers those warnings.

DIAG_ON_FLEX restores those warnings, so we do the checks for code that
*we* wrote.

Use them in .l files.

Change-Id: I613a20309a30cd4c61111a1edbe27a5d05fcbf59
Reviewed-on: https://code.wireshark.org/review/25815
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-16 10:35:10 +00:00
João Valverde 8615e78630 Disable flex-generated [-Wsign-compare] warnings
Change-Id: Iace0462e6bb50573f3e4603f7a19e4b7ee1f9733
Reviewed-on: https://code.wireshark.org/review/23541
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-19 10:06:07 +00:00
Peter Wu 220772dc19 text2pcap: fix -Wmacro-redefined warning
With flex 2.6.3, this warning is observed (which causes a build failure
when -Werror is not disabled:

    text2pcap-scanner.c:398:9: warning: 'yywrap' macro redefined [-Wmacro-redefined]
    #define yywrap() (/*CONSTCOND*/1)
            ^
    text2pcap-scanner.c:76:13: note: previous definition is here
        #define yywrap yywrap

Issue is specific to flex 2.6.3 and resolved upstream at
https://github.com/westes/flex/issues/162

Change-Id: I861565f5080f87a9457427e7a63b5d9256c49e85
Reviewed-on: https://code.wireshark.org/review/20294
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-27 12:52:36 +00:00
Dario Lombardo 513eed6871 text2pcap: check return values of functions and use a single exit point.
This is going to check every function for success and following patches
will free allocated memory in clean_exit.

Change-Id: I7ba7a53eae8a37a4c25e56369af20e575c3489fb
Reviewed-on: https://code.wireshark.org/review/20225
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-27 00:51:37 +00:00
Guy Harris 6f37317539 Include config.h at the very beginning of all Flex scanners.
That way, if we #define anything for large file support, that's done
before we include any system header files that either depend on that
definition or that define it themselves if it's not already defined.

Change-Id: I9b07344151103be337899dead44d6960715d6813
Reviewed-on: https://code.wireshark.org/review/19035
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-02 21:02:10 +00:00
Vasil Velichckov d5c1449d1b [text2pcap] Fix parsing of hash sign at the end of the line
Change-Id: I4ff1ef28aba353fd7548cb5c0603fc29479aa854
Reviewed-on: https://code.wireshark.org/review/13294
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-02-04 05:13:16 +00:00
Guy Harris f51bad11d7 Use noyywrap rather than defining our own yywrap functions.
Tweak lemonflex-tail.inc to fix an issue this reveals.

It appears that, at least on the buildbots, the Visual Studio compiler
no longer issues warnings for the code generated with %option noyywrap.

Change-Id: Id64d56f1ae8a79d0336488a4a50518da1f511497
Reviewed-on: https://code.wireshark.org/review/12433
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-05 08:06:50 +00:00
Guy Harris 018e93a384 Another unnecessary include of io.h.
Change-Id: Ie4a8d79474ae61194b1ceaafad45cca9b2970b60
Reviewed-on: https://code.wireshark.org/review/11589
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-06 07:48:40 +00:00
Guy Harris ce22578996 Don't include io.h in Flex scanners - they're not interactive.
We don't have any Flex scanners that support an interactive command-line
interface, so none of our scanners are, or need to be, interactive.
Mark text2pcap's scanner as not interactive.

That means none of our scanners should call isatty(), so they don't have
any need to include <io.h> on Windows; remove that include from the
Lucent/Ascent text capture scanner.

Update a comment to reflect that what matters isn't whether we can read
from a terminal or whether we actually do so, what matters is whether
they read *interactively* from a terminal (if you want to run text2pcap
reading from the standard input and type at it, be my guest).

Change-Id: I59979d1fdb37e1913125a400963ff7a3fa6b9bbd
Reviewed-on: https://code.wireshark.org/review/11587
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-06 01:14:31 +00:00
Bill Meier 8fad63807a text2pcap-scanner.l: On Windows: #include <io.h> req'd for isatty()
Change-Id: I6464f11c3bc5f8dd671f6f36006fb74059d30b26
Reviewed-on: https://code.wireshark.org/review/3776
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-08-21 17:20:17 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Guy Harris 0a20c5dd91 Add %option noinput to some Flex files, as we aren't using the input()
routine and thus don't need to have it generated - and as it produces
warnings of a routine defined but not used, we don't want to have it
generated.

svn path=/trunk/; revision=47616
2013-02-10 20:21:05 +00:00
Bill Meier bf4844eb99 Fix some gcc 'old-style function definition' warnings.
svn path=/trunk/; revision=37482
2011-05-31 15:49:59 +00:00
Bill Meier a34ed6fcff Handle lines ending in \r\n.
Fixes Bug #4780 
See: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4780

svn path=/trunk/; revision=32956
2010-05-25 22:27:00 +00:00
Bill Meier 2bce8b248c Bug 2493: Fix (Part 3 of 3):
To prevent Windows compiler errors when using flex 2.5.35.
  Ignore 'signed /unsigned mismatch' warnings


svn path=/trunk/; revision=25174
2008-04-25 18:26:54 +00:00
Bill Meier 0d4b874b44 Bug 2493: Fix (Part 2):
To prevent Windows compiler errors when using flex 2.5.35.
 Fixes "missing unistd.h" and yywrap "mismatched parameter" warnings
 [Upcoming Part 3: ignore 'signed /unsigned mismatch' errors]

svn path=/trunk/; revision=25173
2008-04-25 17:40:29 +00:00
Guy Harris 968d363f11 Add comments to various %option items to explain what they're doing.
Move the %options to the beginning if they weren't already there, and
put them in the same order in all files.

Add "prefix=" options to .l files that don't already have them, so we
don't have to pass a "-P" option.

Add "never-interactive" and "noyywrap" options to our lexical analyzers,
to remove extra isatty() checks and to eliminate the need for yywrap()
from the Flex library.

Get rid of %option nostdinit - that's the default.

Add .l.c: rules to Makefile.am files, replacing the rules for specific
.l files.  Have those rules all check that $(LEX) is set.

Update the address for the FSF.

svn path=/trunk/; revision=22424
2007-07-30 20:22:37 +00:00
Richard van der Hoff 8cebae3c33 disable unput here, too
svn path=/trunk/; revision=21323
2007-04-03 19:28:59 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00
Guy Harris 8a8b883450 Set the svn:eol-style property on all text files to "native", so that
they have LF at the end of the line on UN*X and CR/LF on Windows;
hopefully this means that if a CR/LF version is checked in on Windows,
the CRs will be stripped so that they show up only when checked out on
Windows, not on UN*X.

svn path=/trunk/; revision=11400
2004-07-18 00:24:25 +00:00
Guy Harris e690b88d75 Fix to text2pcap to handle colons after offset field, from Gordon
McKinney.

svn path=/trunk/; revision=4256
2001-11-24 09:46:28 +00:00
Guy Harris 0bc13df91e Treat a bunch of digits followed by a newline differently from a bunch
of digits followed by a blank or tab, so that we recognize the newline
as an end-of-line.

svn path=/trunk/; revision=4249
2001-11-24 02:13:34 +00:00
Ashok Narayanan 2914e81177 Added 'text2pcap', a utility to convert text hexdumps into pcap
files. See text2pcap.1 (built from doc/text2pcap.pod) for details.

Changed 'tethereal -x' output to match hex dump format of text2pcap,
Ethereal and others.

svn path=/trunk/; revision=3421
2001-05-16 21:32:05 +00:00