Add mechanisms to reformant and check code style (#128)
[openjpeg.git] / thirdparty / libtiff / snprintf.c
1 /**
2  * Workaround for lack of snprintf(3) in Visual Studio.  See
3  * http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010/8712996#8712996
4  * It's a trivial wrapper around the builtin _vsnprintf_s and
5  * _vscprintf functions.
6  */
7
8 #ifdef _MSC_VER
9
10 #include <stdio.h>
11 #include <stdarg.h>
12 #include "libport.h"
13
14 int _TIFF_vsnprintf_f(char* str, size_t size, const char* format, va_list ap)
15 {
16   int count = -1;
17
18   if (size != 0)
19     count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
20   if (count == -1)
21     count = _vscprintf(format, ap);
22
23   return count;
24 }
25
26 int _TIFF_snprintf_f(char* str, size_t size, const char* format, ...)
27 {
28   int count;
29   va_list ap;
30
31   va_start(ap, format);
32   count = vsnprintf(str, size, format, ap);
33   va_end(ap);
34
35   return count;
36 }
37
38 #endif // _MSC_VER