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