Commit Graph

111 Commits

Author SHA1 Message Date
Bill Meier 95a64a667d Fix another instance of a variable/parameter name "shadowing" a library function name;
(At least some (gcc ?) compilers give a "shadow" warning for these).

svn path=/trunk/; revision=46404
2012-12-05 16:19:12 +00:00
Jeff Morriss 3551a86c36 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45015
2012-09-20 01:29:52 +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 00d329575d Casting a negative value to unsigned makes it positive; I'm not sure
that will do the right thing here.  Instead, cast its negative (which is
positive) to unsigned, use that value as the adjustment, and flip the
signs of the subsequent adjustment operations.

svn path=/trunk/; revision=43105
2012-06-05 08:59:37 +00:00
Anders Broman af9f210f5c Add another cast to make it build on Win32.
svn path=/trunk/; revision=43104
2012-06-05 08:39:58 +00:00
Guy Harris 92bd70a380 Making "had" a ptrdiff_t caused warnings, even if it eliminated a
warning about assigning the difference between two (64-bit) pointers to
a (32-bit) variable.  That difference is guaranteed to fit in an
unsigned int; make "had" an unsigned int, and cast the difference to
unsigned int before assigning it to "had".

svn path=/trunk/; revision=43103
2012-06-05 08:04:15 +00:00
Guy Harris 7ed3d0e959 From Jakub Zawadzki: when seeking backwards, if the seek will put you at
a position that's in our data buffer, just reposition within the
buffer, don't do any seeks or I/O on the underlying file.  This lets us
do some backwards seeking on a pipe, to allow the rewind-and-try scheme
we use to try to identify capture file types to work, at least for some
capture file formats (those that have magic numbers at the beginning or
have heuristics that don't require much data), on pipes, allowing, for
example, TShark to read those formats from a pipe.

svn path=/trunk/; revision=43102
2012-06-05 07:24:17 +00:00
Anders Broman cd7c20c9d9 Try to squelch warnings
svn path=/trunk/; revision=43000
2012-06-02 15:32:34 +00:00
Anders Broman 2bc42dc547 Try to squelch warnings
svn path=/trunk/; revision=42998
2012-06-02 14:13:14 +00:00
Guy Harris 129c881fcf Sigh. There appears to be no way to get Windows to allow us to rename a
file that we ourselves have open.  In the "safe save" code path for
capture files, on Windows temporarily close the file descriptors for the
currently-open capture before doing the rename and then, if the rename
failed, reopen them, leaving the rest of the wtap and capture_file
structures intact.

Rename filed_open() to file_fdopen(), to make its name match what it
does a bit better (it's an fdopen()-style routine, i.e. do the
equivalent of an open with an already-open file descriptor rather than a
pathname, in the file_wrappers.c set of routines).

Remove the file_ routines from the .def file for Wiretap - they should
only be called by code inside Wiretap.

Closing a descriptor open for input has no reason to fail (closing a
descriptor open for *writing* could fail if the file is on a server and
dirty pages are pushed asynchronously to the server and synchronously on
a close), so just have file_close() return void.

svn path=/trunk/; revision=42961
2012-06-01 08:05:12 +00:00
Guy Harris cf6d9841e3 Keep track, in Wiretap, of whether the file is compressed, and provide
an API to fetch that.

When doing "Save" on a compressed file, write it out compressed.

In the Statistics -> Summary dialog and in capinfos, report whether the
file is gzip-compressed.

svn path=/trunk/; revision=42818
2012-05-24 05:05:29 +00:00
Jakub Zawadzki 63d6b6bf2a Z_BLOCK was added in zlib-1.2.0.5
Pass Z_NO_FLUSH to inflate() when Z_BLOCK is not defined,
just in case also disable fast seeking when it's not defined.

References: http://www.wireshark.org/lists/wireshark-dev/201205/msg00145.html 

svn path=/trunk/; revision=42714
2012-05-19 13:27:43 +00:00
Guy Harris ecacaacbe2 Add a file_skip() routine to skip N bytes forward in the file - it's
currently just a wrapper around file_seek(), but could be implemented by
reading forward if, for example, we add support for reading
(sequentially only!) from a pipe.

Sort the declarations of file-reading routines into one block.

svn path=/trunk/; revision=42391
2012-05-02 21:25:48 +00:00
Guy Harris e1ee9ca907 Put all the comments about the "don't check the CRC" flag together, and
expand the resulting comment a bit.

svn path=/trunk/; revision=42390
2012-05-02 21:11:28 +00:00
Jakub Zawadzki 8a1dc57c03 Remove doubled semicolons and semicolons outside function.
svn path=/trunk/; revision=42053
2012-04-13 20:22:31 +00:00
Guy Harris e4a193fe5e Replace wtap_file_extensions_string() with a routine that returns a
GSList of extensions for a file type, including extensions for the
compressed versions of those file types that we can read.

svn path=/trunk/; revision=40623
2012-01-21 08:59:21 +00:00
Guy Harris f3a88d4084 Return *some* error if we end up trying to seek before the beginning of
the file, so you don't get weird random errors.  EINVAL is as good as
anything.

svn path=/trunk/; revision=39896
2011-11-17 06:36:32 +00:00
Guy Harris 128216dfbe Strings are not writable, and the compiler warns that assigning a
pointer to a string to a non-const pointer discards qualifiers; make the
err_info member of the wtap_reader structure a const pointer.

svn path=/trunk/; revision=37671
2011-06-15 19:34:54 +00:00
Guy Harris 06256dfe5b The only place where we care about zlib is file_wrappers.c; include
<zlib.h> there, rather than wtap-int.h.  That obviates the need to
include config.h earlier in ascend_scanner.l; revert the previous
change, so we don't require a version of Flex that supports %top.

svn path=/trunk/; revision=37640
2011-06-09 22:46:00 +00:00
Guy Harris f4a752873f Note that compressed Windows Sniffer files might have a CRC, just not
one computed the right way (as specified by RFC 1952).

svn path=/trunk/; revision=37032
2011-05-09 17:53:45 +00:00
Guy Harris 3de2b1be74 Get rid of the fd member of a wth structure; the FILE_T's in that
structure include a file descriptor.  Add a wtap_fstat() for the file
readers that use file times to generate time stamps (we really need a
way to say "this file has no time stamps" or "this file has only
relative time stamps).

svn path=/trunk/; revision=37026
2011-05-09 08:12:26 +00:00
Guy Harris 88a1ed85e3 From Jakub Zawadzki: for file read progress bars, use the raw offset in
the file, rather than the offset in the uncompressed data stream.  That
way we don't get the "hey, we're more than 100% into the file, better
refigure this" surprise.

svn path=/trunk/; revision=37025
2011-05-09 05:30:59 +00:00
Guy Harris 42ba70cf9c If a gzipped file's name ends in .caz, don't check the CRC - it's
probably a compressed file from the Windows Sniffer, and they don't
bother setting the CRC.

svn path=/trunk/; revision=37024
2011-05-09 03:48:41 +00:00
Jakub Zawadzki 229adbc1e5 configure: remove test for gzclearerr (not used anymore), add test for inflatePrime.
svn path=/trunk/; revision=36949
2011-04-29 07:49:55 +00:00
Guy Harris 140cc563c6 In file_wrappers.c, explicitly set err_info to null for all errors that
don't have an "additional information" string.

Get rid of WTAP_ERR_ZLIB; just report an internal error with
WTAP_ERR_INTERNAL instead.  (If they start happening, we can think about
supplying an "additional information" string for compression errors on
output.)

svn path=/trunk/; revision=36774
2011-04-21 17:51:19 +00:00
Guy Harris 6cbf6ce16c Add a new WTAP_ERR_DECOMPRESS error, and use that for errors discovered
by the gunzipping code.  Have it also supply a err_info string, and
report it.  Have file_error() supply an err_info string.

Put "the file" - or, for WTAP_ERR_DECOMPRESS, "the compressed file", to
suggest a decompression error - into the rawshark and tshark errors,
along the lines of what other programs print.

Fix a case in the Netscaler code where we weren't fetching the error
code on a read failure.

svn path=/trunk/; revision=36748
2011-04-21 09:41:52 +00:00
Guy Harris ff783ad1d5 Always check whether NEXT() failed - and rename it to GZ_GETC(), as it
has semantics similar to getc().

If it fails due to an EOF, set state->err to WTAP_ERR_SHORT_READ to
report a premature EOF; otherwise, raw_read() has already set
state->err, so don't set state->err to something else - that loses the
errno value in favor of a generic "bad data" error.

svn path=/trunk/; revision=36744
2011-04-20 21:36:23 +00:00
Guy Harris cd1a4b036c Return ENOMEM if we run out of memory. (We're either running on UN*X,
in which case ENOMEM is the right error, or we're running on Windows but
using UN*Xy routines, in which case ENOMEM is the right error; unlike
zlib, we don't have to run on a whole pile of OSes.)

svn path=/trunk/; revision=36648
2011-04-15 07:27:03 +00:00
Guy Harris fd96236cdf From Jakub Zawadski: some small fixes.
From me: small indentation fix (use spaces rather than tabs in all lines
in that routine).

svn path=/trunk/; revision=36591
2011-04-12 16:31:16 +00:00
Guy Harris 91e1769ac5 Update and expand some comments.
In the end-of-stream code, when we're checking the CRC and length, don't
check the CRC or length if we failed to read them, and don't check the
length if the CRC is bad.

We define O_BINARY as 0 on UN*X in <wsutil/file_util.h>, so we don't
need to avoid using it on UN*X.

In file_gets(), check for delayed errors.

svn path=/trunk/; revision=36590
2011-04-12 16:21:14 +00:00
Martin Mathieson b76b05b75b A parameter isn't used if ZLIB isn't enabled.
svn path=/trunk/; revision=36584
2011-04-12 14:33:31 +00:00
Guy Harris b28ee8b331 From Jakub Zawadzki: speed up random access to gzipped files, as per the
zran.c example in the zlib source.

This means that problems in the file's contents might not be reported
when a packet is read, as long as there's no problem in the contents of
the file up to the last bit of compressed data for the packet; we now
check for errors after finishing the sequential read of the file, at
least in some programs, so that shouldn't be an issue (the other
programs need to be changed to do so as well).  This is necessary in
order to be able to read all the packets we saw in the sequential pass;
it also lets us get a few more packets from truncated files in some
cases.

svn path=/trunk/; revision=36577
2011-04-12 02:40:14 +00:00
Guy Harris f5f74bed3d Use ws_open(), not open(), so we handle UTF-8 pathnames on Windows.
Update or remove some additional "we don't have ferror() in zlib"
comments to reflect the current reality.

svn path=/trunk/; revision=36568
2011-04-11 22:19:01 +00:00
Guy Harris b184c69559 Don't use the zlib I/O routines for writing compressed files, either;
this frees us from worrying about zlib large file issues on the write
side, and also lets us clean up a few other things.

svn path=/trunk/; revision=36563
2011-04-11 21:33:22 +00:00
Guy Harris c349caf925 Use AC_SYS_LARGEFILE to turn on large file support on platforms that
support it.

Rename ws_lseek to ws_lseek64, as it should be given a 64-bit offset,
and have it use _lseeki64 on Windows, to try to get 64-bit offset
support; AC_SYS_LARGEFILE should cause lseek() to support 64-bit offsets
on UN*X if possible.

svn path=/trunk/; revision=36542
2011-04-10 18:22:47 +00:00
Guy Harris f3502974a0 Point to RFC 1952 as a description of the gzip file format.
Point to pages for some other compressed file formats we might want to
support.

svn path=/trunk/; revision=36539
2011-04-10 17:01:13 +00:00
Guy Harris f27f61ac9e Move the definition of the structure pointed to by a FILE_T into
wiretap/file_wrappers.c; nothing outside of file_wrappers.c needs to
know what it looks like, it just passes around pointers to it.

svn path=/trunk/; revision=36538
2011-04-10 16:53:32 +00:00
Guy Harris f3873931ec To squelch some compiler warnings, temporarily cast the argument to
ws_lseek() to the appropriate type for the second argument to _lseek()
for Windows or lseek() for UN*X; ultimately, we want to call the
appropriate 64-bit-offset seek routine if available, otherwise cast the
value down and hand it to the 32-bit-offset seek routine.

svn path=/trunk/; revision=36514
2011-04-08 01:55:25 +00:00
Guy Harris ab261a3281 From Jakub Zawadzki:
Steal file_wrappers functions from zlib v2.

svn path=/trunk/; revision=36513
2011-04-08 00:28:37 +00:00
Guy Harris f73c579d55 From Jakub Zawadzki:
file-wrappers.[ch] is used only for reading files, and mode is always
"rb".

Attached patch removes 'mode' argument from file_open() & filed_open().

svn path=/trunk/; revision=36493
2011-04-06 07:09:56 +00:00
Guy Harris 2101397e40 Update a comment to discuss how zlib and z_off_t has gotten messier lately.
svn path=/trunk/; revision=32280
2010-03-25 19:45:29 +00:00
Jeff Morriss a5cee04fad Move the file utility functions from wiretap to libwsutil so that
libwireshark (and the plugins using those functions) do not depend on
wiretap on Windows.

While doing that, rename the eth_* functions to ws_*.

svn path=/trunk/; revision=25354
2008-05-22 15:46:27 +00:00
Jeff Morriss 75849c12f1 s/%ll/%" G_GINT64_MODIFIER "/g
svn path=/trunk/; revision=24181
2008-01-24 21:57:13 +00:00
Ulf Lamping ecfa9c3d2b fix the return value of file_seek, as noted by Steve
svn path=/trunk/; revision=19816
2006-11-06 00:24:24 +00:00
Ulf Lamping 59d6c8ea33 change all file offsets from long to gint64 so we can - theoretically - handle files > 2GB correct.
Please distclean Win32 builds!

svn path=/trunk/; revision=19814
2006-11-05 22:46:44 +00:00
Guy Harris 17456c2e09 Include <unistd.h> if available, to get "close()" declared.
Update the big comment to reflect current reality.

svn path=/trunk/; revision=16453
2005-11-10 02:49:54 +00:00
Guy Harris 7474bc0f13 If we're using libz, make file_open() construct the open() flag
argument, rather than requiring the caller to get the open() flag and
the fopen() flag in sync.  That also means that if we're *not* using
libz, it can just be a wrapper around eth_fopen().

We need to include <fcntl.h>, at least on UN*X, to get open() declared
and the O_ flags defined.

svn path=/trunk/; revision=16409
2005-11-07 02:45:19 +00:00
Ulf Lamping c3187174bf replace *a lot* of file related calls by their GLib counterparts. This is necessary for the switch to GTK 2.6 (at least on WIN32).
to do this, I've added file_util.h to wiretap (would file_compat.h be a better name?), and provide compat_macros like eth_open() instead of open(). While at it, move other file related things there, like #include <io.h>, definition of O_BINARY and alike, so it's all in one place.

deleted related things from config.h.win32

As of these massive changes, I'm almost certain that this will break the Unix build. I'll keep an eye on the buildbot so hopefully everything is working again soon.

svn path=/trunk/; revision=16403
2005-11-06 22:43:25 +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
Jörg Mayer 64b6acac6d Removed trailing whitespaces from .h and .c files using the
winapi_cleanup tool written by Patrik Stridvall for the wine
project.

svn path=/trunk/; revision=6115
2002-08-28 20:30:45 +00:00
Guy Harris 2aad75bb82 Graeme Hewson noted that zlib has a bug wherein "gzseek()" doesn't set
the internal z_err value for the stream if an "fseek()" call it makes
fails, so that if "gzerror()" is subsequently called, it returns Z_OK
rather than an error.

To work around this, we pass "file_seek()" an "int *err", and have the
with-zlib version of "file_seek()" check, if "gzseek()" fails, whether
the return value of "file_error()" is 0 and, if so, have it return
"errno" instead.

svn path=/trunk/; revision=5642
2002-06-07 07:27:35 +00:00
Guy Harris 23d1a63f39 zlib 1.0.8 - the version that comes with X11 - does have "gzseek()",
even if it doesn't have "gzgets()", so one might think we could use it
by using our own replacement for "gzgets()".

One would be wrong to think so, however, as the "gzseek()" it has
doesn't actually work when reading uncompressed files.

zlib 1.0.9 has "gzgets()", and fixes that bug, so we rever to checking
for "gzgets()" rather than "gzseek()", so that we don't accept pre-1.0.9
versions of zlib, and we get rid of our "gzgets()" replacement.

svn path=/trunk/; revision=4702
2002-02-06 09:58:30 +00:00
Gilbert Ramirez f14a6b8b91 Hopefully the last time I have to change my e-mail address.
svn path=/trunk/; revision=4199
2001-11-13 23:55:44 +00:00
Ashok Narayanan 29c8fa03b3 Removed the dependency on gzgetc and gzgets by implementing internal
versions of these commands in file_wrappers.c. This allows us to
compile successfully even on platforms where X has an older zlib built
in.

Removed this restriction from acinclude.m4

svn path=/trunk/; revision=3948
2001-09-20 16:36:45 +00:00
Gilbert Ramirez d7e6e0e384 Add wtap-int.h. Move definitions relevant to the internal workins of wiretap
to that file, leave public definitions in wtap.h.

Rename "union pseudo_header" to "union wtap_pseudo_header".
Make the wtap_pseudo_header pointer available in packet_info struct.

svn path=/trunk/; revision=1989
2000-05-19 23:07:04 +00:00
Guy Harris 6fa0fd5fa8 Sigh. OpenBSD defines "HAVE_UNISTD_H" in the Makefile for zlib, so,
unlike FreeBSD and older versions of NetBSD, which give "gzseek()" and
"gztell()" signatures with "long" file-offset arguments, and thus, on
some versions, requires that "HAVE_UNISTD_H" *not* be defined before
including "zlib.h" if you want the functions declared with a signature
that matches what's actually in the library, it requires that it *be*
defined before including "zlib.h" if you want the functions declared
with a signature that matches what's actually in the library.

svn path=/trunk/; revision=1719
2000-03-14 18:27:44 +00:00
Guy Harris 9f458a52fc Always declare, and define, "file_seek()" to return a "long", as it's
supposed to look like "ftell()".

If you don't have zlib, just define "file_seek" as an alias for "fseek",
rather than defining it as a routine.

svn path=/trunk/; revision=1571
2000-01-26 19:22:04 +00:00
Guy Harris f71823a907 "gztell()" is also affected by the libz mess on platforms where "off_t"
is bigger than a "long"; this is itojun's fix for that, turning
"file_tell()" into a wrapper function in "file_wrappers.c", just like
"file_seek()".

svn path=/trunk/; revision=1554
2000-01-25 04:49:55 +00:00
Guy Harris 3e067b812c Fix files that had Gilbert's old e-mail address or that didn't have my
forwarding e-mail address.

svn path=/trunk/; revision=1522
2000-01-22 06:22:44 +00:00
Guy Harris cc9a1060ca Fix "ascend-scanner.l" to include "file_wrappers.h" rather than the
defunct "file.h".

Make "file_wrappers.c" include "wtap.h", so that the WTAP_ERR_ZLIB_
values are defined.

svn path=/trunk/; revision=1464
2000-01-13 07:18:50 +00:00
Guy Harris 7a36bede0b We are obliged to define HAVE_UNISTD_H in "config.h"; to avoid the
hideous problem on FreeBSD 3.[23] (and perhaps other BSDs) if
HAVE_UNISTD_H is defined before "zlib.h" is included, turn "file_seek()"
into a subroutine defined in a file that *undefines* HAVE_UNISTD_H
before including "zlib.h", so that the *only* call to "gzseek()" is made
from a file that does not have HAVE_UNISTD_H defined when it includes
"zlib.h".

Move "file_error()" to that file while you're at it, so it holds all the
wrappers that hide the presence or absence of zlib from routines to read
capture files.

Turn "file.h", which declared those wrapper functions as well as wrapper
macros, into "file_wrapper.h" - it belongs with the "file_wrapper.c"
file that defines the wrapper functions, not with "file.c" which handles
higher-layer file access functions.

Remove the comment in "configure.in" that explained why defining
HAVE_UNISTD_H was a bad idea, as we're not obliged to define it and work
around the problem.  (The comment in "file_wrapper.c" explains the
workaround.)

svn path=/trunk/; revision=1463
2000-01-13 07:09:20 +00:00