Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / lib-config / get.c
index e4c5cf07fba7d8fa6e09d0b97a9bb18178a2aac5..ccc8c689a6cba07e3ae40361ce979bbc7c65b844 100644 (file)
@@ -171,46 +171,6 @@ int config_get_bool(CONFIG_REC *rec, const char *section, const char *key, int d
         return i_toupper(*str) == 'T' || i_toupper(*str) == 'Y';
 }
 
-/* Return value of key `value_key' from list item where `key' is `value' */
-const char *config_list_find(CONFIG_REC *rec, const char *section, const char *key, const char *value, const char *value_key)
-{
-       CONFIG_NODE *node;
-
-       node = config_list_find_node(rec, section, key, value, value_key);
-       return node != NULL && node->type == NODE_TYPE_KEY ?
-               node->value : NULL;
-}
-
-/* Like config_list_find(), but return node instead of it's value */
-CONFIG_NODE *config_list_find_node(CONFIG_REC *rec, const char *section, const char *key, const char *value, const char *value_key)
-{
-       CONFIG_NODE *node, *keynode;
-       GSList *tmp;
-
-       g_return_val_if_fail(rec != NULL, NULL);
-       g_return_val_if_fail(key != NULL, NULL);
-       g_return_val_if_fail(value_key != NULL, NULL);
-
-       node = config_node_traverse(rec, section, FALSE);
-       if (node == NULL || !is_node_list(node)) return NULL;
-
-       for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
-               node = tmp->data;
-
-               if (node->type != NODE_TYPE_BLOCK)
-                       continue;
-
-               /* key matches value? */
-               keynode = config_node_find(node, key);
-               if (keynode == NULL || keynode->type != NODE_TYPE_KEY ||
-                   g_strcasecmp(keynode->value, value) != 0) continue;
-
-               return config_node_find(node, value_key);
-       }
-
-       return NULL;
-}
-
 char *config_node_get_str(CONFIG_NODE *parent, const char *key, const char *def)
 {
        CONFIG_NODE *node;
@@ -316,9 +276,14 @@ CONFIG_NODE *config_node_nth(CONFIG_NODE *node, int index)
        g_return_val_if_fail(node != NULL, NULL);
        g_return_val_if_fail(is_node_list(node), NULL);
 
-       for (tmp = node->value; tmp != NULL; tmp = tmp->next, index--) {
-               if (index == 0)
-                        return tmp->data;
+       for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
+               CONFIG_NODE *node = tmp->data;
+
+               if (node->type != NODE_TYPE_COMMENT) {
+                       if (index == 0)
+                               return node;
+                       index--;
+               }
        }
 
        return NULL;
@@ -328,6 +293,8 @@ CONFIG_NODE *config_node_nth(CONFIG_NODE *node, int index)
 int config_node_index(CONFIG_NODE *parent, const char *key)
 {
        CONFIG_NODE *node;
+       GSList *tmp;
+       int index;
 
        g_return_val_if_fail(parent != NULL, -1);
        g_return_val_if_fail(key != NULL, -1);
@@ -336,7 +303,18 @@ int config_node_index(CONFIG_NODE *parent, const char *key)
        if (node == NULL)
                return -1;
 
-        return g_slist_index(parent->value, node);
+       index = 0;
+       for (tmp = parent->value; tmp != NULL; tmp = tmp->next) {
+               CONFIG_NODE *tmpnode = tmp->data;
+
+               if (tmpnode == node)
+                       return index;
+
+               if (tmpnode->type != NODE_TYPE_COMMENT)
+                       index++;
+       }
+
+        return -1;
 }
 
 /* Returns the first non-comment node in list */