diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/list.c | 14 | ||||
-rw-r--r-- | src/utils/list.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/utils/list.c b/src/utils/list.c index bd7eeac..d47f761 100644 --- a/src/utils/list.c +++ b/src/utils/list.c @@ -64,6 +64,20 @@ void add_key(struct list **l, const char *key) } } +int set_value(struct list *l, json_object *val, int index) +{ + int i; + + for (i = 0; i < index; i++) { + l = l->next; + if ( l == NULL ) + return -1; + } + + l->value = val; + return 0; +} + struct list *get_elt(struct list *l, int index) { int i; diff --git a/src/utils/list.h b/src/utils/list.h index 7cacbed..9f93cb6 100644 --- a/src/utils/list.h +++ b/src/utils/list.h @@ -29,6 +29,7 @@ struct list { void destroy_list(struct list *l); void add_elt(struct list **l, const char *key, json_object *value); void add_key(struct list **l, const char *key); +int set_value(struct list *l, json_object *val, int index); struct list *get_elt(struct list *l, int index); struct list *find_elt_from_key(struct list *l, const char *key); json_object *find_key_value(struct list *l, const char *key); |