3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
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.
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.
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.
22 #define INI_FILE_COMMENT_CHAR ';'
24 // This structure describes a single .ini file item
25 // The item format in the .ini file is:
33 } INI_SECTION_ITEM
, *PINI_SECTION_ITEM
;
35 // This structure describes a .ini file section
36 // The section format in the .ini file is:
38 // This structure has a list of section items with
39 // one INI_SECTION_ITEM for each line in the section
44 ULONG SectionItemCount
;
45 LIST_ENTRY SectionItemList
; // Contains PINI_SECTION_ITEM structures
47 } INI_SECTION
, *PINI_SECTION
;
49 extern LIST_ENTRY IniFileSectionListHead
;
50 extern BOOLEAN IniFileSectionInitialized
;
51 extern ULONG IniFileSectionCount
;
52 extern ULONG IniFileSettingCount
;
54 BOOLEAN
IniParseFile(PCHAR IniFileData
, ULONG IniFileSize
);
55 ULONG
IniGetNextLineSize(PCHAR IniFileData
, ULONG IniFileSize
, ULONG CurrentOffset
);
56 ULONG
IniGetNextLine(PCHAR IniFileData
, ULONG IniFileSize
, PCHAR Buffer
, ULONG BufferSize
, ULONG CurrentOffset
);
57 BOOLEAN
IniIsLineEmpty(PCHAR LineOfText
, ULONG TextLength
);
58 BOOLEAN
IniIsCommentLine(PCHAR LineOfText
, ULONG TextLength
);
59 BOOLEAN
IniIsSectionName(PCHAR LineOfText
, ULONG TextLength
);
60 ULONG
IniGetSectionNameSize(PCHAR SectionNameLine
, ULONG LineLength
);
61 VOID
IniExtractSectionName(PCHAR SectionName
, PCHAR SectionNameLine
, ULONG LineLength
);
62 BOOLEAN
IniIsSetting(PCHAR LineOfText
, ULONG TextLength
);
63 ULONG
IniGetSettingNameSize(PCHAR SettingNameLine
, ULONG LineLength
);
64 ULONG
IniGetSettingValueSize(PCHAR SettingValueLine
, ULONG LineLength
);
65 VOID
IniExtractSettingName(PCHAR SettingName
, PCHAR SettingNameLine
, ULONG LineLength
);
66 VOID
IniExtractSettingValue(PCHAR SettingValue
, PCHAR SettingValueLine
, ULONG LineLength
);
68 BOOLEAN
IniFileInitialize(VOID
);
70 BOOLEAN
IniOpenSection(PCSTR SectionName
, ULONG_PTR
* SectionId
);
71 ULONG
IniGetNumSectionItems(ULONG_PTR SectionId
);
72 ULONG
IniGetSectionSettingNameSize(ULONG_PTR SectionId
, ULONG SettingIndex
);
73 ULONG
IniGetSectionSettingValueSize(ULONG_PTR SectionId
, ULONG SettingIndex
);
74 BOOLEAN
IniReadSettingByNumber(ULONG_PTR SectionId
, ULONG SettingNumber
, PCHAR SettingName
, ULONG NameSize
, PCHAR SettingValue
, ULONG ValueSize
);
75 BOOLEAN
IniReadSettingByName(ULONG_PTR SectionId
, PCSTR SettingName
, PCHAR Buffer
, ULONG BufferSize
);
76 BOOLEAN
IniAddSection(PCSTR SectionName
, ULONG_PTR
* SectionId
);
77 BOOLEAN
IniAddSettingValueToSection(ULONG_PTR SectionId
, PCSTR SettingName
, PCSTR SettingValue
);