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

@@ -4,7 +4,7 @@
#include <errno.h>
#include <jansson.h>
#include "jsonrpc/proxy.h"
#include "wf/jsonrpc/proxy.h"
#include "webfuse/core/util.h"
void wf_impl_operation_close(
@@ -13,12 +13,12 @@ void wf_impl_operation_close(
struct fuse_file_info * file_info)
{
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
struct jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
struct wf_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
if (NULL != rpc)
{
int handle = (int) (file_info->fh & INT_MAX);
jsonrpc_proxy_notify(rpc, "close", "siii", user_data->name, inode, handle, file_info->flags);
wf_jsonrpc_proxy_notify(rpc, "close", "siii", user_data->name, inode, handle, file_info->flags);
}
fuse_reply_err(request, 0);

View File

@@ -7,7 +7,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include "jsonrpc/proxy.h"
#include "wf/jsonrpc/proxy.h"
#include "webfuse/core/json_util.h"
#include "webfuse/core/util.h"
@@ -83,7 +83,7 @@ void wf_impl_operation_getattr (
{
struct fuse_ctx const * context = fuse_req_ctx(request);
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
struct jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
struct wf_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
if (NULL != rpc)
{
@@ -94,7 +94,7 @@ void wf_impl_operation_getattr (
getattr_context->gid = context->gid;
getattr_context->timeout = user_data->timeout;
jsonrpc_proxy_invoke(rpc, &wf_impl_operation_getattr_finished, getattr_context, "getattr", "si", user_data->name, inode);
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_getattr_finished, getattr_context, "getattr", "si", user_data->name, inode);
}
else
{

View File

@@ -10,7 +10,7 @@
#include <stdlib.h>
#include "jsonrpc/proxy.h"
#include "wf/jsonrpc/proxy.h"
#include "webfuse/core/json_util.h"
#include "webfuse/core/util.h"
@@ -92,7 +92,7 @@ void wf_impl_operation_lookup (
{
struct fuse_ctx const * context = fuse_req_ctx(request);
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
struct jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
struct wf_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
if (NULL != rpc)
{
@@ -102,7 +102,7 @@ void wf_impl_operation_lookup (
lookup_context->gid = context->gid;
lookup_context->timeout = user_data->timeout;
jsonrpc_proxy_invoke(rpc, &wf_impl_operation_lookup_finished, lookup_context, "lookup", "sis", user_data->name, (int) (parent & INT_MAX), name);
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_lookup_finished, lookup_context, "lookup", "sis", user_data->name, (int) (parent & INT_MAX), name);
}
else
{

View File

@@ -4,7 +4,7 @@
#include <errno.h>
#include <jansson.h>
#include "jsonrpc/proxy.h"
#include "wf/jsonrpc/proxy.h"
#include "webfuse/core/util.h"
#include "webfuse/core/status.h"
#include "webfuse/core/json_util.h"
@@ -49,11 +49,11 @@ void wf_impl_operation_open(
struct fuse_file_info * file_info)
{
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
struct jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
struct wf_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
if (NULL != rpc)
{
jsonrpc_proxy_invoke(rpc, &wf_impl_operation_open_finished, request, "open", "sii", user_data->name, inode, file_info->flags);
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_open_finished, request, "open", "sii", user_data->name, inode, file_info->flags);
}
else
{

View File

@@ -5,7 +5,7 @@
#include <limits.h>
#include <jansson.h>
#include "jsonrpc/proxy.h"
#include "wf/jsonrpc/proxy.h"
#include "webfuse/core/base64.h"
#include "webfuse/core/json_util.h"
@@ -92,13 +92,13 @@ void wf_impl_operation_read(
struct fuse_file_info * file_info)
{
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
struct jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
struct wf_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
if (NULL != rpc)
{
int const length = (size <= WF_MAX_READ_LENGTH) ? (int) size : WF_MAX_READ_LENGTH;
int handle = (file_info->fh & INT_MAX);
jsonrpc_proxy_invoke(rpc, &wf_impl_operation_read_finished, request, "read", "siiii", user_data->name, (int) inode, handle, (int) offset, length);
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_read_finished, request, "read", "siiii", user_data->name, (int) inode, handle, (int) offset, length);
}
else
{

View File

@@ -8,7 +8,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include "jsonrpc/proxy.h"
#include "wf/jsonrpc/proxy.h"
#include "webfuse/core/util.h"
#include "webfuse/core/json_util.h"
@@ -139,16 +139,16 @@ void wf_impl_operation_readdir (
struct fuse_file_info * WF_UNUSED_PARAM(file_info))
{
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
struct jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
struct wf_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data);
if (NULL != rpc)
{
struct wf_impl_operation_readdir_context * readdir_context = malloc(sizeof(struct wf_impl_operation_readdir_context));
readdir_context->request = request;
readdir_context->size = size;
readdir_context->offset = offset;
struct wf_impl_operation_readdir_context * readdir_context = malloc(sizeof(struct wf_impl_operation_readdir_context));
readdir_context->request = request;
readdir_context->size = size;
readdir_context->offset = offset;
jsonrpc_proxy_invoke(rpc, &wf_impl_operation_readdir_finished, readdir_context, "readdir", "si", user_data->name, inode);
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_readdir_finished, readdir_context, "readdir", "si", user_data->name, inode);
}
else
{

View File

@@ -3,10 +3,10 @@
#include "webfuse/adapter/impl/session.h"
#include <stddef.h>
struct jsonrpc_proxy * wf_impl_operations_context_get_proxy(
struct wf_jsonrpc_proxy * wf_impl_operations_context_get_proxy(
struct wf_impl_operations_context * context)
{
struct jsonrpc_proxy * proxy = NULL;
struct wf_jsonrpc_proxy * proxy = NULL;
struct wf_impl_session * session = context->session;
if (NULL != session)

View File

@@ -8,7 +8,7 @@ extern "C" {
#endif
struct wf_impl_session;
struct jsonrpc_proxy;
struct wf_jsonrpc_proxy;
struct wf_impl_operations_context
{
@@ -49,7 +49,7 @@ extern void wf_impl_operation_read(
fuse_ino_t ino, size_t size, off_t off,
struct fuse_file_info *fi);
extern struct jsonrpc_proxy * wf_impl_operations_context_get_proxy(
extern struct wf_jsonrpc_proxy * wf_impl_operations_context_get_proxy(
struct wf_impl_operations_context * context);
#ifdef __cplusplus

View File

@@ -9,10 +9,10 @@
#include "webfuse/core/protocol_names.h"
#include "webfuse/adapter/impl/credentials.h"
#include "jsonrpc/request.h"
#include "webfuse/adapter/impl/uuid_mountpoint_factory.h"
#include "webfuse/core/status_intern.h"
#include "wf/jsonrpc/request.h"
#include "wf/timer/manager.h"
#include "wf/timer/timer.h"
@@ -133,7 +133,7 @@ void wf_impl_server_protocol_init_lws(
}
static void wf_impl_server_protocol_authenticate(
struct jsonrpc_request * request,
struct wf_jsonrpc_request * request,
char const * WF_UNUSED_PARAM(method_name),
json_t * params,
void * WF_UNUSED_PARAM(user_data))
@@ -149,7 +149,7 @@ static void wf_impl_server_protocol_authenticate(
struct wf_credentials creds;
wf_impl_credentials_init(&creds, type, creds_holder);
struct wf_impl_session * session = jsonrpc_request_get_userdata(request);
struct wf_impl_session * session = wf_jsonrpc_request_get_userdata(request);
result = wf_impl_session_authenticate(session, &creds);
wf_impl_credentials_cleanup(&creds);
@@ -159,11 +159,11 @@ static void wf_impl_server_protocol_authenticate(
if (result)
{
json_t * result = json_object();
jsonrpc_respond(request, result);
wf_jsonrpc_respond(request, result);
}
else
{
jsonrpc_respond_error(request, WF_BAD_ACCESS_DENIED, wf_status_tostring(WF_BAD_ACCESS_DENIED));
wf_jsonrpc_respond_error(request, WF_BAD_ACCESS_DENIED, wf_status_tostring(WF_BAD_ACCESS_DENIED));
}
}
@@ -183,12 +183,12 @@ static bool wf_impl_server_protocol_check_name(char const * value)
}
static void wf_impl_server_protocol_add_filesystem(
struct jsonrpc_request * request,
struct wf_jsonrpc_request * request,
char const * WF_UNUSED_PARAM(method_name),
json_t * params,
void * WF_UNUSED_PARAM(user_data))
{
struct wf_impl_session * session = jsonrpc_request_get_userdata(request);
struct wf_impl_session * session = wf_jsonrpc_request_get_userdata(request);
wf_status status = (session->is_authenticated) ? WF_GOOD : WF_BAD_ACCESS_DENIED;
char const * name = NULL;
@@ -222,11 +222,11 @@ static void wf_impl_server_protocol_add_filesystem(
{
json_t * result = json_object();
json_object_set_new(result, "id", json_string(name));
jsonrpc_respond(request, result);
wf_jsonrpc_respond(request, result);
}
else
{
jsonrpc_respond_error(request, status, wf_status_tostring(status));
wf_jsonrpc_respond_error(request, status, wf_status_tostring(status));
}
@@ -244,9 +244,9 @@ void wf_impl_server_protocol_init(
wf_impl_session_manager_init(&protocol->session_manager);
wf_impl_authenticators_init(&protocol->authenticators);
protocol->server = jsonrpc_server_create();
jsonrpc_server_add(protocol->server, "authenticate", &wf_impl_server_protocol_authenticate, protocol);
jsonrpc_server_add(protocol->server, "add_filesystem", &wf_impl_server_protocol_add_filesystem, protocol);
protocol->server = wf_jsonrpc_server_create();
wf_jsonrpc_server_add(protocol->server, "authenticate", &wf_impl_server_protocol_authenticate, protocol);
wf_jsonrpc_server_add(protocol->server, "add_filesystem", &wf_impl_server_protocol_add_filesystem, protocol);
}
void wf_impl_server_protocol_cleanup(
@@ -254,7 +254,7 @@ void wf_impl_server_protocol_cleanup(
{
protocol->is_operational = false;
jsonrpc_server_dispose(protocol->server);
wf_jsonrpc_server_dispose(protocol->server);
wf_timer_manager_dispose(protocol->timer_manager);
wf_impl_authenticators_cleanup(&protocol->authenticators);
wf_impl_session_manager_cleanup(&protocol->session_manager);

View File

@@ -1,11 +1,11 @@
#ifndef WF_ADAPTER_IMPL_SERVER_PROTOCOL_H
#define WF_ADAPTER_IMPL_SERVER_PROTOCOL_H
#include "jsonrpc/proxy.h"
#include "webfuse/adapter/impl/authenticators.h"
#include "webfuse/adapter/impl/mountpoint_factory.h"
#include "webfuse/adapter/impl/session_manager.h"
#include "jsonrpc/server.h"
#include "wf/jsonrpc/proxy.h"
#include "wf/jsonrpc/server.h"
#ifndef __cplusplus
#include <stdbool.h>
@@ -24,7 +24,7 @@ struct wf_server_protocol
struct wf_impl_authenticators authenticators;
struct wf_impl_mountpoint_factory mountpoint_factory;
struct wf_impl_session_manager session_manager;
struct jsonrpc_server * server;
struct wf_jsonrpc_server * server;
struct wf_timer_manager * timer_manager;
bool is_operational;
};

View File

@@ -2,15 +2,16 @@
#include "webfuse/adapter/impl/authenticators.h"
#include "webfuse/core/message_queue.h"
#include "webfuse/core/message.h"
#include "jsonrpc/proxy.h"
#include "jsonrpc/request.h"
#include "jsonrpc/response.h"
#include "webfuse/adapter/impl/mountpoint_factory.h"
#include "webfuse/adapter/impl/mountpoint.h"
#include "webfuse/core/container_of.h"
#include "webfuse/core/util.h"
#include "wf/jsonrpc/proxy.h"
#include "wf/jsonrpc/request.h"
#include "wf/jsonrpc/response.h"
#include <libwebsockets.h>
#include <stddef.h>
#include <stdlib.h>
@@ -24,7 +25,7 @@ static bool wf_impl_session_send(
struct wf_impl_session * session = user_data;
struct wf_message * message = wf_message_create(request);
bool result = (session->is_authenticated || jsonrpc_is_response(request)) && (NULL != session->wsi);
bool result = (session->is_authenticated || wf_jsonrpc_is_response(request)) && (NULL != session->wsi);
if (result)
{
@@ -45,7 +46,7 @@ struct wf_impl_session * wf_impl_session_create(
struct lws * wsi,
struct wf_impl_authenticators * authenticators,
struct wf_timer_manager * timer_manager,
struct jsonrpc_server * server,
struct wf_jsonrpc_server * server,
struct wf_impl_mountpoint_factory * mountpoint_factory)
{
@@ -59,7 +60,7 @@ struct wf_impl_session * wf_impl_session_create(
session->authenticators = authenticators;
session->server = server;
session->mountpoint_factory = mountpoint_factory;
session->rpc = jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &wf_impl_session_send, session);
session->rpc = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &wf_impl_session_send, session);
wf_slist_init(&session->messages);
}
@@ -83,7 +84,7 @@ static void wf_impl_session_dispose_filesystems(
void wf_impl_session_dispose(
struct wf_impl_session * session)
{
jsonrpc_proxy_dispose(session->rpc);
wf_jsonrpc_proxy_dispose(session->rpc);
wf_message_queue_cleanup(&session->messages);
wf_impl_session_dispose_filesystems(&session->filesystems);
@@ -154,13 +155,13 @@ void wf_impl_session_receive(
json_t * message = json_loadb(data, length, 0, NULL);
if (NULL != message)
{
if (jsonrpc_is_response(message))
if (wf_jsonrpc_is_response(message))
{
jsonrpc_proxy_onresult(session->rpc, message);
wf_jsonrpc_proxy_onresult(session->rpc, message);
}
else if (jsonrpc_is_request(message))
else if (wf_jsonrpc_is_request(message))
{
jsonrpc_server_process(session->server, message, &wf_impl_session_send, session);
wf_jsonrpc_server_process(session->server, message, &wf_impl_session_send, session);
}
json_decref(message);

View File

@@ -10,11 +10,12 @@ using std::size_t;
#endif
#include "webfuse/core/message_queue.h"
#include "jsonrpc/proxy.h"
#include "jsonrpc/server.h"
#include "webfuse/adapter/impl/filesystem.h"
#include "webfuse/core/slist.h"
#include "wf/jsonrpc/proxy.h"
#include "wf/jsonrpc/server.h"
#ifdef __cplusplus
extern "C"
{
@@ -25,7 +26,6 @@ struct wf_message;
struct wf_credentials;
struct wf_impl_authenticators;
struct wf_impl_mountpoint_factory;
struct timer_manager;
struct wf_impl_session
{
@@ -35,8 +35,8 @@ struct wf_impl_session
struct wf_slist messages;
struct wf_impl_authenticators * authenticators;
struct wf_impl_mountpoint_factory * mountpoint_factory;
struct jsonrpc_server * server;
struct jsonrpc_proxy * rpc;
struct wf_jsonrpc_server * server;
struct wf_jsonrpc_proxy * rpc;
struct wf_slist filesystems;
};
@@ -44,7 +44,7 @@ extern struct wf_impl_session * wf_impl_session_create(
struct lws * wsi,
struct wf_impl_authenticators * authenticators,
struct wf_timer_manager * timer_manager,
struct jsonrpc_server * server,
struct wf_jsonrpc_server * server,
struct wf_impl_mountpoint_factory * mountpoint_factory);
extern void wf_impl_session_dispose(

View File

@@ -29,7 +29,7 @@ struct wf_impl_session * wf_impl_session_manager_add(
struct wf_impl_authenticators * authenticators,
struct wf_impl_mountpoint_factory * mountpoint_factory,
struct wf_timer_manager * timer_manager,
struct jsonrpc_server * server)
struct wf_jsonrpc_server * server)
{
struct wf_impl_session * session = wf_impl_session_create(
wsi, authenticators, timer_manager, server, mountpoint_factory);

View File

@@ -16,7 +16,7 @@ extern "C"
struct lws;
struct wf_timer_manager;
struct jsonrpc_server;
struct wf_jsonrpc_server;
struct wf_impl_session_manager
{
@@ -35,7 +35,7 @@ extern struct wf_impl_session * wf_impl_session_manager_add(
struct wf_impl_authenticators * authenticators,
struct wf_impl_mountpoint_factory * mountpoint_factory,
struct wf_timer_manager * timer_manager,
struct jsonrpc_server * server);
struct wf_jsonrpc_server * server);
extern struct wf_impl_session * wf_impl_session_manager_get(
struct wf_impl_session_manager * manager,