1 /*
2  * Public domain
3  * stdio.h compatibility shim
4  */
5 
6 #ifndef LIBCRYPTOCOMPAT_STDIO_H
7 #define LIBCRYPTOCOMPAT_STDIO_H
8 
9 #ifdef _MSC_VER
10 #if _MSC_VER >= 1900
11 #include <../ucrt/stdlib.h>
12 #include <../ucrt/corecrt_io.h>
13 #include <../ucrt/stdio.h>
14 #else
15 #include <../include/stdio.h>
16 #endif
17 #else
18 #include_next <stdio.h>
19 #endif
20 
21 #ifndef HAVE_ASPRINTF
22 #include <stdarg.h>
23 int vasprintf(char **str, const char *fmt, va_list ap);
24 int asprintf(char **str, const char *fmt, ...);
25 #endif
26 
27 #ifdef _WIN32
28 
29 #if defined(_MSC_VER)
30 #define __func__ __FUNCTION__
31 #endif
32 
33 void posix_perror(const char *s);
34 FILE * posix_fopen(const char *path, const char *mode);
35 char * posix_fgets(char *s, int size, FILE *stream);
36 int posix_rename(const char *oldpath, const char *newpath);
37 
38 #ifndef NO_REDEF_POSIX_FUNCTIONS
39 #define perror(errnum) posix_perror(errnum)
40 #define fopen(path, mode) posix_fopen(path, mode)
41 #define fgets(s, size, stream) posix_fgets(s, size, stream)
42 #define rename(oldpath, newpath) posix_rename(oldpath, newpath)
43 #endif
44 
45 #ifdef _MSC_VER
46 #define snprintf _snprintf
47 #endif
48 
49 #endif
50 
51 #endif
52