0ad/source/lib/secure_crt.cpp

41 lines
878 B
C++
Raw Normal View History

/**
* =========================================================================
* File : secure_crt.cpp
* Project : 0 A.D.
* Description : partial implementation of VC8's secure CRT functions
* =========================================================================
*/
// license: GPL; see lib/license.txt
#include "precompiled.h"
#include <stdio.h>
#include <errno.h>
#include "secure_crt.h"
#if !HAVE_SECURE_CRT
int sprintf_s(char* buf, size_t max_chars, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
int len = vsnprintf(buf, max_chars, fmt, args);
va_end(args);
return len;
}
errno_t fopen_s(FILE** pfile, const char* filename, const char* mode)
{
*pfile = NULL;
FILE* file = fopen(filename, mode);
if(!file)
return ENOENT;
*pfile = file;
return 0;
}
#endif // #if !HAVE_SECURE_CRT