diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-04-10 20:59:10 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-04-10 20:59:10 +0000 |
commit | c6de809d9c1128996584e433614a85ae42c561b5 (patch) | |
tree | d13512b25cf373d606ea059eae4f836085f3a99e | |
parent | a42af1c46241ddb6ab46702ddea6c2b3d826d6cd (diff) |
Rename ws_stat to ws_stat64, and make it take a pointer to a ws_statb64
as an argument, along the lines of ws_fstat64, and, on Windows, make it
use _wstati64, to handle 64-bit file sizes.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36547 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | asn1/kerberos/packet-kerberos-template.c | 4 | ||||
-rw-r--r-- | capture_opts.c | 4 | ||||
-rw-r--r-- | dumpcap.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-kerberos.c | 4 | ||||
-rw-r--r-- | epan/filesystem.c | 34 | ||||
-rw-r--r-- | gtk/capture_if_dlg.c | 4 | ||||
-rw-r--r-- | gtk/main_welcome.c | 4 | ||||
-rw-r--r-- | rawshark.c | 4 | ||||
-rw-r--r-- | wiretap/file_access.c | 4 | ||||
-rw-r--r-- | wsutil/file_util.c | 6 | ||||
-rw-r--r-- | wsutil/file_util.h | 18 |
11 files changed, 46 insertions, 44 deletions
diff --git a/asn1/kerberos/packet-kerberos-template.c b/asn1/kerberos/packet-kerberos-template.c index b82ce9230a..15e59109c6 100644 --- a/asn1/kerberos/packet-kerberos-template.c +++ b/asn1/kerberos/packet-kerberos-template.c @@ -557,12 +557,12 @@ static void read_keytab_file(const char *service_key_file) { FILE *skf; - struct stat st; + ws_statb64 st; service_key_t *sk; unsigned char buf[SERVICE_KEY_SIZE]; int newline_skip = 0, count = 0; - if (service_key_file != NULL && ws_stat (service_key_file, &st) == 0) { + if (service_key_file != NULL && ws_stat64 (service_key_file, &st) == 0) { /* The service key file contains raw 192-bit (24 byte) 3DES keys. * There can be zero, one (\n), or two (\r\n) characters between diff --git a/capture_opts.c b/capture_opts.c index c13adb5ec0..de857ad06c 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -683,9 +683,9 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt /* copied from filesystem.c */ static int capture_opts_test_for_fifo(const char *path) { - struct stat statb; + ws_statb64 statb; - if (ws_stat(path, &statb) < 0) + if (ws_stat64(path, &statb) < 0) return errno; if (S_ISFIFO(statb.st_mode)) @@ -1621,7 +1621,7 @@ cap_pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld, char *errmsg, int errmsgl) { #ifndef _WIN32 - struct stat pipe_stat; + ws_statb64 pipe_stat; struct sockaddr_un sa; int sel_ret; int b; @@ -1654,7 +1654,7 @@ cap_pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld, #endif /* _WIN32 */ } else { #ifndef _WIN32 - if (ws_stat(pipename, &pipe_stat) < 0) { + if (ws_stat64(pipename, &pipe_stat) < 0) { if (errno == ENOENT || errno == ENOTDIR) ld->cap_pipe_err = PIPNEXIST; else { diff --git a/epan/dissectors/packet-kerberos.c b/epan/dissectors/packet-kerberos.c index 71ceb4bb3b..8d4c9f3a64 100644 --- a/epan/dissectors/packet-kerberos.c +++ b/epan/dissectors/packet-kerberos.c @@ -799,12 +799,12 @@ static void read_keytab_file(const char *service_key_file) { FILE *skf; - struct stat st; + ws_statb64 st; service_key_t *sk; unsigned char buf[SERVICE_KEY_SIZE]; int newline_skip = 0, count = 0; - if (service_key_file != NULL && ws_stat (service_key_file, &st) == 0) { + if (service_key_file != NULL && ws_stat64 (service_key_file, &st) == 0) { /* The service key file contains raw 192-bit (24 byte) 3DES keys. * There can be zero, one (\n), or two (\r\n) characters between diff --git a/epan/filesystem.c b/epan/filesystem.c index 17fe5aceb5..01f6324ce8 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -215,9 +215,9 @@ get_dirname(char *path) int test_for_directory(const char *path) { - struct stat statb; + ws_statb64 statb; - if (ws_stat(path, &statb) < 0) + if (ws_stat64(path, &statb) < 0) return errno; if (S_ISDIR(statb.st_mode)) @@ -229,9 +229,9 @@ test_for_directory(const char *path) int test_for_fifo(const char *path) { - struct stat statb; + ws_statb64 statb; - if (ws_stat(path, &statb) < 0) + if (ws_stat64(path, &statb) < 0) return errno; if (S_ISFIFO(statb.st_mode)) @@ -1191,7 +1191,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) char *pf_dir_path_copy, *pf_dir_parent_path; size_t pf_dir_parent_path_len; #endif - struct stat s_buf; + ws_statb64 s_buf; int ret; if (profilename) { @@ -1207,7 +1207,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) * If not then create it. */ pf_dir_path = get_profiles_dir (); - if (ws_stat(pf_dir_path, &s_buf) != 0 && errno == ENOENT) { + if (ws_stat64(pf_dir_path, &s_buf) != 0 && errno == ENOENT) { ret = ws_mkdir(pf_dir_path, 0755); if (ret == -1) { *pf_dir_path_return = g_strdup(pf_dir_path); @@ -1217,7 +1217,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) } pf_dir_path = get_persconffile_dir(profilename); - if (ws_stat(pf_dir_path, &s_buf) != 0 && errno == ENOENT) { + if (ws_stat64(pf_dir_path, &s_buf) != 0 && errno == ENOENT) { #ifdef _WIN32 /* * Does the parent directory of that directory @@ -1235,7 +1235,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) pf_dir_parent_path_len = strlen(pf_dir_parent_path); if (pf_dir_parent_path_len > 0 && pf_dir_parent_path[pf_dir_parent_path_len - 1] != ':' - && ws_stat(pf_dir_parent_path, &s_buf) != 0) { + && ws_stat64(pf_dir_parent_path, &s_buf) != 0) { /* * No, it doesn't exist - make it first. */ @@ -1466,7 +1466,7 @@ get_persconffile_path(const char *filename, gboolean from_profile, gboolean for_ { char *path; #ifdef _WIN32 - struct stat s_buf; + ws_statb64 s_buf; char *old_path; #endif if (do_store_persconffiles && from_profile && !g_hash_table_lookup (profile_files, filename)) { @@ -1483,7 +1483,7 @@ get_persconffile_path(const char *filename, gboolean from_profile, gboolean for_ } #ifdef _WIN32 if (!for_writing) { - if (ws_stat(path, &s_buf) != 0 && errno == ENOENT) { + if (ws_stat64(path, &s_buf) != 0 && errno == ENOENT) { /* * OK, it's not in the personal configuration file * directory; is it in the ".wireshark" subdirectory @@ -1492,7 +1492,7 @@ get_persconffile_path(const char *filename, gboolean from_profile, gboolean for_ old_path = g_strdup_printf( "%s" G_DIR_SEPARATOR_S ".wireshark" G_DIR_SEPARATOR_S "%s", get_home_dir(), filename); - if (ws_stat(old_path, &s_buf) == 0) { + if (ws_stat64(old_path, &s_buf) == 0) { /* * OK, it exists; return it instead. */ @@ -1697,7 +1697,7 @@ file_write_error_message(int err) gboolean file_exists(const char *fname) { - struct stat file_stat; + ws_statb64 file_stat; #ifdef _WIN32 /* @@ -1707,14 +1707,14 @@ file_exists(const char *fname) * so this is working, but maybe not quite the way expected. ULFL */ file_stat.st_ino = 1; /* this will make things work if an error occured */ - ws_stat(fname, &file_stat); + ws_stat64(fname, &file_stat); if (file_stat.st_ino == 0) { return TRUE; } else { return FALSE; } #else - if (ws_stat(fname, &file_stat) != 0 && errno == ENOENT) { + if (ws_stat64(fname, &file_stat) != 0 && errno == ENOENT) { return FALSE; } else { return TRUE; @@ -1764,14 +1764,14 @@ files_identical(const char *fname1, const char *fname2) return FALSE; } #else - struct stat filestat1, filestat2; + ws_statb64 filestat1, filestat2; /* * Compare st_dev and st_ino. */ - if (ws_stat(fname1, &filestat1) == -1) + if (ws_stat64(fname1, &filestat1) == -1) return FALSE; /* can't get info about the first file */ - if (ws_stat(fname2, &filestat2) == -1) + if (ws_stat64(fname2, &filestat2) == -1) return FALSE; /* can't get info about the second file */ return (filestat1.st_dev == filestat2.st_dev && filestat1.st_ino == filestat2.st_ino); diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c index eba82c5b96..ad42805f80 100644 --- a/gtk/capture_if_dlg.c +++ b/gtk/capture_if_dlg.c @@ -389,12 +389,12 @@ GtkWidget * capture_get_if_icon(const if_info_t* if_info _U_) /* * Look for /sys/class/net/{device}/wireless. */ - struct stat statb; + ws_statb64 statb; char *wireless_path; wireless_path = g_strdup_printf("/sys/class/net/%s/wireless", if_info->name); if (wireless_path != NULL) { - if (ws_stat(wireless_path, &statb) == 0) { + if (ws_stat64(wireless_path, &statb) == 0) { g_free(wireless_path); return pixbuf_to_widget(network_wireless_pb_data); } diff --git a/gtk/main_welcome.c b/gtk/main_welcome.c index 4b7215353a..8d92d66f11 100644 --- a/gtk/main_welcome.c +++ b/gtk/main_welcome.c @@ -447,7 +447,7 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label) gsize uni_start, uni_end; const glong max = 60; int err; - struct stat stat_buf; + ws_statb64 stat_buf; GtkTooltips *tooltips; @@ -475,7 +475,7 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label) * Add file size. We use binary prefixes instead of IEC because that's what * most OSes use. */ - err = ws_stat(filename, &stat_buf); + err = ws_stat64(filename, &stat_buf); if(err == 0) { if (stat_buf.st_size/1024/1024/1024 > 10) { g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d GB)", (gint64) (stat_buf.st_size/1024/1024/1024)); diff --git a/rawshark.c b/rawshark.c index 27d4d7639d..d1e08b98cf 100644 --- a/rawshark.c +++ b/rawshark.c @@ -247,7 +247,7 @@ static int raw_pipe_open(const char *pipe_name) { #ifndef _WIN32 - struct stat pipe_stat; + ws_statb64 pipe_stat; #else char *pncopy, *pos; DWORD err; @@ -272,7 +272,7 @@ raw_pipe_open(const char *pipe_name) #endif /* _WIN32 */ } else { #ifndef _WIN32 - if (ws_stat(pipe_name, &pipe_stat) < 0) { + if (ws_stat64(pipe_name, &pipe_stat) < 0) { fprintf(stderr, "rawshark: The pipe %s could not be checked: %s\n", pipe_name, strerror(errno)); return -1; diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 9a2f469096..7cdf216d1d 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -222,7 +222,7 @@ void wtap_register_open_routine(wtap_open_routine_t open_routine, gboolean has_m wtap* wtap_open_offline(const char *filename, int *err, char **err_info, gboolean do_random) { - struct stat statb; + ws_statb64 statb; wtap *wth; unsigned int i; gboolean use_stdin = FALSE; @@ -238,7 +238,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info, return NULL; } } else { - if (ws_stat(filename, &statb) < 0) { + if (ws_stat64(filename, &statb) < 0) { *err = errno; return NULL; } diff --git a/wsutil/file_util.c b/wsutil/file_util.c index c9bb0dc647..47b8deff1a 100644 --- a/wsutil/file_util.c +++ b/wsutil/file_util.c @@ -222,8 +222,8 @@ ws_stdio_mkdir (const gchar *filename, * Since: 2.6 */ int -ws_stdio_stat (const gchar *filename, - struct stat *buf) +ws_stdio_stat64 (const gchar *filename, + ws_statb64 *buf) { wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL); int retval; @@ -243,7 +243,7 @@ ws_stdio_stat (const gchar *filename, (!g_path_is_absolute (filename) || len > (size_t) (g_path_skip_root (filename) - filename))) wfilename[len] = '\0'; - retval = _wstat (wfilename, (struct _stat *) buf); + retval = _wstati64 (wfilename, buf); save_errno = errno; g_free (wfilename); diff --git a/wsutil/file_util.h b/wsutil/file_util.h index 65164165c3..d31746498f 100644 --- a/wsutil/file_util.h +++ b/wsutil/file_util.h @@ -60,7 +60,7 @@ extern FILE * ws_stdio_freopen (const gchar *filename, const gchar *mode, FILE * #define ws_open ws_stdio_open #define ws_rename ws_stdio_rename #define ws_mkdir ws_stdio_mkdir -#define ws_stat ws_stdio_stat +#define ws_stat64 ws_stdio_stat64 #define ws_unlink ws_stdio_unlink #define ws_remove ws_stdio_remove #define ws_fopen ws_stdio_fopen @@ -70,14 +70,16 @@ extern FILE * ws_stdio_freopen (const gchar *filename, const gchar *mode, FILE * /* "Not Windows" or GLib < 2.6: use "old school" functions */ #ifdef _WIN32 -#define ws_open _open -#define ws_stat _stat -#define ws_unlink _unlink +/* Windows, but GLib < 2.6 */ +#define ws_open _open +#define ws_stat64 _stati64 /* use _stati64 for 64-bit size support */ +#define ws_unlink _unlink #define ws_mkdir(dir,mode) _mkdir(dir) -#else -#define ws_open open -#define ws_stat stat -#define ws_unlink unlink +#else /* _WIN32 */ +/* "Not Windows" */ +#define ws_open open +#define ws_stat64 stat +#define ws_unlink unlink #define ws_mkdir(dir,mode) mkdir(dir,mode) #endif /* _WIN32 */ |