mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
Merge pull request #9 from falk-werner/feature-provider
integrates provider
This commit is contained in:
commit
7934319d73
@ -46,12 +46,14 @@ set(EXTRA_CFLAGS
|
||||
set(WSFS_COMMON_SOURCES
|
||||
lib/wsfs/message.c
|
||||
lib/wsfs/message_queue.c
|
||||
lib/wsfs/status.c
|
||||
)
|
||||
|
||||
install(FILES include/wsfs/status.h DESTINATION include/wsfs)
|
||||
|
||||
# libwsfs-adapter
|
||||
|
||||
set(WSFS_ADAPTER_SOURCES
|
||||
lib/wsfs/adapter/status.c
|
||||
lib/wsfs/adapter/filesystem.c
|
||||
lib/wsfs/adapter/server.c
|
||||
lib/wsfs/adapter/time/timepoint.c
|
||||
@ -106,6 +108,7 @@ install(FILES "${PROJECT_BINARY_DIR}/libwsfs-adapter.pc" DESTINATION lib${LIB_SU
|
||||
set(WSFS_PROVIDER_SOURCES
|
||||
lib/wsfs/provider/url.c
|
||||
lib/wsfs/provider/client.c
|
||||
lib/wsfs/provider/client_config.c
|
||||
lib/wsfs/provider/client_protocol.c
|
||||
lib/wsfs/provider/provider.c
|
||||
lib/wsfs/provider/request.c
|
||||
|
@ -4,8 +4,20 @@
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "wsfs_provider.h"
|
||||
|
||||
struct config
|
||||
{
|
||||
char * url;
|
||||
struct wsfsp_client_config * client_config;
|
||||
bool show_help;
|
||||
};
|
||||
|
||||
enum fs_entry_type
|
||||
{
|
||||
FS_FILE,
|
||||
@ -23,28 +35,93 @@ struct fs_entry
|
||||
char const * content;
|
||||
};
|
||||
|
||||
struct fs_dir
|
||||
{
|
||||
ino_t parent;
|
||||
ino_t inode;
|
||||
char const * name;
|
||||
};
|
||||
|
||||
struct fs_file
|
||||
{
|
||||
ino_t parent;
|
||||
ino_t inode;
|
||||
char const * name;
|
||||
char const * content;
|
||||
size_t content_length;
|
||||
bool is_executable;
|
||||
};
|
||||
|
||||
struct fs
|
||||
{
|
||||
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(
|
||||
struct fs * fs,
|
||||
ino_t inode)
|
||||
@ -116,7 +193,7 @@ static void fs_lookup(
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, -1);
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +215,7 @@ static void fs_getattr(
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, -1);
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,7 +247,7 @@ static void fs_readdir(
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, -1);
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,12 +257,29 @@ static void fs_open(
|
||||
int flags,
|
||||
void * user_data)
|
||||
{
|
||||
(void) inode;
|
||||
(void) flags;
|
||||
(void) user_data;
|
||||
struct fs * fs = (struct fs*) user_data;
|
||||
|
||||
puts("open");
|
||||
wsfsp_respond_error(request, -1);
|
||||
struct fs_entry const * entry = fs_getentry(fs, inode);
|
||||
if ((NULL != entry) && (FS_FILE == entry->type))
|
||||
{
|
||||
if (O_RDONLY == (flags & O_ACCMODE))
|
||||
{
|
||||
wsfsp_respond_open(request, 0U);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOACCESS);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
static size_t min(size_t const a, size_t const b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
static void fs_read(
|
||||
@ -196,24 +290,30 @@ static void fs_read(
|
||||
size_t length,
|
||||
void * user_data)
|
||||
{
|
||||
(void) inode;
|
||||
(void) handle;
|
||||
(void) offset;
|
||||
(void) length;
|
||||
(void) user_data;
|
||||
|
||||
wsfsp_respond_error(request, -1);
|
||||
struct fs * fs = (struct fs*) user_data;
|
||||
struct fs_entry const * entry = fs_getentry(fs, inode);
|
||||
if ((NULL != entry) && (FS_FILE == entry->type))
|
||||
{
|
||||
if (entry->content_length > offset)
|
||||
{
|
||||
size_t const remaining = entry->content_length - offset;
|
||||
size_t const count = min(remaining, length);
|
||||
|
||||
wsfsp_respond_read(request, &entry->content[offset], count);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
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 void on_interrupt(int signal_id)
|
||||
@ -225,36 +325,57 @@ static void on_interrupt(int signal_id)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
struct config config;
|
||||
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,
|
||||
.inode = 2,
|
||||
.name = "hello.txt",
|
||||
.mode = 0555,
|
||||
.type = FS_FILE,
|
||||
.content="hello, world!",
|
||||
.content_length = 13,
|
||||
},
|
||||
{.parent = 0, .inode = 0, .name = NULL}
|
||||
};
|
||||
{.parent = 0, .inode = 1, .name = "<root>", .mode = 0555, .type = FS_DIR},
|
||||
{
|
||||
.parent = 1,
|
||||
.inode = 2,
|
||||
.name = "hello.txt",
|
||||
.mode = 0555,
|
||||
.type = FS_FILE,
|
||||
.content="hello, world!",
|
||||
.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);
|
||||
|
||||
client = wsfsp_client_create(&fs_provider, &fs);
|
||||
wsfsp_client_connect(client, "ws://localhost:8080/");
|
||||
|
||||
wsfsp_client_run(client);
|
||||
|
||||
wsfsp_client_dispose(client);
|
||||
return EXIT_SUCCESS;
|
||||
free(config.url);
|
||||
wsfsp_client_config_dispose(config.client_config);
|
||||
return result;
|
||||
}
|
@ -3,8 +3,8 @@
|
||||
|
||||
#include "wsfs/provider/api.h"
|
||||
|
||||
struct wsfsp_provider;
|
||||
struct wsfsp_client;
|
||||
struct wsfsp_client_config;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -12,8 +12,15 @@ extern "C"
|
||||
#endif
|
||||
|
||||
extern WSFSP_API struct wsfsp_client * wsfsp_client_create(
|
||||
struct wsfsp_provider * provider,
|
||||
void * user_data);
|
||||
struct wsfsp_client_config * config);
|
||||
|
||||
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(
|
||||
struct wsfsp_client * client,
|
||||
|
88
include/wsfs/provider/client_config.h
Normal file
88
include/wsfs/provider/client_config.h
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef WSFS_PROVIDER_CLIENT_CONFIG_H
|
||||
#define WSFS_PROVIDER_CLIENT_CONFIG_H
|
||||
|
||||
#include <wsfs/provider/api.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>
|
||||
|
||||
struct wsfsp_client_config;
|
||||
|
||||
typedef void wsfsp_connected_fn(
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_disconnected_fn(
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_ontimer_fn(
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern WSFSP_API struct wsfsp_client_config * wsfsp_client_config_create(void);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_dispose(
|
||||
struct wsfsp_client_config * config);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_userdata(
|
||||
struct wsfsp_client_config * config,
|
||||
void * user_data);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_keypath(
|
||||
struct wsfsp_client_config * config,
|
||||
char const * key_path);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_certpath(
|
||||
struct wsfsp_client_config * config,
|
||||
char const * cert_path);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onconnected(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_connected_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_ondisconnected(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_disconnected_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_ontimer(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_ontimer_fn * handler);
|
||||
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onlookup(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_lookup_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_ongetattr(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_getattr_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onreaddir(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_readdir_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onopen(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_open_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onclose(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_close_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onread(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_read_fn * handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -2,6 +2,7 @@
|
||||
#define WSFSP_OPERATION_ERROR_H
|
||||
|
||||
#include "wsfs/provider/api.h"
|
||||
#include "wsfs/status.h"
|
||||
|
||||
struct wsfsp_request;
|
||||
|
||||
@ -12,7 +13,7 @@ extern "C"
|
||||
|
||||
extern WSFSP_API void wsfsp_respond_error(
|
||||
struct wsfsp_request * request,
|
||||
int status);
|
||||
wsfs_status status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -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
|
@ -1,5 +1,5 @@
|
||||
#ifndef WSFS_ADAPTER_STATUS_H
|
||||
#define WSFS_ADAPTER_STATUS_H
|
||||
#ifndef WSFS_STATUS_H
|
||||
#define WSFS_STATUS_H
|
||||
|
||||
#define WSFS_GOOD 0
|
||||
#define WSFS_BAD 1
|
||||
@ -14,17 +14,4 @@
|
||||
|
||||
typedef int wsfs_status;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int wsfs_status_to_rc(wsfs_status status);
|
||||
|
||||
extern char const * wsfs_status_tostring(wsfs_status status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef WSFS_ADAPTER_H
|
||||
#define WSFS_ADAPTER_H
|
||||
|
||||
#include <wsfs/status.h>
|
||||
|
||||
#include <wsfs/adapter/api.h>
|
||||
#include <wsfs/adapter/server.h>
|
||||
#include <wsfs/adapter/server_config.h>
|
||||
|
@ -1,10 +1,12 @@
|
||||
#ifndef WSFS_PROVIDER_H
|
||||
#define WSFS_PROVIDER_H
|
||||
|
||||
#include <wsfs/status.h>
|
||||
|
||||
#include <wsfs/provider/api.h>
|
||||
#include <wsfs/provider/client.h>
|
||||
#include <wsfs/provider/client_config.h>
|
||||
#include <wsfs/provider/client_protocol.h>
|
||||
#include <wsfs/provider/provider.h>
|
||||
#include <wsfs/provider/dirbuffer.h>
|
||||
|
||||
#include <wsfs/provider/operation/error.h>
|
||||
|
@ -6,7 +6,7 @@
|
||||
#endif
|
||||
|
||||
#include <jansson.h>
|
||||
#include "wsfs/adapter/status.h"
|
||||
#include "wsfs/status.h"
|
||||
|
||||
|
||||
typedef bool wsfs_jsonrpc_method_invoke_fn(
|
||||
|
@ -9,7 +9,7 @@ using std::size_t;
|
||||
#endif
|
||||
|
||||
#include <jansson.h>
|
||||
#include "wsfs/adapter/status.h"
|
||||
#include "wsfs/status.h"
|
||||
|
||||
struct wsfs_jsonrpc_response
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "wsfs/adapter/jsonrpc/server.h"
|
||||
#include "wsfs/util.h"
|
||||
#include "wsfs/adapter/status.h"
|
||||
#include "wsfs/status.h"
|
||||
|
||||
static void wsfs_operation_open_finished(
|
||||
void * user_data,
|
||||
|
@ -10,32 +10,32 @@
|
||||
|
||||
#define WSFS_MAX_READ_LENGTH 4096
|
||||
|
||||
static wsfs_status wsfs_fill_buffer(
|
||||
char * * buffer,
|
||||
char const * format,
|
||||
static char * wsfs_fill_buffer(
|
||||
char const * data,
|
||||
size_t count)
|
||||
char const * format,
|
||||
size_t count,
|
||||
wsfs_status * status)
|
||||
{
|
||||
wsfs_status status = WSFS_GOOD;
|
||||
*status = WSFS_GOOD;
|
||||
char * buffer = malloc(count + 1);
|
||||
|
||||
if (0 < count)
|
||||
if ((NULL != buffer) && (0 < count))
|
||||
{
|
||||
*buffer = malloc(count);
|
||||
if (0 == strcmp("identity", format))
|
||||
{
|
||||
memcpy(*buffer, data, count); /* Flawfinder: ignore */
|
||||
memcpy(buffer, data, count); /* Flawfinder: ignore */
|
||||
}
|
||||
else if (0 == strcmp("base64", format))
|
||||
{
|
||||
lws_b64_decode_string(data, *buffer, count);
|
||||
lws_b64_decode_string(data, buffer, count + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = WSFS_BAD;
|
||||
*status = WSFS_BAD;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void wsfs_operation_read_finished(void * user_data, wsfs_status status, json_t const * data)
|
||||
@ -50,15 +50,15 @@ static void wsfs_operation_read_finished(void * user_data, wsfs_status status, j
|
||||
json_t * format_holder = json_object_get(data, "format");
|
||||
json_t * count_holder = json_object_get(data, "count");
|
||||
|
||||
if ((NULL != data_holder) && (json_is_string(data_holder)) &&
|
||||
(NULL != format_holder) && (json_is_string(format_holder)) &&
|
||||
(NULL != count_holder) && (json_is_integer(count_holder)))
|
||||
if (json_is_string(data_holder) &&
|
||||
json_is_string(format_holder) &&
|
||||
json_is_integer(count_holder))
|
||||
{
|
||||
char const * const data = json_string_value(data_holder);
|
||||
char const * const format = json_string_value(format_holder);
|
||||
length = (size_t) json_integer_value(count_holder);
|
||||
|
||||
status = wsfs_fill_buffer(&buffer, format, data, length);
|
||||
buffer = wsfs_fill_buffer(data, format, length, &status);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5,12 +5,6 @@
|
||||
|
||||
extern struct wsfs_message * wsfs_message_create(json_t const * value)
|
||||
{
|
||||
#if 0
|
||||
char * msg = json_dumps(value, JSON_COMPACT);
|
||||
puts(msg);
|
||||
free(msg);
|
||||
#endif
|
||||
|
||||
struct wsfs_message * message = NULL;
|
||||
size_t const length = json_dumpb(value, NULL, 0, JSON_COMPACT);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
112
lib/wsfs/provider/client_config.c
Normal file
112
lib/wsfs/provider/client_config.c
Normal file
@ -0,0 +1,112 @@
|
||||
#include "wsfs/provider/client_config_intern.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct wsfsp_client_config * wsfsp_client_config_create(void)
|
||||
{
|
||||
struct wsfsp_client_config * config = malloc(sizeof(struct wsfsp_client_config));
|
||||
if (NULL != config)
|
||||
{
|
||||
wsfsp_provider_init(&config->provider);
|
||||
config->user_data = NULL;
|
||||
config->key_path = NULL;
|
||||
config->cert_path = NULL;
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_dispose(
|
||||
struct wsfsp_client_config * config)
|
||||
{
|
||||
free(config->key_path);
|
||||
free(config->cert_path);
|
||||
free(config);
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_userdata(
|
||||
struct wsfsp_client_config * config,
|
||||
void * user_data)
|
||||
{
|
||||
config->user_data = user_data;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_keypath(
|
||||
struct wsfsp_client_config * config,
|
||||
char const * key_path)
|
||||
{
|
||||
free(config->key_path);
|
||||
config->key_path = strdup(key_path);
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_certpath(
|
||||
struct wsfsp_client_config * config,
|
||||
char const * cert_path)
|
||||
{
|
||||
free(config->cert_path);
|
||||
config->cert_path = strdup(cert_path);
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onconnected(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_connected_fn * handler)
|
||||
{
|
||||
config->provider.connected = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_ondisconnected(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_disconnected_fn * handler)
|
||||
{
|
||||
config->provider.disconnected = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_ontimer(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_ontimer_fn * handler)
|
||||
{
|
||||
config->provider.ontimer = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onlookup(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_lookup_fn * handler)
|
||||
{
|
||||
config->provider.lookup = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_ongetattr(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_getattr_fn * handler)
|
||||
{
|
||||
config->provider.getattr = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onreaddir(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_readdir_fn * handler)
|
||||
{
|
||||
config->provider.readdir = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onopen(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_open_fn * handler)
|
||||
{
|
||||
config->provider.open = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onclose(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_close_fn * handler)
|
||||
{
|
||||
config->provider.close = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onread(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_read_fn * handler)
|
||||
{
|
||||
config->provider.read = handler;
|
||||
}
|
24
lib/wsfs/provider/client_config_intern.h
Normal file
24
lib/wsfs/provider/client_config_intern.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef WSFS_PROVIDER_CLIENT_CONFIG_INTERN_H
|
||||
#define WSFS_PROVIDER_CLIENT_CONFIG_INTERN_H
|
||||
|
||||
#include "wsfs/provider/client_config.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
|
||||
struct wsfsp_client_config
|
||||
{
|
||||
struct wsfsp_provider provider;
|
||||
void * user_data;
|
||||
char * key_path;
|
||||
char * cert_path;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -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"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "wsfs/provider/operation/getattr_intern.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
|
@ -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"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "wsfs/provider/operation/lookup_intern.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
@ -63,6 +62,6 @@ void wsfsp_lookup_default(
|
||||
char const * WSFS_UNUSED_PARAM(name),
|
||||
void * WSFS_UNUSED_PARAM(user_data))
|
||||
{
|
||||
wsfsp_respond_error(request, -1);
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "wsfs/provider/operation/open_intern.h"
|
||||
#include <stdio.h>
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
#include "wsfs/provider/request.h"
|
||||
#include "wsfs/util.h"
|
||||
|
||||
void wsfsp_open(
|
||||
@ -8,11 +8,23 @@ void wsfsp_open(
|
||||
json_t * params,
|
||||
int id)
|
||||
{
|
||||
(void) context;
|
||||
(void) params;
|
||||
(void) id;
|
||||
size_t const count = json_array_size(params);
|
||||
if (2 == count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 0);
|
||||
json_t * flags_holder = json_array_get(params, 1);
|
||||
|
||||
puts("open");
|
||||
if (json_is_integer(inode_holder) &&
|
||||
json_is_integer(flags_holder))
|
||||
{
|
||||
ino_t inode = (ino_t) json_integer_value(inode_holder);
|
||||
int flags = (ino_t) json_integer_value(flags_holder);
|
||||
|
||||
struct wsfsp_request * request = wsfsp_request_create(context->request, id);
|
||||
|
||||
context->provider->open(request, inode, flags, context->user_data); /* Flawfinder: ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wsfsp_open_default(
|
||||
@ -21,15 +33,15 @@ void wsfsp_open_default(
|
||||
int WSFS_UNUSED_PARAM(flags),
|
||||
void * WSFS_UNUSED_PARAM(user_data))
|
||||
{
|
||||
wsfsp_respond_error(request, -1);
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
}
|
||||
|
||||
void wsfsp_respond_open(
|
||||
struct wsfsp_request * request,
|
||||
uint32_t handle)
|
||||
{
|
||||
(void) request;
|
||||
(void) handle;
|
||||
json_t * result = json_object();
|
||||
json_object_set_new(result, "handle", json_integer((int) handle));
|
||||
|
||||
// ToDo: implement me
|
||||
wsfsp_respond(request, result);
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "wsfs/provider/operation/read_intern.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <libwebsockets.h>
|
||||
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
#include "wsfs/util.h"
|
||||
|
||||
@ -8,11 +11,28 @@ void wsfsp_read(
|
||||
json_t * params,
|
||||
int id)
|
||||
{
|
||||
(void) context;
|
||||
(void) params;
|
||||
(void) id;
|
||||
size_t const count = json_array_size(params);
|
||||
if (4 == count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 0);
|
||||
json_t * handle_holder = json_array_get(params, 1);
|
||||
json_t * offset_holder = json_array_get(params, 2);
|
||||
json_t * length_holder = json_array_get(params, 3);
|
||||
|
||||
puts("read");
|
||||
if (json_is_integer(inode_holder) &&
|
||||
json_is_integer(handle_holder) &&
|
||||
json_is_integer(offset_holder) &&
|
||||
json_is_integer(length_holder))
|
||||
{
|
||||
ino_t inode = (ino_t) json_integer_value(inode_holder);
|
||||
int handle = json_integer_value(handle_holder);
|
||||
size_t offset = json_integer_value(offset_holder);
|
||||
size_t length = json_integer_value(length_holder);
|
||||
struct wsfsp_request * request = wsfsp_request_create(context->request, id);
|
||||
|
||||
context->provider->read(request, inode, handle, offset, length, context->user_data); /* Flawfinder: ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wsfsp_read_default(
|
||||
@ -23,7 +43,7 @@ void wsfsp_read_default(
|
||||
size_t WSFS_UNUSED_PARAM(length),
|
||||
void * WSFS_UNUSED_PARAM(user_data))
|
||||
{
|
||||
wsfsp_respond_error(request, -1);
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
}
|
||||
|
||||
void wsfsp_respond_read(
|
||||
@ -31,7 +51,34 @@ void wsfsp_respond_read(
|
||||
char const * data,
|
||||
size_t length)
|
||||
{
|
||||
(void) request;
|
||||
(void) data;
|
||||
(void) length;
|
||||
if (0 < length)
|
||||
{
|
||||
size_t const size = 4 * ((length / 3) + 2);
|
||||
char * buffer = malloc(size);
|
||||
if (NULL != buffer)
|
||||
{
|
||||
lws_b64_encode_string(data, length, buffer, size);
|
||||
|
||||
json_t * result = json_object();
|
||||
json_object_set_new(result, "data", json_string(buffer));
|
||||
json_object_set_new(result, "format", json_string("base64"));
|
||||
json_object_set_new(result, "count", json_integer((int) length));
|
||||
|
||||
wsfsp_respond(request, result);
|
||||
free(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
json_t * result = json_object();
|
||||
json_object_set_new(result, "data", json_string(""));
|
||||
json_object_set_new(result, "format", json_string("identitiy"));
|
||||
json_object_set_new(result, "count", json_integer(0));
|
||||
|
||||
wsfsp_respond(request, result);
|
||||
}
|
||||
}
|
@ -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"
|
||||
|
@ -1,7 +1,4 @@
|
||||
#include "wsfs/provider/operation/readdir_intern.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
#include "wsfs/provider/dirbuffer_intern.h"
|
||||
#include "wsfs/provider/request.h"
|
||||
@ -32,7 +29,7 @@ void wsfsp_readdir_default(
|
||||
ino_t WSFS_UNUSED_PARAM(directory),
|
||||
void * WSFS_UNUSED_PARAM(user_data))
|
||||
{
|
||||
wsfsp_respond_error(request, -1);
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
}
|
||||
|
||||
void wsfsp_respond_readdir(
|
||||
|
@ -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)
|
||||
|
65
lib/wsfs/provider/provider.h
Normal file
65
lib/wsfs/provider/provider.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef WSFS_PROVIDER_PROVIDER_H
|
||||
#define WSFS_PROVIDER_PROVIDER_H
|
||||
|
||||
#include "wsfs/provider/client_config.h"
|
||||
#include "wsfs/provider/request.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>
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
struct wsfsp_invokation_context
|
||||
{
|
||||
struct wsfsp_provider * provider;
|
||||
void * user_data;
|
||||
struct wsfsp_request * request;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_provider_init(
|
||||
struct wsfsp_provider * provider);
|
||||
|
||||
extern void wsfsp_provider_init_from_prototype(
|
||||
struct wsfsp_provider * provider,
|
||||
struct wsfsp_provider const * prototype);
|
||||
|
||||
|
||||
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
|
@ -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
|
@ -40,7 +40,7 @@ extern void wsfsp_respond(
|
||||
|
||||
void wsfsp_respond_error(
|
||||
struct wsfsp_request * request,
|
||||
int status)
|
||||
wsfs_status status)
|
||||
{
|
||||
json_t * response = json_object();
|
||||
json_t * error = json_object();
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "wsfs/adapter/status.h"
|
||||
#include "wsfs/status_intern.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
19
lib/wsfs/status_intern.h
Normal file
19
lib/wsfs/status_intern.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef WSFS_STATUS_INTERN_H
|
||||
#define WSFS_STATUS_INTERN_H
|
||||
|
||||
#include "wsfs/status.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int wsfs_status_to_rc(wsfs_status status);
|
||||
|
||||
extern char const * wsfs_status_tostring(wsfs_status status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user