Commit Graph

34 Commits

Author SHA1 Message Date
João Valverde 0ccd69e530 Replace g_strdup_printf() with ws_strdup_printf()
Use macros from inttypes.h.
2021-12-19 21:21:58 +00:00
Gerald Combs 9222bd77cd Remove unneeded modelines in ui.
Remove the editor modeline blocks from the source files in ui that use 4
space indentation by running

perl -i -p0e 's{ \n+ /[ *\n]+ editor \s+ modelines .* shiftwidth= .* \*/ \s+ } {\n}gsix' $( ag -l shiftwidth=4 $( ag -g '\.(c|cpp|h|m|mm)') )

This gives us one source of indentation truth for these files, and it
*shouldn't* affect anyone since

- These files match the default in our top-level .editorconfig.

- The one notable editor that's likely to be used on these files and
*doesn't* support EditorConfig (Qt Creator) defaults to 4 space
indentation.
2021-04-20 07:43:39 +00:00
Guy Harris 24acef0885 wiretap: file types have a name and a description.
The "short name" is really just the name, used to look it up.  The
"name" is really a description intended solely for human consumption.
Rename the fields, and the functions that access them, to match.

The "description" maintained by Lua for file type handlers is used
*only* for one debugging message; we should probably just eliminate it.
Call it an "internal description" for now.
2021-02-13 01:25:39 -08:00
Guy Harris 6e6233521a Have WTAP_ERR_INTERNAL include an err_info string giving details.
That way, users won't just see "You got an internal error", the details
will be given, so they can report them in a bug.
2020-10-14 04:51:45 +00:00
Dario Lombardo f3b82ffae7 ui: add missing break.
Error:
../ui/alert_box.c: In function ‘cfile_write_failure_alert_box’:
../ui/alert_box.c:359:13: error: this statement may fall through [-Werror=implicit-fallthrough=]
             simple_error_message_box(
             ^~~~~~~~~~~~~~~~~~~~~~~~~
                         "Frame %u%s has a network type that differs from the network type of earlier packets, which isn't supported in a \"%s\" file.",
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         framenum, in_file_string,
                         ~~~~~~~~~~~~~~~~~~~~~~~~~
                         wtap_file_type_subtype_string(file_type_subtype));
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../ui/alert_box.c:364:9: note: here
         case WTAP_ERR_PACKET_TOO_LARGE:
         ^~~~

Change-Id: I55464afff5625ae8c587470e417234560c7e606c
Reviewed-on: https://code.wireshark.org/review/30623
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-11-14 09:30:55 +00:00
Guy Harris 3aec5e1a28 Catch attempts to write multiple encapsulation types if unsupported.
If, in the process of opening the input file, we determine that it has
packets of more than one link-layer type, we can catch attempts to write
that file to a file of a format that doesn't support more than one
link-layer type at the time we try to open the output file.

If, however, we don't discover that the file has more than one
link-layer type until we've already created the output file - for
example, if we have a pcapng file with a new IDB, with a different
link-layer type from previous IDBs, after packet blocks for the earlier
interfces - we can't catch that until we try to write the packet.

Currently, that causes the packet's data to be written out as is, so the
output file claims it's of the file's link-layer type, causing programs
reading the file to misdissect the packet.

Report WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED on the write attempt
instead, and have a nicer error message for
WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED on a write.

Change-Id: Ic41f2e4367cfe5667eb30c88cc6d3bfe422462f6
Reviewed-on: https://code.wireshark.org/review/30617
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-14 03:38:45 +00:00
Stig Bjørlykke 14720ace06 Fix comment end after SPDX identifier
Move */ to a separate line below the SPDX identifier.

Change-Id: Id1032215449cfccae0933147b45e04b65e0b727f
Reviewed-on: https://code.wireshark.org/review/27211
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-01 06:56:37 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
The first is deprecated, as per https://spdx.org/licenses/.

Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed
Reviewed-on: https://code.wireshark.org/review/25661
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 14:57:36 +00:00
Dario Lombardo e5f4ef0c42 ui: use SPDX identifiers.
Change-Id: I6b05399395bcc35e59b73b4030ba4a05711a7b1a
Reviewed-on: https://code.wireshark.org/review/25565
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-02-02 13:39:04 +00:00
Guy Harris 9cc00c5623 Check for gzipped files even if we don't have libz.
If we aren't built with libz, report a new "decompression not supported"
error if the file is gzipped; the problem isn't that it's a new capture
file format we don't support, it's that a *compressed* capture file, in
some format, but we don't support the *compression* format used.

This can be extended if we add support for other compression formats.

Change-Id: I19239525d4e02357e3ca7189996556839af8fce2
Reviewed-on: https://code.wireshark.org/review/25315
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-01-14 21:08:18 +00:00
Guy Harris 64ec2b2e5e Take the error message generation out of the merge_files routines.
Have them just return the information needed for the caller to produce
an error message, and have the callers use the new cfile_ routines for
reporting errors.

This requires that the "write failure alert box" routine take the
*input* file name as an argument, so that, on a merge, if the problem is
that a record from a given input file can't be written out to the type
of output file we're generating, the input file name can be given, along
with the record number in that file.

Change-Id: If5a5e00539e7e652008a523dec92c0b359a48e71
Reviewed-on: https://code.wireshark.org/review/21257
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-20 20:25:59 +00:00
Guy Harris 9e9d284d91 Have separate routines for open-for-reading and open-for-writing errors.
Expand comments while we're at it.

Change-Id: I6dcc791eab1c9e323a9572f3d54720d223bdd64b
Reviewed-on: https://code.wireshark.org/review/21252
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-20 18:24:20 +00:00
Guy Harris d09ef61459 Make the command-line and alert-box failure messages more similar.
Change-Id: I94af221a0ce8b6b3ff8e0e1b94d5379351ac0962
Reviewed-on: https://code.wireshark.org/review/21251
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-20 17:15:22 +00:00
Guy Harris 9e36106baf Have a common "capture file write failure alert box" routine.
Take the code from save_record() to pop up an alert box and put it into
libui, with the name cfile_write_failure_alert_box().

While we're at it, clean up some variable names and comments.

Change-Id: If56e649e5afe50e7a20b39720ec96e8fe2983b24
Reviewed-on: https://code.wireshark.org/review/21233
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-19 22:06:59 +00:00
Guy Harris 4362e63dd5 Have a common "capture file close alert box" routine.
Take the code from cf_read() to pop up an alert box and put it into
libui, with the name cfile_read_failure_alert_box().  Use it in a couple
of places where we pop up such an error dialog.

While we're at it, get rid of the "err" argument to rescan_file();
nobody uses what it returns.

Change-Id: Iba7099b95de24309359d94eb96f606020e2ff2c3
Reviewed-on: https://code.wireshark.org/review/21232
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-19 21:43:47 +00:00
Guy Harris e6b9c7706f Fix a comment.
Change-Id: I2ed361efdaa6dcf632f054634dc473d518df4cc8
Reviewed-on: https://code.wireshark.org/review/21204
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-18 21:08:16 +00:00
Guy Harris 1015fa0431 Have a common "capture file close alert box" routine.
Take cf_close_failure_alert_box() and put it into libui, with the name
cfile_close_failure_alert_box().  Use it not only in file.c but also
in ui/export_pdu_ui_utils.c, ui/gtk/file_import_dlg.c, and
ui/qt/import_text_dialog.cpp where the error we get back isn't
necessarily an errno.

Have ui/gtk/file_import_dlg.c and ui/qt/import_text_dialog.cpp also use
cfile_open_failure_alert_box() on open errors.

Change-Id: I987f339a23ea58609390306a319923e7f92d5c07
Reviewed-on: https://code.wireshark.org/review/21203
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-18 21:02:54 +00:00
Guy Harris e34d76942c Have a commont "capture file open alert box" routine.
Take cf_open_failure_alert_box() and put it into libui, with the name
cfile_open_failure_alert_box().  Use it not only in file.c but also in
ui/export_pdu_ui_utils.c, where the error we get back isn't necessarily
an errno.

Change-Id: Ia053f3e403ba464d446bd9530778d5ed302796d2
Reviewed-on: https://code.wireshark.org/review/21174
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-18 01:59:32 +00:00
Guy Harris f0a24bee89 Have vwarning_alert_box() pop up a warning, not an error.
Change-Id: I993133931af222c94f4a8814583fef97e49542ca
Reviewed-on: https://code.wireshark.org/review/20972
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-09 02:54:36 +00:00
Guy Harris 2c44a7f930 Clean up handling of enabled/disabled protocols/heuristic dissectors.
Add a "report a warning message" routine to the "report_err" code in
libwsutil, and rename files and routines appropriately, as they don't
only handle errors any more.

Have a routine read_enabled_and_disabled_protos() that reads all the
files that enable or disable protocols or heuristic dissectors, enables
and disables them based on the contents of those files, and reports
errors itself (as warnings) using the new "report a warning message"
routine.  Fix that error reporting to report separately on the disabled
protocols, enabled protocols, and heuristic dissectors files.

Have a routine to set up the enabled and disabled protocols and
heuristic dissectors from the command-line arguments, so it's done the
same way in all programs.

If we try to enable or disable an unknown heuristic dissector via a
command-line argument, report an error.

Update a bunch of comments.

Update the name of disabled_protos_cleanup(), as it cleans up
information for disabled *and* enabled protocols and for heuristic
dissectors.

Support the command-line flags to enable and disable protocols and
heuristic dissectors in tfshark.

Change-Id: I9b8bd29947cccdf6dc34a0540b5509ef941391df
Reviewed-on: https://code.wireshark.org/review/20966
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-08 20:40:08 +00:00
Guy Harris f0ada20a91 Make failure_alert_box() be printf-like.
Have it be printf-like, and have vfailure_alert_box() be vprintf-like.

Rename a few variables to make it clearer what pointers point to
vprintf-like functions.

Change-Id: I960e2138a18edcc742c450d68a0c6f7248f50c3f
Reviewed-on: https://code.wireshark.org/review/14646
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-27 02:06:28 +00:00
Martin Mathieson 43f09e67b4 Remove unneeded includes from ui folder
Change-Id: Ifd1eebff9080cd3867e44e4dcb2d2681370ed60a
Reviewed-on: https://code.wireshark.org/review/6128
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2015-01-01 23:11:10 +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
Jakub Zawadzki 82e2675f45 Avoid including <wiretap/wtap.h> in dissectors.
svn path=/trunk/; revision=53655
2013-11-29 20:53:00 +00:00
Guy Harris db25270df8 Move the epan/filesystem.c routines to wsutil; they're not specific to
packet dissection, they're specific to the entire Wireshark suite of
programs.

svn path=/trunk/; revision=53377
2013-11-17 02:55:14 +00:00
Guy Harris 0b7d789607 Clean up indentation.
svn path=/trunk/; revision=49279
2013-05-13 23:17:12 +00:00
Alexis La Goutte 14f2efec2b Fix indent and add Modelines info for new common ui source file(s)
svn path=/trunk/; revision=45765
2012-10-24 15:52:26 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Guy Harris 29e4e24184 Add "simple dialog" routines to pop up modal message boxes. Use them in
file.c and routines called from it; non-modal dialogs end up, in some
cases, either hidden, devoid of the input focus and not dismissable, or
both.

svn path=/trunk/; revision=43321
2012-06-17 22:32:03 +00:00
Guy Harris 00de07144d Use the modal version of the bad display filter alert box in the I/O
statistics window.

Get rid of the non-modal version (it's not being used any more), and
remove the now-redundant _modal from the modal version.

svn path=/trunk/; revision=43081
2012-06-04 20:08:59 +00:00
Guy Harris 9e79ec13bf Move alert_box.c to the ui directory.
svn path=/trunk/; revision=41436
2012-03-08 17:30:02 +00:00
Guy Harris 31badacab3 Move alert_box.c back up to the top-level directory for now, to fix the
Windows build.  We probably want to construct a "ui" (static) library
the same way we construct the libwireshark (dynamic) library, out of
stuff in the ui directory and the relevant subdirectories.

svn path=/trunk/; revision=40541
2012-01-16 03:23:22 +00:00
Guy Harris d7b2aad043 Move some headers for UI stuff, and the alert_box.c UI-specific file, to
the ui directory.  (Perhaps some other files that would be used by all
flavors of Wireshark, for any GUI toolkit or for someting such as
ncurses, and not for any command-line tool such as TShark, should be
moved there as well.)

Shuffle some #includes to put the "ui/XXX.h" includes together.

svn path=/trunk/; revision=40529
2012-01-16 01:07:52 +00:00