aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wiretap/file_access.c4
-rw-r--r--wiretap/file_wrappers.c27
-rw-r--r--wiretap/file_wrappers.h8
3 files changed, 10 insertions, 29 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 19df5e9f80..60a4eac110 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -307,7 +307,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
g_free(wth);
return NULL;
}
- if (!(wth->fh = filed_open(wth->fd, "rb"))) {
+ if (!(wth->fh = filed_open(wth->fd))) {
*err = errno;
ws_close(wth->fd);
g_free(wth);
@@ -315,7 +315,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
}
if (do_random) {
- if (!(wth->random_fh = file_open(filename, "rb"))) {
+ if (!(wth->random_fh = file_open(filename))) {
*err = errno;
file_close(wth->fh);
g_free(wth);
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c
index ccd8209532..b8682ff205 100644
--- a/wiretap/file_wrappers.c
+++ b/wiretap/file_wrappers.c
@@ -127,41 +127,22 @@
#ifdef HAVE_LIBZ
FILE_T
-file_open(const char *path, const char *mode)
+file_open(const char *path)
{
int fd;
FILE_T ft;
int oflag;
- if (*mode == 'r') {
- if (strchr(mode + 1, '+') != NULL)
- oflag = O_RDWR;
- else
- oflag = O_RDONLY;
- } else if (*mode == 'w') {
- if (strchr(mode + 1, '+') != NULL)
- oflag = O_RDWR|O_CREAT|O_TRUNC;
- else
- oflag = O_RDONLY|O_CREAT|O_TRUNC;
- } else if (*mode == 'a') {
- if (strchr(mode + 1, '+') != NULL)
- oflag = O_RDWR|O_APPEND;
- else
- oflag = O_RDONLY|O_APPEND;
- } else {
- errno = EINVAL;
- return NULL;
- }
+ oflag = O_RDONLY;
#ifdef _WIN32
- if (strchr(mode + 1, 'b') != NULL)
- oflag |= O_BINARY;
+ oflag |= O_BINARY;
#endif
/* open file and do correct filename conversions */
if ((fd = ws_open(path, oflag, 0666)) == -1)
return NULL;
/* open zlib file handle */
- ft = gzdopen(fd, mode);
+ ft = gzdopen(fd, "rb");
if (ft == NULL) {
ws_close(fd);
return NULL;
diff --git a/wiretap/file_wrappers.h b/wiretap/file_wrappers.h
index 93dec01434..544d995b6b 100644
--- a/wiretap/file_wrappers.h
+++ b/wiretap/file_wrappers.h
@@ -30,8 +30,8 @@ extern int file_error(void *fh);
#ifdef HAVE_LIBZ
-extern FILE_T file_open(const char *path, const char *mode);
-#define filed_open gzdopen
+extern FILE_T file_open(const char *path);
+#define filed_open(fildes) gzdopen(fildes, "rb")
#define file_read(buf, count, file) gzread((file),(buf),(unsigned)(count))
#define file_close gzclose
#define file_getc gzgetc
@@ -40,8 +40,8 @@ extern FILE_T file_open(const char *path, const char *mode);
#else /* No zLib */
-#define file_open(path, mode) ws_fopen(path, mode)
-#define filed_open fdopen
+#define file_open(path) ws_fopen(path, "rb")
+#define filed_open(fildes) fdopen(fildes, "rb")
#define file_read(buf, count, file) fread((buf), (1), (count), (file))
#define file_close fclose
#define file_getc fgetc