8164
|
1
|
|
2 #ifndef NEW_CONFIG
|
|
3 #warning "Including m_config.h but NEW_CONFIG is disabled"
|
|
4 #else
|
|
5
|
|
6 typedef struct m_config_option m_config_option_t;
|
|
7 typedef struct m_config_save_slot m_config_save_slot_t;
|
|
8 struct m_option;
|
|
9 struct m_option_type;
|
|
10
|
|
11 struct m_config_save_slot {
|
|
12 m_config_save_slot_t* prev;
|
|
13 int lvl;
|
|
14 unsigned char data[0];
|
|
15 };
|
|
16
|
|
17 struct m_config_option {
|
|
18 m_config_option_t* next;
|
|
19 char* name; // Full name (ie option:subopt)
|
|
20 struct m_option* opt;
|
|
21 m_config_save_slot_t* slots;
|
|
22 unsigned int flags; // currently it only tell if the option was set
|
|
23 };
|
|
24
|
|
25 typedef struct m_config {
|
|
26 m_config_option_t* opts;
|
|
27 int lvl; // Current stack level
|
|
28 int mode;
|
|
29 } m_config_t;
|
|
30
|
|
31
|
|
32 //////////////////////////// Functions ///////////////////////////////////
|
|
33
|
|
34 m_config_t*
|
|
35 m_config_new(void);
|
|
36
|
|
37 void
|
|
38 m_config_free(m_config_t* config);
|
|
39
|
|
40 void
|
|
41 m_config_push(m_config_t* config);
|
|
42
|
|
43 void
|
|
44 m_config_pop(m_config_t* config);
|
|
45
|
|
46 int
|
|
47 m_config_register_options(m_config_t *config, struct m_option *args);
|
|
48
|
|
49 int
|
|
50 m_config_set_option(m_config_t *config, char* arg, char* param);
|
|
51
|
|
52 int
|
|
53 m_config_check_option(m_config_t *config, char* arg, char* param);
|
|
54
|
|
55 struct m_option*
|
|
56 m_config_get_option(m_config_t *config, char* arg);
|
|
57
|
8168
|
58 void
|
|
59 m_config_print_option_list(m_config_t *config);
|
|
60
|
8164
|
61 /////////////////////////////////////////////////////////////////////////////////////
|
|
62 /////////////////////////// Backward compat. stuff ////////////////////////////////
|
|
63 ////////////////////////////////////////////////////////////////////////////////////
|
|
64
|
|
65 typedef struct config config_t;
|
|
66 struct config {
|
|
67 char *name;
|
|
68 void *p;
|
|
69 struct m_option_type* type;
|
|
70 unsigned int flags;
|
|
71 float min,max;
|
|
72 void* priv;
|
|
73 };
|
|
74
|
|
75
|
|
76 #define CONF_MIN (1<<0)
|
|
77 #define CONF_MAX (1<<1)
|
|
78 #define CONF_RANGE (CONF_MIN|CONF_MAX)
|
|
79 #define CONF_NOCFG (1<<2)
|
|
80 #define CONF_NOCMD (1<<3)
|
|
81 #define CONF_GLOBAL (1<<4)
|
|
82 #define CONF_NOSAVE (1<<5)
|
|
83 #define CONF_OLD (1<<6)
|
|
84
|
|
85 #define ERR_NOT_AN_OPTION -1
|
|
86 #define ERR_MISSING_PARAM -2
|
|
87 #define ERR_OUT_OF_RANGE -3
|
|
88 #define ERR_FUNC_ERR -4
|
|
89
|
|
90 #endif
|