From Jakub Zawadzki:
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
This commit is contained in:
parent
7fa6d929cf
commit
f73c579d55
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue