19
static struct hash_table *settings;
19
static HASH_TABLE(const char *, struct testsuite_setting *) settings;
21
21
static const char *testsuite_setting_get
22
22
(void *context, const char *identifier);
24
24
void testsuite_settings_init(void)
26
settings = hash_table_create
27
(default_pool, default_pool, 0, str_hash, (hash_cmp_callback_t *)strcmp);
26
hash_table_create(&settings, default_pool, 0, str_hash, strcmp);
29
28
sieve_tool_set_setting_callback(sieve_tool, testsuite_setting_get, NULL);
32
31
void testsuite_settings_deinit(void)
34
struct hash_iterate_context *itx =
33
struct hash_iterate_context *itx =
35
34
hash_table_iterate_init(settings);
39
while ( hash_table_iterate(itx, &key, &value) ) {
40
struct testsuite_setting *setting = (struct testsuite_setting *) value;
36
struct testsuite_setting *setting;
38
while ( hash_table_iterate(itx, settings, &key, &setting) ) {
42
39
i_free(setting->identifier);
43
40
i_free(setting->value);
47
hash_table_iterate_deinit(&itx);
44
hash_table_iterate_deinit(&itx);
49
46
hash_table_destroy(&settings);
52
49
static const char *testsuite_setting_get
53
50
(void *context ATTR_UNUSED, const char *identifier)
55
struct testsuite_setting *setting = (struct testsuite_setting *)
52
struct testsuite_setting *setting =
56
53
hash_table_lookup(settings, identifier);
58
55
if ( setting == NULL ) {
65
62
void testsuite_setting_set(const char *identifier, const char *value)
67
struct testsuite_setting *setting = (struct testsuite_setting *)
64
struct testsuite_setting *setting =
68
65
hash_table_lookup(settings, identifier);
70
67
if ( setting != NULL ) {
74
71
setting = i_new(struct testsuite_setting, 1);
75
72
setting->identifier = i_strdup(identifier);
76
73
setting->value = i_strdup(value);
78
hash_table_insert(settings, (void *) identifier, (void *) setting);
75
hash_table_insert(settings, identifier, setting);
82
79
void testsuite_setting_unset(const char *identifier)
84
struct testsuite_setting *setting = (struct testsuite_setting *)
81
struct testsuite_setting *setting =
85
82
hash_table_lookup(settings, identifier);
87
84
if ( setting != NULL ) {