mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
refactors provider client api (introduces client_config)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "wsfs/provider/provider.h"
|
||||
#include "wsfs/provider/client_protocol_intern.h"
|
||||
#include "wsfs/provider/client_config_intern.h"
|
||||
#include "wsfs/provider/url.h"
|
||||
|
||||
#define WSFSP_PROTOCOL ("fs")
|
||||
@@ -18,17 +19,17 @@
|
||||
struct wsfsp_client
|
||||
{
|
||||
volatile bool is_running;
|
||||
struct wsfsp_provider provider;
|
||||
struct wsfsp_client_protocol protocol;
|
||||
struct lws_context_creation_info info;
|
||||
struct lws_protocols protocols[WSFSP_CLIENT_PROTOCOL_COUNT];
|
||||
struct lws_context * context;
|
||||
char * key_path;
|
||||
char * cert_path;
|
||||
};
|
||||
|
||||
|
||||
struct wsfsp_client * wsfsp_client_create(
|
||||
struct wsfsp_provider * provider,
|
||||
void * user_data)
|
||||
struct wsfsp_client_config * config)
|
||||
{
|
||||
lws_set_log_level(WSFSP_DISABLE_LWS_LOG, NULL);
|
||||
|
||||
@@ -36,7 +37,7 @@ struct wsfsp_client * wsfsp_client_create(
|
||||
if (NULL != client)
|
||||
{
|
||||
client->is_running = true;
|
||||
wsfsp_client_protocol_init(&client->protocol, provider, user_data);
|
||||
wsfsp_client_protocol_init(&client->protocol, &config->provider, config->user_data);
|
||||
|
||||
memset(client->protocols, 0, sizeof(struct lws_protocols) * WSFSP_CLIENT_PROTOCOL_COUNT);
|
||||
client->protocols[0].name = "fs";
|
||||
@@ -48,6 +49,11 @@ struct wsfsp_client * wsfsp_client_create(
|
||||
client->info.uid = -1;
|
||||
client->info.gid = -1;
|
||||
|
||||
if ((NULL != config->cert_path) && (NULL != config->key_path))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
client->context = lws_create_context(&client->info);
|
||||
}
|
||||
|
||||
@@ -96,17 +102,6 @@ void wsfsp_client_disconnect(
|
||||
// ToDo: implement me
|
||||
}
|
||||
|
||||
void wsfsp_client_settimeout(
|
||||
struct wsfsp_client * client,
|
||||
unsigned int timepoint)
|
||||
{
|
||||
(void) client;
|
||||
(void) timepoint;
|
||||
|
||||
// ToDo: implement me
|
||||
}
|
||||
|
||||
|
||||
void wsfsp_client_run(
|
||||
struct wsfsp_client * client)
|
||||
{
|
||||
|
||||
@@ -7,14 +7,7 @@
|
||||
#include <jansson.h>
|
||||
|
||||
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
#include "wsfs/provider/operation/lookup_intern.h"
|
||||
#include "wsfs/provider/operation/getattr_intern.h"
|
||||
#include "wsfs/provider/operation/readdir_intern.h"
|
||||
#include "wsfs/provider/operation/open_intern.h"
|
||||
#include "wsfs/provider/operation/close_intern.h"
|
||||
#include "wsfs/provider/operation/read_intern.h"
|
||||
|
||||
#include "wsfs/provider/provider.h"
|
||||
#include "wsfs/util.h"
|
||||
#include "wsfs/message.h"
|
||||
|
||||
@@ -117,15 +110,7 @@ void wsfsp_client_protocol_init(
|
||||
protocol->request.user_data = protocol;
|
||||
|
||||
protocol->user_data = user_data;
|
||||
protocol->provider.lookup = (NULL != provider->lookup) ? provider->lookup : &wsfsp_lookup_default;
|
||||
protocol->provider.getattr = (NULL != provider->getattr) ? provider->getattr : &wsfsp_getattr_default;
|
||||
protocol->provider.readdir = (NULL != provider->readdir) ? provider->readdir : &wsfsp_readdir_default;
|
||||
protocol->provider.open = (NULL != provider->open) ? provider->open : &wsfsp_open_default;
|
||||
protocol->provider.close = (NULL != provider->close) ? provider->close : &wsfsp_close_default;
|
||||
protocol->provider.read = (NULL != provider->read) ? provider->read : &wsfsp_read_default;
|
||||
protocol->provider.connected = (NULL != provider->connected) ? provider->connected : &wsfsp_connected_default;
|
||||
protocol->provider.disconnected = (NULL != provider->disconnected) ? provider->disconnected : &wsfsp_disconnected_default;
|
||||
protocol->provider.ontimer = (NULL != provider->ontimer) ? provider->ontimer : &wsfsp_ontimer_default;
|
||||
wsfsp_provider_init_from_prototype(&protocol->provider, provider);
|
||||
}
|
||||
|
||||
void wsfsp_client_protocol_cleanup(
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define WSFS_PROVIDER_OPERATION_CLOSE_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/close.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define WSFS_PROVIDER_OPERATION_GETATTR_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/getattr.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define WSFS_PROVIDER_OPERATION_LOOKUP_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/lookup.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define WSFS_PROVIDER_OPERATION_OPEN_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/open.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define WSFS_PROVIDER_OPERATION_READ_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/read.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define WSFS_PROVIDER_OPERATION_READDIR_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/readdir.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
@@ -55,6 +55,35 @@ static void wsfsp_provider_invoke_method(
|
||||
}
|
||||
}
|
||||
|
||||
void wsfsp_provider_init(
|
||||
struct wsfsp_provider * provider)
|
||||
{
|
||||
provider->lookup = &wsfsp_lookup_default;
|
||||
provider->getattr = &wsfsp_getattr_default;
|
||||
provider->readdir = &wsfsp_readdir_default;
|
||||
provider->open = &wsfsp_open_default;
|
||||
provider->close = &wsfsp_close_default;
|
||||
provider->read = &wsfsp_read_default;
|
||||
provider->connected = &wsfsp_connected_default;
|
||||
provider->disconnected = &wsfsp_disconnected_default;
|
||||
provider->ontimer = &wsfsp_ontimer_default;
|
||||
}
|
||||
|
||||
void wsfsp_provider_init_from_prototype(
|
||||
struct wsfsp_provider * provider,
|
||||
struct wsfsp_provider const * prototype)
|
||||
{
|
||||
provider->lookup = prototype->lookup;
|
||||
provider->getattr = prototype->getattr;
|
||||
provider->readdir = prototype->readdir;
|
||||
provider->open = prototype->open;
|
||||
provider->close = prototype->close;
|
||||
provider->read = prototype->read;
|
||||
provider->connected = prototype->connected;
|
||||
provider->disconnected = prototype->disconnected;
|
||||
provider->ontimer = prototype->ontimer;
|
||||
}
|
||||
|
||||
void wsfsp_provider_invoke(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * request)
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#ifndef WSFS_PROVIDER_PROVIDER_INTERN_H
|
||||
#define WSFS_PROVIDER_PROVIDER_INTERN_H
|
||||
|
||||
#include "wsfs/provider/provider.h"
|
||||
#include "wsfs/provider/request.h"
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
struct wsfsp_invokation_context
|
||||
{
|
||||
struct wsfsp_provider * provider;
|
||||
void * user_data;
|
||||
struct wsfsp_request * request;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_provider_invoke(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * request);
|
||||
|
||||
extern void wsfsp_connected_default(
|
||||
void * user_data);
|
||||
|
||||
extern void wsfsp_disconnected_default(
|
||||
void * user_data);
|
||||
|
||||
extern void wsfsp_ontimer_default(
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user