aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_wrappers.c
AgeCommit message (Collapse)AuthorFilesLines
2015-12-16Make zlib API constness-aware, take 2.Guy Harris1-1/+17
ZLIB_CONST must be defined before including zlib.h to expose z_const, *AND* z_const shouldn't be used unless it's defined, because older versions of zlib don't define it even if you define ZLIB_CONST. While we're at it, throw in some DIAG_OFF(cast-qual)/DIAG_ON(cast-qual) pairs to suppress unavoidable "cast throws away const qualification" warnings. The original "make zlib constness-aware" change also removed an unnecessary include of <zlib.h> from wiretap/wtap.c, so we do that as well. Change-Id: I3c5269a8fbc54bbbb4d316544cc7b8fa30614c19 Reviewed-on: https://code.wireshark.org/review/12675 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-12-16Revert "Make zlib API constness-aware"Guy Harris1-3/+6
This reverts commit fb0246c6fd7cd34b820558f75eb48bba6326b768. That commit assumes that if you define Z_CONST, z_const will be defined; that is *not* the case with older versions of zlib, which don't define z_const under any circumstances. Change-Id: I6f9b7ea18922799b1aaf94dc2c63120128f2550a Reviewed-on: https://code.wireshark.org/review/12671 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-16Make zlib API constness-awareJoão Valverde1-6/+3
ZLIB_CONST must be defined before including zlib.h to expose 'z_const'. Change-Id: Ic0dbd59ed3c760dd84ef4546f6ff4d5d3db91519 Reviewed-on: https://code.wireshark.org/review/12547 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-10Skip only the actual file descriptor close when writing to stdout.Guy Harris1-4/+12
Have a "this is stdout" flag for a wtap_dumper, and have "open the standard output for dumping" routines that set that flag. When closing a wtap_dumper, do most of the work regardless of whether we're writing to the standard output or not (so that everything gets written out) and only skip the closing of the underlying file descriptor. Change-Id: I9f7e4d142b3bd598055d806b7ded1cb4c378de8e Reviewed-on: https://code.wireshark.org/review/11673 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-08Use ws_{read,write,fdopen,close}.Guy Harris1-4/+4
Be more consistent about using the ws_ routines, as we suggest in README.developer. In C++ on UN*X, define ws_close as ::close rather than close, so that it works even in classes with methods or members named "close". Change-Id: Ide2652229e6b6b4624cbddae0e909a4ea1efa591 Reviewed-on: https://code.wireshark.org/review/11637 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-08More unnecessary <stdio.h> includes.Guy Harris1-1/+0
libwiretap no longer uses standard I/O routines to read files; those includes are left over from when it did. Change-Id: Ia46c5e24ed25c6bd254cd271746ace539a37e590 Reviewed-on: https://code.wireshark.org/review/11634 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-07Clean up includes of unistd.h, fcntl.h, and sys/stat.h.Guy Harris1-7/+0
Have wsutil/file_util.h include them on UN*X, just as it includes io.h on Windows, so we can have a rule of "if you do file operations, include <wsutil/file_util.h> and use the routines in it". Remove includes of unistd.h, fcntl.h, and sys/stat.h that aren't necessary (whether because of the addition of them to wsutil/file_util.h or because they weren't needed in the first place). Change-Id: Ie241dd74deff284e39a5f690a297dbb6e1dc485f Reviewed-on: https://code.wireshark.org/review/11619 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-05-09Make everything unsigned.Guy Harris1-1/+1
The LHS of the & operation is unsigned; make the RHS unsigned as well. That squelches a Sun/Oracle C warning. Change-Id: I6983cc89603a512020b8e8b560c00632de6b2fb3 Reviewed-on: https://code.wireshark.org/review/8363 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-11-19Wiretap: Added file_seek SEEK_END support.Stig Bjørlykke1-4/+13
This is needed for Lua File:seek("end"). Change-Id: I28fb23f2f29ca8083c77bf065db8816e039ae5a1 Reviewed-on: https://code.wireshark.org/review/4722 Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Michal Labedzki <michal.labedzki@tieto.com> Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-10-25Expand comments.Guy Harris1-6/+52
Change-Id: I92348f98cd04ff0e7fc05e472075315ca0fd260e Reviewed-on: https://code.wireshark.org/review/4931 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-08No need to set *err_info if there's no error.Guy Harris1-2/+0
Change-Id: I98ae9ec50e079d48b6247bb208528b7c5ad16027 Reviewed-on: https://code.wireshark.org/review/4564 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-08Make sure we don't dereference a null pointer.Gerald Combs1-1/+2
Change-Id: I033c60cdc5b78f4db31903277c659661e0dc5123 Reviewed-on: https://code.wireshark.org/review/4561 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-10-08Set err_info to null for errors that don't have an informaton string.Guy Harris1-1/+2
Change-Id: Ibbcf3496ebfb20c53b953db84b2ddb69083dcb86 Reviewed-on: https://code.wireshark.org/review/4556 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-22Try to fix some buildbot warningsMichal Labedzki1-0/+4
Most interesting are: warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations] warning: ISO C forbids zero-size array [-Wpedantic] warning: ISO C90 doesn't support unnamed structs/unions [-Wpedantic] warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual warning: initializer element is not computable at load time [enabled by default] Change-Id: I5573c6bdca856a304877d9bef643f8c0fa93cdaf Reviewed-on: https://code.wireshark.org/review/3174 Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
2014-09-10Various minor changes:Bill Meier1-1033/+1046
- Create/use some extended value_strings - Remove unneeded #includes; - Do whitespace changes; - Add editor modelines. Change-Id: I2e1ea37dddfd5e8656c90c0d45a6596c4912bb2c Reviewed-on: https://code.wireshark.org/review/4065 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-09Fix some spelling & grammar.Bill Meier1-1/+1
Change-Id: Iedeaa411caa0823922dd79c27897a2349d4e6907 Reviewed-on: https://code.wireshark.org/review/4054 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-07-25Replace lseek/fstat by ws_lseek64/ws_fstat64Peter Wu1-2/+2
lseek returns an off_t type which is system-dependent. Use ws_lseek64 in favor of lseek as that supports 64-bit quanities. Use ws_fstat64 instead of stat to support 64-bit file sizes on Windows. For the majority of the changes, this makes no difference as they do not apply to Windows ("ifndef _WIN32"; availability of st_blksize). There are no other users of "struct stat" besides the portability code in wsutil. Forbid the use of fstat and lseek in checkAPIs. Change-Id: I17b930ab9543f21a9d3100f3795d250c9b9ae459 Reviewed-on: https://code.wireshark.org/review/3198 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-19Add capture file reader/writer support for Lua so scripts can implement new ↵Michael Mann1-0/+47
capture file formats. This enables a Lua script to implement a brand new capture file format reader/writer, so that for example one could write a script to read from vendor-specific "logs" of packets, and show them as normal packets in wireshark. Change-Id: Id394edfffa94529f39789844c382b7ab6cc2d814 Reviewed-on: https://code.wireshark.org/review/431 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(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-02-03allow tshark reading from pipesPeter Hatina1-1/+2
Change-Id: If20a14b949667911df44f09c6a705b7645d4c49e Reviewed-on: https://code.wireshark.org/review/85 Reviewed-by: Evan Huus <eapache@gmail.com> Tested-by: Evan Huus <eapache@gmail.com>
2013-10-29simplify file_error()Martin Kaiser1-5/+4
svn path=/trunk/; revision=52944
2013-10-29allow err_info==NULL in file_error()Martin Kaiser1-1/+2
this fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9309 reported by Peter Wu svn path=/trunk/; revision=52943
2013-07-23Don't cast away constness (except where APIs render that impossible).Guy Harris1-1/+1
svn path=/trunk/; revision=50854
2013-07-23Handle operating systems that are anticipating the day when files shouldGuy Harris1-1/+9
be read in chunks > 2GB. svn path=/trunk/; revision=50847
2013-06-03file_skip() only needs to return a Boolean; if anybody cares what theGuy Harris1-2/+4
seek offset is after calling it, they can use file_tell(). (Some routines were already assuming it returned a gboolean.) svn path=/trunk/; revision=49733
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