diff options
author | Anders Broman <anders.broman@ericsson.com> | 2013-03-17 09:20:13 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2013-03-17 09:20:13 +0000 |
commit | 05a8c94ddf4bc48888d3dfbdcfff3eddc0f15093 (patch) | |
tree | 97ab76474fb96e5d33e9769d8a50ed6f584bbe9f /wiretap/file_access.c | |
parent | 2e52e2ac997ca58caabee3270b5a6c3f96159ff0 (diff) | |
download | wireshark-05a8c94ddf4bc48888d3dfbdcfff3eddc0f15093.tar.gz |
From beroset:
implemented wtap_dump_file_seek() and _tell()
implemented the previously declared but unimplemented wtap_dump_file_seek() and wtap_dump_file_tell() functions and used them in the seven files that had previously used a plain ftell or fseek and added error checking as appropriate. I also added a new error WTAP_ERR_CANT_SEEK_COMPRESSED and put it next to WTAP_ERR_CANT_SEEK causing renumbering of two of the existing error codes.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416
svn path=/trunk/; revision=48348
Diffstat (limited to 'wiretap/file_access.c')
-rw-r--r-- | wiretap/file_access.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c index c63f538c2f..8b9094498b 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -1513,3 +1513,41 @@ static int wtap_dump_file_close(wtap_dumper *wdh) return fclose((FILE *)wdh->fh); } } + +gint64 wtap_dump_file_seek(wtap_dumper *wdh, gint64 offset, int whence, int *err) +{ +#ifdef HAVE_LIBZ + if(wdh->compressed) { + *err = WTAP_ERR_CANT_SEEK_COMPRESSED; + return -1; + } else +#endif + { + if (-1 == fseek((FILE *)wdh->fh, (long)offset, whence)) { + *err = errno; + return -1; + } else + { + return 0; + } + } +} +gint64 wtap_dump_file_tell(wtap_dumper *wdh, int *err) +{ + gint64 rval; +#ifdef HAVE_LIBZ + if(wdh->compressed) { + *err = WTAP_ERR_CANT_SEEK_COMPRESSED; + return -1; + } else +#endif + { + if (-1 == (rval = ftell((FILE *)wdh->fh))) { + *err = errno; + return -1; + } else + { + return rval; + } + } +} |