diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-06-29 11:20:51 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-06-29 11:20:51 +0800 |
commit | 1719796a3a10eccf91eadb38c019829110e96294 (patch) | |
tree | 47ff1e6401fd5202aad0eccacb94bb19550f294f /util.c | |
parent | b065c82627d83d1b207985d78276eb80f0b7b266 (diff) | |
download | matrix-curl-1719796a3a10eccf91eadb38c019829110e96294.tar.xz |
update get_devices
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -1,5 +1,6 @@ #include <string.h> #include <stdlib.h> +#include "util.h" #define SLMAX 100 @@ -25,3 +26,23 @@ char * alloc_build_string(const char *ss[]) res[cur] = 0; return res; } + +const char *json_gets(json_object *j, const char *key) +{ + json_object *val; + + if (json_object_object_get_ex(j, key, &val)) { + if (json_object_is_type(val, json_type_string)) + return json_object_get_string(val); + } + return NULL; +} + +char *json_gets_dup(json_object *j, const char *key) +{ + const char *t = json_gets(j, key); + if (t == NULL) + return NULL; + else + return strdup(t); +} |