- Implement ProtocolResetComplete
[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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __PARSEINI_H
21 #define __PARSEINI_H
22
23 #define INI_FILE_COMMENT_CHAR ';'
24
25
26
27 // This structure describes a single .ini file item
28 // The item format in the .ini file is:
29 // Name=Value
30 typedef struct
31 {
32 LIST_ENTRY ListEntry;
33 PCHAR ItemName;
34 PCHAR ItemValue;
35
36 } INI_SECTION_ITEM, *PINI_SECTION_ITEM;
37
38 // This structure describes a .ini file section
39 // The section format in the .ini file is:
40 // [Section Name]
41 // This structure has a list of section items with
42 // one INI_SECTION_ITEM for each line in the section
43 typedef struct
44 {
45 LIST_ENTRY ListEntry;
46 PCHAR SectionName;
47 ULONG SectionItemCount;
48 LIST_ENTRY SectionItemList; // Contains PINI_SECTION_ITEM structures
49
50 } INI_SECTION, *PINI_SECTION;
51
52 extern LIST_ENTRY IniFileSectionListHead;
53 extern BOOLEAN IniFileSectionInitialized;
54 extern ULONG IniFileSectionCount;
55 extern ULONG IniFileSettingCount;
56
57 PFILE IniOpenIniFile();
58
59 BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize);
60 ULONG IniGetNextLineSize(PCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset);
61 ULONG IniGetNextLine(PCHAR IniFileData, ULONG IniFileSize, PCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset);
62 BOOLEAN IniIsLineEmpty(PCHAR LineOfText, ULONG TextLength);
63 BOOLEAN IniIsCommentLine(PCHAR LineOfText, ULONG TextLength);
64 BOOLEAN IniIsSectionName(PCHAR LineOfText, ULONG TextLength);
65 ULONG IniGetSectionNameSize(PCHAR SectionNameLine, ULONG LineLength);
66 VOID IniExtractSectionName(PCHAR SectionName, PCHAR SectionNameLine, ULONG LineLength);
67 BOOLEAN IniIsSetting(PCHAR LineOfText, ULONG TextLength);
68 ULONG IniGetSettingNameSize(PCHAR SettingNameLine, ULONG LineLength);
69 ULONG IniGetSettingValueSize(PCHAR SettingValueLine, ULONG LineLength);
70 VOID IniExtractSettingName(PCHAR SettingName, PCHAR SettingNameLine, ULONG LineLength);
71 VOID IniExtractSettingValue(PCHAR SettingValue, PCHAR SettingValueLine, ULONG LineLength);
72
73 BOOLEAN IniFileInitialize(VOID);
74
75 BOOLEAN IniOpenSection(PCSTR SectionName, ULONG* SectionId);
76 ULONG IniGetNumSectionItems(ULONG SectionId);
77 ULONG IniGetSectionSettingNameSize(ULONG SectionId, ULONG SettingIndex);
78 ULONG IniGetSectionSettingValueSize(ULONG SectionId, ULONG SettingIndex);
79 BOOLEAN IniReadSettingByNumber(ULONG SectionId, ULONG SettingNumber, PCHAR SettingName, ULONG NameSize, PCHAR SettingValue, ULONG ValueSize);
80 BOOLEAN IniReadSettingByName(ULONG SectionId, PCSTR SettingName, PCHAR Buffer, ULONG BufferSize);
81 BOOLEAN IniAddSection(PCSTR SectionName, ULONG* SectionId);
82 BOOLEAN IniAddSettingValueToSection(ULONG SectionId, PCSTR SettingName, PCSTR SettingValue);
83
84
85 #endif // defined __PARSEINI_H