2020-06-16 21:39:45 +00:00
|
|
|
#include "webfuse_provider/impl/jsonrpc/request.h"
|
|
|
|
#include "webfuse_provider/impl/jsonrpc/error.h"
|
2019-04-01 20:15:12 +00:00
|
|
|
#include <stdlib.h>
|
2019-02-09 02:08:02 +00:00
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
struct wfp_jsonrpc_request
|
2019-02-09 02:08:02 +00:00
|
|
|
{
|
2019-04-01 20:15:12 +00:00
|
|
|
int id;
|
2020-06-16 21:57:41 +00:00
|
|
|
wfp_jsonrpc_send_fn * send;
|
2019-04-01 20:15:12 +00:00
|
|
|
void * user_data;
|
|
|
|
};
|
|
|
|
|
2020-02-29 01:32:03 +00:00
|
|
|
bool
|
2020-06-16 21:57:41 +00:00
|
|
|
wfp_jsonrpc_is_request(
|
2019-04-01 20:15:12 +00:00
|
|
|
json_t * message)
|
|
|
|
{
|
|
|
|
json_t * id = json_object_get(message, "id");
|
|
|
|
json_t * method = json_object_get(message, "method");
|
|
|
|
json_t * params = json_object_get(message, "params");
|
|
|
|
|
|
|
|
return (json_is_integer(id) && json_is_string(method) &&
|
|
|
|
(json_is_array(params) || json_is_object(params)));
|
2019-02-09 02:08:02 +00:00
|
|
|
}
|
2019-04-01 20:15:12 +00:00
|
|
|
|
|
|
|
|
2020-02-29 01:32:03 +00:00
|
|
|
void
|
2020-06-16 21:57:41 +00:00
|
|
|
wfp_jsonrpc_request_dispose(
|
|
|
|
struct wfp_jsonrpc_request * request)
|
2019-04-01 20:15:12 +00:00
|
|
|
{
|
|
|
|
free(request);
|
|
|
|
}
|
|
|
|
|
2020-02-29 01:32:03 +00:00
|
|
|
void *
|
2020-06-16 21:57:41 +00:00
|
|
|
wfp_jsonrpc_request_get_userdata(
|
|
|
|
struct wfp_jsonrpc_request * request)
|
2019-04-01 20:15:12 +00:00
|
|
|
{
|
|
|
|
return request->user_data;
|
|
|
|
}
|