mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-25 03:32:23 +00:00
2e5d9452aa
move all except user-specified config choices out of config.h and into appropriate headers CPU_IA32 -> ARCH_IA32 wsdl: disable use of ddraw (will soon be replaced by WMI) use shared_ptr without namespace qualifier (it's in tr1) debug_warn -> debug_assert(0) LIB_API to allow building as DLL smart pointers: reduce use of .get() cache_adt: use map instead of hash_map (avoids needing a hashCompare class). also remove spurious warning code_annotation.h: better cassert implementation move FPS measuring portion of timer.cpp into frequency_filter move include of memory headers into mmgr.h (to avoid errors, we must ensure they are included if mmgr is used) posix_filesystem.h: move definition of mkdir to wfilesystem stl: disable iterator checks in release mode wmi: fix COM init bug, use smart pointers wutil: add code to get DLL module handle (if compiled as such), add WinScopedLock timer: fix handling of raw ticks This was SVN commit r5517.
87 lines
3.6 KiB
C++
87 lines
3.6 KiB
C++
/**
|
|
* =========================================================================
|
|
* File : secure_crt.cpp
|
|
* Project : 0 A.D.
|
|
* Description : partial implementation of VC8's secure CRT functions
|
|
* =========================================================================
|
|
*/
|
|
|
|
// license: GPL; see lib/license.txt
|
|
|
|
#ifndef INCLUDED_SECURE_CRT
|
|
#define INCLUDED_SECURE_CRT
|
|
|
|
namespace ERR
|
|
{
|
|
const LibError STRING_NOT_TERMINATED = -100600;
|
|
}
|
|
|
|
// if the platform lacks a secure CRT implementation, we'll provide one.
|
|
#if MSC_VERSION >= 1400
|
|
# define EMULATE_SECURE_CRT 0
|
|
#else
|
|
# define EMULATE_SECURE_CRT 1
|
|
#endif
|
|
|
|
|
|
#if EMULATE_SECURE_CRT
|
|
|
|
// (conflicts with glibc definitions)
|
|
#if !OS_UNIX
|
|
// return length [in characters] of a string, not including the trailing
|
|
// null character. to protect against access violations, only the
|
|
// first <max_len> characters are examined; if the null character is
|
|
// not encountered by then, <max_len> is returned.
|
|
extern size_t strnlen(const char* str, size_t max_len);
|
|
extern size_t wcsnlen(const wchar_t* str, size_t max_len);
|
|
#endif
|
|
|
|
// copy at most <max_src_chars> (not including trailing null) from
|
|
// <src> into <dst>, which must not overlap.
|
|
// if thereby <max_dst_chars> (including null) would be exceeded,
|
|
// <dst> is set to the empty string and ERANGE returned; otherwise,
|
|
// 0 is returned to indicate success and that <dst> is null-terminated.
|
|
//
|
|
// note: padding with zeroes is not called for by NG1031.
|
|
extern int strncpy_s(char* dst, size_t max_dst_chars, const char* src, size_t max_src_chars);
|
|
extern int wcsncpy_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src, size_t max_src_chars);
|
|
|
|
// copy <src> (including trailing null) into <dst>, which must not overlap.
|
|
// if thereby <max_dst_chars> (including null) would be exceeded,
|
|
// <dst> is set to the empty string and ERANGE returned; otherwise,
|
|
// 0 is returned to indicate success and that <dst> is null-terminated.
|
|
//
|
|
// note: implemented as tncpy_s(dst, max_dst_chars, src, SIZE_MAX)
|
|
extern int strcpy_s(char* dst, size_t max_dst_chars, const char* src);
|
|
extern int wcscpy_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src);
|
|
|
|
// append at most <max_src_chars> (not including trailing null) from
|
|
// <src> to <dst>, which must not overlap.
|
|
// if thereby <max_dst_chars> (including null) would be exceeded,
|
|
// <dst> is set to the empty string and ERANGE returned; otherwise,
|
|
// 0 is returned to indicate success and that <dst> is null-terminated.
|
|
extern int strncat_s(char* dst, size_t max_dst_chars, const char* src, size_t max_src_chars);
|
|
extern int wcsncat_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src, size_t max_src_chars);
|
|
|
|
// append <src> to <dst>, which must not overlap.
|
|
// if thereby <max_dst_chars> (including null) would be exceeded,
|
|
// <dst> is set to the empty string and ERANGE returned; otherwise,
|
|
// 0 is returned to indicate success and that <dst> is null-terminated.
|
|
//
|
|
// note: implemented as tncat_s(dst, max_dst_chars, src, SIZE_MAX)
|
|
extern int strcat_s(char* dst, size_t max_dst_chars, const char* src);
|
|
extern int wcscat_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src);
|
|
|
|
|
|
extern int sprintf_s(char* buf, size_t max_chars, const char* fmt, ...);
|
|
extern int swprintf_s(wchar_t* buf, size_t max_chars, const wchar_t* fmt, ...);
|
|
|
|
typedef int errno_t;
|
|
extern errno_t fopen_s(FILE** pfile, const char* filename, const char* mode);
|
|
extern errno_t _wfopen_s(FILE** pfile, const wchar_t* filename, const wchar_t* mode);
|
|
|
|
#define fscanf_s fscanf
|
|
|
|
#endif // #if EMULATE_SECURE_CRT
|
|
#endif // #ifndef INCLUDED_SECURE_CRT
|