1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

chore: prefixed jsonrpc by wf_

This commit is contained in:
Falk Werner
2020-03-01 16:55:58 +01:00
parent 8a40919296
commit 1a29b44ad6
69 changed files with 1047 additions and 1045 deletions

View File

@@ -0,0 +1,14 @@
#ifndef WF_JSONRPC_H
#define WF_JSONRPC_H
#include <wf/jsonrpc/api.h>
#include <wf/jsonrpc/method_invoke_fn.h>
#include <wf/jsonrpc/proxy.h>
#include <wf/jsonrpc/proxy_finished_fn.h>
#include <wf/jsonrpc/request.h>
#include <wf/jsonrpc/response.h>
#include <wf/jsonrpc/send_fn.h>
#include <wf/jsonrpc/server.h>
#include <wf/jsonrpc/status.h>
#endif

View File

@@ -0,0 +1,8 @@
#ifndef WF_JSONRPC_API_H
#define WF_JSONRPC_API_H
#ifndef WF_JSONRPC_API
#define WF_JSONRPC_API
#endif
#endif

View File

@@ -0,0 +1,26 @@
#ifndef WF_JSONRPC_METHOD_INVOKE_FN_H
#define WF_JSONRPC_METHOD_INVOKE_FN_H
#include <wf/jsonrpc/api.h>
#include <jansson.h>
#ifdef __cplusplus
extern "C"
{
#endif
struct wf_jsonrpc_request;
typedef void wf_jsonrpc_method_invoke_fn(
struct wf_jsonrpc_request * request,
char const * method_name,
json_t * params,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,75 @@
#ifndef WF_JSONRPC_PROXY_H
#define WF_JSONRPC_PROXY_H
#ifndef __cplusplus
#include <stdarg.h>
#include <stddef.h>
#include <stdbool.h>
#else
#include <cstdarg>
#include <cstddef>
using std::size_t;
#endif
#include <jansson.h>
#include <wf/jsonrpc/api.h>
#include <wf/jsonrpc/send_fn.h>
#include <wf/jsonrpc/proxy_finished_fn.h>
#ifdef __cplusplus
extern "C" {
#endif
struct wf_jsonrpc_proxy;
struct wf_timer_manager;
extern WF_JSONRPC_API struct wf_jsonrpc_proxy *
wf_jsonrpc_proxy_create(
struct wf_timer_manager * manager,
int timeout,
wf_jsonrpc_send_fn * send,
void * user_data);
extern WF_JSONRPC_API void wf_jsonrpc_proxy_dispose(
struct wf_jsonrpc_proxy * proxy);
//------------------------------------------------------------------------------
/// \brief Invokes a method.
///
/// Creates a method an sends it using the send function.
/// Proxy keeps track of method invokation. If no response is returned within
/// timeout, an error is propagated.
///
/// \param proxy pointer to proxy instance
/// \param finished function which is called exactly once, either on success or
/// on failure.
/// \param method_name name of the method to invoke
/// \param param_info types of the param (s = string, i = integer, j = json)
/// \param ... params
//------------------------------------------------------------------------------
extern WF_JSONRPC_API void wf_jsonrpc_proxy_invoke(
struct wf_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished,
void * user_data,
char const * method_name,
char const * param_info,
...
);
extern WF_JSONRPC_API void wf_jsonrpc_proxy_notify(
struct wf_jsonrpc_proxy * proxy,
char const * method_name,
char const * param_info,
...
);
extern WF_JSONRPC_API void wf_jsonrpc_proxy_onresult(
struct wf_jsonrpc_proxy * proxy,
json_t * message);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,20 @@
#ifndef WF_JSONRPC_PROXY_FINISHED_FN_H
#define WF_JSONRPC_PROXY_FINISHED_FN_H
#include <jansson.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef void wf_jsonrpc_proxy_finished_fn(
void * user_data,
json_t const * result,
json_t const * error);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,54 @@
#ifndef WF_JSONRPC_REQUEST_H
#define WF_JSONRPC_REQUEST_H
#ifndef __cplusplus
#include <stdarg.h>
#include <stddef.h>
#include <stdbool.h>
#else
#include <cstdarg>
#include <cstddef>
using std::size_t;
#endif
#include <jansson.h>
#include <wf/jsonrpc/api.h>
#include "wf/jsonrpc/send_fn.h"
#ifdef __cplusplus
extern "C"
{
#endif
struct wf_jsonrpc_request;
extern WF_JSONRPC_API bool wf_jsonrpc_is_request(
json_t * message);
extern WF_JSONRPC_API struct wf_jsonrpc_request *
wf_jsonrpc_request_create(
int id,
wf_jsonrpc_send_fn * send,
void * user_data);
extern WF_JSONRPC_API void wf_jsonrpc_request_dispose(
struct wf_jsonrpc_request * request);
extern WF_JSONRPC_API void * wf_jsonrpc_request_get_userdata(
struct wf_jsonrpc_request * request);
extern WF_JSONRPC_API void wf_jsonrpc_respond(
struct wf_jsonrpc_request * request,
json_t * result);
extern WF_JSONRPC_API void wf_jsonrpc_respond_error(
struct wf_jsonrpc_request * request,
int code,
char const * message);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,23 @@
#ifndef WF_JSONRPC_RESPONSE_H
#define WF_JSONRPC_RESPONSE_H
#ifndef __cplusplus
#include <stdbool.h>
#endif
#include <jansson.h>
#include <wf/jsonrpc/api.h>
#ifdef __cplusplus
extern "C"
{
#endif
extern WF_JSONRPC_API bool wf_jsonrpc_is_response(
json_t * message);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,24 @@
#ifndef WF_JSONRPC_SEND_FN_H
#define WF_JSONRPC_SEND_FN_H
#ifndef __cplusplus
#include <stdbool.h>
#endif
#include <jansson.h>
#include <wf/jsonrpc/api.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef bool wf_jsonrpc_send_fn(
json_t * request,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,46 @@
#ifndef WF_JSONRPC_SERVER_H
#define WF_JSONRPC_SERVER_H
#ifndef __cplusplus
#include <stdarg.h>
#include <stdbool.h>
#else
#include <cstdarg>
#endif
#include <jansson.h>
#include <wf/jsonrpc/api.h>
#include <wf/jsonrpc/send_fn.h>
#include <wf/jsonrpc/method_invoke_fn.h>
#ifdef __cplusplus
extern "C"
{
#endif
struct wf_jsonrpc_server;
extern WF_JSONRPC_API struct wf_jsonrpc_server *
wf_jsonrpc_server_create(void);
extern WF_JSONRPC_API void
wf_jsonrpc_server_dispose(
struct wf_jsonrpc_server * server);
extern WF_JSONRPC_API void wf_jsonrpc_server_add(
struct wf_jsonrpc_server * server,
char const * method_name,
wf_jsonrpc_method_invoke_fn * invoke,
void * user_data);
extern WF_JSONRPC_API void wf_jsonrpc_server_process(
struct wf_jsonrpc_server * server,
json_t * request,
wf_jsonrpc_send_fn * send,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,11 @@
#ifndef WF_JSONRPC_STATUS_H
#define WF_JSONRPC_STATUS_H
#define WF_JSONRPC_GOOD 0
#define WF_JSONRPC_BAD -1
#define WF_JSONRPC_BAD_NOTIMPLEMENTED -2
#define WF_JSONRPC_BAD_TIMEOUT -3
#define WF_JSONRPC_BAD_BUSY -4
#define WF_JSONRPC_BAD_FORMAT -5
#endif