From dcbe4f075a4658cab475ec50f058c2e2f20b56f7 Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Thu, 11 Jun 2020 09:10:14 +0200 Subject: [PATCH] added stub of client implementation --- include/webfuse/adapter/client.h | 21 +----- include/webfuse/adapter/client_callback.h | 35 +++++++++ include/webfuse_adapter.h | 1 + lib/webfuse/adapter/api.c | 27 +++---- lib/webfuse/adapter/impl/client.c | 87 +++++++++++++++++++++++ lib/webfuse/adapter/impl/client.h | 57 +++++++++++++++ meson.build | 1 + 7 files changed, 194 insertions(+), 35 deletions(-) create mode 100644 include/webfuse/adapter/client_callback.h create mode 100644 lib/webfuse/adapter/impl/client.c create mode 100644 lib/webfuse/adapter/impl/client.h diff --git a/include/webfuse/adapter/client.h b/include/webfuse/adapter/client.h index 2e8273f..1971106 100644 --- a/include/webfuse/adapter/client.h +++ b/include/webfuse/adapter/client.h @@ -6,33 +6,16 @@ #ifndef WF_ADAPTER_CLIENT_H #define WF_ADAPTER_CLIENT_H -#include "webfuse/adapter/api.h" +#include +#include #ifdef __cplusplus extern "C" { #endif -#define WF_CLIENT_CREATED 0x0001 -#define WF_CLIENT_DISPOSING 0x0002 - -#define WF_CLIENT_CONNECTED 0x0011 -#define WF_CLIENT_DISCONNECTED 0x0012 - -#define WF_CLIENT_AUTHENTICATED 0x0021 -#define WF_CLIENT_AUTHENTICATION_FAILED 0x0022 -#define WF_CLIENT_AUTHENTICATE_GET_CREDENTIALS 0x0023 - -#define WF_CLIENT_FILESYSTEM_ADDED 0x0031 -#define WF_CLIENT_FILESYSTEM_ADD_FAILED 0x0032 - struct wf_client; -typedef void wf_client_callback_fn( - struct wf_client * client, - int reason, - void * args); - extern WF_API struct wf_client * wf_client_create( wf_client_callback_fn * callback, diff --git a/include/webfuse/adapter/client_callback.h b/include/webfuse/adapter/client_callback.h new file mode 100644 index 0000000..b603a1c --- /dev/null +++ b/include/webfuse/adapter/client_callback.h @@ -0,0 +1,35 @@ +#ifndef WF_ADAPTER_CLIENT_CALLBACK_H +#define WF_ADAPTER_CLIENT_CALLBACK_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#define WF_CLIENT_CREATED 0x0001 +#define WF_CLIENT_DISPOSING 0x0002 + +#define WF_CLIENT_CONNECTED 0x0011 +#define WF_CLIENT_DISCONNECTED 0x0012 + +#define WF_CLIENT_AUTHENTICATED 0x0021 +#define WF_CLIENT_AUTHENTICATION_FAILED 0x0022 +#define WF_CLIENT_AUTHENTICATE_GET_CREDENTIALS 0x0023 + +#define WF_CLIENT_FILESYSTEM_ADDED 0x0031 +#define WF_CLIENT_FILESYSTEM_ADD_FAILED 0x0032 + +struct wf_client; + +typedef void wf_client_callback_fn( + struct wf_client * client, + int reason, + void * args); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/include/webfuse_adapter.h b/include/webfuse_adapter.h index 954f988..a198e8b 100644 --- a/include/webfuse_adapter.h +++ b/include/webfuse_adapter.h @@ -18,6 +18,7 @@ #include #include +#include #endif diff --git a/lib/webfuse/adapter/api.c b/lib/webfuse/adapter/api.c index 613aaf7..382a6c4 100644 --- a/lib/webfuse/adapter/api.c +++ b/lib/webfuse/adapter/api.c @@ -8,6 +8,8 @@ #include "webfuse/core/util.h" +#include "webfuse/adapter/impl/client.h" + // server struct wf_server * wf_server_create( @@ -201,39 +203,35 @@ wf_client_create( wf_client_callback_fn * callback, void * user_data) { - (void) callback; - (void) user_data; - - return NULL; + return wf_impl_client_create(callback, user_data); } void wf_client_dispose( struct wf_client * client) { - (void) client; + wf_impl_client_dispose(client); } void * wf_client_get_userdata( struct wf_client * client) { - (void) client; - return NULL; + return wf_impl_client_get_userdata(client); } void wf_client_service( struct wf_client * client) { - (void) client; + wf_impl_client_service(client); } void wf_client_interrupt( struct wf_client * client) { - (void) client; + wf_impl_client_interrupt(client); } void @@ -241,22 +239,21 @@ wf_client_connect( struct wf_client * client, char const * url) { - (void) client; - (void) url; + wf_impl_client_connect(client, url); } void wf_client_disconnect( struct wf_client * client) { - (void) client; + wf_impl_client_disconnect(client); } void wf_client_authenticate( struct wf_client * client) { - (void) client; + wf_impl_client_authenticate(client); } void @@ -265,8 +262,6 @@ wf_client_add_filesystem( char const * local_path, char const * name) { - (void) client; - (void) local_path; - (void) name; + wf_impl_client_add_filesystem(client, local_path, name); } diff --git a/lib/webfuse/adapter/impl/client.c b/lib/webfuse/adapter/impl/client.c new file mode 100644 index 0000000..cefe39c --- /dev/null +++ b/lib/webfuse/adapter/impl/client.c @@ -0,0 +1,87 @@ +#include "webfuse/adapter/impl/client.h" + +#include + +struct wf_client +{ + wf_client_callback_fn * callback; + void * user_data; +}; + +struct wf_client * +wf_impl_client_create( + wf_client_callback_fn * callback, + void * user_data) +{ + struct wf_client * client = malloc(sizeof(struct wf_client)); + client->callback = callback; + client->user_data = user_data; + + client->callback(client, WF_CLIENT_CREATED, NULL); + + return client; +} + +void +wf_impl_client_dispose( + struct wf_client * client) +{ + client->callback(client, WF_CLIENT_DISPOSING, NULL); + free(client); +} + +void * +wf_impl_client_get_userdata( + struct wf_client * client) +{ + return client->user_data; +} + +void +wf_impl_client_service( + struct wf_client * client) +{ + (void) client; +} + +void +wf_impl_client_interrupt( + struct wf_client * client) +{ + (void) client; +} + +void +wf_impl_client_connect( + struct wf_client * client, + char const * url) +{ + (void) url; + client->callback(client, WF_CLIENT_DISCONNECTED, NULL); +} + +void +wf_impl_client_disconnect( + struct wf_client * client) +{ + (void) client; +} + +void +wf_impl_client_authenticate( + struct wf_client * client) +{ + client->callback(client, WF_CLIENT_AUTHENTICATION_FAILED, NULL); +} + +void +wf_impl_client_add_filesystem( + struct wf_client * client, + char const * local_path, + char const * name) +{ + (void) local_path; + (void) name; + + client->callback(client, WF_CLIENT_FILESYSTEM_ADD_FAILED, NULL); +} diff --git a/lib/webfuse/adapter/impl/client.h b/lib/webfuse/adapter/impl/client.h new file mode 100644 index 0000000..62d1299 --- /dev/null +++ b/lib/webfuse/adapter/impl/client.h @@ -0,0 +1,57 @@ +#ifndef WF_ADAPTER_IMPL_CLIENT_H +#define WF_ADAPTER_IMPL_CLIENT_H + + +#include "webfuse/adapter/client_callback.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern struct wf_client * +wf_impl_client_create( + wf_client_callback_fn * callback, + void * user_data); + +extern void +wf_impl_client_dispose( + struct wf_client * client); + +extern void * +wf_impl_client_get_userdata( + struct wf_client * client); + +extern void +wf_impl_client_service( + struct wf_client * client); + +extern void +wf_impl_client_interrupt( + struct wf_client * client); + +extern void +wf_impl_client_connect( + struct wf_client * client, + char const * url); + +extern void +wf_impl_client_disconnect( + struct wf_client * client); + +extern void +wf_impl_client_authenticate( + struct wf_client * client); + +extern void +wf_impl_client_add_filesystem( + struct wf_client * client, + char const * local_path, + char const * name); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/meson.build b/meson.build index 42edd6f..4f58ab0 100644 --- a/meson.build +++ b/meson.build @@ -132,6 +132,7 @@ webfuse_adapter_static = static_library('webfuse_adapter', 'lib/webfuse/adapter/impl/operation/open.c', 'lib/webfuse/adapter/impl/operation/close.c', 'lib/webfuse/adapter/impl/operation/read.c', + 'lib/webfuse/adapter/impl/client.c', c_args: ['-fvisibility=hidden'], include_directories: private_inc_dir, dependencies: [webfuse_core_dep, libfuse_dep])