2015-06-25 09:24:52 -04:00
|
|
|
/**
|
|
|
|
* Workaround for lack of snprintf(3) in Visual Studio. See
|
|
|
|
* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010/8712996#8712996
|
|
|
|
* It's a trivial wrapper around the builtin _vsnprintf_s and
|
|
|
|
* _vscprintf functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
2015-08-18 22:31:04 -04:00
|
|
|
#include "libport.h"
|
2015-06-25 09:24:52 -04:00
|
|
|
|
2015-08-20 21:59:33 -04:00
|
|
|
int _TIFF_vsnprintf_f(char* str, size_t size, const char* format, va_list ap)
|
2015-06-25 09:24:52 -04:00
|
|
|
{
|
|
|
|
int count = -1;
|
|
|
|
|
|
|
|
if (size != 0)
|
2018-11-18 21:25:17 -05:00
|
|
|
#if _MSC_VER <= 1310
|
|
|
|
count = _vsnprintf(str, size, format, ap);
|
|
|
|
#else
|
2015-06-25 09:24:52 -04:00
|
|
|
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
|
2018-11-18 21:25:17 -05:00
|
|
|
#endif
|
2015-06-25 09:24:52 -04:00
|
|
|
if (count == -1)
|
|
|
|
count = _vscprintf(format, ap);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2015-08-20 21:59:33 -04:00
|
|
|
int _TIFF_snprintf_f(char* str, size_t size, const char* format, ...)
|
2015-06-25 09:24:52 -04:00
|
|
|
{
|
|
|
|
int count;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, format);
|
|
|
|
count = vsnprintf(str, size, format, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // _MSC_VER
|