Rename ws_stat to ws_stat64, and make it take a pointer to a ws_statb64
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 10 Apr 2011 20:59:10 +0000 (20:59 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 10 Apr 2011 20:59:10 +0000 (20:59 +0000)
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

asn1/kerberos/packet-kerberos-template.c
capture_opts.c
dumpcap.c
epan/dissectors/packet-kerberos.c
epan/filesystem.c
gtk/capture_if_dlg.c
gtk/main_welcome.c
rawshark.c
wiretap/file_access.c
wsutil/file_util.c
wsutil/file_util.h

index b82ce9230a750cea0d926490fa86ca9c9eb817ca..15e59109c6839a435d66f7260bf3f0cba26f7aa8 100644 (file)
@@ -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
index c13adb5ec0d03ebf231cd0b903db73f0fd3f4bd9..de857ad06cc9e1a79e4527d060a1c2cc462da222 100644 (file)
@@ -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))
index fd949d4684ed39e257c19a58780e26d2cebd9ba3..9a979484dac8fa774dad7904edcde9cdbf1f7156 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -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 {
index 71ceb4bb3baa58edb8997cfdda52047413a9e4c9..8d4c9f3a64cc372b5ad2be3a0bf7d2dc419340b6 100644 (file)
@@ -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
index 17fe5aceb582b1027bbc4eacd098b6e88135c852..01f6324ce8968fb81c66b3b866505ce95f7c763d 100644 (file)
@@ -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);
index eba82c5b9652f3681816af5feef0776cb272e1e4..ad42805f804b4b2a4291419b4a4acc6f11315028 100644 (file)
@@ -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);
     }
index 4b7215353a22d7d35897afe55335ba58e3298149..8d92d66f11f7ebd63fd10da6cf2ee511f091c3e5 100644 (file)
@@ -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));
index 27d4d7639de98e4be8d06bc1650b4bcb3ce0bf6b..d1e08b98cfa37353e5bd165e36b70a748f5d9e6a 100644 (file)
@@ -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;
index 9a2f469096620eaa625aff673455df35bec133db..7cdf216d1da5c7d402fb651dd2222f73f623c692 100644 (file)
@@ -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;
                }
index c9bb0dc647c94b6a1e1ad29ddebc576ff8e4c07c..47b8deff1ae29ff3b9246628364d8ed52d295295 100644 (file)
@@ -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);
index 65164165c3ba9a759f452ad5fc5fc7683c41554f..d31746498f7f4f0a52cb187ae5f2a7222a60ec57 100644 (file)
@@ -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 */