mirror of
https://github.com/vivier/EMILE.git
synced 2024-12-21 18:30:20 +00:00
functions return index if possible
This commit is contained in:
parent
523f28afcf
commit
d9d6867a57
@ -9,7 +9,7 @@
|
||||
|
||||
#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);
|
||||
|
||||
@ -20,4 +20,6 @@ void config_add_property(char* configuration, char* name, char* property)
|
||||
}
|
||||
sprintf(configuration + index,
|
||||
"%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_name, index_property,
|
||||
name, property);
|
||||
if (index == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
return index;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
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,
|
||||
index_property, name, NULL);
|
||||
if (last_index == -1)
|
||||
return;
|
||||
return -1;
|
||||
index = config_get_next_property(configuration,
|
||||
last_index, NULL, NULL);
|
||||
if (index != -1)
|
||||
@ -31,4 +31,6 @@ void config_remove_indexed_property(char *configuration, char *index_name,
|
||||
if (configuration[index + len - 1] == '\n')
|
||||
len--;
|
||||
configuration[index + len] = 0;
|
||||
|
||||
return last_index;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#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"
|
||||
|
||||
void config_set_indexed_property(char *configuration,
|
||||
int config_set_indexed_property(char *configuration,
|
||||
char *index_name, char *index_property,
|
||||
char *name, char *property)
|
||||
{
|
||||
@ -80,4 +80,6 @@ void config_set_indexed_property(char *configuration,
|
||||
if (configuration[last_index + len - 1] == '\n')
|
||||
len--;
|
||||
configuration[last_index + len] = 0;
|
||||
|
||||
return last_index;
|
||||
}
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
#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_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 void config_remove_property(char *configuration, char *name);
|
||||
extern void 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 void config_remove_indexed_property(char *configuration, char *index_name, char *index_property, char *name);
|
||||
extern int config_remove_property(char *configuration, char *name);
|
||||
extern int config_set_property(char *configuration, char *name, char *property);
|
||||
extern int config_set_indexed_property(char *configuration, char *index_name, char *index_property, char *name, char *property);
|
||||
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_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);
|
||||
|
Loading…
Reference in New Issue
Block a user