SysIo  1.9.0
Embedded Library and tools
compat.h
1 
9 #ifndef _SYSIO_COMPAT_H_
10 #define _SYSIO_COMPAT_H_
11 
12 #if defined(_MSC_VER)
13 // -----------------------------------------------------------------------------
14 // Portabilité POSIX et GNU
15 #include <string.h>
16 
17 // -----------------------------------------------------------------------------
18 __inline int
19 strcasecmp(const char *s1, const char *s2) {
20 
21  return _stricmp (s1, s2);
22 }
23 
24 #if _MSC_VER < 1900
25 // -----------------------------------------------------------------------------
26 #include <stdio.h>
27 #include <stdarg.h>
28 
29 #define snprintf c99_snprintf
30 #define vsnprintf c99_vsnprintf
31 
32 // -----------------------------------------------------------------------------
33 __inline int
34 c99_vsnprintf (char *outBuf, size_t size, const char *format, va_list ap) {
35  int count = -1;
36 
37  if (size != 0) {
38  count = _vsnprintf_s (outBuf, size, _TRUNCATE, format, ap);
39  }
40  if (count == -1) {
41  count = _vscprintf (format, ap);
42  }
43 
44  return count;
45 }
46 
47 // -----------------------------------------------------------------------------
48 __inline int
49 c99_snprintf (char *outBuf, size_t size, const char *format, ...) {
50  int count;
51  va_list ap;
52 
53  va_start (ap, format);
54  count = c99_vsnprintf (outBuf, size, format, ap);
55  va_end (ap);
56 
57  return count;
58 }
59 // -----------------------------------------------------------------------------
60 #endif /* _MSC_VER < 1900 */
61 #endif /* _MSC_VER defined */
62 #endif /* _SYSIO_COMPAT_H_ defined */