]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
use the underscore version of stat on Windows
authorHeiko Hund <heiko.hund@sophos.com>
Thu, 16 Feb 2012 17:30:40 +0000 (18:30 +0100)
committerDavid Sommerseth <davids@redhat.com>
Fri, 17 Feb 2012 10:01:10 +0000 (11:01 +0100)
MSVC does not know wstat(). Instead _wstat() must be used here.
Unfortunately _wstat() takes a 'struct _stat'. A type 'stat_t' is
introduced to handle this situation in a portable way.

[v2: Use openvpn_stat_t instead of stat_t (David Sommerseth)]

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
misc.h
pf.c
win32.c

diff --git a/misc.h b/misc.h
index e7a0b55e9817c02b0fa2bbb2d589911efaa6f45c..bdada42c5b8c03d5b7f09813b77bf5bd98ee26ed 100644 (file)
--- a/misc.h
+++ b/misc.h
@@ -168,10 +168,12 @@ openvpn_open (const char *path, int flags, mode_t mode)
 #endif
 
 #ifdef WIN32
-int openvpn_stat (const char *path, struct stat *buf);
+typedef struct _stat openvpn_stat_t;
+int openvpn_stat (const char *path, openvpn_stat_t *buf);
 #else
+typedef struct stat openvpn_stat_t;
 static inline int
-openvpn_stat (const char *path, struct stat *buf)
+openvpn_stat (const char *path, openvpn_stat_t *buf)
 {
   return stat (path, buf);
 }
diff --git a/pf.c b/pf.c
index a0e9fc82d0163d4de50857d57dc502dc30b5f5e3..0ef839e01276b029f2c2ecb159421977415dec73 100644 (file)
--- a/pf.c
+++ b/pf.c
@@ -498,7 +498,7 @@ pf_check_reload (struct context *c)
       && c->c2.pf.filename
       && event_timeout_trigger (&c->c2.pf.reload, &c->c2.timeval, ETT_DEFAULT))
     {
-      struct stat s;
+      openvpn_stat_t s;
       if (!openvpn_stat (c->c2.pf.filename, &s))
        {
          if (s.st_mtime > c->c2.pf.file_last_mod)
diff --git a/win32.c b/win32.c
index a8f4ed9a6681a585a4c837aa48527462ca80120f..2ba97fcf3bd08de78883e9ccd2ffbd0e29dee4f6 100644 (file)
--- a/win32.c
+++ b/win32.c
@@ -1073,10 +1073,10 @@ openvpn_open (const char *path, int flags, int mode)
 }
 
 int
-openvpn_stat (const char *path, struct stat *buf)
+openvpn_stat (const char *path, openvpn_stat_t *buf)
 {
   struct gc_arena gc = gc_new ();
-  int res = wstat (wide_string (path, &gc), buf);
+  int res = _wstat (wide_string (path, &gc), buf);
   gc_free (&gc);
   return res;
 }