EMILE/libconfig/config_remove_indexed_property.c
2007-08-31 20:42:27 +00:00

37 lines
758 B
C

/*
*
* (c) 2005 Laurent Vivier <Laurent@lvivier.info>
*
*/
#include <stdio.h>
#include <string.h>
#include "libconfig.h"
int config_remove_indexed_property(char *configuration, char *index_name,
char *index_property, char *name)
{
int last_index;
int index;
int len = 0;
last_index = config_find_indexed_property(configuration, index_name,
index_property, name, NULL);
if (last_index == -1)
return -1;
index = config_get_next_property(configuration,
last_index, NULL, NULL);
if (index != -1)
{
len = strlen(configuration + index);
memmove(configuration + last_index, configuration + index, len);
}
if (configuration[index + len - 1] == '\n')
len--;
configuration[index + len] = 0;
return last_index;
}