summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2013-07-01 14:23:04 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2013-07-01 14:23:04 (GMT)
commit53afd20aeb09fb2565811cc3dbf22890f0fcf900 (patch)
treef4d7a807515ed9c4f39fc7302824c55155cc9c0a /src
parenta157eb2f689d873a53e96cfc486db423658c7902 (diff)
downloadhdf5-53afd20aeb09fb2565811cc3dbf22890f0fcf900.zip
hdf5-53afd20aeb09fb2565811cc3dbf22890f0fcf900.tar.gz
hdf5-53afd20aeb09fb2565811cc3dbf22890f0fcf900.tar.bz2
[svn-r23854] HDFFV-8302: Add macros/code function to use coorect Windows (v)snprintf statement. Also fix use other uses of macros for windows.
Tested
Diffstat (limited to 'src')
-rw-r--r--src/H5FDstdio.c4
-rw-r--r--src/H5system.c24
-rw-r--r--src/H5win32defs.h10
3 files changed, 35 insertions, 3 deletions
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index 8f4f7f0..64919ed 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -414,7 +414,11 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id,
}
/* Get the file descriptor (needed for truncate and some Windows information) */
+#ifdef H5_HAVE_WIN32_API
+ file->fd = _fileno(file->fp);
+#else /* H5_HAVE_WIN32_API */
file->fd = fileno(file->fp);
+#endif /* H5_HAVE_WIN32_API */
if(file->fd < 0) {
free(file);
fclose(f);
diff --git a/src/H5system.c b/src/H5system.c
index a93a128..85e554e 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -666,6 +666,30 @@ Wgetlogin()
return NULL;
}
+int c99_snprintf(char* str, size_t size, const char* format, ...)
+{
+ int count;
+ va_list ap;
+
+ va_start(ap, format);
+ count = c99_vsnprintf(str, size, format, ap);
+ va_end(ap);
+
+ return count;
+}
+
+int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
+{
+ int count = -1;
+
+ if (size != 0)
+ count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
+ if (count == -1)
+ count = _vscprintf(format, ap);
+
+ return count;
+}
+
#endif
diff --git a/src/H5win32defs.h b/src/H5win32defs.h
index e9b87625..d452925 100644
--- a/src/H5win32defs.h
+++ b/src/H5win32defs.h
@@ -29,6 +29,7 @@ typedef struct _stati64 h5_stat_t;
typedef __int64 h5_stat_size_t;
#define HDaccess(F,M) _access(F,M)
+#define HDchdir(S) _chdir(S)
#define HDclose(F) _close(F)
#define HDdup(F) _dup(F)
#define HDfdopen(N,S) _fdopen(N,S)
@@ -47,16 +48,15 @@ typedef __int64 h5_stat_size_t;
*/
#define HDopen(S,F,M) _open(S,F|_O_BINARY,M)
#define HDread(F,M,Z) _read(F,M,Z)
+#define HDrmdir(S) _rmdir(S)
#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2))
#define HDsleep(S) Sleep(S*1000)
#define HDstat(S,B) _stati64(S,B)
#define HDstrcasecmp(A,B) _stricmp(A,B)
#define HDstrtoull(S,R,N) _strtoui64(S,R,N)
#define HDstrdup(S) _strdup(S)
-#define HDsnprintf _snprintf /*varargs*/
#define HDtzset() _tzset()
#define HDunlink(S) _unlink(S)
-#define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A)
#define HDwrite(F,M,Z) _write(F,M,Z)
#ifdef H5_HAVE_VISUAL_STUDIO
@@ -75,11 +75,15 @@ struct timezone {
#endif /* __cplusplus */
H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz);
H5_DLL char* Wgetlogin();
+ H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...);
+ H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#define HDgettimeofday(V,Z) Wgettimeofday(V,Z)
-#define HDgetlogin() Wgetlogin()
+#define HDgetlogin() Wgetlogin()
+#define HDsnprintf c99_snprintf /*varargs*/
+#define HDvsnprintf c99_vsnprintf
#endif /* H5_HAVE_VISUAL_STUDIO */