summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-04-17 18:25:12 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-07-10 23:41:14 +0200
commitf93730e72eeeade82ca72d7a7ad8cde404ef95f1 (patch)
tree8569e6ab7d62e7d03aebab9442f091175f907558 /src/utils
parent4b6d97da2d4bc1a9e328cf861e75f5ee1bb968e3 (diff)
Handle query result and prepare to forward by API
First draft to be able to read at regular interval the TSDB InfluxDB. This prepare a JSON object formated to be handled as an input argument from a regular call to the API verb 'write' Then it is only needed to call the remote verb to forward all the results Change-Id: I80076dd9cf00ba43075d37dd4d15180e63e37289 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/list.c14
-rw-r--r--src/utils/list.h1
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);