1 /* 2 * Copyright 2016 Michael Müller 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 */ 18 19 #ifndef _INSENG_PRIVATE_H 20 #define _INSENG_PRIVATE_H 21 22 #define WIN32_NO_STATUS 23 #define _INC_WINDOWS 24 #define COM_NO_WINDOWS_H 25 26 #define COBJMACROS 27 28 #include <config.h> 29 30 #include <windef.h> 31 #include <winbase.h> 32 #include <ole2.h> 33 #include <inseng.h> 34 35 #include <wine/list.h> 36 #include <wine/unicode.h> 37 38 #include <wine/debug.h> 39 40 WINE_DEFAULT_DEBUG_CHANNEL(inseng); 41 42 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size) 43 { 44 return HeapAlloc(GetProcessHeap(), 0, size); 45 } 46 47 static inline void *heap_zero_alloc(size_t len) 48 { 49 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); 50 } 51 52 static inline BOOL heap_free(void *mem) 53 { 54 return HeapFree(GetProcessHeap(), 0, mem); 55 } 56 57 static inline char *strdupA(const char *src) 58 { 59 char *dest = heap_alloc(strlen(src) + 1); 60 if (dest) strcpy(dest, src); 61 return dest; 62 } 63 64 static inline WCHAR *strdupW(const WCHAR *src) 65 { 66 WCHAR *dest; 67 if (!src) return NULL; 68 dest = HeapAlloc(GetProcessHeap(), 0, (strlenW(src) + 1) * sizeof(WCHAR)); 69 if (dest) strcpyW(dest, src); 70 return dest; 71 } 72 73 static inline LPWSTR strAtoW(const char *str) 74 { 75 LPWSTR ret = NULL; 76 77 if (str) 78 { 79 DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); 80 if ((ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) 81 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); 82 } 83 84 return ret; 85 } 86 87 struct inf_value; 88 struct inf_section; 89 struct inf_file; 90 91 HRESULT inf_load(const char *path, struct inf_file **inf_file) DECLSPEC_HIDDEN; 92 void inf_free(struct inf_file *inf) DECLSPEC_HIDDEN; 93 94 BOOL inf_next_section(struct inf_file *inf, struct inf_section **sec) DECLSPEC_HIDDEN; 95 struct inf_section *inf_get_section(struct inf_file *inf, const char *name) DECLSPEC_HIDDEN; 96 char *inf_section_get_name(struct inf_section *section) DECLSPEC_HIDDEN; 97 BOOL inf_section_next_value(struct inf_section *sec, struct inf_value **value) DECLSPEC_HIDDEN; 98 99 struct inf_value *inf_get_value(struct inf_section *sec, const char *key) DECLSPEC_HIDDEN; 100 char *inf_value_get_key(struct inf_value *value) DECLSPEC_HIDDEN; 101 char *inf_value_get_value(struct inf_value *value) DECLSPEC_HIDDEN; 102 103 char *trim(char *str, char **last_chr, BOOL strip_quotes) DECLSPEC_HIDDEN; 104 105 void component_set_actual_download_size(ICifComponent *iface, DWORD size) DECLSPEC_HIDDEN; 106 void component_set_downloaded(ICifComponent *iface, BOOL value) DECLSPEC_HIDDEN; 107 void component_set_installed(ICifComponent *iface, BOOL value) DECLSPEC_HIDDEN; 108 char *component_get_id(ICifComponent *iface) DECLSPEC_HIDDEN; 109 110 #endif /* _INSENG_PRIVATE_H */ 111