~ubuntu-branches/ubuntu/feisty/irssi/feisty-backports

« back to all changes in this revision

Viewing changes to src/core/settings.h

  • Committer: Bazaar Package Importer
  • Author(s): David Pashley
  • Date: 2005-12-10 21:25:51 UTC
  • Revision ID: james.westby@ubuntu.com-20051210212551-5qwm108g7inyu2f2
Tags: upstream-0.8.10
ImportĀ upstreamĀ versionĀ 0.8.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __SETTINGS_H
 
2
#define __SETTINGS_H
 
3
 
 
4
typedef enum {
 
5
        SETTING_TYPE_STRING,
 
6
        SETTING_TYPE_INT,
 
7
        SETTING_TYPE_BOOLEAN,
 
8
        SETTING_TYPE_TIME,
 
9
        SETTING_TYPE_LEVEL,
 
10
        SETTING_TYPE_SIZE
 
11
} SettingType;
 
12
 
 
13
typedef struct {
 
14
        char *v_string;
 
15
        int v_int;
 
16
        unsigned int v_bool:1;
 
17
} SettingValue;
 
18
 
 
19
typedef struct {
 
20
        int refcount;
 
21
 
 
22
        char *module;
 
23
        char *key;
 
24
        char *section;
 
25
 
 
26
        SettingType type;
 
27
        SettingValue default_value;
 
28
} SETTINGS_REC;
 
29
 
 
30
/* macros for handling the default Irssi configuration */
 
31
#define iconfig_get_str(a, b, c) config_get_str(mainconfig, a, b, c)
 
32
#define iconfig_get_int(a, b, c) config_get_int(mainconfig, a, b, c)
 
33
#define iconfig_get_bool(a, b, c) config_get_bool(mainconfig, a, b, c)
 
34
 
 
35
#define iconfig_set_str(a, b, c) config_set_str(mainconfig, a, b, c)
 
36
#define iconfig_set_int(a, b, c) config_set_int(mainconfig, a, b, c)
 
37
#define iconfig_set_bool(a, b, c) config_set_bool(mainconfig, a, b, c)
 
38
 
 
39
#define iconfig_node_traverse(a, b) config_node_traverse(mainconfig, a, b)
 
40
#define iconfig_node_set_str(a, b, c) config_node_set_str(mainconfig, a, b, c)
 
41
#define iconfig_node_set_int(a, b, c) config_node_set_int(mainconfig, a, b, c)
 
42
#define iconfig_node_set_bool(a, b, c) config_node_set_bool(mainconfig, a, b, c)
 
43
#define iconfig_node_list_remove(a, b) config_node_list_remove(mainconfig, a, b)
 
44
#define iconfig_node_remove(a, b) config_node_remove(mainconfig, a, b)
 
45
#define iconfig_node_clear(a) config_node_clear(mainconfig, a)
 
46
#define iconfig_node_add_list(a, b) config_node_add_list(mainconfig, a, b)
 
47
 
 
48
extern CONFIG_REC *mainconfig;
 
49
extern const char *default_config;
 
50
 
 
51
/* Functions for handling the "settings" node of Irssi configuration */
 
52
const char *settings_get_str(const char *key);
 
53
int settings_get_int(const char *key);
 
54
int settings_get_bool(const char *key);
 
55
int settings_get_time(const char *key); /* as milliseconds */
 
56
int settings_get_level(const char *key);
 
57
int settings_get_size(const char *key); /* as bytes */
 
58
 
 
59
/* Functions to add/remove settings */
 
60
void settings_add_str_module(const char *module, const char *section,
 
61
                             const char *key, const char *def);
 
62
void settings_add_int_module(const char *module, const char *section,
 
63
                             const char *key, int def);
 
64
void settings_add_bool_module(const char *module, const char *section,
 
65
                              const char *key, int def);
 
66
void settings_add_time_module(const char *module, const char *section,
 
67
                              const char *key, const char *def);
 
68
void settings_add_level_module(const char *module, const char *section,
 
69
                               const char *key, const char *def);
 
70
void settings_add_size_module(const char *module, const char *section,
 
71
                              const char *key, const char *def);
 
72
void settings_remove(const char *key);
 
73
void settings_remove_module(const char *module);
 
74
 
 
75
#define settings_add_str(section, key, def) \
 
76
        settings_add_str_module(MODULE_NAME, section, key, def)
 
77
#define settings_add_int(section, key, def) \
 
78
        settings_add_int_module(MODULE_NAME, section, key, def)
 
79
#define settings_add_bool(section, key, def) \
 
80
        settings_add_bool_module(MODULE_NAME, section, key, def)
 
81
#define settings_add_time(section, key, def) \
 
82
        settings_add_time_module(MODULE_NAME, section, key, def)
 
83
#define settings_add_level(section, key, def) \
 
84
        settings_add_level_module(MODULE_NAME, section, key, def)
 
85
#define settings_add_size(section, key, def) \
 
86
        settings_add_size_module(MODULE_NAME, section, key, def)
 
87
 
 
88
void settings_set_str(const char *key, const char *value);
 
89
void settings_set_int(const char *key, int value);
 
90
void settings_set_bool(const char *key, int value);
 
91
int settings_set_time(const char *key, const char *value);
 
92
int settings_set_level(const char *key, const char *value);
 
93
int settings_set_size(const char *key, const char *value);
 
94
 
 
95
/* Get the type (SETTING_TYPE_xxx) of `key' */
 
96
SettingType settings_get_type(const char *key);
 
97
/* Get all settings sorted by section. Free the result with g_slist_free() */
 
98
GSList *settings_get_sorted(void);
 
99
/* Get the record of the setting */
 
100
SETTINGS_REC *settings_get_record(const char *key);
 
101
 
 
102
/* verify that all settings in config file for `module' are actually found
 
103
   from /SET list */
 
104
void settings_check_module(const char *module);
 
105
#define settings_check() settings_check_module(MODULE_NAME)
 
106
 
 
107
/* remove all invalid settings from config file. works only with the
 
108
   modules that have already called settings_check() */
 
109
void settings_clean_invalid(void);
 
110
 
 
111
/* if `fname' is NULL, the default is used */
 
112
int settings_reread(const char *fname);
 
113
int settings_save(const char *fname, int autosave);
 
114
int irssi_config_is_changed(const char *fname);
 
115
 
 
116
void settings_init(void);
 
117
void settings_deinit(void);
 
118
 
 
119
#endif