2000-04-26 04:03:38 -04:00
|
|
|
#ifndef __SETTINGS_H
|
|
|
|
#define __SETTINGS_H
|
|
|
|
|
2002-12-28 12:54:13 -05:00
|
|
|
typedef enum {
|
2000-04-26 04:03:38 -04:00
|
|
|
SETTING_TYPE_STRING,
|
|
|
|
SETTING_TYPE_INT,
|
2002-12-28 12:54:13 -05:00
|
|
|
SETTING_TYPE_BOOLEAN,
|
|
|
|
SETTING_TYPE_TIME,
|
|
|
|
SETTING_TYPE_LEVEL,
|
|
|
|
SETTING_TYPE_SIZE
|
|
|
|
} SettingType;
|
|
|
|
|
2003-11-16 11:14:25 -05:00
|
|
|
typedef struct {
|
2002-12-28 12:54:13 -05:00
|
|
|
char *v_string;
|
|
|
|
int v_int;
|
|
|
|
unsigned int v_bool:1;
|
|
|
|
} SettingValue;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
typedef struct {
|
2002-12-28 12:54:13 -05:00
|
|
|
int refcount;
|
|
|
|
|
|
|
|
char *module;
|
2000-04-26 04:03:38 -04:00
|
|
|
char *key;
|
|
|
|
char *section;
|
2002-12-28 12:54:13 -05:00
|
|
|
|
|
|
|
SettingType type;
|
|
|
|
SettingValue default_value;
|
2000-04-26 04:03:38 -04:00
|
|
|
} SETTINGS_REC;
|
|
|
|
|
|
|
|
/* macros for handling the default Irssi configuration */
|
2000-05-10 09:57:42 -04:00
|
|
|
#define iconfig_get_str(a, b, c) config_get_str(mainconfig, a, b, c)
|
|
|
|
#define iconfig_get_int(a, b, c) config_get_int(mainconfig, a, b, c)
|
|
|
|
#define iconfig_get_bool(a, b, c) config_get_bool(mainconfig, a, b, c)
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-10 09:57:42 -04:00
|
|
|
#define iconfig_set_str(a, b, c) config_set_str(mainconfig, a, b, c)
|
|
|
|
#define iconfig_set_int(a, b, c) config_set_int(mainconfig, a, b, c)
|
|
|
|
#define iconfig_set_bool(a, b, c) config_set_bool(mainconfig, a, b, c)
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
#define iconfig_node_traverse(a, b) config_node_traverse(mainconfig, a, b)
|
2000-05-10 09:57:42 -04:00
|
|
|
#define iconfig_node_set_str(a, b, c) config_node_set_str(mainconfig, a, b, c)
|
2000-11-26 05:24:30 -05:00
|
|
|
#define iconfig_node_set_int(a, b, c) config_node_set_int(mainconfig, a, b, c)
|
|
|
|
#define iconfig_node_set_bool(a, b, c) config_node_set_bool(mainconfig, a, b, c)
|
2000-05-10 09:57:42 -04:00
|
|
|
#define iconfig_node_list_remove(a, b) config_node_list_remove(mainconfig, a, b)
|
|
|
|
#define iconfig_node_remove(a, b) config_node_remove(mainconfig, a, b)
|
2000-08-26 11:39:44 -04:00
|
|
|
#define iconfig_node_clear(a) config_node_clear(mainconfig, a)
|
2000-11-26 05:24:30 -05:00
|
|
|
#define iconfig_node_add_list(a, b) config_node_add_list(mainconfig, a, b)
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
extern CONFIG_REC *mainconfig;
|
2001-10-13 11:17:54 -04:00
|
|
|
extern const char *default_config;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
/* Functions for handling the "settings" node of Irssi configuration */
|
|
|
|
const char *settings_get_str(const char *key);
|
2000-11-23 16:40:07 -05:00
|
|
|
int settings_get_int(const char *key);
|
|
|
|
int settings_get_bool(const char *key);
|
2002-12-28 12:54:13 -05:00
|
|
|
int settings_get_time(const char *key); /* as milliseconds */
|
|
|
|
int settings_get_level(const char *key);
|
|
|
|
int settings_get_size(const char *key); /* as bytes */
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
/* Functions to add/remove settings */
|
2000-12-16 23:14:47 -05:00
|
|
|
void settings_add_str_module(const char *module, const char *section,
|
|
|
|
const char *key, const char *def);
|
|
|
|
void settings_add_int_module(const char *module, const char *section,
|
|
|
|
const char *key, int def);
|
|
|
|
void settings_add_bool_module(const char *module, const char *section,
|
|
|
|
const char *key, int def);
|
2002-12-28 12:54:13 -05:00
|
|
|
void settings_add_time_module(const char *module, const char *section,
|
|
|
|
const char *key, const char *def);
|
|
|
|
void settings_add_level_module(const char *module, const char *section,
|
|
|
|
const char *key, const char *def);
|
|
|
|
void settings_add_size_module(const char *module, const char *section,
|
|
|
|
const char *key, const char *def);
|
2000-04-26 04:03:38 -04:00
|
|
|
void settings_remove(const char *key);
|
2000-12-16 23:14:47 -05:00
|
|
|
void settings_remove_module(const char *module);
|
|
|
|
|
|
|
|
#define settings_add_str(section, key, def) \
|
|
|
|
settings_add_str_module(MODULE_NAME, section, key, def)
|
|
|
|
#define settings_add_int(section, key, def) \
|
|
|
|
settings_add_int_module(MODULE_NAME, section, key, def)
|
|
|
|
#define settings_add_bool(section, key, def) \
|
|
|
|
settings_add_bool_module(MODULE_NAME, section, key, def)
|
2002-12-28 12:54:13 -05:00
|
|
|
#define settings_add_time(section, key, def) \
|
|
|
|
settings_add_time_module(MODULE_NAME, section, key, def)
|
|
|
|
#define settings_add_level(section, key, def) \
|
|
|
|
settings_add_level_module(MODULE_NAME, section, key, def)
|
|
|
|
#define settings_add_size(section, key, def) \
|
|
|
|
settings_add_size_module(MODULE_NAME, section, key, def)
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-12-17 00:44:45 -05:00
|
|
|
void settings_set_str(const char *key, const char *value);
|
|
|
|
void settings_set_int(const char *key, int value);
|
|
|
|
void settings_set_bool(const char *key, int value);
|
2002-12-28 12:54:13 -05:00
|
|
|
int settings_set_time(const char *key, const char *value);
|
|
|
|
int settings_set_level(const char *key, const char *value);
|
|
|
|
int settings_set_size(const char *key, const char *value);
|
2000-12-17 00:44:45 -05:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
/* Get the type (SETTING_TYPE_xxx) of `key' */
|
2002-12-28 12:54:13 -05:00
|
|
|
SettingType settings_get_type(const char *key);
|
2000-04-26 04:03:38 -04:00
|
|
|
/* Get all settings sorted by section. Free the result with g_slist_free() */
|
|
|
|
GSList *settings_get_sorted(void);
|
|
|
|
/* Get the record of the setting */
|
|
|
|
SETTINGS_REC *settings_get_record(const char *key);
|
|
|
|
|
2000-12-17 00:44:45 -05:00
|
|
|
/* verify that all settings in config file for `module' are actually found
|
|
|
|
from /SET list */
|
|
|
|
void settings_check_module(const char *module);
|
|
|
|
#define settings_check() settings_check_module(MODULE_NAME)
|
|
|
|
|
2001-03-16 18:57:24 -05:00
|
|
|
/* remove all invalid settings from config file. works only with the
|
|
|
|
modules that have already called settings_check() */
|
|
|
|
void settings_clean_invalid(void);
|
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
/* if `fname' is NULL, the default is used */
|
2000-07-22 18:05:29 -04:00
|
|
|
int settings_reread(const char *fname);
|
2001-11-14 11:28:56 -05:00
|
|
|
int settings_save(const char *fname, int autosave);
|
2000-10-15 15:21:21 -04:00
|
|
|
int irssi_config_is_changed(const char *fname);
|
2000-05-15 04:25:45 -04:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
void settings_init(void);
|
|
|
|
void settings_deinit(void);
|
|
|
|
|
|
|
|
#endif
|