From 6de132f0f071cbe0068eb2cae8d8e6348a1410d4 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 3 Feb 2015 13:59:36 +1100 Subject: [PATCH] Export json_get_int64 helper --- src/ckpool.c | 10 +++++++--- src/ckpool.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ckpool.c b/src/ckpool.c index 6ead89b0..e51af761 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -965,20 +965,24 @@ bool json_get_string(char **store, const json_t *val, const char *res) return _json_get_string(store, json_object_get(val, res), res); } -static void json_get_int64(int64_t *store, const json_t *val, const char *res) +bool json_get_int64(int64_t *store, const json_t *val, const char *res) { json_t *entry = json_object_get(val, res); + bool ret = false; if (!entry) { LOGDEBUG("Json did not find entry %s", res); - return; + goto out; } if (!json_is_integer(entry)) { LOGWARNING("Json entry %s is not an integer", res); - return; + goto out; } *store = json_integer_value(entry); LOGDEBUG("Json found entry %s: %ld", res, *store); + ret = true; +out: + return ret; } bool json_get_int(int *store, const json_t *val, const char *res) diff --git a/src/ckpool.h b/src/ckpool.h index ab7d685a..2da96ed5 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -220,6 +220,7 @@ json_t *json_rpc_call(connsock_t *cs, const char *rpc_req); int process_exit(ckpool_t *ckp, const proc_instance_t *pi, int ret); bool json_get_string(char **store, const json_t *val, const char *res); +bool json_get_int64(int64_t *store, const json_t *val, const char *res); bool json_get_int(int *store, const json_t *val, const char *res); bool json_get_double(double *store, const json_t *val, const char *res);