1 /*
2 * Summary: Windows configuration header
3 * Description: Windows configuration header
4 *
5 * Copy: See Copyright for the status of this software.
6 *
7 * Author: Igor Zlatkovic
8 */
9 #ifndef __LIBXSLT_WIN32_CONFIG__
10 #define __LIBXSLT_WIN32_CONFIG__
11
12 /* snprintf emulation taken from http://stackoverflow.com/a/8712996/1956010 */
13 #if defined(_MSC_VER) && _MSC_VER < 1900
14
15 #include <stdarg.h>
16 #include <stdio.h>
17
18 #define snprintf c99_snprintf
19 #define vsnprintf c99_vsnprintf
20
c99_vsnprintf(char * outBuf,size_t size,const char * format,va_list ap)21 __inline int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
22 {
23 int count = -1;
24
25 if (size != 0)
26 count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
27 if (count == -1)
28 count = _vscprintf(format, ap);
29
30 return count;
31 }
32
c99_snprintf(char * outBuf,size_t size,const char * format,...)33 __inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
34 {
35 int count;
36 va_list ap;
37
38 va_start(ap, format);
39 count = c99_vsnprintf(outBuf, size, format, ap);
40 va_end(ap);
41
42 return count;
43 }
44
45 #endif /* defined(_MSC_VER) && _MSC_VER < 1900 */
46
47 #define HAVE_SYS_STAT_H
48 #define HAVE__STAT
49
50 #endif /* __LIBXSLT_WIN32_CONFIG__ */
51
52