00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _EGG_CONFIG_H_
00023 #define _EGG_CONFIG_H_
00024
00025 #define CONFIG_INT 1
00026 #define CONFIG_STRING 2
00027
00028
00029 #define BTN_CONFIG_STR "config_str"
00030 #define BTN_CONFIG_INT "config_int"
00031 #define BTN_CONFIG_SAVE "config_save"
00032
00033 typedef struct {
00034 const char *name;
00035 void *ptr;
00036 int type;
00037 } config_var_t;
00038
00039 int config_init(void);
00040 int config_shutdown(void);
00041
00042 void *config_load(const char *fname);
00043 int config_save(const char *handle, const char *fname);
00044 int config_destroy(void *config_root);
00045 void *config_get_root(const char *handle);
00046 int config_set_root(const char *handle, void *config_root);
00047 int config_delete_root(const char *handle);
00048 void *config_lookup_section(void *config_root, ...);
00049 void *config_exists(void *config_root, ...);
00050 int config_get_int(int *intptr, void *config_root, ...);
00051 int config_get_str(char **strptr, void *config_root, ...);
00052 int config_set_int(int intval, void *config_root, ...);
00053 int config_set_str(const char *strval, void *config_root, ...);
00054 int config_link_table(config_var_t *table, void *config_root, ...);
00055 int config_update_table(config_var_t *table, void *config_root, ...);
00056 int config_unlink_table(config_var_t *table, void *config_root, ...);
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 typedef struct config_variable config_variable_t;
00095 typedef struct config_type config_type_t;
00096
00097
00098
00099
00100 #define CONFIG_NONE 0
00101
00102
00103
00104
00105
00106 #define CONFIG_ARRAY 1
00107
00108
00109
00110
00111 #define CONFIG_ENUM 2
00112
00113
00114
00115
00116
00117
00118
00119
00120 #define CONFIG_LIST 3
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 #define CONFIG_LIST_DL 4
00131
00132 struct config_variable
00133 {
00134 char *path;
00135 int modifier;
00136 config_type_t *type;
00137 };
00138
00139 struct config_type
00140 {
00141 char *name;
00142 size_t size;
00143 config_variable_t *vars;
00144 };
00145
00146 extern config_type_t CONFIG_TYPE_BOOL;
00147 extern config_type_t CONFIG_TYPE_INT;
00148 extern config_type_t CONFIG_TYPE_STRING;
00149 extern config_type_t CONFIG_TYPE_TIMESTAMP;
00150
00151 int config2_link(int config, config_type_t *type, void *instance);
00152 int config2_sync(int config, config_type_t *type, void *instance);
00153
00154 #endif