-
Notifications
You must be signed in to change notification settings - Fork 2
/
PancakeConfiguration.h
121 lines (94 loc) · 4.63 KB
/
PancakeConfiguration.h
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef _PANCAKE_CONFIGURATION_H
#define _PANCAKE_CONFIGURATION_H
#include "Pancake.h"
#include "ConfigurationParser/PancakeConfigurationParser.h"
#ifndef PANCAKE_CONFIG_PATH
# define PANCAKE_CONFIG_PATH "config/pancake.cfg"
#endif
#define CONFIG_TYPE_SERVER_ARCHITECTURE 16
#define CONFIG_TYPE_SPECIAL 17
#define CONFIG_TYPE_FILE 18
#define CONFIG_TYPE_ANY 19
#define CONFIG_TYPE_COPY 20
#define PANCAKE_CONFIGURATION_INIT 1 << 0
#define PANCAKE_CONFIGURATION_DTOR 1 << 1
/* Forward declarations */
typedef struct _PancakeConfigurationScope PancakeConfigurationScope;
typedef struct _PancakeConfigurationGroup PancakeConfigurationGroup;
typedef struct _PancakeConfigurationScopeValue PancakeConfigurationScopeValue;
typedef UByte (*PancakeConfigurationHook)(UByte step, config_setting_t *setting, PancakeConfigurationScope **scope);
typedef struct _PancakeConfigurationSetting {
/* Hash handle must be the first and type the second element */
UT_hash_handle hh;
UByte type;
UInt8 valueSize;
UByte haveScopedValue;
UByte haveValue;
String name;
PancakeConfigurationHook hook;
PancakeConfigurationGroup *listGroup;
void *valuePtr;
config_value_t defaultValue;
} PancakeConfigurationSetting;
typedef struct _PancakeConfigurationSettingCopy {
/* Hash handle must be the first and type the second element */
UT_hash_handle hh;
UByte type;
PancakeConfigurationSetting *setting;
} PancakeConfigurationSettingCopy;
typedef struct _PancakeConfigurationGroup {
String name;
PancakeConfigurationSetting *settings;
PancakeConfigurationGroup *children;
PancakeConfigurationHook hook;
UByte isCopy;
UT_hash_handle hh;
} PancakeConfigurationGroup;
typedef struct _PancakeConfigurationScopeValue {
PancakeConfigurationSetting *setting;
config_value_t value;
PancakeConfigurationScopeValue *prev;
PancakeConfigurationScopeValue *next;
} PancakeConfigurationScopeValue;
typedef struct _PancakeConfigurationScope {
PancakeConfigurationScopeValue *values;
void *data;
UByte isRootScope;
} PancakeConfigurationScope;
typedef struct _PancakeConfigurationScopeGroup {
PancakeConfigurationScope **scopes;
UInt16 numScopes;
} PancakeConfigurationScopeGroup;
typedef struct _PancakeConfigurationStructure {
config_t *wrapper;
PancakeConfigurationGroup *groups;
PancakeConfigurationSetting *settings;
} PancakeConfigurationStructure;
extern PancakeConfigurationStructure *PancakeConfiguration;
/* Configuration API */
PANCAKE_API PancakeConfigurationGroup *PancakeConfigurationAddGroup(PancakeConfigurationGroup *parent, String name, PancakeConfigurationHook hook);
PANCAKE_API PancakeConfigurationSetting *PancakeConfigurationAddSetting(PancakeConfigurationGroup *group, String name, UByte type, void *valuePtr, UInt8 valueSize, config_value_t defaultValue, PancakeConfigurationHook hook);
PANCAKE_API void PancakeConfigurationAddGroupToGroup(PancakeConfigurationGroup *parent, PancakeConfigurationGroup *child);
PANCAKE_API void PancakeConfigurationAddSettingToGroup(PancakeConfigurationGroup *parent, PancakeConfigurationSetting *child);
PANCAKE_API PancakeConfigurationGroup *PancakeConfigurationListGroup(PancakeConfigurationSetting *setting, PancakeConfigurationHook hook);
PANCAKE_API PancakeConfigurationGroup *PancakeConfigurationLookupGroup(PancakeConfigurationGroup *parent, String name);
PANCAKE_API PancakeConfigurationSetting *PancakeConfigurationLookupSetting(PancakeConfigurationGroup *parent, String name);
/* Configuration scoping API */
PANCAKE_API PancakeConfigurationScope *PancakeConfigurationAddScope();
PANCAKE_API void PancakeConfigurationActivateScope(PancakeConfigurationScope *scope);
PANCAKE_API void PancakeConfigurationUnscope();
PANCAKE_API void PancakeConfigurationDestroyScope(PancakeConfigurationScope *scope);
PANCAKE_API void PancakeConfigurationInitializeScopeGroup(PancakeConfigurationScopeGroup *group);
PANCAKE_API void PancakeConfigurationScopeGroupAddScope(PancakeConfigurationScopeGroup *group, PancakeConfigurationScope *scope);
PANCAKE_API void PancakeConfigurationActivateScopeGroup(PancakeConfigurationScopeGroup *group);
PANCAKE_API void PancakeConfigurationDestroyScopeGroup(PancakeConfigurationScopeGroup *group);
/* Initialization functions */
void PancakeConfigurationInitialize();
UByte PancakeConfigurationLoad();
void PancakeConfigurationUnload();
void PancakeConfigurationDestroy();
/* Configuration Hooks */
UByte PancakeConfigurationFile(UByte step, config_setting_t *setting, PancakeConfigurationScope **scope);
UByte PancakeConfigurationString(UByte step, config_setting_t *setting, PancakeConfigurationScope **scope);
UByte PancakeConfigurationServerArchitecture(UByte step, config_setting_t *setting, PancakeConfigurationScope **scope);
#endif