rpc: add bool-type decoder
Allow passing booleans in JSON. Change-Id: I0b8f6c1579d8382b5b19a987ef5d913b4423c954 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
This commit is contained in:
parent
fb87f80c20
commit
1bc2c5ab57
@ -146,6 +146,7 @@ int spdk_json_decode_object(const struct spdk_json_val *values,
|
||||
int spdk_json_decode_array(const struct spdk_json_val *values, spdk_json_decode_fn decode_func,
|
||||
void *out, size_t max_size, size_t *out_size, size_t stride);
|
||||
|
||||
int spdk_json_decode_bool(const struct spdk_json_val *val, void *out);
|
||||
int spdk_json_decode_int32(const struct spdk_json_val *val, void *out);
|
||||
int spdk_json_decode_uint32(const struct spdk_json_val *val, void *out);
|
||||
int spdk_json_decode_string(const struct spdk_json_val *val, void *out);
|
||||
|
@ -249,6 +249,19 @@ spdk_json_decode_array(const struct spdk_json_val *values, spdk_json_decode_fn d
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_json_decode_bool(const struct spdk_json_val *val, void *out)
|
||||
{
|
||||
bool *f = out;
|
||||
|
||||
if (val->type != SPDK_JSON_VAL_TRUE && val->type != SPDK_JSON_VAL_FALSE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*f = val->type == SPDK_JSON_VAL_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_json_decode_int32(const struct spdk_json_val *val, void *out)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user