[APPHELP] Implement automatic stringtable generation when writing an Sdb database...
[reactos.git] / reactos / dll / appcompat / apphelp / sdbpapi.h
1 /*
2 * Copyright 2013 Mislav Blažević
3 * Copyright 2015,2016 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 SDBPAPI_H
21 #define SDBPAPI_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 void SdbpHeapInit(void);
28 void SdbpHeapDeinit(void);
29
30 #if SDBAPI_DEBUG_ALLOC
31
32 LPVOID SdbpAlloc(SIZE_T size, int line, const char* file);
33 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, int line, const char* file);
34 void SdbpFree(LPVOID mem, int line, const char* file);
35
36 #define SdbAlloc(size) SdbpAlloc(size, __LINE__, __FILE__)
37 #define SdbReAlloc(mem, size) SdbpReAlloc(mem, size, __LINE__, __FILE__)
38 #define SdbFree(mem) SdbpFree(mem, __LINE__, __FILE__)
39
40 #else
41
42 LPVOID SdbpAlloc(SIZE_T size);
43 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size);
44 void SdbpFree(LPVOID mem);
45
46 #define SdbAlloc(size) SdbpAlloc(size)
47 #define SdbReAlloc(mem, size) SdbpReAlloc(mem, size)
48 #define SdbFree(mem) SdbpFree(mem)
49
50 #endif
51
52 #if !defined(SDBWRITE_HOSTTOOL)
53 typedef struct tagMEMMAPPED {
54 HANDLE file;
55 HANDLE section;
56 PBYTE view;
57 SIZE_T size;
58 SIZE_T mapped_size;
59 } MEMMAPPED, *PMEMMAPPED;
60
61 BOOL WINAPI SdbpOpenMemMappedFile(LPCWSTR path, PMEMMAPPED mapping);
62 void WINAPI SdbpCloseMemMappedFile(PMEMMAPPED mapping);
63 #endif
64
65
66 PDB WINAPI SdbpCreate(LPCWSTR path, PATH_TYPE type, BOOL write);
67 void WINAPI SdbpFlush(PDB db);
68 DWORD SdbpStrlen(PCWSTR string);
69 DWORD SdbpStrsize(PCWSTR string);
70
71 BOOL WINAPI SdbpCheckTagType(TAG tag, WORD type);
72 BOOL WINAPI SdbpCheckTagIDType(PDB db, TAGID tagid, WORD type);
73
74
75 typedef enum _SHIM_LOG_LEVEL {
76 SHIM_ERR = 1,
77 SHIM_WARN = 2,
78 SHIM_INFO = 3,
79 } SHIM_LOG_LEVEL;
80
81 BOOL WINAPIV ShimDbgPrint(SHIM_LOG_LEVEL Level, PCSTR FunctionName, PCSTR Format, ...);
82 extern ULONG g_ShimDebugLevel;
83
84 #define SHIM_ERR(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_ERR, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
85 #define SHIM_WARN(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_WARN, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
86 #define SHIM_INFO(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_INFO, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
87
88 #ifdef __cplusplus
89 } // extern "C"
90 #endif
91
92 #endif // SDBPAPI_H