8bed7b64b292e3afe2e3db90ab232b4f796d35d0
[reactos.git] / reactos / dll / appcompat / apphelp / apphelp.h
1 /*
2 * Copyright 2013 Mislav Blažević
3 * Copyright 2015 Mark Jansen
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 #ifndef APPHELP_H
21 #define APPHELP_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 typedef enum _SHIM_LOG_LEVEL {
28 SHIM_ERR = 1,
29 SHIM_WARN = 2,
30 SHIM_INFO = 3,
31 }SHIM_LOG_LEVEL;
32
33 /* apphelp.c */
34 BOOL WINAPIV ShimDbgPrint(SHIM_LOG_LEVEL Level, PCSTR FunctionName, PCSTR Format, ...);
35 extern ULONG g_ShimDebugLevel;
36
37 #define SHIM_ERR(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_ERR, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
38 #define SHIM_WARN(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_WARN, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
39 #define SHIM_INFO(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_INFO, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
40
41
42 /* sdbapi.c */
43 void SdbpHeapInit(void);
44 void SdbpHeapDeinit(void);
45 #if SDBAPI_DEBUG_ALLOC
46
47 LPVOID SdbpAlloc(SIZE_T size, int line, const char* file);
48 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, int line, const char* file);
49 void SdbpFree(LPVOID mem, int line, const char* file);
50
51 #define SdbAlloc(size) SdbpAlloc(size, __LINE__, __FILE__)
52 #define SdbReAlloc(mem, size) SdbpReAlloc(mem, size, __LINE__, __FILE__)
53 #define SdbFree(mem) SdbpFree(mem, __LINE__, __FILE__)
54
55 #else
56
57 LPVOID SdbpAlloc(SIZE_T size);
58 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size);
59 void SdbpFree(LPVOID mem);
60
61 #define SdbAlloc(size) SdbpAlloc(size)
62 #define SdbReAlloc(mem, size) SdbpReAlloc(mem, size)
63 #define SdbFree(mem) SdbpFree(mem)
64
65 #endif
66
67 #ifdef __cplusplus
68 } // extern "C"
69 #endif
70
71 #endif // APPHELP_H