mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
switched prefix to wfp for old wf stuff
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "webfuse_provider/impl/jsonrpc/error.h"
|
||||
|
||||
json_t *
|
||||
wf_jsonrpc_error(
|
||||
wfp_jsonrpc_error(
|
||||
int code,
|
||||
char const * message)
|
||||
{
|
||||
@@ -13,13 +13,13 @@ wf_jsonrpc_error(
|
||||
}
|
||||
|
||||
void
|
||||
wf_jsonrpc_propate_error(
|
||||
wf_jsonrpc_proxy_finished_fn * finised,
|
||||
wfp_jsonrpc_propate_error(
|
||||
wfp_jsonrpc_proxy_finished_fn * finised,
|
||||
void * user_data,
|
||||
int code,
|
||||
char const * message)
|
||||
{
|
||||
json_t * error = wf_jsonrpc_error(code, message);
|
||||
json_t * error = wfp_jsonrpc_error(code, message);
|
||||
finised(user_data, NULL, error);
|
||||
|
||||
json_decref(error);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_ERROR_H
|
||||
#define WF_JSONRPC_ERROR_H
|
||||
#ifndef WFP_JSONRPC_ERROR_H
|
||||
#define WFP_JSONRPC_ERROR_H
|
||||
|
||||
#include <jansson.h>
|
||||
#include "webfuse_provider/impl/jsonrpc/proxy_finished_fn.h"
|
||||
@@ -10,13 +10,13 @@ extern "C"
|
||||
#endif
|
||||
|
||||
extern json_t *
|
||||
wf_jsonrpc_error(
|
||||
wfp_jsonrpc_error(
|
||||
int code,
|
||||
char const * message);
|
||||
|
||||
extern void
|
||||
wf_jsonrpc_propate_error(
|
||||
wf_jsonrpc_proxy_finished_fn * finised,
|
||||
wfp_jsonrpc_propate_error(
|
||||
wfp_jsonrpc_proxy_finished_fn * finised,
|
||||
void * user_data,
|
||||
int code,
|
||||
char const * message);
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct wf_jsonrpc_method * wf_jsonrpc_method_create(
|
||||
struct wfp_jsonrpc_method * wfp_jsonrpc_method_create(
|
||||
char const * method_name,
|
||||
wf_jsonrpc_method_invoke_fn * invoke,
|
||||
wfp_jsonrpc_method_invoke_fn * invoke,
|
||||
void * user_data)
|
||||
{
|
||||
struct wf_jsonrpc_method * method = malloc(sizeof(struct wf_jsonrpc_method));
|
||||
struct wfp_jsonrpc_method * method = malloc(sizeof(struct wfp_jsonrpc_method));
|
||||
method->next = NULL;
|
||||
method->name = strdup(method_name);
|
||||
method->invoke = invoke;
|
||||
@@ -16,8 +16,8 @@ struct wf_jsonrpc_method * wf_jsonrpc_method_create(
|
||||
return method;
|
||||
}
|
||||
|
||||
void wf_jsonrpc_method_dispose(
|
||||
struct wf_jsonrpc_method * method)
|
||||
void wfp_jsonrpc_method_dispose(
|
||||
struct wfp_jsonrpc_method * method)
|
||||
{
|
||||
free(method->name);
|
||||
free(method);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_METHOD_H
|
||||
#define WF_JSONRPC_METHOD_H
|
||||
#ifndef WFP_JSONRPC_METHOD_H
|
||||
#define WFP_JSONRPC_METHOD_H
|
||||
|
||||
#include "webfuse_provider/impl/jsonrpc/method_invoke_fn.h"
|
||||
|
||||
@@ -8,23 +8,23 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wf_jsonrpc_method
|
||||
struct wfp_jsonrpc_method
|
||||
{
|
||||
struct wf_jsonrpc_method * next;
|
||||
struct wfp_jsonrpc_method * next;
|
||||
char * name;
|
||||
wf_jsonrpc_method_invoke_fn * invoke;
|
||||
wfp_jsonrpc_method_invoke_fn * invoke;
|
||||
void * user_data;
|
||||
};
|
||||
|
||||
extern struct wf_jsonrpc_method *
|
||||
wf_jsonrpc_method_create(
|
||||
extern struct wfp_jsonrpc_method *
|
||||
wfp_jsonrpc_method_create(
|
||||
char const * method_name,
|
||||
wf_jsonrpc_method_invoke_fn * invoke,
|
||||
wfp_jsonrpc_method_invoke_fn * invoke,
|
||||
void * user_data);
|
||||
|
||||
extern void
|
||||
wf_jsonrpc_method_dispose(
|
||||
struct wf_jsonrpc_method * method);
|
||||
wfp_jsonrpc_method_dispose(
|
||||
struct wfp_jsonrpc_method * method);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_METHOD_INVOKE_FN_H
|
||||
#define WF_JSONRPC_METHOD_INVOKE_FN_H
|
||||
#ifndef WFP_JSONRPC_METHOD_INVOKE_FN_H
|
||||
#define WFP_JSONRPC_METHOD_INVOKE_FN_H
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
@@ -8,10 +8,10 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wf_jsonrpc_request;
|
||||
struct wfp_jsonrpc_request;
|
||||
|
||||
typedef void wf_jsonrpc_method_invoke_fn(
|
||||
struct wf_jsonrpc_request * request,
|
||||
typedef void wfp_jsonrpc_method_invoke_fn(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
char const * method_name,
|
||||
json_t * params,
|
||||
void * user_data);
|
||||
|
||||
@@ -8,47 +8,47 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct wf_jsonrpc_proxy *
|
||||
wf_jsonrpc_proxy_create(
|
||||
struct wf_timer_manager * manager,
|
||||
struct wfp_jsonrpc_proxy *
|
||||
wfp_jsonrpc_proxy_create(
|
||||
struct wfp_timer_manager * manager,
|
||||
int timeout,
|
||||
wf_jsonrpc_send_fn * send,
|
||||
wfp_jsonrpc_send_fn * send,
|
||||
void * user_data)
|
||||
{
|
||||
struct wf_jsonrpc_proxy * proxy = malloc(sizeof(struct wf_jsonrpc_proxy));
|
||||
wf_jsonrpc_proxy_init(proxy, manager, timeout, send, user_data);
|
||||
struct wfp_jsonrpc_proxy * proxy = malloc(sizeof(struct wfp_jsonrpc_proxy));
|
||||
wfp_jsonrpc_proxy_init(proxy, manager, timeout, send, user_data);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
void wf_jsonrpc_proxy_dispose(
|
||||
struct wf_jsonrpc_proxy * proxy)
|
||||
void wfp_jsonrpc_proxy_dispose(
|
||||
struct wfp_jsonrpc_proxy * proxy)
|
||||
{
|
||||
wf_jsonrpc_proxy_cleanup(proxy);
|
||||
wfp_jsonrpc_proxy_cleanup(proxy);
|
||||
free(proxy);
|
||||
}
|
||||
|
||||
static void wf_jsonrpc_proxy_on_timeout(
|
||||
struct wf_timer * timer, void * proxy_ptr)
|
||||
static void wfp_jsonrpc_proxy_on_timeout(
|
||||
struct wfp_timer * timer, void * proxy_ptr)
|
||||
{
|
||||
struct wf_jsonrpc_proxy * proxy = proxy_ptr;
|
||||
struct wfp_jsonrpc_proxy * proxy = proxy_ptr;
|
||||
|
||||
if (proxy->request.is_pending)
|
||||
{
|
||||
wf_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
|
||||
wfp_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
|
||||
void * user_data = proxy->request.user_data;
|
||||
|
||||
proxy->request.is_pending = false;
|
||||
proxy->request.id = 0;
|
||||
proxy->request.user_data = NULL;
|
||||
proxy->request.finished = NULL;
|
||||
wf_timer_cancel(timer);
|
||||
wfp_timer_cancel(timer);
|
||||
|
||||
wf_jsonrpc_propate_error(finished, user_data, WF_BAD_TIMEOUT, "Timeout");
|
||||
wfp_jsonrpc_propate_error(finished, user_data, WFP_BAD_TIMEOUT, "Timeout");
|
||||
}
|
||||
}
|
||||
|
||||
static json_t * wf_jsonrpc_request_create(
|
||||
static json_t * wfp_jsonrpc_request_create(
|
||||
char const * method,
|
||||
int id,
|
||||
char const * param_info,
|
||||
@@ -98,44 +98,44 @@ static json_t * wf_jsonrpc_request_create(
|
||||
return request;
|
||||
}
|
||||
|
||||
void wf_jsonrpc_proxy_init(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
struct wf_timer_manager * timeout_manager,
|
||||
void wfp_jsonrpc_proxy_init(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
struct wfp_timer_manager * timeout_manager,
|
||||
int timeout,
|
||||
wf_jsonrpc_send_fn * send,
|
||||
wfp_jsonrpc_send_fn * send,
|
||||
void * user_data)
|
||||
{
|
||||
proxy->send = send;
|
||||
proxy->timeout = timeout;
|
||||
proxy->user_data = user_data;
|
||||
proxy->request.is_pending = false;
|
||||
proxy->request.timer = wf_timer_create(timeout_manager,
|
||||
&wf_jsonrpc_proxy_on_timeout, proxy);
|
||||
proxy->request.timer = wfp_timer_create(timeout_manager,
|
||||
&wfp_jsonrpc_proxy_on_timeout, proxy);
|
||||
}
|
||||
|
||||
void wf_jsonrpc_proxy_cleanup(
|
||||
struct wf_jsonrpc_proxy * proxy)
|
||||
void wfp_jsonrpc_proxy_cleanup(
|
||||
struct wfp_jsonrpc_proxy * proxy)
|
||||
{
|
||||
if (proxy->request.is_pending)
|
||||
{
|
||||
void * user_data = proxy->request.user_data;
|
||||
wf_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
|
||||
wfp_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
|
||||
|
||||
proxy->request.is_pending = false;
|
||||
proxy->request.finished = NULL;
|
||||
proxy->request.user_data = NULL;
|
||||
proxy->request.id = 0;
|
||||
wf_timer_cancel(proxy->request.timer);
|
||||
wfp_timer_cancel(proxy->request.timer);
|
||||
|
||||
wf_jsonrpc_propate_error(finished, user_data, WF_BAD, "Bad: cancelled pending request during shutdown");
|
||||
wfp_jsonrpc_propate_error(finished, user_data, WFP_BAD, "Bad: cancelled pending request during shutdown");
|
||||
}
|
||||
|
||||
wf_timer_dispose(proxy->request.timer);
|
||||
wfp_timer_dispose(proxy->request.timer);
|
||||
}
|
||||
|
||||
void wf_jsonrpc_proxy_vinvoke(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
wf_jsonrpc_proxy_finished_fn * finished,
|
||||
void wfp_jsonrpc_proxy_vinvoke(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
wfp_jsonrpc_proxy_finished_fn * finished,
|
||||
void * user_data,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
@@ -147,9 +147,9 @@ void wf_jsonrpc_proxy_vinvoke(
|
||||
proxy->request.finished = finished;
|
||||
proxy->request.user_data = user_data;
|
||||
proxy->request.id = 42;
|
||||
wf_timer_start(proxy->request.timer, proxy->timeout);
|
||||
wfp_timer_start(proxy->request.timer, proxy->timeout);
|
||||
|
||||
json_t * request = wf_jsonrpc_request_create(method_name, proxy->request.id, param_info, args);
|
||||
json_t * request = wfp_jsonrpc_request_create(method_name, proxy->request.id, param_info, args);
|
||||
|
||||
bool const is_send = ((NULL != request) && (proxy->send(request, proxy->user_data)));
|
||||
if (!is_send)
|
||||
@@ -158,9 +158,9 @@ void wf_jsonrpc_proxy_vinvoke(
|
||||
proxy->request.finished = NULL;
|
||||
proxy->request.user_data = NULL;
|
||||
proxy->request.id = 0;
|
||||
wf_timer_cancel(proxy->request.timer);
|
||||
wfp_timer_cancel(proxy->request.timer);
|
||||
|
||||
wf_jsonrpc_propate_error(finished, user_data, WF_BAD, "Bad: requenst is not sent");
|
||||
wfp_jsonrpc_propate_error(finished, user_data, WFP_BAD, "Bad: requenst is not sent");
|
||||
}
|
||||
|
||||
if (NULL != request)
|
||||
@@ -170,17 +170,17 @@ void wf_jsonrpc_proxy_vinvoke(
|
||||
}
|
||||
else
|
||||
{
|
||||
wf_jsonrpc_propate_error(finished, user_data, WF_BAD_BUSY, "Busy");
|
||||
wfp_jsonrpc_propate_error(finished, user_data, WFP_BAD_BUSY, "Busy");
|
||||
}
|
||||
}
|
||||
|
||||
extern void wf_jsonrpc_proxy_vnotify(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
extern void wfp_jsonrpc_proxy_vnotify(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
va_list args)
|
||||
{
|
||||
json_t * request = wf_jsonrpc_request_create(method_name, 0, param_info, args);
|
||||
json_t * request = wfp_jsonrpc_request_create(method_name, 0, param_info, args);
|
||||
|
||||
if (NULL != request)
|
||||
{
|
||||
@@ -190,27 +190,27 @@ extern void wf_jsonrpc_proxy_vnotify(
|
||||
}
|
||||
|
||||
|
||||
void wf_jsonrpc_proxy_onresult(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
void wfp_jsonrpc_proxy_onresult(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
json_t * message)
|
||||
{
|
||||
struct wf_jsonrpc_response response;
|
||||
wf_jsonrpc_response_init(&response, message);
|
||||
struct wfp_jsonrpc_response response;
|
||||
wfp_jsonrpc_response_init(&response, message);
|
||||
|
||||
if ((proxy->request.is_pending) && (response.id == proxy->request.id))
|
||||
{
|
||||
wf_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
|
||||
wfp_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
|
||||
void * user_data = proxy->request.user_data;
|
||||
|
||||
proxy->request.is_pending = false;
|
||||
proxy->request.id = 0;
|
||||
proxy->request.user_data = NULL;
|
||||
proxy->request.finished = NULL;
|
||||
wf_timer_cancel(proxy->request.timer);
|
||||
wfp_timer_cancel(proxy->request.timer);
|
||||
|
||||
finished(user_data, response.result, response.error);
|
||||
}
|
||||
|
||||
wf_jsonrpc_response_cleanup(&response);
|
||||
wfp_jsonrpc_response_cleanup(&response);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_PROXY_H
|
||||
#define WF_JSONRPC_PROXY_H
|
||||
#ifndef WFP_JSONRPC_PROXY_H
|
||||
#define WFP_JSONRPC_PROXY_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdarg.h>
|
||||
@@ -19,18 +19,18 @@ using std::size_t;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wf_jsonrpc_proxy;
|
||||
struct wf_timer_manager;
|
||||
struct wfp_jsonrpc_proxy;
|
||||
struct wfp_timer_manager;
|
||||
|
||||
extern struct wf_jsonrpc_proxy *
|
||||
wf_jsonrpc_proxy_create(
|
||||
struct wf_timer_manager * manager,
|
||||
extern struct wfp_jsonrpc_proxy *
|
||||
wfp_jsonrpc_proxy_create(
|
||||
struct wfp_timer_manager * manager,
|
||||
int timeout,
|
||||
wf_jsonrpc_send_fn * send,
|
||||
wfp_jsonrpc_send_fn * send,
|
||||
void * user_data);
|
||||
|
||||
extern void wf_jsonrpc_proxy_dispose(
|
||||
struct wf_jsonrpc_proxy * proxy);
|
||||
extern void wfp_jsonrpc_proxy_dispose(
|
||||
struct wfp_jsonrpc_proxy * proxy);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \brief Invokes a method.
|
||||
@@ -46,24 +46,24 @@ extern void wf_jsonrpc_proxy_dispose(
|
||||
/// \param param_info types of the param (s = string, i = integer, j = json)
|
||||
/// \param ... params
|
||||
//------------------------------------------------------------------------------
|
||||
extern void wf_jsonrpc_proxy_invoke(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
wf_jsonrpc_proxy_finished_fn * finished,
|
||||
extern void wfp_jsonrpc_proxy_invoke(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
wfp_jsonrpc_proxy_finished_fn * finished,
|
||||
void * user_data,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
...
|
||||
);
|
||||
|
||||
extern void wf_jsonrpc_proxy_notify(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
extern void wfp_jsonrpc_proxy_notify(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
...
|
||||
);
|
||||
|
||||
extern void wf_jsonrpc_proxy_onresult(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
extern void wfp_jsonrpc_proxy_onresult(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
json_t * message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_PROXY_FINISHED_FN_H
|
||||
#define WF_JSONRPC_PROXY_FINISHED_FN_H
|
||||
#ifndef WFP_JSONRPC_PROXY_FINISHED_FN_H
|
||||
#define WFP_JSONRPC_PROXY_FINISHED_FN_H
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
@@ -8,7 +8,7 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef void wf_jsonrpc_proxy_finished_fn(
|
||||
typedef void wfp_jsonrpc_proxy_finished_fn(
|
||||
void * user_data,
|
||||
json_t const * result,
|
||||
json_t const * error);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_PROXY_INTERN_H
|
||||
#define WF_JSONRPC_PROXY_INTERN_H
|
||||
#ifndef WFP_JSONRPC_PROXY_INTERN_H
|
||||
#define WFP_JSONRPC_PROXY_INTERN_H
|
||||
|
||||
#include "webfuse_provider/impl/jsonrpc/proxy.h"
|
||||
#include "webfuse_provider/impl/jsonrpc/proxy_finished_fn.h"
|
||||
@@ -10,47 +10,47 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wf_timer;
|
||||
struct wfp_timer;
|
||||
|
||||
struct wf_jsonrpc_request
|
||||
struct wfp_jsonrpc_request
|
||||
{
|
||||
bool is_pending;
|
||||
wf_jsonrpc_proxy_finished_fn * finished;
|
||||
wfp_jsonrpc_proxy_finished_fn * finished;
|
||||
void * user_data;
|
||||
int id;
|
||||
struct wf_timer * timer;
|
||||
struct wfp_timer * timer;
|
||||
};
|
||||
|
||||
struct wf_jsonrpc_proxy
|
||||
struct wfp_jsonrpc_proxy
|
||||
{
|
||||
struct wf_jsonrpc_request request;
|
||||
struct wfp_jsonrpc_request request;
|
||||
int timeout;
|
||||
wf_jsonrpc_send_fn * send;
|
||||
wfp_jsonrpc_send_fn * send;
|
||||
void * user_data;
|
||||
};
|
||||
|
||||
extern void
|
||||
wf_jsonrpc_proxy_init(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
struct wf_timer_manager * manager,
|
||||
wfp_jsonrpc_proxy_init(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
struct wfp_timer_manager * manager,
|
||||
int timeout,
|
||||
wf_jsonrpc_send_fn * send,
|
||||
wfp_jsonrpc_send_fn * send,
|
||||
void * user_data);
|
||||
|
||||
extern void
|
||||
wf_jsonrpc_proxy_cleanup(
|
||||
struct wf_jsonrpc_proxy * proxy);
|
||||
wfp_jsonrpc_proxy_cleanup(
|
||||
struct wfp_jsonrpc_proxy * proxy);
|
||||
|
||||
extern void wf_jsonrpc_proxy_vinvoke(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
wf_jsonrpc_proxy_finished_fn * finished,
|
||||
extern void wfp_jsonrpc_proxy_vinvoke(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
wfp_jsonrpc_proxy_finished_fn * finished,
|
||||
void * user_data,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
va_list args);
|
||||
|
||||
extern void wf_jsonrpc_proxy_vnotify(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
extern void wfp_jsonrpc_proxy_vnotify(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
va_list args);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "webfuse_provider/impl/jsonrpc/proxy_intern.h"
|
||||
|
||||
void wf_jsonrpc_proxy_invoke(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
wf_jsonrpc_proxy_finished_fn * finished,
|
||||
void wfp_jsonrpc_proxy_invoke(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
wfp_jsonrpc_proxy_finished_fn * finished,
|
||||
void * user_data,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
@@ -10,12 +10,12 @@ void wf_jsonrpc_proxy_invoke(
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, param_info);
|
||||
wf_jsonrpc_proxy_vinvoke(proxy, finished, user_data, method_name, param_info, args);
|
||||
wfp_jsonrpc_proxy_vinvoke(proxy, finished, user_data, method_name, param_info, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
extern void wf_jsonrpc_proxy_notify(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
extern void wfp_jsonrpc_proxy_notify(
|
||||
struct wfp_jsonrpc_proxy * proxy,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
...
|
||||
@@ -23,6 +23,6 @@ extern void wf_jsonrpc_proxy_notify(
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, param_info);
|
||||
wf_jsonrpc_proxy_vnotify(proxy, method_name, param_info, args);
|
||||
wfp_jsonrpc_proxy_vnotify(proxy, method_name, param_info, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
#include "webfuse_provider/impl/jsonrpc/error.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
struct wf_jsonrpc_request
|
||||
struct wfp_jsonrpc_request
|
||||
{
|
||||
int id;
|
||||
wf_jsonrpc_send_fn * send;
|
||||
wfp_jsonrpc_send_fn * send;
|
||||
void * user_data;
|
||||
};
|
||||
|
||||
bool
|
||||
wf_jsonrpc_is_request(
|
||||
wfp_jsonrpc_is_request(
|
||||
json_t * message)
|
||||
{
|
||||
json_t * id = json_object_get(message, "id");
|
||||
@@ -22,13 +22,13 @@ wf_jsonrpc_is_request(
|
||||
}
|
||||
|
||||
|
||||
struct wf_jsonrpc_request *
|
||||
wf_jsonrpc_request_create(
|
||||
struct wfp_jsonrpc_request *
|
||||
wfp_jsonrpc_request_create(
|
||||
int id,
|
||||
wf_jsonrpc_send_fn * send,
|
||||
wfp_jsonrpc_send_fn * send,
|
||||
void * user_data)
|
||||
{
|
||||
struct wf_jsonrpc_request * request = malloc(sizeof(struct wf_jsonrpc_request));
|
||||
struct wfp_jsonrpc_request * request = malloc(sizeof(struct wfp_jsonrpc_request));
|
||||
request->id = id;
|
||||
request->send = send;
|
||||
request->user_data = user_data;
|
||||
@@ -37,23 +37,23 @@ wf_jsonrpc_request_create(
|
||||
}
|
||||
|
||||
void
|
||||
wf_jsonrpc_request_dispose(
|
||||
struct wf_jsonrpc_request * request)
|
||||
wfp_jsonrpc_request_dispose(
|
||||
struct wfp_jsonrpc_request * request)
|
||||
{
|
||||
free(request);
|
||||
}
|
||||
|
||||
void *
|
||||
wf_jsonrpc_request_get_userdata(
|
||||
struct wf_jsonrpc_request * request)
|
||||
wfp_jsonrpc_request_get_userdata(
|
||||
struct wfp_jsonrpc_request * request)
|
||||
{
|
||||
return request->user_data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wf_jsonrpc_respond(
|
||||
struct wf_jsonrpc_request * request,
|
||||
wfp_jsonrpc_respond(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
json_t * result)
|
||||
{
|
||||
json_t * response = json_object();
|
||||
@@ -62,20 +62,20 @@ wf_jsonrpc_respond(
|
||||
|
||||
request->send(response, request->user_data);
|
||||
json_decref(response);
|
||||
wf_jsonrpc_request_dispose(request);
|
||||
wfp_jsonrpc_request_dispose(request);
|
||||
}
|
||||
|
||||
void wf_jsonrpc_respond_error(
|
||||
struct wf_jsonrpc_request * request,
|
||||
void wfp_jsonrpc_respond_error(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
int code,
|
||||
char const * message)
|
||||
{
|
||||
json_t * response = json_object();
|
||||
json_object_set_new(response, "error", wf_jsonrpc_error(code, message));
|
||||
json_object_set_new(response, "error", wfp_jsonrpc_error(code, message));
|
||||
json_object_set_new(response, "id", json_integer(request->id));
|
||||
|
||||
request->send(response, request->user_data);
|
||||
json_decref(response);
|
||||
wf_jsonrpc_request_dispose(request);
|
||||
wfp_jsonrpc_request_dispose(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_REQUEST_H
|
||||
#define WF_JSONRPC_REQUEST_H
|
||||
#ifndef WFP_JSONRPC_REQUEST_H
|
||||
#define WFP_JSONRPC_REQUEST_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdarg.h>
|
||||
@@ -19,29 +19,29 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wf_jsonrpc_request;
|
||||
struct wfp_jsonrpc_request;
|
||||
|
||||
extern bool wf_jsonrpc_is_request(
|
||||
extern bool wfp_jsonrpc_is_request(
|
||||
json_t * message);
|
||||
|
||||
extern struct wf_jsonrpc_request *
|
||||
wf_jsonrpc_request_create(
|
||||
extern struct wfp_jsonrpc_request *
|
||||
wfp_jsonrpc_request_create(
|
||||
int id,
|
||||
wf_jsonrpc_send_fn * send,
|
||||
wfp_jsonrpc_send_fn * send,
|
||||
void * user_data);
|
||||
|
||||
extern void wf_jsonrpc_request_dispose(
|
||||
struct wf_jsonrpc_request * request);
|
||||
extern void wfp_jsonrpc_request_dispose(
|
||||
struct wfp_jsonrpc_request * request);
|
||||
|
||||
extern void * wf_jsonrpc_request_get_userdata(
|
||||
struct wf_jsonrpc_request * request);
|
||||
extern void * wfp_jsonrpc_request_get_userdata(
|
||||
struct wfp_jsonrpc_request * request);
|
||||
|
||||
extern void wf_jsonrpc_respond(
|
||||
struct wf_jsonrpc_request * request,
|
||||
extern void wfp_jsonrpc_respond(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
json_t * result);
|
||||
|
||||
extern void wf_jsonrpc_respond_error(
|
||||
struct wf_jsonrpc_request * request,
|
||||
extern void wfp_jsonrpc_respond_error(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
int code,
|
||||
char const * message);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "webfuse_provider/status.h"
|
||||
|
||||
bool
|
||||
wf_jsonrpc_is_response(
|
||||
wfp_jsonrpc_is_response(
|
||||
json_t * message)
|
||||
{
|
||||
json_t * id = json_object_get(message, "id");
|
||||
@@ -16,8 +16,8 @@ wf_jsonrpc_is_response(
|
||||
|
||||
|
||||
void
|
||||
wf_jsonrpc_response_init(
|
||||
struct wf_jsonrpc_response * result,
|
||||
wfp_jsonrpc_response_init(
|
||||
struct wfp_jsonrpc_response * result,
|
||||
json_t * response)
|
||||
{
|
||||
result->id = -1;
|
||||
@@ -27,7 +27,7 @@ wf_jsonrpc_response_init(
|
||||
json_t * id_holder = json_object_get(response, "id");
|
||||
if (!json_is_integer(id_holder))
|
||||
{
|
||||
result->error = wf_jsonrpc_error(WF_BAD_FORMAT, "invalid format: missing id");
|
||||
result->error = wfp_jsonrpc_error(WFP_BAD_FORMAT, "invalid format: missing id");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,14 +47,14 @@ wf_jsonrpc_response_init(
|
||||
}
|
||||
else
|
||||
{
|
||||
result->error = wf_jsonrpc_error(WF_BAD_FORMAT, "invalid format: invalid error object");
|
||||
result->error = wfp_jsonrpc_error(WFP_BAD_FORMAT, "invalid format: invalid error object");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wf_jsonrpc_response_cleanup(
|
||||
struct wf_jsonrpc_response * response)
|
||||
wfp_jsonrpc_response_cleanup(
|
||||
struct wfp_jsonrpc_response * response)
|
||||
{
|
||||
if (NULL != response->result)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_RESPONSE_H
|
||||
#define WF_JSONRPC_RESPONSE_H
|
||||
#ifndef WFP_JSONRPC_RESPONSE_H
|
||||
#define WFP_JSONRPC_RESPONSE_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
@@ -12,7 +12,7 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern bool wf_jsonrpc_is_response(
|
||||
extern bool wfp_jsonrpc_is_response(
|
||||
json_t * message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_RESPONSE_INTERN_H
|
||||
#define WF_JSONRPC_RESPONSE_INTERN_H
|
||||
#ifndef WFP_JSONRPC_RESPONSE_INTERN_H
|
||||
#define WFP_JSONRPC_RESPONSE_INTERN_H
|
||||
|
||||
#include "webfuse_provider/impl/jsonrpc/response.h"
|
||||
|
||||
@@ -14,19 +14,19 @@ using std::size_t;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wf_jsonrpc_response
|
||||
struct wfp_jsonrpc_response
|
||||
{
|
||||
json_t * result;
|
||||
json_t * error;
|
||||
int id;
|
||||
};
|
||||
|
||||
extern void wf_jsonrpc_response_init(
|
||||
struct wf_jsonrpc_response * response,
|
||||
extern void wfp_jsonrpc_response_init(
|
||||
struct wfp_jsonrpc_response * response,
|
||||
json_t * message);
|
||||
|
||||
extern void wf_jsonrpc_response_cleanup(
|
||||
struct wf_jsonrpc_response * response);
|
||||
extern void wfp_jsonrpc_response_cleanup(
|
||||
struct wfp_jsonrpc_response * response);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_SEND_FN_H
|
||||
#define WF_JSONRPC_SEND_FN_H
|
||||
#ifndef WFP_JSONRPC_SEND_FN_H
|
||||
#define WFP_JSONRPC_SEND_FN_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
@@ -12,7 +12,7 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef bool wf_jsonrpc_send_fn(
|
||||
typedef bool wfp_jsonrpc_send_fn(
|
||||
json_t * request,
|
||||
void * user_data);
|
||||
|
||||
|
||||
@@ -7,89 +7,89 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct wf_jsonrpc_server
|
||||
struct wfp_jsonrpc_server
|
||||
{
|
||||
struct wf_jsonrpc_method * methods;
|
||||
struct wfp_jsonrpc_method * methods;
|
||||
};
|
||||
|
||||
static void
|
||||
wf_jsonrpc_server_init(
|
||||
struct wf_jsonrpc_server * server);
|
||||
wfp_jsonrpc_server_init(
|
||||
struct wfp_jsonrpc_server * server);
|
||||
|
||||
static void
|
||||
wf_jsonrpc_server_cleanup(
|
||||
struct wf_jsonrpc_server * server);
|
||||
wfp_jsonrpc_server_cleanup(
|
||||
struct wfp_jsonrpc_server * server);
|
||||
|
||||
struct wf_jsonrpc_server *
|
||||
wf_jsonrpc_server_create(void)
|
||||
struct wfp_jsonrpc_server *
|
||||
wfp_jsonrpc_server_create(void)
|
||||
{
|
||||
struct wf_jsonrpc_server * server = malloc(sizeof(struct wf_jsonrpc_server));
|
||||
wf_jsonrpc_server_init(server);
|
||||
struct wfp_jsonrpc_server * server = malloc(sizeof(struct wfp_jsonrpc_server));
|
||||
wfp_jsonrpc_server_init(server);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
void
|
||||
wf_jsonrpc_server_dispose(
|
||||
struct wf_jsonrpc_server * server)
|
||||
wfp_jsonrpc_server_dispose(
|
||||
struct wfp_jsonrpc_server * server)
|
||||
{
|
||||
wf_jsonrpc_server_cleanup(server);
|
||||
wfp_jsonrpc_server_cleanup(server);
|
||||
free(server);
|
||||
}
|
||||
|
||||
static void wf_jsonrpc_server_init(
|
||||
struct wf_jsonrpc_server * server)
|
||||
static void wfp_jsonrpc_server_init(
|
||||
struct wfp_jsonrpc_server * server)
|
||||
{
|
||||
server->methods = NULL;
|
||||
}
|
||||
|
||||
static void wf_jsonrpc_server_cleanup(
|
||||
struct wf_jsonrpc_server * server)
|
||||
static void wfp_jsonrpc_server_cleanup(
|
||||
struct wfp_jsonrpc_server * server)
|
||||
{
|
||||
struct wf_jsonrpc_method * current = server->methods;
|
||||
struct wfp_jsonrpc_method * current = server->methods;
|
||||
while (NULL != current)
|
||||
{
|
||||
struct wf_jsonrpc_method * next = current->next;
|
||||
wf_jsonrpc_method_dispose(current);
|
||||
struct wfp_jsonrpc_method * next = current->next;
|
||||
wfp_jsonrpc_method_dispose(current);
|
||||
current = next;
|
||||
}
|
||||
server->methods = NULL;
|
||||
}
|
||||
|
||||
void wf_jsonrpc_server_add(
|
||||
struct wf_jsonrpc_server * server,
|
||||
void wfp_jsonrpc_server_add(
|
||||
struct wfp_jsonrpc_server * server,
|
||||
char const * method_name,
|
||||
wf_jsonrpc_method_invoke_fn * invoke,
|
||||
wfp_jsonrpc_method_invoke_fn * invoke,
|
||||
void * user_data)
|
||||
{
|
||||
struct wf_jsonrpc_method * method = wf_jsonrpc_method_create(method_name, invoke, user_data);
|
||||
struct wfp_jsonrpc_method * method = wfp_jsonrpc_method_create(method_name, invoke, user_data);
|
||||
method->next = server->methods;
|
||||
server->methods = method;
|
||||
}
|
||||
|
||||
static void wf_jsonrpc_server_invalid_method_invoke(
|
||||
struct wf_jsonrpc_request * request,
|
||||
char const * WF_UNUSED_PARAM(method_name),
|
||||
json_t * WF_UNUSED_PARAM(params),
|
||||
void * WF_UNUSED_PARAM(user_data))
|
||||
static void wfp_jsonrpc_server_invalid_method_invoke(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
char const * WFP_UNUSED_PARAM(method_name),
|
||||
json_t * WFP_UNUSED_PARAM(params),
|
||||
void * WFP_UNUSED_PARAM(user_data))
|
||||
{
|
||||
wf_jsonrpc_respond_error(request, WF_BAD_NOTIMPLEMENTED, "not implemented");
|
||||
wfp_jsonrpc_respond_error(request, WFP_BAD_NOTIMPLEMENTED, "not implemented");
|
||||
}
|
||||
|
||||
static struct wf_jsonrpc_method const wf_jsonrpc_server_invalid_method =
|
||||
static struct wfp_jsonrpc_method const wfp_jsonrpc_server_invalid_method =
|
||||
{
|
||||
.next = NULL,
|
||||
.name = "<invalid>",
|
||||
.invoke = &wf_jsonrpc_server_invalid_method_invoke,
|
||||
.invoke = &wfp_jsonrpc_server_invalid_method_invoke,
|
||||
.user_data = NULL
|
||||
};
|
||||
|
||||
static struct wf_jsonrpc_method const *
|
||||
wf_jsonrpc_server_get_method(
|
||||
struct wf_jsonrpc_server * server,
|
||||
static struct wfp_jsonrpc_method const *
|
||||
wfp_jsonrpc_server_get_method(
|
||||
struct wfp_jsonrpc_server * server,
|
||||
char const * method_name)
|
||||
{
|
||||
struct wf_jsonrpc_method const * current = server->methods;
|
||||
struct wfp_jsonrpc_method const * current = server->methods;
|
||||
while (NULL != current)
|
||||
{
|
||||
if (0 == strcmp(method_name, current->name))
|
||||
@@ -100,13 +100,13 @@ wf_jsonrpc_server_get_method(
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
return &wf_jsonrpc_server_invalid_method;
|
||||
return &wfp_jsonrpc_server_invalid_method;
|
||||
}
|
||||
|
||||
void wf_jsonrpc_server_process(
|
||||
struct wf_jsonrpc_server * server,
|
||||
void wfp_jsonrpc_server_process(
|
||||
struct wfp_jsonrpc_server * server,
|
||||
json_t * request_data,
|
||||
wf_jsonrpc_send_fn * send,
|
||||
wfp_jsonrpc_send_fn * send,
|
||||
void * user_data)
|
||||
{
|
||||
json_t * method_holder = json_object_get(request_data, "method");
|
||||
@@ -119,8 +119,8 @@ void wf_jsonrpc_server_process(
|
||||
{
|
||||
char const * method_name = json_string_value(method_holder);
|
||||
int id = json_integer_value(id_holder);
|
||||
struct wf_jsonrpc_request * request = wf_jsonrpc_request_create(id, send, user_data);
|
||||
struct wf_jsonrpc_method const * method = wf_jsonrpc_server_get_method(server, method_name);
|
||||
struct wfp_jsonrpc_request * request = wfp_jsonrpc_request_create(id, send, user_data);
|
||||
struct wfp_jsonrpc_method const * method = wfp_jsonrpc_server_get_method(server, method_name);
|
||||
|
||||
method->invoke(request, method_name, params, method->user_data);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_JSONRPC_SERVER_H
|
||||
#define WF_JSONRPC_SERVER_H
|
||||
#ifndef WFP_JSONRPC_SERVER_H
|
||||
#define WFP_JSONRPC_SERVER_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdarg.h>
|
||||
@@ -17,25 +17,25 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wf_jsonrpc_server;
|
||||
struct wfp_jsonrpc_server;
|
||||
|
||||
extern struct wf_jsonrpc_server *
|
||||
wf_jsonrpc_server_create(void);
|
||||
extern struct wfp_jsonrpc_server *
|
||||
wfp_jsonrpc_server_create(void);
|
||||
|
||||
extern void
|
||||
wf_jsonrpc_server_dispose(
|
||||
struct wf_jsonrpc_server * server);
|
||||
wfp_jsonrpc_server_dispose(
|
||||
struct wfp_jsonrpc_server * server);
|
||||
|
||||
extern void wf_jsonrpc_server_add(
|
||||
struct wf_jsonrpc_server * server,
|
||||
extern void wfp_jsonrpc_server_add(
|
||||
struct wfp_jsonrpc_server * server,
|
||||
char const * method_name,
|
||||
wf_jsonrpc_method_invoke_fn * invoke,
|
||||
wfp_jsonrpc_method_invoke_fn * invoke,
|
||||
void * user_data);
|
||||
|
||||
extern void wf_jsonrpc_server_process(
|
||||
struct wf_jsonrpc_server * server,
|
||||
extern void wfp_jsonrpc_server_process(
|
||||
struct wfp_jsonrpc_server * server,
|
||||
json_t * request,
|
||||
wf_jsonrpc_send_fn * send,
|
||||
wfp_jsonrpc_send_fn * send,
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user