/* The X64 libraries from Microsoft are missing all the 'secure' system
   calls. Below are some glue functions to translate the _s calls into
   flat calls. */

#ifdef _WIN64

#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdio.h>
#include <time.h>
#include <sys/timeb.h>

#define errno_t int
#define fprintf_s fprintf
#define fwprintf_s fwprintf
#define INT_MAX 2147483647

errno_t fopen_s(FILE** pFile, const char *filename, const char *mode);
errno_t _wfopen_s(FILE** pFile, const WCHAR *filename, const WCHAR *mode);
errno_t localtime_s(struct tm *TimeTm, const time_t *Time);
errno_t _ftime64_s(struct __timeb64 *TimeB);
errno_t strcpy_s(char *StrDestination, size_t SizeInBytes, const char *StrSource);
errno_t strncpy_s(char *StrDestination, size_t SizeInBytes, const char *StrSource, size_t Count);
errno_t wcscpy_s(wchar_t *StrDestination, size_t SizeInBytes, const wchar_t *StrSource);
errno_t wcsncpy_s(wchar_t *StrDestination, size_t SizeInBytes, const wchar_t *StrSource, size_t Count);
errno_t strcat_s(char *StrDestination, size_t SizeInBytes, const char *StrSource);
errno_t wcscat_s(wchar_t *StrDestination, size_t SizeInBytes, const wchar_t *StrSource);
int sprintf_s(char *Buffer, size_t SizeOfBuffer, const char *Format, ... );
int swprintf_s(wchar_t *Buffer, size_t SizeOfBuffer, const wchar_t *Format, ... );
int vsprintf_s(char *Buffer, size_t SizeOfBuffer, const char *Format, va_list Args);
int vswprintf_s(WCHAR *Buffer, size_t SizeOfBuffer, const WCHAR *Format, va_list Args);
int vfprintf_s(FILE *Stream, const char *Format, va_list Args);
int vfwprintf_s(FILE *Stream, const WCHAR *Format, va_list Args);
errno_t _strerror_s(char *Buffer, size_t SizeInBytes, const char *strErrMsg);

#endif