mirror of
https://github.com/vivier/EMILE.git
synced 2025-08-15 07:27:41 +00:00
functions return index if possible
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "libconfig.h"
|
#include "libconfig.h"
|
||||||
|
|
||||||
void config_add_property(char* configuration, char* name, char* property)
|
int config_add_property(char* configuration, char* name, char* property)
|
||||||
{
|
{
|
||||||
int index = strlen(configuration);
|
int index = strlen(configuration);
|
||||||
|
|
||||||
@@ -20,4 +20,6 @@ void config_add_property(char* configuration, char* name, char* property)
|
|||||||
}
|
}
|
||||||
sprintf(configuration + index,
|
sprintf(configuration + index,
|
||||||
"%s %s", name, property);
|
"%s %s", name, property);
|
||||||
|
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,5 @@ int config_get_indexed_property(char *configuration, char *index_name, char *ind
|
|||||||
index = config_find_indexed_property(configuration,
|
index = config_find_indexed_property(configuration,
|
||||||
index_name, index_property,
|
index_name, index_property,
|
||||||
name, property);
|
name, property);
|
||||||
if (index == -1)
|
return index;
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "libconfig.h"
|
#include "libconfig.h"
|
||||||
|
|
||||||
void config_remove_indexed_property(char *configuration, char *index_name,
|
int config_remove_indexed_property(char *configuration, char *index_name,
|
||||||
char *index_property, char *name)
|
char *index_property, char *name)
|
||||||
{
|
{
|
||||||
int last_index;
|
int last_index;
|
||||||
@@ -19,7 +19,7 @@ void config_remove_indexed_property(char *configuration, char *index_name,
|
|||||||
last_index = config_find_indexed_property(configuration, index_name,
|
last_index = config_find_indexed_property(configuration, index_name,
|
||||||
index_property, name, NULL);
|
index_property, name, NULL);
|
||||||
if (last_index == -1)
|
if (last_index == -1)
|
||||||
return;
|
return -1;
|
||||||
index = config_get_next_property(configuration,
|
index = config_get_next_property(configuration,
|
||||||
last_index, NULL, NULL);
|
last_index, NULL, NULL);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
@@ -31,4 +31,6 @@ void config_remove_indexed_property(char *configuration, char *index_name,
|
|||||||
if (configuration[index + len - 1] == '\n')
|
if (configuration[index + len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
configuration[index + len] = 0;
|
configuration[index + len] = 0;
|
||||||
|
|
||||||
|
return last_index;
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "libconfig.h"
|
#include "libconfig.h"
|
||||||
|
|
||||||
void config_remove_property(char *configuration, char *name)
|
int config_remove_property(char *configuration, char *name)
|
||||||
{
|
{
|
||||||
config_remove_indexed_property(configuration, name, NULL, NULL);
|
return config_remove_indexed_property(configuration, name, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "libconfig.h"
|
#include "libconfig.h"
|
||||||
|
|
||||||
void config_set_indexed_property(char *configuration,
|
int config_set_indexed_property(char *configuration,
|
||||||
char *index_name, char *index_property,
|
char *index_name, char *index_property,
|
||||||
char *name, char *property)
|
char *name, char *property)
|
||||||
{
|
{
|
||||||
@@ -80,4 +80,6 @@ void config_set_indexed_property(char *configuration,
|
|||||||
if (configuration[last_index + len - 1] == '\n')
|
if (configuration[last_index + len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
configuration[last_index + len] = 0;
|
configuration[last_index + len] = 0;
|
||||||
|
|
||||||
|
return last_index;
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
#include "libconfig.h"
|
#include "libconfig.h"
|
||||||
|
|
||||||
void config_set_property(char *configuration, char *name, char *property)
|
int config_set_property(char *configuration, char *name, char *property)
|
||||||
{
|
{
|
||||||
config_set_indexed_property(configuration, NULL, NULL, name, property);
|
return config_set_indexed_property(configuration, NULL, NULL,
|
||||||
|
name, property);
|
||||||
}
|
}
|
||||||
|
@@ -8,10 +8,10 @@ extern char *config_read_word(char *line, char **next);
|
|||||||
extern int config_get_next_property(char *configuration, int index, char *name, char *property);
|
extern int config_get_next_property(char *configuration, int index, char *name, char *property);
|
||||||
extern int config_get_indexed_property(char *configuration, char *index_name, char *index_property, char *name, char *property);
|
extern int config_get_indexed_property(char *configuration, char *index_name, char *index_property, char *name, char *property);
|
||||||
extern int config_get_property(char *configuration, char *name, char *property);
|
extern int config_get_property(char *configuration, char *name, char *property);
|
||||||
extern void config_remove_property(char *configuration, char *name);
|
extern int config_remove_property(char *configuration, char *name);
|
||||||
extern void config_set_property(char *configuration, char *name, char *property);
|
extern int config_set_property(char *configuration, char *name, char *property);
|
||||||
extern void config_set_indexed_property(char *configuration, char *index_name, char *index_property, char *name, char *property);
|
extern int config_set_indexed_property(char *configuration, char *index_name, char *index_property, char *name, char *property);
|
||||||
extern void config_remove_indexed_property(char *configuration, char *index_name, char *index_property, char *name);
|
extern int config_remove_indexed_property(char *configuration, char *index_name, char *index_property, char *name);
|
||||||
extern int config_find_indexed_property(char *configuration, char *index_name, char *index_property, char *name, char *property);
|
extern int config_find_indexed_property(char *configuration, char *index_name, char *index_property, char *name, char *property);
|
||||||
extern int config_find_entry(char *configuration, char *name, char *property);
|
extern int config_find_entry(char *configuration, char *name, char *property);
|
||||||
extern void config_add_property(char* configuration, char* name, char* property);
|
extern int config_add_property(char* configuration, char* name, char* property);
|
||||||
|
Reference in New Issue
Block a user