9bed7004d178fa3ad79ddf3a23737d9d32f2c322
[reactos.git] / boot / freeldr / freeldr / include / inifile.h
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #pragma once
21
22 #define INI_FILE_COMMENT_CHAR ';'
23
24 #define TAG_INI_FILE 'FinI'
25 #define TAG_INI_SECTION 'SinI'
26 #define TAG_INI_SECTION_ITEM 'IinI'
27 #define TAG_INI_NAME 'NinI'
28 #define TAG_INI_VALUE 'VinI'
29
30 // This structure describes a single .ini file item
31 // The item format in the .ini file is:
32 // Name=Value
33 typedef struct
34 {
35 LIST_ENTRY ListEntry;
36 PCHAR ItemName;
37 PCHAR ItemValue;
38
39 } INI_SECTION_ITEM, *PINI_SECTION_ITEM;
40
41 // This structure describes a .ini file section
42 // The section format in the .ini file is:
43 // [Section Name]
44 // This structure has a list of section items with
45 // one INI_SECTION_ITEM for each line in the section
46 typedef struct
47 {
48 LIST_ENTRY ListEntry;
49 PCHAR SectionName;
50 ULONG SectionItemCount;
51 LIST_ENTRY SectionItemList; // Contains PINI_SECTION_ITEM structures
52
53 } INI_SECTION, *PINI_SECTION;
54
55 extern LIST_ENTRY IniFileSectionListHead;
56 extern BOOLEAN IniFileSectionInitialized;
57 extern ULONG IniFileSectionCount;
58 extern ULONG IniFileSettingCount;
59
60 BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize);
61 ULONG IniGetNextLineSize(PCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset);
62 ULONG IniGetNextLine(PCHAR IniFileData, ULONG IniFileSize, PCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset);
63 BOOLEAN IniIsLineEmpty(PCHAR LineOfText, ULONG TextLength);
64 BOOLEAN IniIsCommentLine(PCHAR LineOfText, ULONG TextLength);
65 BOOLEAN IniIsSectionName(PCHAR LineOfText, ULONG TextLength);
66 ULONG IniGetSectionNameSize(PCHAR SectionNameLine, ULONG LineLength);
67 VOID IniExtractSectionName(PCHAR SectionName, PCHAR SectionNameLine, ULONG LineLength);
68 BOOLEAN IniIsSetting(PCHAR LineOfText, ULONG TextLength);
69 ULONG IniGetSettingNameSize(PCHAR SettingNameLine, ULONG LineLength);
70 ULONG IniGetSettingValueSize(PCHAR SettingValueLine, ULONG LineLength);
71 VOID IniExtractSettingName(PCHAR SettingName, PCHAR SettingNameLine, ULONG LineLength);
72 VOID IniExtractSettingValue(PCHAR SettingValue, PCHAR SettingValueLine, ULONG LineLength);
73
74 BOOLEAN IniFileInitialize(VOID);
75
76 BOOLEAN IniOpenSection(PCSTR SectionName, ULONG_PTR* SectionId);
77 ULONG IniGetNumSectionItems(ULONG_PTR SectionId);
78 ULONG IniGetSectionSettingNameSize(ULONG_PTR SectionId, ULONG SettingIndex);
79 ULONG IniGetSectionSettingValueSize(ULONG_PTR SectionId, ULONG SettingIndex);
80 BOOLEAN IniReadSettingByNumber(ULONG_PTR SectionId, ULONG SettingNumber, PCHAR SettingName, ULONG NameSize, PCHAR SettingValue, ULONG ValueSize);
81 BOOLEAN IniReadSettingByName(ULONG_PTR SectionId, PCSTR SettingName, PCHAR Buffer, ULONG BufferSize);
82 BOOLEAN IniAddSection(PCSTR SectionName, ULONG_PTR* SectionId);
83 BOOLEAN IniAddSettingValueToSection(ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue);
84 VOID IniCleanup(VOID);