winprefs v0.3.2
A registry exporter for programmers.
Loading...
Searching...
No Matches
wrappers.c
1#include "wrappers.h"
2#include "io.h"
3
4bool __wrap_save_preferences(bool commit,
5 const wchar_t *deploy_key,
6 const wchar_t *output_dir,
7 const wchar_t *output_file,
8 int max_depth,
9 HKEY hk,
10 const wchar_t *specified_path,
11 enum OUTPUT_FORMAT format) {
12 check_expected(commit);
13 check_expected(format);
14 check_expected(max_depth);
15 check_expected_ptr(deploy_key);
16 check_expected_ptr(hk);
17 check_expected_ptr(output_dir);
18 check_expected_ptr(output_file);
19 check_expected_ptr(specified_path);
20 return mock_type(bool);
21}
22
23bool __wrap_export_single_value(HKEY top_key, const wchar_t *reg_path, enum OUTPUT_FORMAT format) {
24 check_expected(format);
25 check_expected_ptr(reg_path);
26 check_expected_ptr(top_key);
27 return mock_type(bool);
28}
29
30wchar_t *__wrap_get_git_branch(const wchar_t *git_dir_arg,
31 size_t git_dir_arg_len,
32 const wchar_t *work_tree_arg,
33 size_t work_tree_arg_len) {
34 return mock_ptr_type(wchar_t *);
35}
36
37LSTATUS __wrap_RegCloseKey(HKEY hKey) {
38 return mock_type(LSTATUS);
39}
40
41int __wrap_GetTimeFormat(LCID Locale,
42 DWORD dwFlags,
43 const SYSTEMTIME *lpTime,
44 LPCWSTR lpFormat,
45 LPWSTR lpTimeStr,
46 int cchTime) {
47 return mock_type(int);
48}
49
50int __wrap_GetDateFormat(LCID Locale,
51 DWORD dwFlags,
52 const SYSTEMTIME *lpDate,
53 LPCWSTR lpFormat,
54 LPWSTR lpDateStr,
55 int cchDate) {
56 return mock_type(int);
57}
58
59wchar_t *__wrap__wfullpath(wchar_t *absPath, const wchar_t *relPath, size_t maxLength) {
60 wchar_t *absPathRet = mock_ptr_type(wchar_t *);
61 wmemset(absPath, L'\0', maxLength);
62 if (absPathRet) {
63 wmemcpy(absPath, absPathRet, wcslen(absPathRet));
64 }
65 return mock_ptr_type(wchar_t *);
66}
67
68DWORD __wrap_GetLastError() {
69 return mock_type(DWORD);
70}
71
72int __wrap__wchdir(const wchar_t *dirname) {
73 return mock_type(int);
74}
75
76bool __wrap_CloseHandle(HANDLE hObject) {
77 return mock_type(bool);
78}
79
80bool __wrap_CreateProcess(LPCWSTR lpApplicationName,
81 LPWSTR lpCommandLine,
82 LPSECURITY_ATTRIBUTES lpProcessAttributes,
83 LPSECURITY_ATTRIBUTES lpThreadAttributes,
84 bool bInheritHandles,
85 DWORD dwCreationFlags,
86 LPVOID lpEnvironment,
87 LPCWSTR lpCurrentDirectory,
88 LPSTARTUPINFO lpStartupInfo,
89 LPPROCESS_INFORMATION lpProcessInformation) {
90 return mock_type(bool);
91}
92
93bool __wrap_WriteFile(HANDLE hFile,
94 LPCVOID lpBuffer,
95 DWORD nNumberOfBytesToWrite,
96 LPDWORD lpNumberOfBytesWritten,
97 LPOVERLAPPED lpOverlapped) {
98 check_expected(nNumberOfBytesToWrite);
99 *lpNumberOfBytesWritten = mock_type(DWORD);
100 return mock_type(bool);
101}
102
103HANDLE __wrap_GetStdHandle(DWORD nStdHandle) {
104 return mock_ptr_type(HANDLE);
105}
106
107int __wrap_MultiByteToWideChar(UINT CodePage,
108 DWORD dwFlags,
109 LPCCH lpMultiByteStr,
110 int cbMultiByte,
111 LPWSTR lpWideCharStr,
112 int cchWideChar) {
113 check_expected(cchWideChar);
114 wchar_t *wc_ret = mock_ptr_type(wchar_t *);
115 if (lpWideCharStr && wc_ret) {
116 wmemcpy(lpWideCharStr, wc_ret, (size_t)cchWideChar);
117 }
118 return mock_type(int);
119}
120
121int __wrap_WideCharToMultiByte(UINT CodePage,
122 DWORD dwFlags,
123 LPCWCH lpWideCharStr,
124 int cchWideChar,
125 LPSTR lpMultiByteStr,
126 int cbMultiByte,
127 LPCCH lpDefaultChar,
128 bool *lpUsedDefaultChar) {
129 return mock_type(int);
130}
131
132void __wrap_PathStripPath(LPWSTR pszPath) {
133}
134
135LSTATUS __wrap_RegEnumValue(HKEY hKey,
136 DWORD dwIndex,
137 LPWSTR lpValueName,
138 LPDWORD lpcchValueName,
139 LPDWORD lpReserved,
140 LPDWORD lpType,
141 LPBYTE lpData,
142 LPDWORD lpcbData) {
143 return mock_type(LSTATUS);
144}
145
146DWORD __wrap_WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) {
147 return mock_type(DWORD);
148}
149
150bool __wrap_PeekNamedPipe(HANDLE hNamedPipe,
151 LPVOID lpBuffer,
152 DWORD nBufferSize,
153 LPDWORD lpBytesRead,
154 LPDWORD lpTotalBytesAvail,
155 LPDWORD lpBytesLeftThisMessage) {
156 *lpTotalBytesAvail = mock_type(DWORD);
157 return mock_type(bool);
158}
159
160bool __wrap_ReadFile(HANDLE hFile,
161 LPVOID lpBuffer,
162 DWORD nNumberOfBytesToRead,
163 LPDWORD lpNumberOfBytesRead,
164 LPOVERLAPPED lpOverlapped) {
165 lpBuffer = mock_ptr_type(char *);
166 *lpNumberOfBytesRead = mock_type(DWORD);
167 return mock_type(bool);
168}
169
170HANDLE __wrap_CreateFile(LPCWSTR lpFileName,
171 DWORD dwDesiredAccess,
172 DWORD dwShareMode,
173 LPSECURITY_ATTRIBUTES lpSecurityAttributes,
174 DWORD dwCreationDisposition,
175 DWORD dwFlagsAndAttributes,
176 HANDLE hTemplateFile) {
177 return mock_ptr_type(HANDLE);
178}
179
180LSTATUS __wrap_RegEnumKeyEx(HKEY hKey,
181 DWORD dwIndex,
182 LPWSTR lpName,
183 LPDWORD lpcchName,
184 LPDWORD lpReserved,
185 LPWSTR lpClass,
186 LPDWORD lpcchClass,
187 PFILETIME lpftLastWriteTime) {
188 wchar_t *name = mock_ptr_type(wchar_t *);
189 if (name) {
190 wmemcpy(lpName, name, wcslen(name));
191 }
192 *lpcchName = mock_type(DWORD);
193 return mock_type(LSTATUS);
194}
195
196LSTATUS __wrap_RegQueryInfoKey(HKEY hKey,
197 LPWSTR lpClass,
198 LPDWORD lpcchClass,
199 LPDWORD lpReserved,
200 LPDWORD lpcSubKeys,
201 LPDWORD lpcbMaxSubKeyLen,
202 LPDWORD lpcbMaxClassLen,
203 LPDWORD lpcValues,
204 LPDWORD lpcbMaxValueNameLen,
205 LPDWORD lpcbMaxValueLen,
206 LPDWORD lpcbSecurityDescriptor,
207 PFILETIME lpftLastWriteTime) {
208 *lpcSubKeys = mock_type(DWORD);
209 return mock_type(LSTATUS);
210}
211
212LSTATUS __wrap_RegQueryValueEx(HKEY hKey,
213 LPCWSTR lpValueName,
214 LPDWORD lpReserved,
215 LPDWORD lpType,
216 LPBYTE lpData,
217 LPDWORD lpcbData) {
218 return mock_type(LSTATUS);
219}
220
221DWORD __wrap_GetFileAttributes(wchar_t *path) {
222 return mock_type(DWORD);
223}
224
225bool __wrap_CreatePipe(PHANDLE hReadPipe,
226 PHANDLE hWritePipe,
227 LPSECURITY_ATTRIBUTES lpPipeAttributes,
228 DWORD nSize) {
229 return mock_type(bool);
230}
231
232wchar_t *__wrap__wgetcwd(wchar_t *buffer, int maxlen) {
233 return mock_ptr_type(wchar_t *);
234}
235
236LSTATUS
237__wrap_RegOpenKeyEx(
238 HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult) {
239 return mock_type(LSTATUS);
240}
241
242bool __wrap_CreateDirectory(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes) {
243 return mock_type(bool);
244}
245
246bool __wrap_PathAppend(LPWSTR pszPath, LPCWSTR pszMore) {
247 LPCWSTR newPszPath = mock_ptr_type(LPWSTR);
248 if (newPszPath) {
249 wmemcpy(pszPath, newPszPath, wcslen(newPszPath));
250 }
251 return mock_type(bool);
252}
253
254DWORD __wrap_FormatMessage(DWORD dwFlags,
255 LPCVOID lpSource,
256 DWORD dwMessageId,
257 DWORD dwLanguageId,
258 LPWSTR lpBuffer,
259 DWORD nSize,
260 va_list *Arguments) {
261 lpBuffer[0] = L'\n';
262 return mock_type(DWORD);
263}
264
265bool __wrap__CrtDumpMemoryLeaks() {
266 return false;
267}
268
269HRESULT
270__wrap_SHGetFolderPath(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath) {
271 LPWSTR newPszPath = mock_ptr_type(LPWSTR);
272 wmemcpy(pszPath, newPszPath, wcslen(newPszPath));
273 return mock_type(HRESULT);
274}
275
276int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format, ...) {
277 int ret = -1;
278 va_list args;
279 va_start(args, format);
280 if (!buffer && count == 0) { // Request for size required only
281 wchar_t buf[10240];
282 ret = vswprintf(buf, 10240, format, args);
283 } else {
284 ret = vswprintf(buffer, count, format, args);
285 }
286 va_end(args);
287 return ret;
288}
289
290bool __wrap_write_output(wchar_t *out, bool use_crlf, writer_t *writer) {
291 check_expected(out);
292 return mock_type(bool);
293}
294
295bool __wrap_do_write_reg_command(writer_t *writer,
296 const wchar_t *full_path,
297 const wchar_t *prop,
298 const char *value,
299 size_t data_len,
300 unsigned long type) {
301 return mock_type(bool);
302}
303
304bool __wrap_do_write_c_reg_code(writer_t *writer,
305 const wchar_t *full_path,
306 const wchar_t *prop,
307 const char *value,
308 size_t data_len,
309 unsigned long type) {
310 return mock_type(bool);
311}
312
313bool __wrap_do_write_c_sharp_reg_code(writer_t *writer,
314 const wchar_t *full_path,
315 const wchar_t *prop,
316 const char *value,
317 size_t data_len,
318 unsigned long type) {
319 return mock_type(bool);
320}
321
322bool __wrap_do_write_powershell_reg_code(writer_t *writer,
323 const wchar_t *full_path,
324 const wchar_t *prop,
325 const char *value,
326 size_t data_len,
327 unsigned long type) {
328 return mock_type(bool);
329}
330
331bool __wrap_write_key_filtered_recursive(HKEY hk,
332 const wchar_t *stem,
333 int max_depth,
334 int depth,
335 const wchar_t *prior_stem,
336 enum OUTPUT_FORMAT format,
337 writer_t *writer) {
338 return mock_type(bool);
339}
340
341bool __wrap_git_commit(wchar_t *output_dir, wchar_t *deploy_key) {
342 return mock_type(bool);
343}
344
345bool __wrap_GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode) {
346 *lpExitCode = mock_type(DWORD);
347 return mock_type(bool);
348}