aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_wrappers.c
AgeCommit message (Collapse)AuthorFilesLines
2013-03-19From beroset:Anders Broman1-1/+1
remove C++ incompatibilities https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 svn path=/trunk/; revision=48424
2013-01-06Make some Boolean flags gbooleans, rename one of them to more clearlyGuy Harris1-51/+57
indicate what it means, and use an enum for the compression types. Note that file_getc() returns a byte, not a character. svn path=/trunk/; revision=46983
2013-01-06Clean up comment alignment.Guy Harris1-4/+4
Get rid of unnecessary pointer cast. svn path=/trunk/; revision=46982
2013-01-04replace "unsigned" datatype with "guint". Some mpeg files needed "unsigned ↵Michael Mann1-16/+16
int" instead. bugs 7825-7827 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7825) svn path=/trunk/; revision=46928
2012-12-21Microsoft CRT's _write expects an unsigned int.Gerald Combs1-1/+1
svn path=/trunk/; revision=46684
2012-12-21Squelch a warning - the code shouldn't ever let "have" get so large thatGuy Harris1-1/+1
it exceeds size_t on any platform, including Win64. svn path=/trunk/; revision=46652
2012-12-21Squelch implicit 64-bit-to-32-bit conversion warnings.Guy Harris1-8/+22
svn path=/trunk/; revision=46650
2012-12-05Fix another instance of a variable/parameter name "shadowing" a library ↵Bill Meier1-5/+5
function name; (At least some (gcc ?) compilers give a "shadow" warning for these). svn path=/trunk/; revision=46404
2012-09-20We always HAVE_CONFIG_H so don't bother checking whether we have it or not.Jeff Morriss1-2/+0
svn path=/trunk/; revision=45015
2012-06-28Update Free Software Foundation address.Jakub Zawadzki1-1/+1
(COPYING will be updated in next commit) svn path=/trunk/; revision=43536
2012-06-05Casting a negative value to unsigned makes it positive; I'm not sureGuy Harris1-3/+16
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-05Add another cast to make it build on Win32.Anders Broman1-1/+1
svn path=/trunk/; revision=43104
2012-06-05Making "had" a ptrdiff_t caused warnings, even if it eliminated aGuy Harris1-1/+6
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-05From Jakub Zawadzki: when seeking backwards, if the seek will put you atGuy Harris1-1/+13
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-02Try to squelch warningsAnders Broman1-5/+5
svn path=/trunk/; revision=43000
2012-06-02Try to squelch warningsAnders Broman1-8/+8
svn path=/trunk/; revision=42998
2012-06-01Sigh. There appears to be no way to get Windows to allow us to rename aGuy Harris1-4/+28
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-05-24Keep track, in Wiretap, of whether the file is compressed, and provideGuy Harris1-3/+14
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-19Z_BLOCK was added in zlib-1.2.0.5Jakub Zawadzki1-2/+8
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-02Add a file_skip() routine to skip N bytes forward in the file - it'sGuy Harris1-0/+13
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-02Put all the comments about the "don't check the CRC" flag together, andGuy Harris1-11/+10
expand the resulting comment a bit. svn path=/trunk/; revision=42390
2012-04-13Remove doubled semicolons and semicolons outside function.Jakub Zawadzki1-1/+1
svn path=/trunk/; revision=42053
2012-01-21Replace wtap_file_extensions_string() with a routine that returns aGuy Harris1-0/+31
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
2011-11-17Return *some* error if we end up trying to seek before the beginning ofGuy Harris1-1/+1
the file, so you don't get weird random errors. EINVAL is as good as anything. svn path=/trunk/; revision=39896
2011-06-15Strings are not writable, and the compiler warns that assigning aGuy Harris1-1/+1
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-09The only place where we care about zlib is file_wrappers.c; includeGuy Harris1-0/+4
<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-05-09Note that compressed Windows Sniffer files might have a CRC, just notGuy Harris1-0/+9
one computed the right way (as specified by RFC 1952). svn path=/trunk/; revision=37032
2011-05-09Get rid of the fd member of a wth structure; the FILE_T's in thatGuy Harris1-2/+14
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-09From Jakub Zawadzki: for file read progress bars, use the raw offset inGuy Harris1-0/+5
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-09If a gzipped file's name ends in .caz, don't check the CRC - it'sGuy Harris1-2/+22
probably a compressed file from the Windows Sniffer, and they don't bother setting the CRC. svn path=/trunk/; revision=37024
2011-04-29configure: remove test for gzclearerr (not used anymore), add test for ↵Jakub Zawadzki1-3/+16
inflatePrime. svn path=/trunk/; revision=36949
2011-04-21In file_wrappers.c, explicitly set err_info to null for all errors thatGuy Harris1-2/+17
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-21Add a new WTAP_ERR_DECOMPRESS error, and use that for errors discoveredGuy Harris1-13/+36
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-20Always check whether NEXT() failed - and rename it to GZ_GETC(), as itGuy Harris1-44/+169
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-15Return ENOMEM if we run out of memory. (We're either running on UN*X,Guy Harris1-3/+7
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-12From Jakub Zawadski: some small fixes.Guy Harris1-6/+5
From me: small indentation fix (use spaces rather than tabs in all lines in that routine). svn path=/trunk/; revision=36591
2011-04-12Update and expand some comments.Guy Harris1-35/+59
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-12A parameter isn't used if ZLIB isn't enabled.Martin Mathieson1-1/+1
svn path=/trunk/; revision=36584
2011-04-12From Jakub Zawadzki: speed up random access to gzipped files, as per theGuy Harris1-51/+282
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-11Use ws_open(), not open(), so we handle UTF-8 pathnames on Windows.Guy Harris1-1/+1
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-11Don't use the zlib I/O routines for writing compressed files, either;Guy Harris1-0/+265
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-10Use AC_SYS_LARGEFILE to turn on large file support on platforms thatGuy Harris1-15/+3
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-10Point to RFC 1952 as a description of the gzip file format.Guy Harris1-0/+10
Point to pages for some other compressed file formats we might want to support. svn path=/trunk/; revision=36539
2011-04-10Move the definition of the structure pointed to by a FILE_T intoGuy Harris1-6/+31
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-08To squelch some compiler warnings, temporarily cast the argument toGuy Harris1-2/+12
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-08From Jakub Zawadzki:Guy Harris1-189/+627
Steal file_wrappers functions from zlib v2. svn path=/trunk/; revision=36513
2011-04-06From Jakub Zawadzki:Guy Harris1-23/+4
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
2010-03-25Update a comment to discuss how zlib and z_off_t has gotten messier lately.Guy Harris1-0/+8
svn path=/trunk/; revision=32280
2008-05-22Move the file utility functions from wiretap to libwsutil so thatJeff Morriss1-3/+3
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-01-24s/%ll/%" G_GINT64_MODIFIER "/gJeff Morriss1-1/+1
svn path=/trunk/; revision=24181