Browse Source

Export json_get_int64 helper

master
Con Kolivas 10 years ago
parent
commit
6de132f0f0
  1. 10
      src/ckpool.c
  2. 1
      src/ckpool.h

10
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)

1
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);

Loading…
Cancel
Save