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 _INICACHEKEY 11 { 12 PWCHAR Name; 13 PWCHAR Data; 14 15 struct _INICACHEKEY *Next; 16 struct _INICACHEKEY *Prev; 17 } INICACHEKEY, *PINICACHEKEY; 18 19 20 typedef struct _INICACHESECTION 21 { 22 PWCHAR Name; 23 24 PINICACHEKEY FirstKey; 25 PINICACHEKEY LastKey; 26 27 struct _INICACHESECTION *Next; 28 struct _INICACHESECTION *Prev; 29 } INICACHESECTION, *PINICACHESECTION; 30 31 32 typedef struct _INICACHE 33 { 34 PINICACHESECTION FirstSection; 35 PINICACHESECTION LastSection; 36 } INICACHE, *PINICACHE; 37 38 39 typedef struct _PINICACHEITERATOR 40 { 41 PINICACHESECTION Section; 42 PINICACHEKEY Key; 43 } INICACHEITERATOR, *PINICACHEITERATOR; 44 45 46 typedef enum 47 { 48 INSERT_FIRST, 49 INSERT_BEFORE, 50 INSERT_AFTER, 51 INSERT_LAST 52 } INSERTION_TYPE; 53 54 /* FUNCTIONS ****************************************************************/ 55 56 NTSTATUS 57 IniCacheLoadFromMemory( 58 PINICACHE *Cache, 59 PCHAR FileBuffer, 60 ULONG FileLength, 61 BOOLEAN String); 62 63 NTSTATUS 64 IniCacheLoadByHandle( 65 PINICACHE *Cache, 66 HANDLE FileHandle, 67 BOOLEAN String); 68 69 NTSTATUS 70 IniCacheLoad( 71 PINICACHE *Cache, 72 PWCHAR FileName, 73 BOOLEAN String); 74 75 VOID 76 IniCacheDestroy( 77 PINICACHE Cache); 78 79 PINICACHESECTION 80 IniCacheGetSection( 81 PINICACHE Cache, 82 PWCHAR Name); 83 84 NTSTATUS 85 IniCacheGetKey( 86 PINICACHESECTION Section, 87 PWCHAR KeyName, 88 PWCHAR *KeyData); 89 90 PINICACHEITERATOR 91 IniCacheFindFirstValue( 92 PINICACHESECTION Section, 93 PWCHAR *KeyName, 94 PWCHAR *KeyData); 95 96 BOOLEAN 97 IniCacheFindNextValue( 98 PINICACHEITERATOR Iterator, 99 PWCHAR *KeyName, 100 PWCHAR *KeyData); 101 102 VOID 103 IniCacheFindClose( 104 PINICACHEITERATOR Iterator); 105 106 107 PINICACHEKEY 108 IniCacheInsertKey( 109 PINICACHESECTION Section, 110 PINICACHEKEY AnchorKey, 111 INSERTION_TYPE InsertionType, 112 PWCHAR Name, 113 PWCHAR Data); 114 115 PINICACHE 116 IniCacheCreate(VOID); 117 118 NTSTATUS 119 IniCacheSaveByHandle( 120 PINICACHE Cache, 121 HANDLE FileHandle); 122 123 NTSTATUS 124 IniCacheSave( 125 PINICACHE Cache, 126 PWCHAR FileName); 127 128 PINICACHESECTION 129 IniCacheAppendSection( 130 PINICACHE Cache, 131 PWCHAR Name); 132 133 /* EOF */ 134