~ubuntu-branches/ubuntu/oneiric/irssi/oneiric

« back to all changes in this revision

Viewing changes to src/lib-config/get.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2009-05-05 15:50:50 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090505155050-aoqlnpes7che9rtd
Tags: 0.8.13-1ubuntu1
* Merge from debian unstable (LP: #372411), remaining changes:
  - debian/patches: 03firsttimer_text
    + Adapt it so it tells you about connecting to irc.ubuntu.com and
      joining #ubuntu instead of irc.debian.org and #debian.
  - debian/patches: 90irc-ubuntu-com
* Fixed debian/patches/90irc-ubuntu-com for new irssi.conf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
        return NULL;
39
39
}
40
40
 
41
 
/* find the section from node - if not found create it unless new_type is -1.
42
 
   you can also specify in new_type if it's NODE_TYPE_LIST or NODE_TYPE_BLOCK */
43
41
CONFIG_NODE *config_node_section(CONFIG_NODE *parent, const char *key, int new_type)
44
42
{
45
43
        return config_node_section_index(parent, key, -1, new_type);
80
78
        return node;
81
79
}
82
80
 
83
 
/* find the section with the whole path.
84
 
   create the path if necessary `create' is TRUE. */
85
81
CONFIG_NODE *config_node_traverse(CONFIG_REC *rec, const char *section, int create)
86
82
{
87
83
        CONFIG_NODE *node;
203
199
                (i_toupper(*str) == 'O' && i_toupper(str[1]) == 'N');
204
200
}
205
201
 
206
 
/* Get the value of keys `key' and `key_value' and put them to
207
 
   `ret_key' and `ret_value'. Returns -1 if not found. */
208
 
int config_node_get_keyvalue(CONFIG_NODE *node, const char *key, const char *value_key, char **ret_key, char **ret_value)
209
 
{
210
 
        CONFIG_NODE *keynode, *valuenode;
211
 
        GSList *tmp;
212
 
 
213
 
        g_return_val_if_fail(node != NULL, -1);
214
 
        g_return_val_if_fail(key != NULL, -1);
215
 
        g_return_val_if_fail(value_key != NULL, -1);
216
 
        g_return_val_if_fail(ret_key != NULL, -1);
217
 
        g_return_val_if_fail(ret_value != NULL, -1);
218
 
 
219
 
        for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
220
 
                node = tmp->data;
221
 
 
222
 
                if (node->type != NODE_TYPE_BLOCK)
223
 
                        continue;
224
 
 
225
 
                keynode = config_node_find(node, key);
226
 
                if (keynode == NULL || keynode->type != NODE_TYPE_KEY)
227
 
                        continue;
228
 
 
229
 
                valuenode = config_node_find(node, value_key);
230
 
 
231
 
                *ret_key = keynode->key;
232
 
                *ret_value = valuenode != NULL && valuenode->type == NODE_TYPE_KEY ?
233
 
                        valuenode->value : NULL;
234
 
                return 0;
235
 
        }
236
 
 
237
 
        return -1;
238
 
}
239
 
 
240
 
/* Return all values from from the list `node' in a g_strsplit() array */
241
202
char **config_node_get_list(CONFIG_NODE *node)
242
203
{
243
204
        GString *values;
253
214
                node = tmp->data;
254
215
 
255
216
                if (node->type == NODE_TYPE_VALUE)
256
 
                        g_string_sprintfa(values, "%s ", (char *) node->value);
 
217
                        g_string_append_printf(values, "%s ", (char *) node->value);
257
218
        }
258
219
 
259
220
        /* split the values to **str array */
268
229
        return ret;
269
230
}
270
231
 
271
 
/* Returns n'th node from list. */
272
232
CONFIG_NODE *config_node_nth(CONFIG_NODE *node, int index)
273
233
{
274
234
        GSList *tmp;
289
249
        return NULL;
290
250
}
291
251
 
292
 
/* Returns index for given key */
293
252
int config_node_index(CONFIG_NODE *parent, const char *key)
294
253
{
295
254
        CONFIG_NODE *node;
317
276
        return -1;
318
277
}
319
278
 
320
 
/* Returns the first non-comment node in list */
321
279
GSList *config_node_first(GSList *list)
322
280
{
323
281
        while (list != NULL) {
330
288
        return list;
331
289
}
332
290
 
333
 
/* Returns the next non-comment node in list */
334
291
GSList *config_node_next(GSList *list)
335
292
{
336
293
        list = list->next;