1 /* 2 * PROJECT: ReactOS Setup Library 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: INI file parser that caches contents of INI file in memory. 5 * COPYRIGHT: Copyright 2002-2018 Royce Mitchell III 6 */ 7 8 #pragma once 9 10 typedef struct _INI_KEYWORD 11 { 12 PWSTR Name; 13 PWSTR Data; 14 LIST_ENTRY ListEntry; 15 } INI_KEYWORD, *PINI_KEYWORD; 16 17 typedef struct _INI_SECTION 18 { 19 PWSTR Name; 20 LIST_ENTRY KeyList; 21 LIST_ENTRY ListEntry; 22 } INI_SECTION, *PINI_SECTION; 23 24 typedef struct _INICACHE 25 { 26 LIST_ENTRY SectionList; 27 } INICACHE, *PINICACHE; 28 29 typedef struct _PINICACHEITERATOR 30 { 31 PINI_SECTION Section; 32 PINI_KEYWORD Key; 33 } INICACHEITERATOR, *PINICACHEITERATOR; 34 35 typedef enum 36 { 37 INSERT_FIRST, 38 INSERT_BEFORE, 39 INSERT_AFTER, 40 INSERT_LAST 41 } INSERTION_TYPE; 42 43 /* FUNCTIONS ****************************************************************/ 44 45 NTSTATUS 46 IniCacheLoadFromMemory( 47 PINICACHE *Cache, 48 PCHAR FileBuffer, 49 ULONG FileLength, 50 BOOLEAN String); 51 52 NTSTATUS 53 IniCacheLoadByHandle( 54 PINICACHE *Cache, 55 HANDLE FileHandle, 56 BOOLEAN String); 57 58 NTSTATUS 59 IniCacheLoad( 60 PINICACHE *Cache, 61 PWCHAR FileName, 62 BOOLEAN String); 63 64 VOID 65 IniCacheDestroy( 66 _In_ PINICACHE Cache); 67 68 PINI_SECTION 69 IniGetSection( 70 _In_ PINICACHE Cache, 71 _In_ PCWSTR Name); 72 73 PINI_KEYWORD 74 IniGetKey( 75 _In_ PINI_SECTION Section, 76 _In_ PCWSTR KeyName, 77 _Out_ PCWSTR* KeyData); 78 79 PINICACHEITERATOR 80 IniFindFirstValue( 81 _In_ PINI_SECTION Section, 82 _Out_ PCWSTR* KeyName, 83 _Out_ PCWSTR* KeyData); 84 85 BOOLEAN 86 IniFindNextValue( 87 _In_ PINICACHEITERATOR Iterator, 88 _Out_ PCWSTR* KeyName, 89 _Out_ PCWSTR* KeyData); 90 91 VOID 92 IniFindClose( 93 _In_ PINICACHEITERATOR Iterator); 94 95 PINI_SECTION 96 IniAddSection( 97 _In_ PINICACHE Cache, 98 _In_ PCWSTR Name); 99 100 VOID 101 IniRemoveSection( 102 _In_ PINI_SECTION Section); 103 104 PINI_KEYWORD 105 IniInsertKey( 106 _In_ PINI_SECTION Section, 107 _In_ PINI_KEYWORD AnchorKey, 108 _In_ INSERTION_TYPE InsertionType, 109 _In_ PCWSTR Name, 110 _In_ PCWSTR Data); 111 112 PINI_KEYWORD 113 IniAddKey( 114 _In_ PINI_SECTION Section, 115 _In_ PCWSTR Name, 116 _In_ PCWSTR Data); 117 118 VOID 119 IniRemoveKeyByName( 120 _In_ PINI_SECTION Section, 121 _In_ PCWSTR KeyName); 122 123 VOID 124 IniRemoveKey( 125 _In_ PINI_SECTION Section, 126 _In_ PINI_KEYWORD Key); 127 128 PINICACHE 129 IniCacheCreate(VOID); 130 131 NTSTATUS 132 IniCacheSaveByHandle( 133 PINICACHE Cache, 134 HANDLE FileHandle); 135 136 NTSTATUS 137 IniCacheSave( 138 PINICACHE Cache, 139 PWCHAR FileName); 140 141 /* EOF */ 142