annotate m_config.h @ 10409:4c9ca4819bed

Commands are read in a loop, but for some commands we need to break the loop to finish processing the command. Otherwise some commands may appears as skiped to the user.
author albeu
date Fri, 11 Jul 2003 07:54:52 +0000
parents 39444d65c4cb
children d46910228a6b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
1
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
2 #ifndef NEW_CONFIG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
3 #warning "Including m_config.h but NEW_CONFIG is disabled"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
4 #else
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
5
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
6 typedef struct m_config_option m_config_option_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
7 typedef struct m_config_save_slot m_config_save_slot_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
8 struct m_option;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
9 struct m_option_type;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
10
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
11 struct m_config_save_slot {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
12 m_config_save_slot_t* prev;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
13 int lvl;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
14 unsigned char data[0];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
15 };
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
16
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
17 struct m_config_option {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
18 m_config_option_t* next;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
19 char* name; // Full name (ie option:subopt)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
20 struct m_option* opt;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
21 m_config_save_slot_t* slots;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
22 unsigned int flags; // currently it only tell if the option was set
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
23 };
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
24
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
25 typedef struct m_config {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
26 m_config_option_t* opts;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
27 int lvl; // Current stack level
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
28 int mode;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
29 } m_config_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
30
9912
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 8168
diff changeset
31 #define M_CFG_OPT_SET (1<<0)
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 8168
diff changeset
32 #define M_CFG_OPT_ALIAS (1<<1)
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 8168
diff changeset
33
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
34
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
35 //////////////////////////// Functions ///////////////////////////////////
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
36
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
37 m_config_t*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
38 m_config_new(void);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
39
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
40 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
41 m_config_free(m_config_t* config);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
42
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
43 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
44 m_config_push(m_config_t* config);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
45
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
46 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
47 m_config_pop(m_config_t* config);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
48
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
49 int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
50 m_config_register_options(m_config_t *config, struct m_option *args);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
51
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
52 int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
53 m_config_set_option(m_config_t *config, char* arg, char* param);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
54
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
55 int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
56 m_config_check_option(m_config_t *config, char* arg, char* param);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
57
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
58 struct m_option*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
59 m_config_get_option(m_config_t *config, char* arg);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
60
8168
ff6a98628e6c Fix the Gui with NEW_CONFIG
albeu
parents: 8164
diff changeset
61 void
ff6a98628e6c Fix the Gui with NEW_CONFIG
albeu
parents: 8164
diff changeset
62 m_config_print_option_list(m_config_t *config);
ff6a98628e6c Fix the Gui with NEW_CONFIG
albeu
parents: 8164
diff changeset
63
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
64 /////////////////////////////////////////////////////////////////////////////////////
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
65 /////////////////////////// Backward compat. stuff ////////////////////////////////
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
66 ////////////////////////////////////////////////////////////////////////////////////
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
67
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
68 typedef struct config config_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
69 struct config {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
70 char *name;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
71 void *p;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
72 struct m_option_type* type;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
73 unsigned int flags;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
74 float min,max;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
75 void* priv;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
76 };
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
77
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
78
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
79 #define CONF_MIN (1<<0)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
80 #define CONF_MAX (1<<1)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
81 #define CONF_RANGE (CONF_MIN|CONF_MAX)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
82 #define CONF_NOCFG (1<<2)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
83 #define CONF_NOCMD (1<<3)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
84 #define CONF_GLOBAL (1<<4)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
85 #define CONF_NOSAVE (1<<5)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
86 #define CONF_OLD (1<<6)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
87
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
88 #define ERR_NOT_AN_OPTION -1
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
89 #define ERR_MISSING_PARAM -2
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
90 #define ERR_OUT_OF_RANGE -3
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
91 #define ERR_FUNC_ERR -4
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
92
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
93 #endif