aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-05-02 21:25:48 +0000
committerGuy Harris <guy@alum.mit.edu>2012-05-02 21:25:48 +0000
commitecacaacbe284c8f94fc39ea45e0cc70e399071b1 (patch)
treee7164b94eb91a720d607cd415c8b63f8f4af2abf /wiretap
parente1ee9ca90779bc2ceb3b28e5ccb66937f45a4bfd (diff)
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
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/file_wrappers.c13
-rw-r--r--wiretap/file_wrappers.h13
2 files changed, 19 insertions, 7 deletions
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c
index fa5aef43aa..0de09143d2 100644
--- a/wiretap/file_wrappers.c
+++ b/wiretap/file_wrappers.c
@@ -1042,6 +1042,19 @@ file_seek(FILE_T file, gint64 offset, int whence, int *err)
return file->pos + offset;
}
+/*
+ * Skip forward the specified number of bytes in the file.
+ * Currently implemented as a wrapper around file_seek(),
+ * but if, for example, we ever add support for reading
+ * sequentially from a pipe, this could instead just skip
+ * forward by reading the bytes in question.
+ */
+gint64
+file_skip(FILE_T file, gint64 delta, int *err)
+{
+ return file_seek(file, delta, SEEK_CUR, err);
+}
+
gint64
file_tell(FILE_T stream)
{
diff --git a/wiretap/file_wrappers.h b/wiretap/file_wrappers.h
index 5ae970ef6b..b594a7330b 100644
--- a/wiretap/file_wrappers.h
+++ b/wiretap/file_wrappers.h
@@ -27,22 +27,21 @@
#include <wtap.h>
#include <wsutil/file_util.h>
+extern FILE_T file_open(const char *path);
+extern FILE_T filed_open(int fildes);
+extern void file_set_random_access(FILE_T stream, gboolean random, GPtrArray *seek);
extern gint64 file_seek(FILE_T stream, gint64 offset, int whence, int *err);
+extern gint64 file_skip(FILE_T file, gint64 delta, int *err);
extern gint64 file_tell(FILE_T stream);
extern gint64 file_tell_raw(FILE_T stream);
extern int file_fstat(FILE_T stream, ws_statb64 *statb, int *err);
-extern int file_error(FILE_T fh, gchar **err_info);
-
-extern FILE_T file_open(const char *path);
-extern FILE_T filed_open(int fildes);
extern int file_read(void *buf, unsigned int count, FILE_T file);
-extern int file_close(FILE_T file);
extern int file_getc(FILE_T stream);
extern char *file_gets(char *buf, int len, FILE_T stream);
extern int file_eof(FILE_T stream);
+extern int file_error(FILE_T fh, gchar **err_info);
extern void file_clearerr(FILE_T stream);
-
-extern void file_set_random_access(FILE_T stream, gboolean random, GPtrArray *seek);
+extern int file_close(FILE_T file);
#ifdef HAVE_LIBZ
typedef struct wtap_writer *GZWFILE_T;