VC6.0 : Provide the missing snprintf function.

git-svn-id: svn://svn.code.sf.net/p/hxcfloppyemu/code/HxCFloppyEmulator/libhxcadaptor/trunk@1765 63fa2f70-6a9b-4bc4-b855-9c6a949b1d69
This commit is contained in:
Jean-François DEL NERO
2019-08-18 16:32:45 +00:00
parent 878df4d5b1
commit 5c87fcca3e
2 changed files with 42 additions and 0 deletions
+39
View File
@@ -580,3 +580,42 @@ int hxc_getfilesize(char * path)
return filesize;
}
#ifdef WIN32
#if defined(_MSC_VER) && _MSC_VER < 1900
#define va_copy(dest, src) (dest = src)
int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
{
int ret;
va_list ap_copy;
if (n == 0)
return 0;
else if (n > INT_MAX)
return 0;
memset(s, 0, n);
va_copy(ap_copy, ap);
ret = _vsnprintf(s, n - 1, fmt, ap_copy);
va_end(ap_copy);
return ret;
}
int snprintf(char *s, size_t n, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = vsnprintf(s, n, fmt, ap);
va_end(ap);
return ret;
}
#endif
#endif
+3
View File
@@ -5,6 +5,9 @@ extern "C" {
#ifdef WIN32
#define DIR_SEPARATOR "\\"
#define DIR_SEPARATOR_CHAR '\\'
#if defined(_MSC_VER) && _MSC_VER < 1900
int snprintf(char *outBuf, size_t size, const char *format, ...);
#endif
#else
#define DIR_SEPARATOR "/"
#define DIR_SEPARATOR_CHAR '/'