2007-05-08 17:11:53 +02:00
|
|
|
/**
|
|
|
|
* =========================================================================
|
|
|
|
* File : secure_crt.cpp
|
|
|
|
* Project : 0 A.D.
|
|
|
|
* Description : partial implementation of VC8's secure CRT functions
|
|
|
|
* =========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
// license: GPL; see lib/license.txt
|
|
|
|
|
2007-01-07 17:50:36 +01:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "secure_crt.h"
|
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
#if !HAVE_SECURE_CRT
|
2007-01-07 17:50:36 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2007-01-08 02:56:46 +01:00
|
|
|
|
|
|
|
#endif // #if !HAVE_SECURE_CRT
|