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 #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'
30 // This structure describes a single .ini file item
31 // The item format in the .ini file is:
39 } INI_SECTION_ITEM
, *PINI_SECTION_ITEM
;
41 // This structure describes a .ini file section
42 // The section format in the .ini file is:
44 // This structure has a list of section items with
45 // one INI_SECTION_ITEM for each line in the section
50 ULONG SectionItemCount
;
51 LIST_ENTRY SectionItemList
; // Contains PINI_SECTION_ITEM structures
53 } INI_SECTION
, *PINI_SECTION
;
55 extern LIST_ENTRY IniFileSectionListHead
;
56 extern BOOLEAN IniFileSectionInitialized
;
57 extern ULONG IniFileSectionCount
;
58 extern ULONG IniFileSettingCount
;
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
);
74 BOOLEAN
IniFileInitialize(VOID
);
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
);