2020-06-21 19:18:43 +00:00
|
|
|
#include "webfuse_provider/impl/util/json_util.h"
|
2020-02-28 22:17:41 +00:00
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
int wfp_impl_json_get_int(json_t const * object, char const * key, int default_value)
|
2020-02-28 22:17:41 +00:00
|
|
|
{
|
|
|
|
int result = default_value;
|
|
|
|
|
|
|
|
json_t * holder = json_object_get(object, key);
|
2020-06-21 19:27:53 +00:00
|
|
|
if (json_is_integer(holder))
|
2020-02-28 22:17:41 +00:00
|
|
|
{
|
|
|
|
result = json_integer_value(holder);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
wfp_status
|
|
|
|
wfp_impl_jsonrpc_get_status(
|
2020-02-28 22:17:41 +00:00
|
|
|
json_t const * error)
|
|
|
|
{
|
2020-06-16 21:57:41 +00:00
|
|
|
wfp_status status = WFP_GOOD;
|
2020-02-28 22:17:41 +00:00
|
|
|
if (NULL != error)
|
|
|
|
{
|
2020-06-16 21:57:41 +00:00
|
|
|
status = wfp_impl_json_get_int(error, "code", WFP_BAD_FORMAT);
|
2020-02-28 22:17:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|