File: configfile.h

package info (click to toggle)
egoboo-data 2.22-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 44,296 kB
  • ctags: 2,618
  • sloc: ansic: 23,985; makefile: 94
file content (78 lines) | stat: -rw-r--r-- 2,372 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

//---------------------------------------------------------------------
//
//	ConfigFile.h
//
//
//---------------------------------------------------------------------


#ifndef _CONFIGFILE_H_
#define _CONFIGFILE_H_

#include "egobootypedef.h"

#include <stdio.h>
#include <stdlib.h>

#include "egoboostrutil.h"

#define MAX_CONFIG_SECTION_LENGTH		64
#define MAX_CONFIG_KEY_LENGTH			64
#define MAX_CONFIG_VALUE_LENGTH			256
#define MAX_CONFIG_COMMENTARY_LENGTH	256

typedef struct ConfigFileValue ConfigFileValue;
typedef struct ConfigFileValue
	{
	char KeyName[MAX_CONFIG_KEY_LENGTH];
	char *Value;
	char *Commentary;
	ConfigFileValue *NextValue;
	} *ConfigFileValuePtr;

typedef struct ConfigFileSection ConfigFileSection;
typedef struct ConfigFileSection
	{
	char SectionName[MAX_CONFIG_SECTION_LENGTH];
	ConfigFileSection	*NextSection;
	ConfigFileValuePtr	FirstValue;
	} *ConfigFileSectionPtr;

typedef struct ConfigFile
	{
	FILE	*f;
	ConfigFileSectionPtr	ConfigSectionList;

	ConfigFileSectionPtr	CurrentSection;
	ConfigFileValuePtr		CurrentValue;
	} ConfigFile, *ConfigFilePtr;


// util
extern void ConvertToKeyCharacters( char *pStr );

//
extern ConfigFilePtr OpenConfigFile( const char *pPath );

//
extern Sint32 GetConfigValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, char *pValue, Sint32 pValueBufferLength );
extern Sint32 GetConfigBooleanValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, BOOL *pBool );
extern Sint32 GetConfigIntValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, Sint32 *pInt );

// 
extern Sint32 SetConfigValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, const char *pValue );
extern Sint32 SetConfigBooleanValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, int pBool);
extern Sint32 SetConfigIntValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, int pInt);
extern Sint32 SetConfigFloatValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, float pFloat);

//
extern void CloseConfigFile( ConfigFilePtr pConfigFile );

//
extern void SaveConfigFile( ConfigFilePtr pConfigFile );
extern Sint32 SaveConfigFileAs( ConfigFilePtr pConfigFile, const char *pPath );


#endif // #ifndef _CONFIGFILE_H_