diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-03-15 13:29:52 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-03-15 14:12:23 +0200 |
commit | 58a8936d30bbb18b8ad93fecfe3fe2210d1c18b2 (patch) | |
tree | 01fcd1416af582e2429f0ae8d120e2af39b8f9d9 /src/util.c | |
parent | 677473cdfc42b9fd83623902e80de946f108825c (diff) | |
download | eclat-58a8936d30bbb18b8ad93fecfe3fe2210d1c18b2.tar.gz eclat-58a8936d30bbb18b8ad93fecfe3fe2210d1c18b2.tar.bz2 |
Upgrade grecs
* grecs: pull
* configure.ac: Enable json
* lib/Makefile.am (AM_CPPFLAGS): Use @GRECS_INCLUDES@
(libeclat_a_SOURCES): Remove json sources.
* src/Makefile.am (AM_CPPFLAGS): Use @GRECS_INCLUDES@
* tests/Makefile.am: Likewise.
* lib/json.h: Remove.
* lib/jsongrm.y: Remove.
* lib/jsonlex.l: Remove.
* tests/tjson.c: Remove.
* src/config.c (eclat_kw): Mark statically initialized memory locations
as such.
* src/mktags.c (process_tags): Use wordsplit to process quoted arguments.
* lib/bidimap.c (bidimap_config): Fill allocated memory with 0's
* lib/filemap.c (filemap_config): Likewise.
* lib/gdbmmap.c (gdbm_map_config): Likewise.
* lib/seqmap.c (seqmap_config): Likewise.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 43 |
1 files changed, 22 insertions, 21 deletions
@@ -15,7 +15,7 @@ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ #include "eclat.h" -#include "json.h" +#include "grecs/json.h" #include <termios.h> #include <sys/ioctl.h> #include <sys/stat.h> @@ -501,7 +501,7 @@ char * eclat_get_instance_zone() { char *doc; - struct json_object *obj, *p; + struct json_value *obj, *p; char *retval = NULL; CURL *curl; char *url; @@ -522,17 +522,17 @@ eclat_get_instance_zone() if (!doc) return NULL; obj = json_parse_string(doc, strlen(doc)); - if (!obj) - die(EX_DATAERR, - "%s: near %s", - json_err_diag, - json_err_ptr); - - p = json_object_lookup(obj, "region"); + if (!obj) { + char *str = NULL; + size_t len = 0; + grecs_asprint_locus(&str, &len, &json_err_locus); + die(EX_DATAERR, "%s: %s", str, json_err_diag); + } + p = json_value_lookup(obj, "region"); if (p && p->type == json_string) retval = grecs_strdup(p->v.s); grecs_txtacc_free(acc); - json_object_free(obj); + json_value_free(obj); return retval; } @@ -544,7 +544,7 @@ eclat_get_instance_creds(char *id, char **access_key_ptr, char **secret_key_ptr, char *url = NULL; char *s; char *doc; - struct json_object *obj, *p; + struct json_value *obj, *p; int err = 0; struct grecs_txtacc *acc; @@ -579,32 +579,33 @@ eclat_get_instance_creds(char *id, char **access_key_ptr, char **secret_key_ptr, free(url); obj = json_parse_string(doc, strlen(doc)); - if (!obj) - die(EX_DATAERR, - "%s: near %s", - json_err_diag, - json_err_ptr); - - p = json_object_lookup(obj, "AccessKeyId"); + if (!obj) { + char *str = NULL; + size_t len = 0; + grecs_asprint_locus(&str, &len, &json_err_locus); + die(EX_DATAERR, "%s: %s", str, json_err_diag); + } + + p = json_value_lookup(obj, "AccessKeyId"); if (p && p->type == json_string) *access_key_ptr = grecs_strdup(p->v.s); else err = 1; - p = json_object_lookup(obj, "SecretAccessKey"); + p = json_value_lookup(obj, "SecretAccessKey"); if (p && p->type == json_string) *secret_key_ptr = grecs_strdup(p->v.s); else err = 1; - p = json_object_lookup(obj, "Token"); + p = json_value_lookup(obj, "Token"); if (p && p->type == json_string) *token_ptr = grecs_strdup(p->v.s); else err = 1; grecs_txtacc_free(acc); - json_object_free(obj); + json_value_free(obj); if (err) die(EX_DATAERR, "security credentials missing"); |