[ATL] Add CString.AllocSysString
[reactos.git] / sdk / lib / runtmchk / rtcuserapi.c
1 /*
2 * PROJECT: MSVC runtime check support library
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * PURPOSE: Provides support functions for MSVC runtime checks
5 * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
6 */
7
8 #include <rtcapi.h>
9
10 extern _RTC_error_fnW _RTC_pErrorFuncW;
11
12 int
13 __cdecl
14 _RTC_DefaultErrorFuncW(
15 int errType,
16 const wchar_t *file,
17 int line,
18 const wchar_t *module,
19 const wchar_t *format,
20 ...);
21
22 static
23 char*
24 _RTC_ErrorDescription[] =
25 {
26 "The stack pointer was wrong after returning from a function call.", /* _RTC_CHKSTK */
27 "Data was lost when a type was converted to a smaller type.", /* _RTC_CVRT_LOSS_INFO */
28 "The stack near a local variable was corrupted.", /* _RTC_CORRUPT_STACK */
29 "An uninitialized local variable was used.", /* _RTC_UNINIT_LOCAL_USE */
30 "The stack around an alloca was corrupted.", /* _RTC_CORRUPTED_ALLOCA */
31 };
32
33 int
34 __cdecl
35 _RTC_NumErrors(void)
36 {
37 /* Not supported yet */
38 __debugbreak();
39 return 0;
40 }
41
42 const char *
43 __cdecl
44 _RTC_GetErrDesc(
45 _RTC_ErrorNumber _Errnum)
46 {
47 if (_Errnum < (sizeof(_RTC_ErrorDescription) / sizeof(_RTC_ErrorDescription[0])))
48 {
49 return _RTC_ErrorDescription[_Errnum];
50 }
51
52 return "Invalid/Unknown error.";
53 }
54
55 int
56 __cdecl
57 _RTC_SetErrorType(
58 _RTC_ErrorNumber _Errnum,
59 int _ErrType)
60 {
61 /* Not supported yet */
62 __debugbreak();
63 return 0;
64 }
65
66 _RTC_error_fn
67 __cdecl
68 _RTC_SetErrorFunc(
69 _RTC_error_fn new_fn)
70 {
71 /* Not supported yet */
72 __debugbreak();
73 return 0;
74 }
75
76 _RTC_error_fnW
77 __cdecl
78 _RTC_SetErrorFuncW(_RTC_error_fnW new_fn)
79 {
80 _RTC_error_fnW old_fn;
81
82 /* Get the current error func */
83 old_fn = _RTC_pErrorFuncW;
84
85 /* Set the new function or reset when 0 was passed */
86 _RTC_pErrorFuncW = new_fn ? new_fn : _RTC_DefaultErrorFuncW;
87
88 /* Return the old error func, or 0, if none was set */
89 return old_fn != _RTC_DefaultErrorFuncW ? old_fn : 0;
90 }
91