2003-08-13 16:29:32 +00:00
|
|
|
#ifndef _M_CONFIG_H
|
|
|
|
#define _M_CONFIG_H
|
2002-11-12 01:56:42 +00:00
|
|
|
|
|
|
|
typedef struct m_config_option m_config_option_t;
|
|
|
|
typedef struct m_config_save_slot m_config_save_slot_t;
|
2006-01-24 11:16:13 +00:00
|
|
|
typedef struct m_profile m_profile_t;
|
2002-11-12 01:56:42 +00:00
|
|
|
struct m_option;
|
|
|
|
struct m_option_type;
|
|
|
|
|
|
|
|
struct m_config_save_slot {
|
|
|
|
m_config_save_slot_t* prev;
|
|
|
|
int lvl;
|
2004-09-04 15:34:20 +00:00
|
|
|
// we have to store other datatypes in this as well,
|
|
|
|
// so make sure we get properly aligned addresses
|
|
|
|
unsigned char data[0] __attribute__ ((aligned (8)));
|
2002-11-12 01:56:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct m_config_option {
|
|
|
|
m_config_option_t* next;
|
|
|
|
char* name; // Full name (ie option:subopt)
|
|
|
|
struct m_option* opt;
|
|
|
|
m_config_save_slot_t* slots;
|
|
|
|
unsigned int flags; // currently it only tell if the option was set
|
|
|
|
};
|
|
|
|
|
2006-01-24 11:16:13 +00:00
|
|
|
struct m_profile {
|
|
|
|
m_profile_t* next;
|
|
|
|
char* name;
|
|
|
|
char* desc;
|
|
|
|
int num_opts;
|
|
|
|
char** opts;
|
|
|
|
};
|
|
|
|
|
2002-11-12 01:56:42 +00:00
|
|
|
typedef struct m_config {
|
|
|
|
m_config_option_t* opts;
|
|
|
|
int lvl; // Current stack level
|
|
|
|
int mode;
|
2006-01-24 11:16:13 +00:00
|
|
|
m_profile_t* profiles;
|
|
|
|
int profile_depth;
|
|
|
|
struct m_option* self_opts;
|
2002-11-12 01:56:42 +00:00
|
|
|
} m_config_t;
|
|
|
|
|
2003-04-12 13:40:30 +00:00
|
|
|
#define M_CFG_OPT_SET (1<<0)
|
|
|
|
#define M_CFG_OPT_ALIAS (1<<1)
|
|
|
|
|
2002-11-12 01:56:42 +00:00
|
|
|
|
|
|
|
//////////////////////////// Functions ///////////////////////////////////
|
|
|
|
|
|
|
|
m_config_t*
|
|
|
|
m_config_new(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
m_config_free(m_config_t* config);
|
|
|
|
|
|
|
|
void
|
|
|
|
m_config_push(m_config_t* config);
|
|
|
|
|
|
|
|
void
|
|
|
|
m_config_pop(m_config_t* config);
|
|
|
|
|
|
|
|
int
|
|
|
|
m_config_register_options(m_config_t *config, struct m_option *args);
|
|
|
|
|
|
|
|
int
|
|
|
|
m_config_set_option(m_config_t *config, char* arg, char* param);
|
|
|
|
|
|
|
|
int
|
|
|
|
m_config_check_option(m_config_t *config, char* arg, char* param);
|
|
|
|
|
|
|
|
struct m_option*
|
|
|
|
m_config_get_option(m_config_t *config, char* arg);
|
|
|
|
|
2002-11-12 12:39:05 +00:00
|
|
|
void
|
|
|
|
m_config_print_option_list(m_config_t *config);
|
|
|
|
|
2006-01-24 11:16:13 +00:00
|
|
|
m_profile_t*
|
|
|
|
m_config_get_profile(m_config_t* config, char* name);
|
|
|
|
|
|
|
|
m_profile_t*
|
|
|
|
m_config_add_profile(m_config_t* config, char* name);
|
|
|
|
|
|
|
|
void
|
|
|
|
m_profile_set_desc(m_profile_t* p, char* desc);
|
|
|
|
|
|
|
|
int
|
|
|
|
m_config_set_profile_option(m_config_t* config, m_profile_t* p,
|
|
|
|
char* name, char* val);
|
|
|
|
|
2003-08-13 16:29:32 +00:00
|
|
|
#endif /* _M_CONFIG_H */
|