1 /*
2 ** This file is placed into the public domain on February 22, 1996, by
3 ** its author: Carey Bloodworth
4 **
5 ** Modifications:
6 **
7 ** 07-Dec-1999 by
8 ** Bob Stout & Jon Guthrie
9 ** General cleanup, use NUL (in SNIPTYPE.H) instead of NULL where appropriate.
10 ** Allow spaces in tag names.
11 ** Allow strings in quotes.
12 ** Allow trailing comments.
13 ** Allow embedded comment separator(s) in quoted strings.
14 ** Speed up line processing.
15 ** ReadCfg() returns an error if section or variable not found.
16 ** Changed integer type to short.
17 ** Use cant() calls in lieu of fopen() calls,
18 ** include ERRORS.H for prototype.
19 */
20
21 #ifndef INI_H_
22 #define INI_H_
23
24 /*lint -e537 */
25 #include <limits.h>
26
27 #define INI_LINESIZE 128
28 #define LAST_CHAR(s) (((char *)s)[strlen(s) - 1])
29 #define NUL '\0'
30
31 typedef enum {Error_ = -1, Success_, False_ = 0, True_} Boolean_T;
32
33 enum CfgTypes {Cfg_String,
34 Cfg_Byte,
35 Cfg_Ushort,
36 Cfg_Short,
37 Cfg_Ulong,
38 Cfg_Long,
39 Cfg_Double,
40 Cfg_Boolean, /* Boolean is actually an integer Y/N T/F */
41 Cfg_I_Array
42 };
43
44 struct CfgStruct {
45 char *Name;
46 void *DataPtr;
47 enum CfgTypes VarType;
48 };
49
50 int ReadCfg(const char *FileName,
51 char *SectionName,
52 struct CfgStruct *MyVars);
53
54 int SearchCfg(const char *FileName,
55 char *SectionName,
56 char *VarName,
57 void *DataPtr,
58 enum CfgTypes VarType);
59
60 int UpdateCfg(const char *FileName,
61 char *SectionName,
62 char *VarWanted,
63 char *NewData);
64
65 #endif
66
Редактировать