EMILE/libconfig/config_find_indexed_property.c

46 lines
984 B
C
Raw Normal View History

2007-08-26 09:16:23 +00:00
/*
*
* (c) 2004-2007 Laurent Vivier <Laurent@Vivier.EU>
2007-08-26 09:16:23 +00:00
*
*/
#include <stdio.h>
#include <string.h>
#include "libconfig.h"
2007-09-08 23:09:14 +00:00
int config_find_indexed_property(int8_t *configuration, char *index_name, char *index_property, char *name, char *property)
2007-08-26 09:16:23 +00:00
{
int index;
int last_index;
char current_name[256];
2007-08-26 19:22:12 +00:00
if (index_name == NULL)
index = 0;
else {
2007-08-26 19:22:12 +00:00
index = config_find_entry(configuration, index_name, index_property);
index = config_get_next_property(configuration, index,
current_name, property);
}
2007-08-26 19:22:12 +00:00
while ((index != -1) && configuration[index])
2007-08-26 09:16:23 +00:00
{
last_index = index;
index = config_get_next_property(configuration, index,
current_name, property);
2007-09-15 05:26:14 +00:00
if ((name != NULL) && (strcmp(name, current_name) == 0))
2007-08-26 09:16:23 +00:00
return last_index;
if ((index_name != NULL) &&
(strcmp(index_name, current_name) == 0))
2007-08-26 19:22:12 +00:00
{
if (name == NULL)
return last_index;
2007-09-17 12:07:42 +00:00
break;
2007-08-26 19:22:12 +00:00
}
2007-08-26 09:16:23 +00:00
}
2007-09-17 12:07:42 +00:00
if (property)
property[0] = 0; /* clear property */
2007-08-26 09:16:23 +00:00
return -1;
}