Merge pull request #2 from falk-werner/master

Upstream upgrade
pull/72/head
nosamad 4 years ago committed by GitHub
commit 218909ee79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 3.10) cmake_minimum_required (VERSION 3.10)
project(webfuse VERSION 0.3.0 DESCRIPTION "Websocket filesystem based on libfuse") project(webfuse VERSION 0.4.0 DESCRIPTION "Websocket filesystem based on libfuse")
option(WITHOUT_TESTS "disable unit tests" OFF) option(WITHOUT_TESTS "disable unit tests" OFF)
option(WITHOUT_ADAPTER "disable adapter library" OFF) option(WITHOUT_ADAPTER "disable adapter library" OFF)

@ -5,7 +5,7 @@
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8 DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "webfuse" PROJECT_NAME = "webfuse"
PROJECT_NUMBER = 0.3.0 PROJECT_NUMBER = 0.4.0
PROJECT_BRIEF = "Websocket filesystem based on libfuse" PROJECT_BRIEF = "Websocket filesystem based on libfuse"
PROJECT_LOGO = PROJECT_LOGO =
OUTPUT_DIRECTORY = "doc/api" OUTPUT_DIRECTORY = "doc/api"

@ -1 +1 @@
0.3.0 0.4.0

@ -0,0 +1,38 @@
# webfuse changelog
## 0.4.0 _(unknown)_
### Fixes
* Fix meson build failure when gtest or jansson are not installed
* Fix crash if libfuse is not available at runtime
## 0.3.0 _(Fri Jun 05 2020)_
### Breaking Changes
* Remove argument `timeout_ms` in `wf_server_service` and `wfp_client_service`
* Remove `wfp_client_ontimer`
### New Features
* Add meson build support
* Add `wf_server_interrupt` and `wfp_client_interrupt`
## 0.2.0 _(Sun Mar 01 2020)_
### New Features
* Add authentication support of provider
* Add API documentation (doxygen)
* Add `mountpoint_factory`
* Add option to build adapter and provider libraries separately
### Fixes
* Fix crash of example when using option `-h`
* Fix error in `static_filesystem` providen when adding multiple files to same directory
## 0.1.0 _(Sat Apr 27 2019)_
* initial version

@ -22,7 +22,7 @@ in order to reduce build dependencies.
- **WITHOUT_ADAPTER**: omit adapter library - **WITHOUT_ADAPTER**: omit adapter library
`cmake -DWITHOUT_ADAPTER=ON` `cmake -DWITHOUT_ADAPTER=ON`
- **WIHTOU_PROVIDER**: omit provider library - **WIHTOUT_PROVIDER**: omit provider library
`cmake -DWITHOUT_PROVIDER=ON` `cmake -DWITHOUT_PROVIDER=ON`
## Build using Meson (experimental) ## Build using Meson (experimental)
@ -33,7 +33,24 @@ _Note: Meson build support is experimental. Do not rely on it._
cd .build cd .build
ninja build ninja build
_Note: Build options are not supported yet._ ### Meson Build options
Build options can be specified during meson setup or later via meson configure.
meson -D<option>=<value> .build
The following options are available:
- **without_tests**: _(boolean)_ diable tests
`meson -Dwithout_tests=true .build`
- **without_adapter**: _(boolean)_ omit adapter library
`meson -Dwithout_adapter=true .build`
- **without_provider**: _(boolean)_ omit provider library
`meson -Dwithout_provider=true .build`
_Note that unit tests are only available, when both libraries are built._
## Create API documentation ## Create API documentation

@ -109,8 +109,11 @@ bool wf_impl_session_add_filesystem(
if (result) if (result)
{ {
struct wf_impl_filesystem * filesystem = wf_impl_filesystem_create(session, name, mountpoint); struct wf_impl_filesystem * filesystem = wf_impl_filesystem_create(session, name, mountpoint);
wf_slist_append(&session->filesystems, &filesystem->item);
result = (NULL != filesystem); result = (NULL != filesystem);
if (result)
{
wf_slist_append(&session->filesystems, &filesystem->item);
}
} }
// cleanup on error // cleanup on error

@ -1,10 +1,17 @@
project('webfuse', 'c', 'cpp', version: '0.3.0', license: 'LGPL-3.0+') project('webfuse', 'c', 'cpp', version: '0.4.0', license: 'LGPL-3.0+')
without_adapter = get_option('without_adapter')
without_provider = get_option('without_provider')
without_tests = get_option('without_tests') or without_adapter or without_provider
libwebsockets_dep = dependency('libwebsockets', version: '>=4.0.13', required: false)
if not libwebsockets_dep.found()
cmake = import('cmake')
libwebsockets = cmake.subproject('libwebsockets')
libwebsockets_dep = libwebsockets.dependency('websockets_shared')
endif
libwebsockets_dep = dependency('libwebsockets', version: '>=4.0.1')
jansson_dep = dependency('jansson', version: '>=2.11', fallback: ['jansson', 'jansson_dep']) jansson_dep = dependency('jansson', version: '>=2.11', fallback: ['jansson', 'jansson_dep'])
libfuse_dep = dependency('fuse3', version: '>=3.8.0', fallback: ['fuse3', 'libfuse_dep'])
gtest_dep = dependency('gtest', version: '>=1.10.0', fallback: ['gtest', 'gtest_dep'])
gmock_main_dep = dependency('gmock_main', version: '>=1.10.0', fallback: ['gtest', 'gmock_main_main_dep'])
pkg_config = import('pkgconfig') pkg_config = import('pkgconfig')
@ -45,6 +52,8 @@ install_subdir('include/webfuse/core', install_dir: 'include/webfuse')
# Webfuse provider # Webfuse provider
if not without_provider
webfuse_provider_static = static_library('webfuse_provider', webfuse_provider_static = static_library('webfuse_provider',
'lib/webfuse/provider/api.c', 'lib/webfuse/provider/api.c',
'lib/webfuse/provider/impl/url.c', 'lib/webfuse/provider/impl/url.c',
@ -67,7 +76,8 @@ webfuse_provider_static = static_library('webfuse_provider',
webfuse_provider_static_dep = declare_dependency( webfuse_provider_static_dep = declare_dependency(
include_directories: inc_dir, include_directories: inc_dir,
link_with: webfuse_provider_static) link_with: webfuse_provider_static,
dependencies: [webfuse_core_dep])
webfuse_provider = shared_library('webfuse_provider', webfuse_provider = shared_library('webfuse_provider',
'lib/webfuse/provider/api.c', 'lib/webfuse/provider/api.c',
@ -86,15 +96,22 @@ install_headers('include/webfuse_provider.h', subdir: 'webfuse')
install_subdir('include/webfuse/provider', install_dir: 'include/webfuse') install_subdir('include/webfuse/provider', install_dir: 'include/webfuse')
pkg_config.generate( pkg_config.generate(
libraries: [webfuse_provider, jansson_dep, libwebsockets_dep], libraries: [webfuse_provider],
requires: ['libwebsockets', 'jansson'],
subdirs: '.', subdirs: '.',
version: meson.project_version(), version: meson.project_version(),
name: 'libwebfuse_provider', name: 'libwebfuse_provider',
filebase: 'webfuse_provider', filebase: 'webfuse_provider',
description: 'Provider library for websockets filesystem') description: 'Provider library for websockets filesystem')
endif
# Webfuse adapter # Webfuse adapter
if not without_adapter
libfuse_dep = dependency('fuse3', version: '>=3.8.0', fallback: ['fuse3', 'libfuse_dep'])
webfuse_adapter_static = static_library('webfuse_adapter', webfuse_adapter_static = static_library('webfuse_adapter',
'lib/webfuse/adapter/api.c', 'lib/webfuse/adapter/api.c',
'lib/webfuse/adapter/impl/filesystem.c', 'lib/webfuse/adapter/impl/filesystem.c',
@ -122,7 +139,7 @@ webfuse_adapter_static = static_library('webfuse_adapter',
webfuse_adapter_static_dep = declare_dependency( webfuse_adapter_static_dep = declare_dependency(
include_directories: inc_dir, include_directories: inc_dir,
link_with: [webfuse_adapter_static], link_with: [webfuse_adapter_static],
dependencies: [libfuse_dep]) dependencies: [webfuse_core_dep, libfuse_dep])
webfuse_adapter = shared_library('webfuse_adapter', webfuse_adapter = shared_library('webfuse_adapter',
'lib/webfuse/adapter/api.c', 'lib/webfuse/adapter/api.c',
@ -141,15 +158,23 @@ install_headers('include/webfuse_adapter.h', subdir: 'webfuse')
install_subdir('include/webfuse/adapter', install_dir: 'include/webfuse') install_subdir('include/webfuse/adapter', install_dir: 'include/webfuse')
pkg_config.generate( pkg_config.generate(
libraries: [webfuse_adapter, jansson_dep, libwebsockets_dep, libfuse_dep], libraries: [webfuse_adapter],
requires: ['fuse3', 'libwebsockets', 'jansson'],
subdirs: '.', subdirs: '.',
version: meson.project_version(), version: meson.project_version(),
name: 'libwebfuse_adapter', name: 'libwebfuse_adapter',
filebase: 'webfuse_adapter', filebase: 'webfuse_adapter',
description: 'Websockets filesystem server library') description: 'Websockets filesystem server library')
endif
# Unit Tests # Unit Tests
if not without_tests
gtest_dep = dependency('gtest', version: '>=1.10.0', fallback: ['gtest', 'gtest_dep'])
gmock_main_dep = dependency('gmock_main', version: '>=1.10.0', fallback: ['gtest', 'gmock_main_dep'])
fscheck = executable('fs_check', fscheck = executable('fs_check',
'test/webfuse/tests/integration/fs_check.c') 'test/webfuse/tests/integration/fs_check.c')
@ -258,3 +283,5 @@ alltests = executable('alltests',
]) ])
test('alltests', alltests) test('alltests', alltests)
endif

@ -0,0 +1,3 @@
option('without_tests', type: 'boolean', value: false, description: 'disable unit tests')
option('without_adapter', type: 'boolean', value: false, description: 'disable adapter library')
option('without_provider', type: 'boolean', value: false, description: 'disable provider library')

@ -0,0 +1,6 @@
[wrap-file]
directory = libwebsockets-4.0.13
source_url = https://github.com/warmcat/libwebsockets/archive/v4.0.13.zip
source_filename = v4.0.13.zip
source_hash = 0914ea3fdec496daf6b6a5c00f7ba1b52eb8cc3d55b66685df92920b232fd7a5

@ -9,6 +9,39 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
namespace
{
enum class ConnectionState
{
disconnected,
connected,
connecting
};
}
extern "C"
{
void
webfuse_test_provider_onconnected(
void * user_data)
{
auto * fs = reinterpret_cast<wfp_static_filesystem*>(user_data);
auto * connection_state = reinterpret_cast<ConnectionState*>(wfp_static_filesystem_get_user_data(fs));
*connection_state = ConnectionState::connected;
}
void
webfuse_test_provider_ondisconnected(
void * user_data)
{
auto * fs = reinterpret_cast<wfp_static_filesystem*>(user_data);
auto * connection_state = reinterpret_cast<ConnectionState*>(wfp_static_filesystem_get_user_data(fs));
*connection_state = ConnectionState::disconnected;
}
}
namespace webfuse_test namespace webfuse_test
{ {
@ -18,24 +51,41 @@ public:
explicit Private(char const * url) explicit Private(char const * url)
: is_shutdown_requested(false) : is_shutdown_requested(false)
{ {
ConnectionState connection_state = ConnectionState::connecting;
config = wfp_client_config_create(); config = wfp_client_config_create();
wfp_client_config_set_certpath(config, "client-cert.pem"); wfp_client_config_set_certpath(config, "client-cert.pem");
wfp_client_config_set_keypath(config, "client-key.pem"); wfp_client_config_set_keypath(config, "client-key.pem");
wfp_client_config_set_ca_filepath(config, "server-cert.pem"); wfp_client_config_set_ca_filepath(config, "server-cert.pem");
wfp_client_config_set_onconnected(config, &webfuse_test_provider_onconnected);
wfp_client_config_set_ondisconnected(config, &webfuse_test_provider_ondisconnected);
fs = wfp_static_filesystem_create(config); fs = wfp_static_filesystem_create(config);
wfp_static_filesystem_set_user_data(fs, reinterpret_cast<void*>(&connection_state));
wfp_static_filesystem_add_text(fs, "hello.txt", 0444, "Hello, World"); wfp_static_filesystem_add_text(fs, "hello.txt", 0444, "Hello, World");
client = wfp_client_create(config); client = wfp_client_create(config);
wfp_client_connect(client, url); wfp_client_connect(client, url);
while (!wfp_impl_client_is_connected(client)) while (ConnectionState::connecting == connection_state)
{ {
wfp_client_service(client); wfp_client_service(client);
} }
if (ConnectionState::connected == connection_state)
{
thread = std::thread(Run, this); thread = std::thread(Run, this);
std::this_thread::sleep_for(200ms); std::this_thread::sleep_for(200ms);
} }
else
{
wfp_client_dispose(client);
wfp_static_filesystem_dispose(fs);
wfp_client_config_dispose(config);
throw std::runtime_error("unable to connect");
}
}
~Private() ~Private()
{ {

@ -38,6 +38,7 @@ struct wfp_static_filesystem
struct wfp_static_filesystem_entry * entries; struct wfp_static_filesystem_entry * entries;
size_t size; size_t size;
size_t capacity; size_t capacity;
void * user_data;
}; };
static struct wfp_static_filesystem_entry * static struct wfp_static_filesystem_entry *
@ -335,6 +336,7 @@ wfp_static_filesystem_create(
filesystem->entries = malloc(sizeof(struct wfp_static_filesystem_entry) * WFP_STATIC_FILESYSTEM_DEFAULT_CAPACITY); filesystem->entries = malloc(sizeof(struct wfp_static_filesystem_entry) * WFP_STATIC_FILESYSTEM_DEFAULT_CAPACITY);
filesystem->size = 0; filesystem->size = 0;
filesystem->capacity = WFP_STATIC_FILESYSTEM_DEFAULT_CAPACITY; filesystem->capacity = WFP_STATIC_FILESYSTEM_DEFAULT_CAPACITY;
filesystem->user_data = NULL;
wfp_static_filesystem_add_dir(filesystem, 0, "<root>"); wfp_static_filesystem_add_dir(filesystem, 0, "<root>");
@ -402,3 +404,18 @@ wfp_static_filesystem_add_text(
size_t length = strlen(content); size_t length = strlen(content);
wfp_static_filesystem_add(filesystem, path, mode, content, length); wfp_static_filesystem_add(filesystem, path, mode, content, length);
} }
void
wfp_static_filesystem_set_user_data(
struct wfp_static_filesystem * filesystem,
void * user_data)
{
filesystem->user_data = user_data;
}
void *
wfp_static_filesystem_get_user_data(
struct wfp_static_filesystem * filesystem)
{
return filesystem->user_data;
}

@ -56,6 +56,15 @@ wfp_static_filesystem_add_text(
int mode, int mode,
char const * content); char const * content);
extern void
wfp_static_filesystem_set_user_data(
struct wfp_static_filesystem * filesystem,
void * user_data);
extern void *
wfp_static_filesystem_get_user_data(
struct wfp_static_filesystem * filesystem);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

Loading…
Cancel
Save