mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
refactors provider client api (introduces client_config)
This commit is contained in:
parent
2781aadf55
commit
d205d2f127
@ -108,6 +108,7 @@ install(FILES "${PROJECT_BINARY_DIR}/libwsfs-adapter.pc" DESTINATION lib${LIB_SU
|
|||||||
set(WSFS_PROVIDER_SOURCES
|
set(WSFS_PROVIDER_SOURCES
|
||||||
lib/wsfs/provider/url.c
|
lib/wsfs/provider/url.c
|
||||||
lib/wsfs/provider/client.c
|
lib/wsfs/provider/client.c
|
||||||
|
lib/wsfs/provider/client_config.c
|
||||||
lib/wsfs/provider/client_protocol.c
|
lib/wsfs/provider/client_protocol.c
|
||||||
lib/wsfs/provider/provider.c
|
lib/wsfs/provider/provider.c
|
||||||
lib/wsfs/provider/request.c
|
lib/wsfs/provider/request.c
|
||||||
|
@ -6,9 +6,18 @@
|
|||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
#include "wsfs_provider.h"
|
#include "wsfs_provider.h"
|
||||||
|
|
||||||
|
struct config
|
||||||
|
{
|
||||||
|
char * url;
|
||||||
|
struct wsfsp_client_config * client_config;
|
||||||
|
bool show_help;
|
||||||
|
};
|
||||||
|
|
||||||
enum fs_entry_type
|
enum fs_entry_type
|
||||||
{
|
{
|
||||||
FS_FILE,
|
FS_FILE,
|
||||||
@ -31,6 +40,88 @@ struct fs
|
|||||||
struct fs_entry const * entries;
|
struct fs_entry const * entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void show_help()
|
||||||
|
{
|
||||||
|
printf(
|
||||||
|
"wsfs-provider, Copyright (c) 2019 fuse-wsfs authors <https://github.com/falk-werner/fuse-wsfs>\n"
|
||||||
|
"Example for websocket file system provider\n"
|
||||||
|
"\n"
|
||||||
|
"Usage: wsfs-provider -u <url> [-k <key_path>] [-c <cert_path>]\n"
|
||||||
|
"\n"
|
||||||
|
"Options:\n"
|
||||||
|
"\t-u, --url URL of WSFS server (required)\n"
|
||||||
|
"\t-k, --key_path Path to private key of provider (default: not set, TLS disabled)\n"
|
||||||
|
"\t-c, --cert_path Path to certificate of provider (defautl: not set, TLS disabled)\n"
|
||||||
|
"\t-h, --help prints this message\n"
|
||||||
|
"\n"
|
||||||
|
"Example:\n"
|
||||||
|
"\twsfs-provider -u ws://localhost:8080/\n"
|
||||||
|
"\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_arguments(
|
||||||
|
int argc,
|
||||||
|
char* argv[],
|
||||||
|
struct config * config)
|
||||||
|
{
|
||||||
|
static struct option const options[] =
|
||||||
|
{
|
||||||
|
{"url", required_argument, NULL, 'u'},
|
||||||
|
{"key_path", required_argument, NULL, 'k'},
|
||||||
|
{"cert_path", required_argument, NULL, 'c'},
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{NULL, 0, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
int result = EXIT_SUCCESS;
|
||||||
|
bool finished = false;
|
||||||
|
while (!finished)
|
||||||
|
{
|
||||||
|
int option_index = 0;
|
||||||
|
int const c = getopt_long(argc, argv, "u:k:c:h", options, &option_index);
|
||||||
|
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
finished = true;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
config->show_help = true;
|
||||||
|
finished = true;
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
free(config->url);
|
||||||
|
config->url = strdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'k':
|
||||||
|
wsfsp_client_config_set_keypath(config->client_config, optarg);
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
wsfsp_client_config_set_certpath(config->client_config, optarg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "error: unknown argument\n");
|
||||||
|
finished = true;
|
||||||
|
result = EXIT_FAILURE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == config->url)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error: missing required argument \"-u\"\n");
|
||||||
|
result = EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != EXIT_SUCCESS)
|
||||||
|
{
|
||||||
|
config->show_help = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static struct fs_entry const * fs_getentry(
|
static struct fs_entry const * fs_getentry(
|
||||||
struct fs * fs,
|
struct fs * fs,
|
||||||
ino_t inode)
|
ino_t inode)
|
||||||
@ -223,15 +314,6 @@ static void fs_read(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wsfsp_provider fs_provider =
|
|
||||||
{
|
|
||||||
.lookup = &fs_lookup,
|
|
||||||
.getattr = &fs_getattr,
|
|
||||||
.readdir = &fs_readdir,
|
|
||||||
.open = &fs_open,
|
|
||||||
.read = &fs_read
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct wsfsp_client * client;
|
static struct wsfsp_client * client;
|
||||||
|
|
||||||
static void on_interrupt(int signal_id)
|
static void on_interrupt(int signal_id)
|
||||||
@ -243,36 +325,57 @@ static void on_interrupt(int signal_id)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
(void) argc;
|
struct config config;
|
||||||
(void) argv;
|
config.url = NULL;
|
||||||
|
config.show_help = false;
|
||||||
|
config.client_config = wsfsp_client_config_create();
|
||||||
|
int result = parse_arguments(argc, argv, &config);
|
||||||
|
|
||||||
static struct fs_entry const entries[]=
|
if (EXIT_SUCCESS == result)
|
||||||
{
|
{
|
||||||
{.parent = 0, .inode = 1, .name = "<root>", .mode = 0555, .type = FS_DIR},
|
static struct fs_entry const entries[]=
|
||||||
{
|
{
|
||||||
.parent = 1,
|
{.parent = 0, .inode = 1, .name = "<root>", .mode = 0555, .type = FS_DIR},
|
||||||
.inode = 2,
|
{
|
||||||
.name = "hello.txt",
|
.parent = 1,
|
||||||
.mode = 0555,
|
.inode = 2,
|
||||||
.type = FS_FILE,
|
.name = "hello.txt",
|
||||||
.content="hello, world!",
|
.mode = 0555,
|
||||||
.content_length = 13,
|
.type = FS_FILE,
|
||||||
},
|
.content="hello, world!",
|
||||||
{.parent = 0, .inode = 0, .name = NULL}
|
.content_length = 13,
|
||||||
};
|
},
|
||||||
|
{.parent = 0, .inode = 0, .name = NULL}
|
||||||
|
};
|
||||||
|
|
||||||
struct fs fs =
|
struct fs fs =
|
||||||
|
{
|
||||||
|
.entries = entries
|
||||||
|
};
|
||||||
|
|
||||||
|
signal(SIGINT, &on_interrupt);
|
||||||
|
|
||||||
|
wsfsp_client_config_set_userdata(config.client_config, &fs);
|
||||||
|
wsfsp_client_config_set_onlookup(config.client_config, &fs_lookup);
|
||||||
|
wsfsp_client_config_set_ongetattr(config.client_config, &fs_getattr);
|
||||||
|
wsfsp_client_config_set_onreaddir(config.client_config, &fs_readdir);
|
||||||
|
wsfsp_client_config_set_onopen(config.client_config, &fs_open);
|
||||||
|
wsfsp_client_config_set_onread(config.client_config, &fs_read);
|
||||||
|
|
||||||
|
client = wsfsp_client_create(config.client_config);
|
||||||
|
wsfsp_client_connect(client, config.url);
|
||||||
|
|
||||||
|
wsfsp_client_run(client);
|
||||||
|
|
||||||
|
wsfsp_client_dispose(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.show_help)
|
||||||
{
|
{
|
||||||
.entries = entries
|
show_help();
|
||||||
};
|
}
|
||||||
|
|
||||||
signal(SIGINT, &on_interrupt);
|
free(config.url);
|
||||||
|
wsfsp_client_config_dispose(config.client_config);
|
||||||
client = wsfsp_client_create(&fs_provider, &fs);
|
return result;
|
||||||
wsfsp_client_connect(client, "ws://localhost:8080/");
|
|
||||||
|
|
||||||
wsfsp_client_run(client);
|
|
||||||
|
|
||||||
wsfsp_client_dispose(client);
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
#include "wsfs/provider/api.h"
|
||||||
|
|
||||||
struct wsfsp_provider;
|
|
||||||
struct wsfsp_client;
|
struct wsfsp_client;
|
||||||
|
struct wsfsp_client_config;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@ -12,8 +12,15 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern WSFSP_API struct wsfsp_client * wsfsp_client_create(
|
extern WSFSP_API struct wsfsp_client * wsfsp_client_create(
|
||||||
struct wsfsp_provider * provider,
|
struct wsfsp_client_config * config);
|
||||||
void * user_data);
|
|
||||||
|
extern WSFSP_API void wsfsp_client_set_keypath(
|
||||||
|
struct wsfsp_client * client,
|
||||||
|
char * key_path);
|
||||||
|
|
||||||
|
extern WSFSP_API void wsfsp_client_set_certpath(
|
||||||
|
struct wsfsp_client * client,
|
||||||
|
char * cert_path);
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_client_connect(
|
extern WSFSP_API void wsfsp_client_connect(
|
||||||
struct wsfsp_client * client,
|
struct wsfsp_client * client,
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
#ifndef WSFS_PROVIDER_PROVIDER_H
|
|
||||||
#define WSFS_PROVIDER_PROVIDER_H
|
|
||||||
|
|
||||||
#include <wsfs/provider/operation/lookup.h>
|
|
||||||
#include <wsfs/provider/operation/getattr.h>
|
|
||||||
#include <wsfs/provider/operation/readdir.h>
|
|
||||||
#include <wsfs/provider/operation/open.h>
|
|
||||||
#include <wsfs/provider/operation/close.h>
|
|
||||||
#include <wsfs/provider/operation/read.h>
|
|
||||||
|
|
||||||
typedef void wsfsp_connected_fn(
|
|
||||||
void * user_data);
|
|
||||||
|
|
||||||
typedef void wsfsp_disconnected_fn(
|
|
||||||
void * user_data);
|
|
||||||
|
|
||||||
typedef void wsfsp_ontimer_fn(
|
|
||||||
void * user_data);
|
|
||||||
|
|
||||||
struct wsfsp_provider
|
|
||||||
{
|
|
||||||
wsfsp_connected_fn * connected;
|
|
||||||
wsfsp_disconnected_fn * disconnected;
|
|
||||||
wsfsp_ontimer_fn * ontimer;
|
|
||||||
wsfsp_lookup_fn * lookup;
|
|
||||||
wsfsp_getattr_fn * getattr;
|
|
||||||
wsfsp_readdir_fn * readdir;
|
|
||||||
wsfsp_open_fn * open;
|
|
||||||
wsfsp_close_fn * close;
|
|
||||||
wsfsp_read_fn * read;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#include <wsfs/provider/api.h>
|
#include <wsfs/provider/api.h>
|
||||||
#include <wsfs/provider/client.h>
|
#include <wsfs/provider/client.h>
|
||||||
|
#include <wsfs/provider/client_config.h>
|
||||||
#include <wsfs/provider/client_protocol.h>
|
#include <wsfs/provider/client_protocol.h>
|
||||||
#include <wsfs/provider/provider.h>
|
|
||||||
#include <wsfs/provider/dirbuffer.h>
|
#include <wsfs/provider/dirbuffer.h>
|
||||||
|
|
||||||
#include <wsfs/provider/operation/error.h>
|
#include <wsfs/provider/operation/error.h>
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "wsfs/provider/provider.h"
|
#include "wsfs/provider/provider.h"
|
||||||
#include "wsfs/provider/client_protocol_intern.h"
|
#include "wsfs/provider/client_protocol_intern.h"
|
||||||
|
#include "wsfs/provider/client_config_intern.h"
|
||||||
#include "wsfs/provider/url.h"
|
#include "wsfs/provider/url.h"
|
||||||
|
|
||||||
#define WSFSP_PROTOCOL ("fs")
|
#define WSFSP_PROTOCOL ("fs")
|
||||||
@ -18,17 +19,17 @@
|
|||||||
struct wsfsp_client
|
struct wsfsp_client
|
||||||
{
|
{
|
||||||
volatile bool is_running;
|
volatile bool is_running;
|
||||||
struct wsfsp_provider provider;
|
|
||||||
struct wsfsp_client_protocol protocol;
|
struct wsfsp_client_protocol protocol;
|
||||||
struct lws_context_creation_info info;
|
struct lws_context_creation_info info;
|
||||||
struct lws_protocols protocols[WSFSP_CLIENT_PROTOCOL_COUNT];
|
struct lws_protocols protocols[WSFSP_CLIENT_PROTOCOL_COUNT];
|
||||||
struct lws_context * context;
|
struct lws_context * context;
|
||||||
|
char * key_path;
|
||||||
|
char * cert_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct wsfsp_client * wsfsp_client_create(
|
struct wsfsp_client * wsfsp_client_create(
|
||||||
struct wsfsp_provider * provider,
|
struct wsfsp_client_config * config)
|
||||||
void * user_data)
|
|
||||||
{
|
{
|
||||||
lws_set_log_level(WSFSP_DISABLE_LWS_LOG, NULL);
|
lws_set_log_level(WSFSP_DISABLE_LWS_LOG, NULL);
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ struct wsfsp_client * wsfsp_client_create(
|
|||||||
if (NULL != client)
|
if (NULL != client)
|
||||||
{
|
{
|
||||||
client->is_running = true;
|
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);
|
memset(client->protocols, 0, sizeof(struct lws_protocols) * WSFSP_CLIENT_PROTOCOL_COUNT);
|
||||||
client->protocols[0].name = "fs";
|
client->protocols[0].name = "fs";
|
||||||
@ -48,6 +49,11 @@ struct wsfsp_client * wsfsp_client_create(
|
|||||||
client->info.uid = -1;
|
client->info.uid = -1;
|
||||||
client->info.gid = -1;
|
client->info.gid = -1;
|
||||||
|
|
||||||
|
if ((NULL != config->cert_path) && (NULL != config->key_path))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
client->context = lws_create_context(&client->info);
|
client->context = lws_create_context(&client->info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,17 +102,6 @@ void wsfsp_client_disconnect(
|
|||||||
// ToDo: implement me
|
// 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(
|
void wsfsp_client_run(
|
||||||
struct wsfsp_client * client)
|
struct wsfsp_client * client)
|
||||||
{
|
{
|
||||||
|
@ -7,14 +7,7 @@
|
|||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
|
|
||||||
|
|
||||||
#include "wsfs/provider/provider_intern.h"
|
#include "wsfs/provider/provider.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/util.h"
|
#include "wsfs/util.h"
|
||||||
#include "wsfs/message.h"
|
#include "wsfs/message.h"
|
||||||
|
|
||||||
@ -117,15 +110,7 @@ void wsfsp_client_protocol_init(
|
|||||||
protocol->request.user_data = protocol;
|
protocol->request.user_data = protocol;
|
||||||
|
|
||||||
protocol->user_data = user_data;
|
protocol->user_data = user_data;
|
||||||
protocol->provider.lookup = (NULL != provider->lookup) ? provider->lookup : &wsfsp_lookup_default;
|
wsfsp_provider_init_from_prototype(&protocol->provider, provider);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfsp_client_protocol_cleanup(
|
void wsfsp_client_protocol_cleanup(
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define WSFS_PROVIDER_OPERATION_CLOSE_INTERN_H
|
#define WSFS_PROVIDER_OPERATION_CLOSE_INTERN_H
|
||||||
|
|
||||||
#include "wsfs/provider/operation/close.h"
|
#include "wsfs/provider/operation/close.h"
|
||||||
#include "wsfs/provider/provider_intern.h"
|
#include "wsfs/provider/provider.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define WSFS_PROVIDER_OPERATION_GETATTR_INTERN_H
|
#define WSFS_PROVIDER_OPERATION_GETATTR_INTERN_H
|
||||||
|
|
||||||
#include "wsfs/provider/operation/getattr.h"
|
#include "wsfs/provider/operation/getattr.h"
|
||||||
#include "wsfs/provider/provider_intern.h"
|
#include "wsfs/provider/provider.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define WSFS_PROVIDER_OPERATION_LOOKUP_INTERN_H
|
#define WSFS_PROVIDER_OPERATION_LOOKUP_INTERN_H
|
||||||
|
|
||||||
#include "wsfs/provider/operation/lookup.h"
|
#include "wsfs/provider/operation/lookup.h"
|
||||||
#include "wsfs/provider/provider_intern.h"
|
#include "wsfs/provider/provider.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define WSFS_PROVIDER_OPERATION_OPEN_INTERN_H
|
#define WSFS_PROVIDER_OPERATION_OPEN_INTERN_H
|
||||||
|
|
||||||
#include "wsfs/provider/operation/open.h"
|
#include "wsfs/provider/operation/open.h"
|
||||||
#include "wsfs/provider/provider_intern.h"
|
#include "wsfs/provider/provider.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define WSFS_PROVIDER_OPERATION_READ_INTERN_H
|
#define WSFS_PROVIDER_OPERATION_READ_INTERN_H
|
||||||
|
|
||||||
#include "wsfs/provider/operation/read.h"
|
#include "wsfs/provider/operation/read.h"
|
||||||
#include "wsfs/provider/provider_intern.h"
|
#include "wsfs/provider/provider.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define WSFS_PROVIDER_OPERATION_READDIR_INTERN_H
|
#define WSFS_PROVIDER_OPERATION_READDIR_INTERN_H
|
||||||
|
|
||||||
#include "wsfs/provider/operation/readdir.h"
|
#include "wsfs/provider/operation/readdir.h"
|
||||||
#include "wsfs/provider/provider_intern.h"
|
#include "wsfs/provider/provider.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "wsfs/provider/provider_intern.h"
|
#include "wsfs/provider/provider.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.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(
|
void wsfsp_provider_invoke(
|
||||||
struct wsfsp_invokation_context * context,
|
struct wsfsp_invokation_context * context,
|
||||||
json_t * request)
|
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
|
|
Loading…
Reference in New Issue
Block a user