From 0a2ccb6513e4db3adaa107f8a76d48eb1b711a8a Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Fri, 06 Oct 2017 00:35:43 -0400 Subject: mq_config_notify_*(): New functions --- (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index ff3b7ee..5bff673 100644 --- a/src/config.c +++ b/src/config.c @@ -424,3 +424,75 @@ mq_config_set(MqConfig *config, const gchar *name, const gchar *value) g_assert_not_reached(); return FALSE; } + +void +mq_config_notify_boolean(MqConfig *config, const gchar *name, + MqConfigBooleanCallback callback, gpointer user_data) +{ + struct item *item; + struct callbacks *cbs; + + item = g_hash_table_lookup(config->types_and_cbs, name); + g_assert(item->type == TYPE_BOOLEAN); + + cbs = g_malloc(sizeof(*cbs)); + cbs->cb.boolean_cb = callback; + cbs->user_data = user_data; + cbs->next = item->callbacks; + + item->callbacks = cbs; +} + +void +mq_config_notify_integer(MqConfig *config, const gchar *name, + MqConfigIntegerCallback callback, gpointer user_data) +{ + struct item *item; + struct callbacks *cbs; + + item = g_hash_table_lookup(config->types_and_cbs, name); + g_assert(item->type == TYPE_INTEGER); + + cbs = g_malloc(sizeof(*cbs)); + cbs->cb.integer_cb = callback; + cbs->user_data = user_data; + cbs->next = item->callbacks; + + item->callbacks = cbs; +} + +void +mq_config_notify_double(MqConfig *config, const gchar *name, + MqConfigDoubleCallback callback, gpointer user_data) +{ + struct item *item; + struct callbacks *cbs; + + item = g_hash_table_lookup(config->types_and_cbs, name); + g_assert(item->type == TYPE_DOUBLE); + + cbs = g_malloc(sizeof(*cbs)); + cbs->cb.double_cb = callback; + cbs->user_data = user_data; + cbs->next = item->callbacks; + + item->callbacks = cbs; +} + +void +mq_config_notify_string(MqConfig *config, const gchar *name, + MqConfigStringCallback callback, gpointer user_data) +{ + struct item *item; + struct callbacks *cbs; + + item = g_hash_table_lookup(config->types_and_cbs, name); + g_assert(item->type == TYPE_STRING); + + cbs = g_malloc(sizeof(*cbs)); + cbs->cb.string_cb = callback; + cbs->user_data = user_data; + cbs->next = item->callbacks; + + item->callbacks = cbs; +} -- cgit v0.9.1