mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
renamed to webfuse
This commit is contained in:
parent
1c9d1c8420
commit
7447fb5dff
2
AUTHORS
2
AUTHORS
@ -1,4 +1,4 @@
|
|||||||
# This is the list of fuse-wsfs authors for copyright purposes.
|
# This is the list of webfuse authors for copyright purposes.
|
||||||
#
|
#
|
||||||
# This does not necessarily list everyone who has contributed code, since in
|
# This does not necessarily list everyone who has contributed code, since in
|
||||||
# some cases, their employer may be the copyright holder. To see the full list
|
# some cases, their employer may be the copyright holder. To see the full list
|
||||||
|
216
CMakeLists.txt
216
CMakeLists.txt
@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required (VERSION 3.10)
|
cmake_minimum_required (VERSION 3.10)
|
||||||
project(fuse-wsfs VERSION 0.1.0 DESCRIPTION "Websocket filesystem based on libfuse")
|
project(webfuse VERSION 0.1.0 DESCRIPTION "Websocket filesystem based on libfuse")
|
||||||
|
|
||||||
option(WITHOUT_TESTS "disable unit tests" OFF)
|
option(WITHOUT_TESTS "disable unit tests" OFF)
|
||||||
option(WITHOUT_EXAMPLE "disable example" OFF)
|
option(WITHOUT_EXAMPLE "disable example" OFF)
|
||||||
@ -45,142 +45,142 @@ set(EXTRA_CFLAGS
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# libwsfs-core
|
# libwebfuse-core
|
||||||
|
|
||||||
add_library(wsfs-core STATIC
|
add_library(webfuse-core STATIC
|
||||||
lib/wsfs/core/message.c
|
lib/webfuse/core/message.c
|
||||||
lib/wsfs/core/message_queue.c
|
lib/webfuse/core/message_queue.c
|
||||||
lib/wsfs/core/status.c
|
lib/webfuse/core/status.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(wsfs-core PROPERTIES OUTPUT_NAME wsfs-core)
|
set_target_properties(webfuse-core PROPERTIES OUTPUT_NAME webfuse-core)
|
||||||
target_include_directories(wsfs-core PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
target_include_directories(webfuse-core PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
||||||
target_compile_options(wsfs-core PUBLIC ${EXTRA_CFLAGS})
|
target_compile_options(webfuse-core PUBLIC ${EXTRA_CFLAGS})
|
||||||
set_target_properties(wsfs-core PROPERTIES C_VISIBILITY_PRESET hidden)
|
set_target_properties(webfuse-core PROPERTIES C_VISIBILITY_PRESET hidden)
|
||||||
|
|
||||||
install(DIRECTORY include/wsfs/core DESTINATION include/wsfs)
|
install(DIRECTORY include/webfuse/core DESTINATION include/webfuse)
|
||||||
|
|
||||||
|
|
||||||
# libwsfs-adapter
|
# libwebfuse-adapter
|
||||||
|
|
||||||
add_library(wsfs-adapter-static STATIC
|
add_library(webfuse-adapter-static STATIC
|
||||||
lib/wsfs/adapter/api.c
|
lib/webfuse/adapter/api.c
|
||||||
lib/wsfs/adapter/impl/filesystem.c
|
lib/webfuse/adapter/impl/filesystem.c
|
||||||
lib/wsfs/adapter/impl/server.c
|
lib/webfuse/adapter/impl/server.c
|
||||||
lib/wsfs/adapter/impl/server_config.c
|
lib/webfuse/adapter/impl/server_config.c
|
||||||
lib/wsfs/adapter/impl/server_protocol.c
|
lib/webfuse/adapter/impl/server_protocol.c
|
||||||
lib/wsfs/adapter/impl/session.c
|
lib/webfuse/adapter/impl/session.c
|
||||||
lib/wsfs/adapter/impl/session_manager.c
|
lib/webfuse/adapter/impl/session_manager.c
|
||||||
lib/wsfs/adapter/impl/authenticator.c
|
lib/webfuse/adapter/impl/authenticator.c
|
||||||
lib/wsfs/adapter/impl/authenticators.c
|
lib/webfuse/adapter/impl/authenticators.c
|
||||||
lib/wsfs/adapter/impl/credentials.c
|
lib/webfuse/adapter/impl/credentials.c
|
||||||
lib/wsfs/adapter/impl/time/timepoint.c
|
lib/webfuse/adapter/impl/time/timepoint.c
|
||||||
lib/wsfs/adapter/impl/time/timer.c
|
lib/webfuse/adapter/impl/time/timer.c
|
||||||
lib/wsfs/adapter/impl/time/timeout_manager.c
|
lib/webfuse/adapter/impl/time/timeout_manager.c
|
||||||
lib/wsfs/adapter/impl/operation/lookup.c
|
lib/webfuse/adapter/impl/operation/lookup.c
|
||||||
lib/wsfs/adapter/impl/operation/getattr.c
|
lib/webfuse/adapter/impl/operation/getattr.c
|
||||||
lib/wsfs/adapter/impl/operation/readdir.c
|
lib/webfuse/adapter/impl/operation/readdir.c
|
||||||
lib/wsfs/adapter/impl/operation/open.c
|
lib/webfuse/adapter/impl/operation/open.c
|
||||||
lib/wsfs/adapter/impl/operation/close.c
|
lib/webfuse/adapter/impl/operation/close.c
|
||||||
lib/wsfs/adapter/impl/operation/read.c
|
lib/webfuse/adapter/impl/operation/read.c
|
||||||
lib/wsfs/adapter/impl/jsonrpc/server.c
|
lib/webfuse/adapter/impl/jsonrpc/server.c
|
||||||
lib/wsfs/adapter/impl/jsonrpc/method.c
|
lib/webfuse/adapter/impl/jsonrpc/method.c
|
||||||
lib/wsfs/adapter/impl/jsonrpc/request.c
|
lib/webfuse/adapter/impl/jsonrpc/request.c
|
||||||
lib/wsfs/adapter/impl/jsonrpc/response.c
|
lib/webfuse/adapter/impl/jsonrpc/response.c
|
||||||
lib/wsfs/adapter/impl/jsonrpc/util.c
|
lib/webfuse/adapter/impl/jsonrpc/util.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(wsfs-adapter-static PROPERTIES OUTPUT_NAME wsfs-adapter)
|
set_target_properties(webfuse-adapter-static PROPERTIES OUTPUT_NAME webfuse-adapter)
|
||||||
target_include_directories(wsfs-adapter-static PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
target_include_directories(webfuse-adapter-static PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
||||||
target_compile_options(wsfs-adapter-static PUBLIC ${EXTRA_CFLAGS})
|
target_compile_options(webfuse-adapter-static PUBLIC ${EXTRA_CFLAGS})
|
||||||
set_target_properties(wsfs-adapter-static PROPERTIES C_VISIBILITY_PRESET hidden)
|
set_target_properties(webfuse-adapter-static PROPERTIES C_VISIBILITY_PRESET hidden)
|
||||||
|
|
||||||
add_library(wsfs-adapter SHARED
|
add_library(webfuse-adapter SHARED
|
||||||
lib/wsfs/adapter/api.c
|
lib/webfuse/adapter/api.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(wsfs-adapter PROPERTIES VERSION ${PROJECT_VERSION})
|
set_target_properties(webfuse-adapter PROPERTIES VERSION ${PROJECT_VERSION})
|
||||||
set_target_properties(wsfs-adapter PROPERTIES SOVERSION 0)
|
set_target_properties(webfuse-adapter PROPERTIES SOVERSION 0)
|
||||||
set_target_properties(wsfs-adapter PROPERTIES C_VISIBILITY_PRESET hidden)
|
set_target_properties(webfuse-adapter PROPERTIES C_VISIBILITY_PRESET hidden)
|
||||||
set_target_properties(wsfs-adapter PROPERTIES COMPILE_DEFINITIONS "WSFSA_API=WSFSA_EXPORT")
|
set_target_properties(webfuse-adapter PROPERTIES COMPILE_DEFINITIONS "WF_API=WF_EXPORT")
|
||||||
|
|
||||||
target_include_directories(wsfs-adapter PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
target_include_directories(webfuse-adapter PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
||||||
target_compile_options(wsfs-adapter PUBLIC ${EXTRA_CFLAGS})
|
target_compile_options(webfuse-adapter PUBLIC ${EXTRA_CFLAGS})
|
||||||
target_link_libraries(wsfs-adapter PRIVATE wsfs-adapter-static wsfs-core)
|
target_link_libraries(webfuse-adapter PRIVATE webfuse-adapter-static webfuse-core)
|
||||||
|
|
||||||
file(WRITE "${PROJECT_BINARY_DIR}/libwsfs-adapter.pc"
|
file(WRITE "${PROJECT_BINARY_DIR}/libwebfuse-adapter.pc"
|
||||||
"prefix=\"${CMAKE_INSTALL_PREFIX}\"
|
"prefix=\"${CMAKE_INSTALL_PREFIX}\"
|
||||||
|
|
||||||
exec_prefix=\${prefix}
|
exec_prefix=\${prefix}
|
||||||
libdir=\${exec_prefix}/lib${LIB_SUFFIX}
|
libdir=\${exec_prefix}/lib${LIB_SUFFIX}
|
||||||
includedir=\${prefix}/include
|
includedir=\${prefix}/include
|
||||||
Name: libwsfs
|
Name: libwebfuse
|
||||||
Description: Websockets filesystem server library
|
Description: Websockets filesystem server library
|
||||||
Version: ${PROJECT_VERSION}
|
Version: ${PROJECT_VERSION}
|
||||||
|
|
||||||
Libs: -L\${libdir} -lwsfs-adapter -l${FUSE3_LIBRARIES} -l${LWS_LIBRARIES} -l${JANSSON_LIBRARIES}
|
Libs: -L\${libdir} -lwebfuse-adapter -l${FUSE3_LIBRARIES} -l${LWS_LIBRARIES} -l${JANSSON_LIBRARIES}
|
||||||
Cflags: -I\${includedir}"
|
Cflags: -I\${includedir}"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS wsfs-adapter DESTINATION lib${LIB_SUFFIX})
|
install(TARGETS webfuse-adapter DESTINATION lib${LIB_SUFFIX})
|
||||||
install(FILES include/wsfs_adapter.h DESTINATION include)
|
install(FILES include/webfuse_adapter.h DESTINATION include)
|
||||||
install(DIRECTORY include/wsfs/adapter DESTINATION include/wsfs)
|
install(DIRECTORY include/webfuse/adapter DESTINATION include/webfuse)
|
||||||
install(FILES "${PROJECT_BINARY_DIR}/libwsfs-adapter.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig)
|
install(FILES "${PROJECT_BINARY_DIR}/libwebfuse-adapter.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig)
|
||||||
|
|
||||||
#libwsfs-provider
|
#libwebfuse-provider
|
||||||
|
|
||||||
add_library(wsfs-provider-static STATIC
|
add_library(webfuse-provider-static STATIC
|
||||||
lib/wsfs/provider/api.c
|
lib/webfuse/provider/api.c
|
||||||
lib/wsfs/provider/impl/url.c
|
lib/webfuse/provider/impl/url.c
|
||||||
lib/wsfs/provider/impl/client.c
|
lib/webfuse/provider/impl/client.c
|
||||||
lib/wsfs/provider/impl/client_config.c
|
lib/webfuse/provider/impl/client_config.c
|
||||||
lib/wsfs/provider/impl/client_protocol.c
|
lib/webfuse/provider/impl/client_protocol.c
|
||||||
lib/wsfs/provider/impl/provider.c
|
lib/webfuse/provider/impl/provider.c
|
||||||
lib/wsfs/provider/impl/request.c
|
lib/webfuse/provider/impl/request.c
|
||||||
lib/wsfs/provider/impl/dirbuffer.c
|
lib/webfuse/provider/impl/dirbuffer.c
|
||||||
lib/wsfs/provider/impl/operation/lookup.c
|
lib/webfuse/provider/impl/operation/lookup.c
|
||||||
lib/wsfs/provider/impl/operation/getattr.c
|
lib/webfuse/provider/impl/operation/getattr.c
|
||||||
lib/wsfs/provider/impl/operation/readdir.c
|
lib/webfuse/provider/impl/operation/readdir.c
|
||||||
lib/wsfs/provider/impl/operation/open.c
|
lib/webfuse/provider/impl/operation/open.c
|
||||||
lib/wsfs/provider/impl/operation/close.c
|
lib/webfuse/provider/impl/operation/close.c
|
||||||
lib/wsfs/provider/impl/operation/read.c
|
lib/webfuse/provider/impl/operation/read.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(wsfs-provider-static PROPERTIES OUTPUT_NAME wsfs-provider)
|
set_target_properties(webfuse-provider-static PROPERTIES OUTPUT_NAME webfuse-provider)
|
||||||
target_include_directories(wsfs-provider-static PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
target_include_directories(webfuse-provider-static PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
||||||
target_compile_options(wsfs-provider-static PUBLIC ${EXTRA_CFLAGS})
|
target_compile_options(webfuse-provider-static PUBLIC ${EXTRA_CFLAGS})
|
||||||
set_target_properties(wsfs-provider-static PROPERTIES C_VISIBILITY_PRESET hidden)
|
set_target_properties(webfuse-provider-static PROPERTIES C_VISIBILITY_PRESET hidden)
|
||||||
|
|
||||||
add_library(wsfs-provider SHARED
|
add_library(webfuse-provider SHARED
|
||||||
lib/wsfs/provider/api.c
|
lib/webfuse/provider/api.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(wsfs-provider PROPERTIES VERSION ${PROJECT_VERSION})
|
set_target_properties(webfuse-provider PROPERTIES VERSION ${PROJECT_VERSION})
|
||||||
set_target_properties(wsfs-provider PROPERTIES SOVERSION 0)
|
set_target_properties(webfuse-provider PROPERTIES SOVERSION 0)
|
||||||
set_target_properties(wsfs-provider PROPERTIES C_VISIBILITY_PRESET hidden)
|
set_target_properties(webfuse-provider PROPERTIES C_VISIBILITY_PRESET hidden)
|
||||||
set_target_properties(wsfs-provider PROPERTIES COMPILE_DEFINITIONS "WSFSP_API=WSFSP_EXPORT")
|
set_target_properties(webfuse-provider PROPERTIES COMPILE_DEFINITIONS "WFP_API=WFP_EXPORT")
|
||||||
|
|
||||||
target_include_directories(wsfs-provider PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
target_include_directories(webfuse-provider PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
||||||
target_compile_options(wsfs-provider PUBLIC ${EXTRA_CFLAGS})
|
target_compile_options(webfuse-provider PUBLIC ${EXTRA_CFLAGS})
|
||||||
target_link_libraries(wsfs-provider PRIVATE wsfs-provider-static wsfs-core)
|
target_link_libraries(webfuse-provider PRIVATE webfuse-provider-static webfuse-core)
|
||||||
|
|
||||||
file(WRITE "${PROJECT_BINARY_DIR}/libwsfs-provider.pc"
|
file(WRITE "${PROJECT_BINARY_DIR}/libwebfuse-provider.pc"
|
||||||
"prefix=\"${CMAKE_INSTALL_PREFIX}\"
|
"prefix=\"${CMAKE_INSTALL_PREFIX}\"
|
||||||
exec_prefix=\${prefix}
|
exec_prefix=\${prefix}
|
||||||
libdir=\${exec_prefix}/lib${LIB_SUFFIX}
|
libdir=\${exec_prefix}/lib${LIB_SUFFIX}
|
||||||
includedir=\${prefix}/include
|
includedir=\${prefix}/include
|
||||||
Name: libwsfs-provider
|
Name: libwebfuse-provider
|
||||||
Description: Provider library for websockets filesystem
|
Description: Provider library for websockets filesystem
|
||||||
Version: ${PROJECT_VERSION}
|
Version: ${PROJECT_VERSION}
|
||||||
|
|
||||||
Libs: -L\${libdir} -lwsfs-provider -l${LWS_LIBRARIES} -l${JANSSON_LIBRARIES}
|
Libs: -L\${libdir} -lwebfuse-provider -l${LWS_LIBRARIES} -l${JANSSON_LIBRARIES}
|
||||||
Cflags: -I\${includedir}"
|
Cflags: -I\${includedir}"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS wsfs-provider DESTINATION lib${LIB_SUFFIX})
|
install(TARGETS webfuse-provider DESTINATION lib${LIB_SUFFIX})
|
||||||
install(FILES include/wsfs_provider.h DESTINATION include)
|
install(FILES include/webfuse_provider.h DESTINATION include)
|
||||||
install(DIRECTORY include/wsfs/provider DESTINATION include/wsfs)
|
install(DIRECTORY include/webfuse/provider DESTINATION include/webfuse)
|
||||||
install(FILES "${PROJECT_BINARY_DIR}/libwsfs-provider.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig)
|
install(FILES "${PROJECT_BINARY_DIR}/libwebfuse-provider.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig)
|
||||||
|
|
||||||
|
|
||||||
# examples
|
# examples
|
||||||
@ -207,49 +207,49 @@ target_compile_options(userdb PUBLIC
|
|||||||
|
|
||||||
# daemon
|
# daemon
|
||||||
|
|
||||||
add_executable(wsfsd
|
add_executable(webfused
|
||||||
example/daemon/main.c
|
example/daemon/main.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(wsfsd PUBLIC wsfs-adapter ${EXTRA_LIBS})
|
target_link_libraries(webfused PUBLIC webfuse-adapter ${EXTRA_LIBS})
|
||||||
target_include_directories(wsfsd PUBLIC ${EXTRA_INCLUDE_DIRS})
|
target_include_directories(webfused PUBLIC ${EXTRA_INCLUDE_DIRS})
|
||||||
target_compile_options(wsfsd PUBLIC ${EXTRA_CFLAGS})
|
target_compile_options(webfused PUBLIC ${EXTRA_CFLAGS})
|
||||||
|
|
||||||
# provider
|
# provider
|
||||||
|
|
||||||
add_executable(wsfs-provider-app
|
add_executable(webfuse-provider-app
|
||||||
example/provider/main.c
|
example/provider/main.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(wsfs-provider-app PROPERTIES OUTPUT_NAME wsfs-provider)
|
set_target_properties(webfuse-provider-app PROPERTIES OUTPUT_NAME webfuse-provider)
|
||||||
|
|
||||||
target_link_libraries(wsfs-provider-app PUBLIC wsfs-provider ${EXTRA_LIBS})
|
target_link_libraries(webfuse-provider-app PUBLIC webfuse-provider ${EXTRA_LIBS})
|
||||||
target_include_directories(wsfs-provider-app PUBLIC ${EXTRA_INCLUDE_DIRS})
|
target_include_directories(webfuse-provider-app PUBLIC ${EXTRA_INCLUDE_DIRS})
|
||||||
target_compile_options(wsfs-provider-app PUBLIC ${EXTRA_CFLAGS})
|
target_compile_options(webfuse-provider-app PUBLIC ${EXTRA_CFLAGS})
|
||||||
|
|
||||||
# wsfs-passwd
|
# webfuse-passwd
|
||||||
|
|
||||||
pkg_check_modules(OPENSSL REQUIRED openssl)
|
pkg_check_modules(OPENSSL REQUIRED openssl)
|
||||||
|
|
||||||
|
|
||||||
add_executable(wsfs-passwd
|
add_executable(webfuse-passwd
|
||||||
example/passwd/main.c
|
example/passwd/main.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(wsfs-passwd PUBLIC
|
target_link_libraries(webfuse-passwd PUBLIC
|
||||||
userdb
|
userdb
|
||||||
${OPENSSL_LIBRARIES}
|
${OPENSSL_LIBRARIES}
|
||||||
${JANSSON_LIBRARIES}
|
${JANSSON_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(wsfs-passwd PUBLIC
|
target_include_directories(webfuse-passwd PUBLIC
|
||||||
example/passwd
|
example/passwd
|
||||||
example/lib/userdb/include
|
example/lib/userdb/include
|
||||||
${OPENSSL_INCLUDE_DIRS}
|
${OPENSSL_INCLUDE_DIRS}
|
||||||
${JANSSON_INCLUDE_DIRS}
|
${JANSSON_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(wsfs-passwd PUBLIC
|
target_compile_options(webfuse-passwd PUBLIC
|
||||||
${C_WARNINGS}
|
${C_WARNINGS}
|
||||||
${OPENSSL_CFLAGS_OTHER}
|
${OPENSSL_CFLAGS_OTHER}
|
||||||
${JANSSON_CFLAGS_OTHER}
|
${JANSSON_CFLAGS_OTHER}
|
||||||
@ -281,7 +281,7 @@ add_executable(alltests
|
|||||||
test/test_authenticators.cc
|
test/test_authenticators.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(alltests PUBLIC wsfs-adapter-static wsfs-provider-static wsfs-core ${EXTRA_LIBS} ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(alltests PUBLIC webfuse-adapter-static webfuse-provider-static webfuse-core ${EXTRA_LIBS} ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES})
|
||||||
target_include_directories(alltests PUBLIC lib ${EXTRA_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS})
|
target_include_directories(alltests PUBLIC lib ${EXTRA_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS})
|
||||||
target_compile_options(alltests PUBLIC ${EXTRA_CFLAGS} ${GMOCK_CFLAGS} ${GTEST_CFLAGS})
|
target_compile_options(alltests PUBLIC ${EXTRA_CFLAGS} ${GMOCK_CFLAGS} ${GTEST_CFLAGS})
|
||||||
|
|
||||||
|
2
Makefile
2
Makefile
@ -9,7 +9,7 @@ export BUILDTIME ?= $(shell date -u -d '@$(SOURCE_DATE_EPOCH)' --rfc-3339 ns 2>/
|
|||||||
VERBOSE ?=
|
VERBOSE ?=
|
||||||
MARCH ?=
|
MARCH ?=
|
||||||
|
|
||||||
PROJECT_NAME ?= webfs
|
PROJECT_NAME ?= webfuse
|
||||||
PROJECT_ROOT ?= .
|
PROJECT_ROOT ?= .
|
||||||
VERSION ?= $(shell cat $(PROJECT_ROOT)/VERSION)
|
VERSION ?= $(shell cat $(PROJECT_ROOT)/VERSION)
|
||||||
OUT ?= $(PROJECT_ROOT)/.build
|
OUT ?= $(PROJECT_ROOT)/.build
|
||||||
|
46
README.md
46
README.md
@ -1,9 +1,9 @@
|
|||||||
[![Build Status](https://travis-ci.org/falk-werner/fuse-wsfs.svg?branch=master)](https://travis-ci.org/falk-werner/fuse-wsfs)
|
[![Build Status](https://travis-ci.org/falk-werner/webfuse.svg?branch=master)](https://travis-ci.org/falk-werner/webfuse)
|
||||||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d6c20d37bb3a456a9c0ee224001081b2)](https://www.codacy.com/app/falk.werner/fuse-wsfs?utm_source=github.com&utm_medium=referral&utm_content=falk-werner/fuse-wsfs&utm_campaign=Badge_Grade)
|
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d6c20d37bb3a456a9c0ee224001081b2)](https://www.codacy.com/app/falk.werner/webfuse?utm_source=github.com&utm_medium=referral&utm_content=falk-werner/webfuse&utm_campaign=Badge_Grade)
|
||||||
|
|
||||||
# fuse-wsfs
|
# webfuse
|
||||||
|
|
||||||
fuse-wsfs combines libwebsockets and libfuse. It allows ot attach a remote filesystem via websockets.
|
webfuse combines libwebsockets and libfuse. It allows ot attach a remote filesystem via websockets.
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
@ -29,13 +29,13 @@ However at least one (unecessary) copy of the upload file is needed on the devic
|
|||||||
|
|
||||||
To avoid Steps 1 and 2, it would be great to keep the update file entirely in web server, just like [NFS](https://en.wikipedia.org/wiki/Network_File_System) or [WebDAV](https://wiki.archlinux.org/index.php/WebDAV). Unfortunately, NFS is not based on any protocol, natively usable by a web application. WebDAV is based on HTTP, but it needs a server providing the update file.
|
To avoid Steps 1 and 2, it would be great to keep the update file entirely in web server, just like [NFS](https://en.wikipedia.org/wiki/Network_File_System) or [WebDAV](https://wiki.archlinux.org/index.php/WebDAV). Unfortunately, NFS is not based on any protocol, natively usable by a web application. WebDAV is based on HTTP, but it needs a server providing the update file.
|
||||||
|
|
||||||
fuse-wsfs solves this problem by using the [WebSocket](https://en.wikipedia.org/wiki/WebSocket) protocol. The emdedded device runs a service, known as WSFS adapter, awaiting incoming connections, e.g. from a web browser. The browser acts as a file system provider, providing the update file to the device.
|
webfuse solves this problem by using the [WebSocket](https://en.wikipedia.org/wiki/WebSocket) protocol. The emdedded device runs a service, known as webfuse adapter, awaiting incoming connections, e.g. from a web browser. The browser acts as a file system provider, providing the update file to the device.
|
||||||
|
|
||||||
## Concecpt
|
## Concecpt
|
||||||
|
|
||||||
+---------------------+ +-------------+ +------+
|
+---------------------+ +-------------+ +------+
|
||||||
| Filesystem Provider | | wsfs daemon | | user |
|
| Filesystem Provider | | webfuse | | user |
|
||||||
| (e.g. Webbrowser) | | | | |
|
| (e.g. Webbrowser) | | daemon | | |
|
||||||
+----------+----------+ +------+------+ +---+--+
|
+----------+----------+ +------+------+ +---+--+
|
||||||
| | |
|
| | |
|
||||||
| +-+-+ |
|
| +-+-+ |
|
||||||
@ -62,18 +62,18 @@ fuse-wsfs solves this problem by using the [WebSocket](https://en.wikipedia.org/
|
|||||||
| +-+-+ +-+-+
|
| +-+-+ +-+-+
|
||||||
| | |
|
| | |
|
||||||
|
|
||||||
With fuse-wsfs it is possible to implement remote filesystems based on websockets.
|
With webfuse it is possible to implement remote filesystems based on websockets.
|
||||||
A reference implementation of such a daemon is provided within the examples. The picture above describes the workflow:
|
A reference implementation of such a daemon is provided within the examples. The picture above describes the workflow:
|
||||||
|
|
||||||
- The websocket filesystem daemon (*wsfs daemon*) mounts a filesystem on startup.
|
- The websocket filesystem daemon (*webfuse daemon*) mounts a filesystem on startup.
|
||||||
It starts the websocket server and waits for incoming connections.
|
It starts the websocket server and waits for incoming connections.
|
||||||
|
|
||||||
- A remote filesystem provider connects to wsfs daemon via websocket protocol.
|
- A remote filesystem provider connects to webfuse daemon via websocket protocol.
|
||||||
The example includes such a provider implemented in HTML and JavaScript.
|
The example includes such a provider implemented in HTML and JavaScript.
|
||||||
|
|
||||||
- Whenever the user makes filesystem requests, such as *ls*, the request is redirected via wsfs daemon to the connected filesystem provider
|
- Whenever the user makes filesystem requests, such as *ls*, the request is redirected via webfuse daemon to the connected filesystem provider
|
||||||
|
|
||||||
Currently all requests are initiated by wsfs daemon and responded by filesystem provider. This may change in future, e.g. when authentication is supported.
|
Currently all requests are initiated by webfuse daemon and responded by filesystem provider. This may change in future, e.g. when authentication is supported.
|
||||||
|
|
||||||
## Similar Projects
|
## Similar Projects
|
||||||
|
|
||||||
@ -81,13 +81,13 @@ Currently all requests are initiated by wsfs daemon and responded by filesystem
|
|||||||
|
|
||||||
[davfs2](http://savannah.nongnu.org/projects/davfs2) is a Linux file system driver that allows to mount a [WebDAV](https://wiki.archlinux.org/index.php/WebDAV) resource. WebDAV is an extension to HTTP/1.1 that allows remote collaborative authoring of Web resources.
|
[davfs2](http://savannah.nongnu.org/projects/davfs2) is a Linux file system driver that allows to mount a [WebDAV](https://wiki.archlinux.org/index.php/WebDAV) resource. WebDAV is an extension to HTTP/1.1 that allows remote collaborative authoring of Web resources.
|
||||||
|
|
||||||
Unlike fuse-wsfs, davfs2 mounts a remote filesystem locally, that is provided by a WebDAV server. In contrast, fuse-wsfs starts a server awaiting client connections to attach the remote file system.
|
Unlike webfuse, davfs2 mounts a remote filesystem locally, that is provided by a WebDAV server. In contrast, webfuse starts a server awaiting client connections to attach the remote file system.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
### Requests, responses and notifications
|
### Requests, responses and notifications
|
||||||
|
|
||||||
There are three types of messages, used for communication between wsfs daemon and filesystem provider. All message types are encoded in [JSON](https://www.json.org/) and strongly inspired by [JSON-RPC](https://www.jsonrpc.org/).
|
There are three types of messages, used for communication between webfuse daemon and filesystem provider. All message types are encoded in [JSON](https://www.json.org/) and strongly inspired by [JSON-RPC](https://www.jsonrpc.org/).
|
||||||
|
|
||||||
#### Request
|
#### Request
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ Notfications are used to inform a receiver about something. Unlike requests, not
|
|||||||
|
|
||||||
Retrieve information about a filesystem entry by name.
|
Retrieve information about a filesystem entry by name.
|
||||||
|
|
||||||
wsfs daemon: {"method": "lookup", "params": [<parent>, <name>], "id": <id>}
|
webfuse daemon: {"method": "lookup", "params": [<parent>, <name>], "id": <id>}
|
||||||
fs provider: {"result": {
|
fs provider: {"result": {
|
||||||
"inode": <inode>,
|
"inode": <inode>,
|
||||||
"mode" : <mode>,
|
"mode" : <mode>,
|
||||||
@ -195,7 +195,7 @@ Retrieve information about a filesystem entry by name.
|
|||||||
|
|
||||||
Get file attributes.
|
Get file attributes.
|
||||||
|
|
||||||
wsfs daemon: {"method": "getattr", "params": [<inode>], "id": <id>}
|
webfuse daemon: {"method": "getattr", "params": [<inode>], "id": <id>}
|
||||||
fs provider: {"result": {
|
fs provider: {"result": {
|
||||||
"mode" : <mode>,
|
"mode" : <mode>,
|
||||||
"type" : <type>,
|
"type" : <type>,
|
||||||
@ -221,7 +221,7 @@ Read directory contents.
|
|||||||
Result is an array of name-inode pairs for each entry. The generic entries
|
Result is an array of name-inode pairs for each entry. The generic entries
|
||||||
"." and ".." should also be provided.
|
"." and ".." should also be provided.
|
||||||
|
|
||||||
wsfs daemon: {"method": "readdir", "params": [<dir_inode>], "id": <id>}
|
webfuse daemon: {"method": "readdir", "params": [<dir_inode>], "id": <id>}
|
||||||
fs provider: {"result": [
|
fs provider: {"result": [
|
||||||
{"name": <name>, "inode": <inode>},
|
{"name": <name>, "inode": <inode>},
|
||||||
...
|
...
|
||||||
@ -237,7 +237,7 @@ Result is an array of name-inode pairs for each entry. The generic entries
|
|||||||
|
|
||||||
Open a file.
|
Open a file.
|
||||||
|
|
||||||
wsfs daemon: {"method": "readdir", "params": [<inode>, <flags>], "id": <id>}
|
webfuse daemon: {"method": "readdir", "params": [<inode>, <flags>], "id": <id>}
|
||||||
fs provider: {"result": {"handle": <handle>}, "id": <id>}
|
fs provider: {"result": {"handle": <handle>}, "id": <id>}
|
||||||
|
|
||||||
| Item | Data type | Description |
|
| Item | Data type | Description |
|
||||||
@ -264,7 +264,7 @@ Open a file.
|
|||||||
Informs filesystem provider, that a file is closed.
|
Informs filesystem provider, that a file is closed.
|
||||||
Since `close` is a notification, it cannot fail.
|
Since `close` is a notification, it cannot fail.
|
||||||
|
|
||||||
wsfs daemon: {"method": "close", "params": [<inode>, <handle>, <flags>], "id": <id>}
|
webfuse daemon: {"method": "close", "params": [<inode>, <handle>, <flags>], "id": <id>}
|
||||||
|
|
||||||
| Item | Data type | Description |
|
| Item | Data type | Description |
|
||||||
| ----------- | ----------| ---------------------------- |
|
| ----------- | ----------| ---------------------------- |
|
||||||
@ -276,7 +276,7 @@ Since `close` is a notification, it cannot fail.
|
|||||||
|
|
||||||
Read from an open file.
|
Read from an open file.
|
||||||
|
|
||||||
wsfs daemon: {"method": "close", "params": [<inode>, <handle>, <offset>, <length>], "id": <id>}
|
webfuse daemon: {"method": "close", "params": [<inode>, <handle>, <offset>, <length>], "id": <id>}
|
||||||
fs provider: {"result": {
|
fs provider: {"result": {
|
||||||
"data": <data>,
|
"data": <data>,
|
||||||
"format": <format>,
|
"format": <format>,
|
||||||
@ -304,12 +304,12 @@ Read from an open file.
|
|||||||
|
|
||||||
To install dependencies, see below.
|
To install dependencies, see below.
|
||||||
|
|
||||||
cd fuse-wsfs
|
cd webfuse
|
||||||
mkdir .build
|
mkdir .build
|
||||||
cd .build
|
cd .build
|
||||||
cmake ..
|
cmake ..
|
||||||
mkdir test
|
mkdir test
|
||||||
./wsfsd -m test --document_root=../exmaple/daemon/www --port=4711
|
./webfused -m test --document_root=../exmaple/daemon/www --port=4711
|
||||||
|
|
||||||
### Build options
|
### Build options
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ By default, unit tests and example application are enabled. You can disable them
|
|||||||
|
|
||||||
#### GoogleTest
|
#### GoogleTest
|
||||||
|
|
||||||
Installation of GoogleTest is optional fuse-wsfs library, but required to compile tests.
|
Installation of GoogleTest is optional webfuse library, but required to compile tests.
|
||||||
|
|
||||||
wget -O gtest-1.8.1.tar.gz https://github.com/google/googletest/archive/release-1.8.1.tar.gz
|
wget -O gtest-1.8.1.tar.gz https://github.com/google/googletest/archive/release-1.8.1.tar.gz
|
||||||
tar -xf gtest-1.8.1.tar.gz
|
tar -xf gtest-1.8.1.tar.gz
|
||||||
|
@ -9,25 +9,25 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
|
|
||||||
#include <wsfs_adapter.h>
|
#include <webfuse_adapter.h>
|
||||||
|
|
||||||
|
|
||||||
struct args
|
struct args
|
||||||
{
|
{
|
||||||
struct wsfs_server_config * config;
|
struct wf_server_config * config;
|
||||||
char * passwd_path;
|
char * passwd_path;
|
||||||
bool show_help;
|
bool show_help;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct wsfs_server * server;
|
static struct wf_server * server;
|
||||||
|
|
||||||
static void show_help(void)
|
static void show_help(void)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"wsfsd, Copyright (c) 2019, Falk Werner\n"
|
"webfused, Copyright (c) 2019, webfuse authors <https://github.com/falk-werner/webfuse>\n"
|
||||||
"Websocket file system daemon\n"
|
"Websocket file system daemon\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Usage: wsfsd [m <mount_point>] [-d <document_root] [-n <vhost_name>] [-p <port>]\n"
|
"Usage: webfused [m <mount_point>] [-d <document_root] [-n <vhost_name>] [-p <port>]\n"
|
||||||
" [-c <server_cert_path>] [-k <server_key_path>] [-P <passwd_path>]\n"
|
" [-c <server_cert_path>] [-k <server_key_path>] [-P <passwd_path>]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
@ -41,13 +41,13 @@ static void show_help(void)
|
|||||||
"\n");
|
"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool authenticate(struct wsfs_credentials * creds, void * user_data)
|
static bool authenticate(struct wf_credentials * creds, void * user_data)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
struct args * args = user_data;
|
struct args * args = user_data;
|
||||||
|
|
||||||
char const * username = wsfs_credentials_get(creds, "username");
|
char const * username = wf_credentials_get(creds, "username");
|
||||||
char const * password = wsfs_credentials_get(creds, "password");
|
char const * password = wf_credentials_get(creds, "password");
|
||||||
if ((NULL != username) && (NULL != password))
|
if ((NULL != username) && (NULL != password))
|
||||||
{
|
{
|
||||||
json_t * passwd = json_load_file(args->passwd_path, 0, NULL);
|
json_t * passwd = json_load_file(args->passwd_path, 0, NULL);
|
||||||
@ -103,28 +103,28 @@ static int parse_arguments(int argc, char * argv[], struct args * args)
|
|||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
wsfs_server_config_set_mountpoint(args->config, optarg);
|
wf_server_config_set_mountpoint(args->config, optarg);
|
||||||
has_mountpoint = true;
|
has_mountpoint = true;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
wsfs_server_config_set_documentroot(args->config, optarg);
|
wf_server_config_set_documentroot(args->config, optarg);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
wsfs_server_config_set_certpath(args->config, optarg);
|
wf_server_config_set_certpath(args->config, optarg);
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
wsfs_server_config_set_keypath(args->config, optarg);
|
wf_server_config_set_keypath(args->config, optarg);
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
wsfs_server_config_set_vhostname(args->config, optarg);
|
wf_server_config_set_vhostname(args->config, optarg);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
wsfs_server_config_set_port(args->config, atoi(optarg));
|
wf_server_config_set_port(args->config, atoi(optarg));
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
free(args->passwd_path);
|
free(args->passwd_path);
|
||||||
args->passwd_path = strdup(optarg);
|
args->passwd_path = strdup(optarg);
|
||||||
wsfs_server_config_add_authenticator(args->config,
|
wf_server_config_add_authenticator(args->config,
|
||||||
"username",
|
"username",
|
||||||
&authenticate,
|
&authenticate,
|
||||||
args);
|
args);
|
||||||
@ -157,15 +157,15 @@ static void on_interrupt(int signal_id)
|
|||||||
{
|
{
|
||||||
(void) signal_id;
|
(void) signal_id;
|
||||||
|
|
||||||
wsfs_server_shutdown(server);
|
wf_server_shutdown(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
struct args args;
|
struct args args;
|
||||||
args.config = wsfs_server_config_create();
|
args.config = wf_server_config_create();
|
||||||
wsfs_server_config_set_vhostname(args.config, "localhost");
|
wf_server_config_set_vhostname(args.config, "localhost");
|
||||||
wsfs_server_config_set_port(args.config, 8080);
|
wf_server_config_set_port(args.config, 8080);
|
||||||
args.passwd_path = NULL;
|
args.passwd_path = NULL;
|
||||||
args.show_help = false;
|
args.show_help = false;
|
||||||
|
|
||||||
@ -174,11 +174,11 @@ int main(int argc, char * argv[])
|
|||||||
if (!args.show_help)
|
if (!args.show_help)
|
||||||
{
|
{
|
||||||
signal(SIGINT, on_interrupt);
|
signal(SIGINT, on_interrupt);
|
||||||
server = wsfs_server_create(args.config);
|
server = wf_server_create(args.config);
|
||||||
if (NULL != server)
|
if (NULL != server)
|
||||||
{
|
{
|
||||||
wsfs_server_run(server);
|
wf_server_run(server);
|
||||||
wsfs_server_dispose(server);
|
wf_server_dispose(server);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -192,7 +192,7 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(args.passwd_path);
|
free(args.passwd_path);
|
||||||
wsfs_server_config_dispose(args.config);
|
wf_server_config_dispose(args.config);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }] */
|
/* eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }] */
|
||||||
|
|
||||||
import { BadState } from "./wsfs/bad_state.js";
|
import { BadState } from "./webfuse/bad_state.js";
|
||||||
import { FileMode } from "./wsfs/file_mode.js";
|
import { FileMode } from "./webfuse/file_mode.js";
|
||||||
import { Provider } from "./wsfs/provider.js";
|
import { Provider } from "./webfuse/provider.js";
|
||||||
|
|
||||||
export class FileSystemProvider extends Provider {
|
export class FileSystemProvider extends Provider {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "wsfs-provider",
|
"name": "webfuse-provider",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Provider for websocket filesystem (wsfs)",
|
"description": "Provider for websocket filesystem (webfuse)",
|
||||||
"main": "startup.js",
|
"main": "startup.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Client } from "./wsfs/client.js";
|
import { Client } from "./webfuse/client.js";
|
||||||
import { ConnectionView } from "./connection_view.js";
|
import { ConnectionView } from "./connection_view.js";
|
||||||
import { FileSystemProvider } from "./filesystem_provider.js";
|
import { FileSystemProvider } from "./filesystem_provider.js";
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ static bool is_compatible(json_t * meta)
|
|||||||
|
|
||||||
result = (
|
result = (
|
||||||
json_is_string(type) &&
|
json_is_string(type) &&
|
||||||
(0 == strcmp(json_string_value(type), "wsfs-userdb")) &&
|
(0 == strcmp(json_string_value(type), "wf-userdb")) &&
|
||||||
json_is_integer(major) &&
|
json_is_integer(major) &&
|
||||||
(USERDB_MAJOR == json_integer_value(major)) &&
|
(USERDB_MAJOR == json_integer_value(major)) &&
|
||||||
json_is_integer(minor) &&
|
json_is_integer(minor) &&
|
||||||
@ -170,7 +170,7 @@ bool userdb_save(
|
|||||||
json_t * container = json_object();
|
json_t * container = json_object();
|
||||||
|
|
||||||
json_t * meta = json_object();
|
json_t * meta = json_object();
|
||||||
json_object_set_new(meta, "type", json_string("wsfs-userdb"));
|
json_object_set_new(meta, "type", json_string("wf-userdb"));
|
||||||
json_object_set_new(meta, "major", json_integer(USERDB_MAJOR));
|
json_object_set_new(meta, "major", json_integer(USERDB_MAJOR));
|
||||||
json_object_set_new(meta, "minor", json_integer(USERDB_MINOR));
|
json_object_set_new(meta, "minor", json_integer(USERDB_MINOR));
|
||||||
json_object_set_new(meta, "hash_algorithm", json_string(db->hash_algorithm));
|
json_object_set_new(meta, "hash_algorithm", json_string(db->hash_algorithm));
|
||||||
|
@ -36,13 +36,13 @@ struct command
|
|||||||
static void print_usage(void)
|
static void print_usage(void)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"wsfs-passwd, Copyright (c) 2019 authors <https://github.com/falk-werner/fuse-wsfs>\n"
|
"webfuse-passwd, Copyright (c) 2019, webfuse authors <https://github.com/falk-werner/webfuse>\n"
|
||||||
"Manage wsfs passwd file\n"
|
"Manage webfuse passwd file\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Usage: wsfs-passwd -f <file> -c <command> [-u <username>] [-p <password>] [-P <pepper>]\n"
|
"Usage: webfuse-passwd -f <file> -c <command> [-u <username>] [-p <password>] [-P <pepper>]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\t-f, --file Path of wsfs passwd file\n"
|
"\t-f, --file Path of wf passwd file\n"
|
||||||
"\t-c, --command Command to execute\n"
|
"\t-c, --command Command to execute\n"
|
||||||
"\t-u, --username Name of user\n"
|
"\t-u, --username Name of user\n"
|
||||||
"\t-p, --password Password of user\n"
|
"\t-p, --password Password of user\n"
|
||||||
@ -51,13 +51,13 @@ static void print_usage(void)
|
|||||||
"\n"
|
"\n"
|
||||||
"Commands:\n"
|
"Commands:\n"
|
||||||
"\tcreate Creates an empty passwd file (or cleans an existing)\n"
|
"\tcreate Creates an empty passwd file (or cleans an existing)\n"
|
||||||
"\t Example: wsfs-passwd -f passwd.json -c create\n"
|
"\t Example: webfuse-passwd -f passwd.json -c create\n"
|
||||||
"\tadd Adds or replaces a user\n"
|
"\tadd Adds or replaces a user\n"
|
||||||
"\t Example: wsfs-passwd -f passwd.json -c add -u bob -p secret\n"
|
"\t Example: webfuse-passwd -f passwd.json -c add -u bob -p secret\n"
|
||||||
"\tremove Removes a user\n"
|
"\tremove Removes a user\n"
|
||||||
"\t Example: wsfs-passwd -f passwd.json -c remove -u bob\n"
|
"\t Example: webfuse-passwd -f passwd.json -c remove -u bob\n"
|
||||||
"\tcheck Checks password of a user\n"
|
"\tcheck Checks password of a user\n"
|
||||||
"\t Example: wsfs-passwd -f passwd.json -c check -u bob -p secret\n"
|
"\t Example: webfuse-passwd -f passwd.json -c check -u bob -p secret\n"
|
||||||
"\n"
|
"\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
#include "wsfs_provider.h"
|
#include "webfuse_provider.h"
|
||||||
|
|
||||||
struct config
|
struct config
|
||||||
{
|
{
|
||||||
char * url;
|
char * url;
|
||||||
struct wsfsp_client_config * client_config;
|
struct wfp_client_config * client_config;
|
||||||
bool show_help;
|
bool show_help;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -43,19 +43,19 @@ struct fs
|
|||||||
static void show_help()
|
static void show_help()
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"wsfs-provider, Copyright (c) 2019 fuse-wsfs authors <https://github.com/falk-werner/fuse-wsfs>\n"
|
"webfuse-provider, Copyright (c) 2019, webfuse authors <https://github.com/falk-werner/webfuse>\n"
|
||||||
"Example for websocket file system provider\n"
|
"Example for websocket file system provider\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Usage: wsfs-provider -u <url> [-k <key_path>] [-c <cert_path>]\n"
|
"Usage: webfuse-provider -u <url> [-k <key_path>] [-c <cert_path>]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\t-u, --url URL of WSFS server (required)\n"
|
"\t-u, --url URL of webfuse server (required)\n"
|
||||||
"\t-k, --key_path Path to private key of provider (default: not set, TLS disabled)\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-c, --cert_path Path to certificate of provider (defautl: not set, TLS disabled)\n"
|
||||||
"\t-h, --help prints this message\n"
|
"\t-h, --help prints this message\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Example:\n"
|
"Example:\n"
|
||||||
"\twsfs-provider -u ws://localhost:8080/\n"
|
"\twebfuse-provider -u ws://localhost:8080/\n"
|
||||||
"\n"
|
"\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -95,10 +95,10 @@ static int parse_arguments(
|
|||||||
config->url = strdup(optarg);
|
config->url = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
wsfsp_client_config_set_keypath(config->client_config, optarg);
|
wfp_client_config_set_keypath(config->client_config, optarg);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
wsfsp_client_config_set_certpath(config->client_config, optarg);
|
wfp_client_config_set_certpath(config->client_config, optarg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "error: unknown argument\n");
|
fprintf(stderr, "error: unknown argument\n");
|
||||||
@ -177,7 +177,7 @@ static void fs_stat(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void fs_lookup(
|
static void fs_lookup(
|
||||||
struct wsfsp_request * request,
|
struct wfp_request * request,
|
||||||
ino_t parent,
|
ino_t parent,
|
||||||
char const * name,
|
char const * name,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
@ -189,17 +189,17 @@ static void fs_lookup(
|
|||||||
struct stat stat;
|
struct stat stat;
|
||||||
fs_stat(entry, &stat);
|
fs_stat(entry, &stat);
|
||||||
|
|
||||||
wsfsp_respond_lookup(request, &stat);
|
wfp_respond_lookup(request, &stat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void fs_getattr(
|
static void fs_getattr(
|
||||||
struct wsfsp_request * request,
|
struct wfp_request * request,
|
||||||
ino_t inode,
|
ino_t inode,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
@ -211,16 +211,16 @@ static void fs_getattr(
|
|||||||
struct stat stat;
|
struct stat stat;
|
||||||
fs_stat(entry, &stat);
|
fs_stat(entry, &stat);
|
||||||
|
|
||||||
wsfsp_respond_getattr(request, &stat);
|
wfp_respond_getattr(request, &stat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fs_readdir(
|
static void fs_readdir(
|
||||||
struct wsfsp_request * request,
|
struct wfp_request * request,
|
||||||
ino_t directory,
|
ino_t directory,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
@ -229,30 +229,30 @@ static void fs_readdir(
|
|||||||
struct fs_entry const * dir = fs_getentry(fs, directory);
|
struct fs_entry const * dir = fs_getentry(fs, directory);
|
||||||
if ((NULL != dir) && (FS_DIR == dir->type))
|
if ((NULL != dir) && (FS_DIR == dir->type))
|
||||||
{
|
{
|
||||||
struct wsfsp_dirbuffer * buffer = wsfsp_dirbuffer_create();
|
struct wfp_dirbuffer * buffer = wfp_dirbuffer_create();
|
||||||
wsfsp_dirbuffer_add(buffer, ".", dir->inode);
|
wfp_dirbuffer_add(buffer, ".", dir->inode);
|
||||||
wsfsp_dirbuffer_add(buffer, "..", dir->inode);
|
wfp_dirbuffer_add(buffer, "..", dir->inode);
|
||||||
|
|
||||||
for(size_t i = 0; 0 != fs->entries[i].inode; i++)
|
for(size_t i = 0; 0 != fs->entries[i].inode; i++)
|
||||||
{
|
{
|
||||||
struct fs_entry const * entry = &fs->entries[i];
|
struct fs_entry const * entry = &fs->entries[i];
|
||||||
if (directory == entry->parent)
|
if (directory == entry->parent)
|
||||||
{
|
{
|
||||||
wsfsp_dirbuffer_add(buffer, entry->name, entry->inode);
|
wfp_dirbuffer_add(buffer, entry->name, entry->inode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wsfsp_respond_readdir(request, buffer);
|
wfp_respond_readdir(request, buffer);
|
||||||
wsfsp_dirbuffer_dispose(buffer);
|
wfp_dirbuffer_dispose(buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fs_open(
|
static void fs_open(
|
||||||
struct wsfsp_request * request,
|
struct wfp_request * request,
|
||||||
ino_t inode,
|
ino_t inode,
|
||||||
int flags,
|
int flags,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
@ -264,16 +264,16 @@ static void fs_open(
|
|||||||
{
|
{
|
||||||
if (O_RDONLY == (flags & O_ACCMODE))
|
if (O_RDONLY == (flags & O_ACCMODE))
|
||||||
{
|
{
|
||||||
wsfsp_respond_open(request, 0U);
|
wfp_respond_open(request, 0U);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsfsp_respond_error(request, WSFS_BAD_NOACCESS);
|
wfp_respond_error(request, WF_BAD_NOACCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ static size_t min(size_t const a, size_t const b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void fs_read(
|
static void fs_read(
|
||||||
struct wsfsp_request * request,
|
struct wfp_request * request,
|
||||||
ino_t inode,
|
ino_t inode,
|
||||||
uint32_t handle,
|
uint32_t handle,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
@ -301,26 +301,26 @@ static void fs_read(
|
|||||||
size_t const remaining = entry->content_length - offset;
|
size_t const remaining = entry->content_length - offset;
|
||||||
size_t const count = min(remaining, length);
|
size_t const count = min(remaining, length);
|
||||||
|
|
||||||
wsfsp_respond_read(request, &entry->content[offset], count);
|
wfp_respond_read(request, &entry->content[offset], count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsfsp_respond_error(request, WSFS_BAD);
|
wfp_respond_error(request, WF_BAD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wsfsp_client * client;
|
static struct wfp_client * client;
|
||||||
|
|
||||||
static void on_interrupt(int signal_id)
|
static void on_interrupt(int signal_id)
|
||||||
{
|
{
|
||||||
(void) signal_id;
|
(void) signal_id;
|
||||||
|
|
||||||
wsfsp_client_shutdown(client);
|
wfp_client_shutdown(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
@ -328,7 +328,7 @@ int main(int argc, char* argv[])
|
|||||||
struct config config;
|
struct config config;
|
||||||
config.url = NULL;
|
config.url = NULL;
|
||||||
config.show_help = false;
|
config.show_help = false;
|
||||||
config.client_config = wsfsp_client_config_create();
|
config.client_config = wfp_client_config_create();
|
||||||
int result = parse_arguments(argc, argv, &config);
|
int result = parse_arguments(argc, argv, &config);
|
||||||
|
|
||||||
if (EXIT_SUCCESS == result)
|
if (EXIT_SUCCESS == result)
|
||||||
@ -355,19 +355,19 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
signal(SIGINT, &on_interrupt);
|
signal(SIGINT, &on_interrupt);
|
||||||
|
|
||||||
wsfsp_client_config_set_userdata(config.client_config, &fs);
|
wfp_client_config_set_userdata(config.client_config, &fs);
|
||||||
wsfsp_client_config_set_onlookup(config.client_config, &fs_lookup);
|
wfp_client_config_set_onlookup(config.client_config, &fs_lookup);
|
||||||
wsfsp_client_config_set_ongetattr(config.client_config, &fs_getattr);
|
wfp_client_config_set_ongetattr(config.client_config, &fs_getattr);
|
||||||
wsfsp_client_config_set_onreaddir(config.client_config, &fs_readdir);
|
wfp_client_config_set_onreaddir(config.client_config, &fs_readdir);
|
||||||
wsfsp_client_config_set_onopen(config.client_config, &fs_open);
|
wfp_client_config_set_onopen(config.client_config, &fs_open);
|
||||||
wsfsp_client_config_set_onread(config.client_config, &fs_read);
|
wfp_client_config_set_onread(config.client_config, &fs_read);
|
||||||
|
|
||||||
client = wsfsp_client_create(config.client_config);
|
client = wfp_client_create(config.client_config);
|
||||||
wsfsp_client_connect(client, config.url);
|
wfp_client_connect(client, config.url);
|
||||||
|
|
||||||
wsfsp_client_run(client);
|
wfp_client_run(client);
|
||||||
|
|
||||||
wsfsp_client_dispose(client);
|
wfp_client_dispose(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.show_help)
|
if (config.show_help)
|
||||||
@ -376,6 +376,6 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(config.url);
|
free(config.url);
|
||||||
wsfsp_client_config_dispose(config.client_config);
|
wfp_client_config_dispose(config.client_config);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
16
include/webfuse/adapter/api.h
Normal file
16
include/webfuse/adapter/api.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef WF_ADAPTER_API_H
|
||||||
|
#define WF_ADAPTER_API_H
|
||||||
|
|
||||||
|
#ifndef WF_API
|
||||||
|
#define WF_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WF_EXPORT
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define WF_EXPORT __attribute__ ((visibility ("default")))
|
||||||
|
#else
|
||||||
|
#define WF_EXPORT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
23
include/webfuse/adapter/authenticate.h
Normal file
23
include/webfuse/adapter/authenticate.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef WF_ADAPTER_AUTHENTICATE_H
|
||||||
|
#define WF_ADAPTER_AUTHENTICATE_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_credentials;
|
||||||
|
|
||||||
|
typedef bool wf_authenticate_fn(
|
||||||
|
struct wf_credentials * credentials,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
25
include/webfuse/adapter/credentials.h
Normal file
25
include/webfuse/adapter/credentials.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef WF_ADAPTER_CREDENTIALS_H
|
||||||
|
#define WF_ADAPTER_CREDENTIALS_H
|
||||||
|
|
||||||
|
#include "webfuse/adapter/api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_credentials;
|
||||||
|
|
||||||
|
extern WF_API char const * wf_credentials_type(
|
||||||
|
struct wf_credentials const * credentials);
|
||||||
|
|
||||||
|
extern WF_API char const * wf_credentials_get(
|
||||||
|
struct wf_credentials const * credentials,
|
||||||
|
char const * key);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
31
include/webfuse/adapter/server.h
Normal file
31
include/webfuse/adapter/server.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef WF_ADAPTER_SERVER_H
|
||||||
|
#define WF_ADAPTER_SERVER_H
|
||||||
|
|
||||||
|
#include "webfuse/adapter/api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_server;
|
||||||
|
struct wf_server_config;
|
||||||
|
|
||||||
|
extern WF_API struct wf_server * wf_server_create(
|
||||||
|
struct wf_server_config * config);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_dispose(
|
||||||
|
struct wf_server * server);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_run(
|
||||||
|
struct wf_server * server);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_shutdown(
|
||||||
|
struct wf_server * server);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
55
include/webfuse/adapter/server_config.h
Normal file
55
include/webfuse/adapter/server_config.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#ifndef WF_ADAPTER_SERVER_CONFIG_H
|
||||||
|
#define WF_ADAPTER_SERVER_CONFIG_H
|
||||||
|
|
||||||
|
#include "webfuse/adapter/api.h"
|
||||||
|
#include "webfuse/adapter/authenticate.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_server_config;
|
||||||
|
|
||||||
|
extern WF_API struct wf_server_config * wf_server_config_create(void);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_config_dispose(
|
||||||
|
struct wf_server_config * config);
|
||||||
|
|
||||||
|
|
||||||
|
extern WF_API void wf_server_config_set_mountpoint(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * mount_point);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_config_set_documentroot(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * document_root);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_config_set_keypath(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * key_path);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_config_set_certpath(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * cert_path);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_config_set_vhostname(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * vhost_name);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_config_set_port(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
int port);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_config_add_authenticator(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data
|
||||||
|
);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
35
include/webfuse/adapter/server_protocol.h
Normal file
35
include/webfuse/adapter/server_protocol.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef WF_ADAPTER_SERVER_PROTOCOL_H
|
||||||
|
#define WF_ADAPTER_SERVER_PROTOCOL_H
|
||||||
|
|
||||||
|
#include <webfuse/adapter/api.h>
|
||||||
|
#include <webfuse/adapter/authenticate.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_server_protocol;
|
||||||
|
struct lws_protocols;
|
||||||
|
|
||||||
|
extern WF_API struct wf_server_protocol * wf_server_protocol_create(
|
||||||
|
char * mount_point);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_protocol_dispose(
|
||||||
|
struct wf_server_protocol * protocol);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_protocol_init_lws(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
struct lws_protocols * lws_protocol);
|
||||||
|
|
||||||
|
extern WF_API void wf_server_protocol_add_authenticator(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
17
include/webfuse/core/status.h
Normal file
17
include/webfuse/core/status.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef WF_STATUS_H
|
||||||
|
#define WF_STATUS_H
|
||||||
|
|
||||||
|
#define WF_GOOD 0
|
||||||
|
#define WF_BAD 1
|
||||||
|
|
||||||
|
#define WF_BAD_NOTIMPLEMENTED 2
|
||||||
|
#define WF_BAD_TIMEOUT 3
|
||||||
|
#define WF_BAD_BUSY 4
|
||||||
|
#define WF_BAD_FORMAT 5
|
||||||
|
|
||||||
|
#define WF_BAD_NOENTRY 101
|
||||||
|
#define WF_BAD_NOACCESS 102
|
||||||
|
|
||||||
|
typedef int wf_status;
|
||||||
|
|
||||||
|
#endif
|
16
include/webfuse/provider/api.h
Normal file
16
include/webfuse/provider/api.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef WFP_PROVIDER_API_H
|
||||||
|
#define WFP_PROVIDER_API_H
|
||||||
|
|
||||||
|
#ifndef WFP_API
|
||||||
|
#define WFP_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WFP_EXPORT
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define WFP_EXPORT __attribute__ ((visibility ("default")))
|
||||||
|
#else
|
||||||
|
#define WFP_EXPORT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
39
include/webfuse/provider/client.h
Normal file
39
include/webfuse/provider/client.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef WF_PROVIDER_CLIENT_H
|
||||||
|
#define WF_PROVIDER_CLIENT_H
|
||||||
|
|
||||||
|
#include "webfuse/provider/api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wfp_client;
|
||||||
|
struct wfp_client_config;
|
||||||
|
|
||||||
|
extern WFP_API struct wfp_client * wfp_client_create(
|
||||||
|
struct wfp_client_config * config);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_connect(
|
||||||
|
struct wfp_client * client,
|
||||||
|
char const * url);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_disconnect(
|
||||||
|
struct wfp_client * client);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_dispose(
|
||||||
|
struct wfp_client * client);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_run(
|
||||||
|
struct wfp_client * client);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_shutdown(
|
||||||
|
struct wfp_client * client);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
88
include/webfuse/provider/client_config.h
Normal file
88
include/webfuse/provider/client_config.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#ifndef WF_PROVIDER_CLIENT_CONFIG_H
|
||||||
|
#define WF_PROVIDER_CLIENT_CONFIG_H
|
||||||
|
|
||||||
|
#include <webfuse/provider/api.h>
|
||||||
|
|
||||||
|
#include <webfuse/provider/operation/lookup.h>
|
||||||
|
#include <webfuse/provider/operation/getattr.h>
|
||||||
|
#include <webfuse/provider/operation/readdir.h>
|
||||||
|
#include <webfuse/provider/operation/open.h>
|
||||||
|
#include <webfuse/provider/operation/close.h>
|
||||||
|
#include <webfuse/provider/operation/read.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wfp_client_config;
|
||||||
|
|
||||||
|
typedef void wfp_connected_fn(
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
typedef void wfp_disconnected_fn(
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
typedef void wfp_ontimer_fn(
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern WFP_API struct wfp_client_config * wfp_client_config_create(void);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_dispose(
|
||||||
|
struct wfp_client_config * config);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_userdata(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_keypath(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
char const * key_path);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_certpath(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
char const * cert_path);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_onconnected(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
wfp_connected_fn * handler);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_ondisconnected(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
wfp_disconnected_fn * handler);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_ontimer(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
wfp_ontimer_fn * handler);
|
||||||
|
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_onlookup(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
wfp_lookup_fn * handler);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_ongetattr(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
wfp_getattr_fn * handler);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_onreaddir(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
wfp_readdir_fn * handler);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_onopen(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
wfp_open_fn * handler);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_onclose(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
wfp_close_fn * handler);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_config_set_onread(
|
||||||
|
struct wfp_client_config * config,
|
||||||
|
wfp_read_fn * handler);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
32
include/webfuse/provider/client_protocol.h
Normal file
32
include/webfuse/provider/client_protocol.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef WF_PROVIDER_CLIENT_PROTOCOL_H
|
||||||
|
#define WF_PROVIDER_CLIENT_PROTOCOL_H
|
||||||
|
|
||||||
|
#include "webfuse/provider/api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wfp_client_protocol;
|
||||||
|
struct wfp_provider;
|
||||||
|
struct lws_protocols;
|
||||||
|
|
||||||
|
extern WFP_API struct wfp_client_protocol * wfp_client_protocol_create(
|
||||||
|
struct wfp_provider const * provider,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_protocol_dispose(
|
||||||
|
struct wfp_client_protocol * protocol);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_client_protocol_init_lws(
|
||||||
|
struct wfp_client_protocol * protocol,
|
||||||
|
struct lws_protocols * lws_protocol);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
32
include/webfuse/provider/dirbuffer.h
Normal file
32
include/webfuse/provider/dirbuffer.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef WF_PROVIDER_DIRBUFFER_H
|
||||||
|
#define WF_PROVIDER_DIRBUFFER_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "webfuse/provider/api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wfp_dirbuffer;
|
||||||
|
|
||||||
|
extern WFP_API struct wfp_dirbuffer * wfp_dirbuffer_create(void);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_dirbuffer_dispose(
|
||||||
|
struct wfp_dirbuffer * buffer);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_dirbuffer_add(
|
||||||
|
struct wfp_dirbuffer * buffer,
|
||||||
|
char const * name,
|
||||||
|
ino_t inode);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef WSFSP_OPERATION_CLOSE_H
|
#ifndef WFP_OPERATION_CLOSE_H
|
||||||
#define WSFSP_OPERATION_CLOSE_H
|
#define WFP_OPERATION_CLOSE_H
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@ -11,14 +11,14 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
#include "webfuse/provider/api.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void wsfsp_close_fn(
|
typedef void wfp_close_fn(
|
||||||
ino_t inode,
|
ino_t inode,
|
||||||
uint32_t handle,
|
uint32_t handle,
|
||||||
int flags,
|
int flags,
|
22
include/webfuse/provider/operation/error.h
Normal file
22
include/webfuse/provider/operation/error.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef WFP_OPERATION_ERROR_H
|
||||||
|
#define WFP_OPERATION_ERROR_H
|
||||||
|
|
||||||
|
#include "webfuse/provider/api.h"
|
||||||
|
#include "webfuse/core/status.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wfp_request;
|
||||||
|
|
||||||
|
extern WFP_API void wfp_respond_error(
|
||||||
|
struct wfp_request * request,
|
||||||
|
wf_status status);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
31
include/webfuse/provider/operation/getattr.h
Normal file
31
include/webfuse/provider/operation/getattr.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef WFP_OPERATION_GETATTR_H
|
||||||
|
#define WFP_OPERATION_GETATTR_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "webfuse/provider/api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wfp_request;
|
||||||
|
|
||||||
|
typedef void wfp_getattr_fn(
|
||||||
|
struct wfp_request * request,
|
||||||
|
ino_t inode,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_respond_getattr(
|
||||||
|
struct wfp_request * request,
|
||||||
|
struct stat const * stat);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
32
include/webfuse/provider/operation/lookup.h
Normal file
32
include/webfuse/provider/operation/lookup.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef WFP_OPERATION_LOOKUP_H
|
||||||
|
#define WFP_OPERATION_LOOKUP_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "webfuse/provider/api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wfp_request;
|
||||||
|
|
||||||
|
typedef void wfp_lookup_fn(
|
||||||
|
struct wfp_request * request,
|
||||||
|
ino_t parent,
|
||||||
|
char const * name,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_respond_lookup(
|
||||||
|
struct wfp_request * request,
|
||||||
|
struct stat const * stat);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef WSFSP_OPERATION_OPEN_H
|
#ifndef WFP_OPERATION_OPEN_H
|
||||||
#define WSFSP_OPERATION_OPEN_H
|
#define WFP_OPERATION_OPEN_H
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@ -11,23 +11,23 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
#include "webfuse/provider/api.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct wsfsp_request;
|
struct wfp_request;
|
||||||
|
|
||||||
typedef void wsfsp_open_fn(
|
typedef void wfp_open_fn(
|
||||||
struct wsfsp_request * request,
|
struct wfp_request * request,
|
||||||
ino_t inode,
|
ino_t inode,
|
||||||
int flags,
|
int flags,
|
||||||
void * user_data);
|
void * user_data);
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_respond_open(
|
extern WFP_API void wfp_respond_open(
|
||||||
struct wsfsp_request * request,
|
struct wfp_request * request,
|
||||||
uint32_t handle);
|
uint32_t handle);
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef WSFSP_OPERATION_READ_H
|
#ifndef WFP_OPERATION_READ_H
|
||||||
#define WSFSP_OPERATION_READ_H
|
#define WFP_OPERATION_READ_H
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -14,25 +14,25 @@ using std::size_t;
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
#include "webfuse/provider/api.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct wsfsp_request;
|
struct wfp_request;
|
||||||
|
|
||||||
typedef void wsfsp_read_fn(
|
typedef void wfp_read_fn(
|
||||||
struct wsfsp_request * request,
|
struct wfp_request * request,
|
||||||
ino_t inode,
|
ino_t inode,
|
||||||
uint32_t handle,
|
uint32_t handle,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
size_t length,
|
size_t length,
|
||||||
void * user_data);
|
void * user_data);
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_respond_read(
|
extern WFP_API void wfp_respond_read(
|
||||||
struct wsfsp_request * request,
|
struct wfp_request * request,
|
||||||
char const * data,
|
char const * data,
|
||||||
size_t length);
|
size_t length);
|
||||||
|
|
31
include/webfuse/provider/operation/readdir.h
Normal file
31
include/webfuse/provider/operation/readdir.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef WFP_OPERATION_READDIR_H
|
||||||
|
#define WFP_OPERATION_READDIR_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "webfuse/provider/api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wfp_dirbuffer;
|
||||||
|
struct wfp_request;
|
||||||
|
|
||||||
|
typedef void wfp_readdir_fn(
|
||||||
|
struct wfp_request * request,
|
||||||
|
ino_t directory,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern WFP_API void wfp_respond_readdir(
|
||||||
|
struct wfp_request * request,
|
||||||
|
struct wfp_dirbuffer * dirbuffer);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
13
include/webfuse_adapter.h
Normal file
13
include/webfuse_adapter.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef WF_ADAPTER_H
|
||||||
|
#define WF_ADAPTER_H
|
||||||
|
|
||||||
|
#include <webfuse/core/status.h>
|
||||||
|
|
||||||
|
#include <webfuse/adapter/api.h>
|
||||||
|
#include <webfuse/adapter/server.h>
|
||||||
|
#include <webfuse/adapter/server_config.h>
|
||||||
|
#include <webfuse/adapter/server_protocol.h>
|
||||||
|
#include <webfuse/adapter/authenticate.h>
|
||||||
|
#include <webfuse/adapter/credentials.h>
|
||||||
|
|
||||||
|
#endif
|
20
include/webfuse_provider.h
Normal file
20
include/webfuse_provider.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef WF_PROVIDER_H
|
||||||
|
#define WF_PROVIDER_H
|
||||||
|
|
||||||
|
#include <webfuse/core/status.h>
|
||||||
|
|
||||||
|
#include <webfuse/provider/api.h>
|
||||||
|
#include <webfuse/provider/client.h>
|
||||||
|
#include <webfuse/provider/client_config.h>
|
||||||
|
#include <webfuse/provider/client_protocol.h>
|
||||||
|
#include <webfuse/provider/dirbuffer.h>
|
||||||
|
|
||||||
|
#include <webfuse/provider/operation/error.h>
|
||||||
|
#include <webfuse/provider/operation/lookup.h>
|
||||||
|
#include <webfuse/provider/operation/getattr.h>
|
||||||
|
#include <webfuse/provider/operation/readdir.h>
|
||||||
|
#include <webfuse/provider/operation/open.h>
|
||||||
|
#include <webfuse/provider/operation/close.h>
|
||||||
|
#include <webfuse/provider/operation/read.h>
|
||||||
|
|
||||||
|
#endif
|
@ -1,16 +0,0 @@
|
|||||||
#ifndef WSFS_ADAPTER_API_H
|
|
||||||
#define WSFS_ADAPTER_API_H
|
|
||||||
|
|
||||||
#ifndef WSFSA_API
|
|
||||||
#define WSFSA_API
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WSFSA_EXPORT
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define WSFSA_EXPORT __attribute__ ((visibility ("default")))
|
|
||||||
#else
|
|
||||||
#define WSFSA_EXPORT
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,23 +0,0 @@
|
|||||||
#ifndef WSFS_ADAPTER_AUTHENTICATE_H
|
|
||||||
#define WSFS_ADAPTER_AUTHENTICATE_H
|
|
||||||
|
|
||||||
#ifndef __cplusplus
|
|
||||||
#include <stdbool.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfs_credentials;
|
|
||||||
|
|
||||||
typedef bool wsfs_authenticate_fn(
|
|
||||||
struct wsfs_credentials * credentials,
|
|
||||||
void * user_data);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,25 +0,0 @@
|
|||||||
#ifndef WSFS_ADAPTER_CREDENTIALS_H
|
|
||||||
#define WSFS_ADAPTER_CREDENTIALS_H
|
|
||||||
|
|
||||||
#include "wsfs/adapter/api.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfs_credentials;
|
|
||||||
|
|
||||||
extern WSFSA_API char const * wsfs_credentials_type(
|
|
||||||
struct wsfs_credentials const * credentials);
|
|
||||||
|
|
||||||
extern WSFSA_API char const * wsfs_credentials_get(
|
|
||||||
struct wsfs_credentials const * credentials,
|
|
||||||
char const * key);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||||||
#ifndef WSFS_ADAPTER_SERVER_H
|
|
||||||
#define WSFS_ADAPTER_SERVER_H
|
|
||||||
|
|
||||||
#include "wsfs/adapter/api.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfs_server;
|
|
||||||
struct wsfs_server_config;
|
|
||||||
|
|
||||||
extern WSFSA_API struct wsfs_server * wsfs_server_create(
|
|
||||||
struct wsfs_server_config * config);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_dispose(
|
|
||||||
struct wsfs_server * server);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_run(
|
|
||||||
struct wsfs_server * server);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_shutdown(
|
|
||||||
struct wsfs_server * server);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,55 +0,0 @@
|
|||||||
#ifndef WSFS_ADAPTER_SERVER_CONFIG_H
|
|
||||||
#define WSFS_ADAPTER_SERVER_CONFIG_H
|
|
||||||
|
|
||||||
#include "wsfs/adapter/api.h"
|
|
||||||
#include "wsfs/adapter/authenticate.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfs_server_config;
|
|
||||||
|
|
||||||
extern WSFSA_API struct wsfs_server_config * wsfs_server_config_create(void);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_config_dispose(
|
|
||||||
struct wsfs_server_config * config);
|
|
||||||
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_config_set_mountpoint(
|
|
||||||
struct wsfs_server_config * config,
|
|
||||||
char const * mount_point);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_config_set_documentroot(
|
|
||||||
struct wsfs_server_config * config,
|
|
||||||
char const * document_root);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_config_set_keypath(
|
|
||||||
struct wsfs_server_config * config,
|
|
||||||
char const * key_path);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_config_set_certpath(
|
|
||||||
struct wsfs_server_config * config,
|
|
||||||
char const * cert_path);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_config_set_vhostname(
|
|
||||||
struct wsfs_server_config * config,
|
|
||||||
char const * vhost_name);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_config_set_port(
|
|
||||||
struct wsfs_server_config * config,
|
|
||||||
int port);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_config_add_authenticator(
|
|
||||||
struct wsfs_server_config * config,
|
|
||||||
char const * type,
|
|
||||||
wsfs_authenticate_fn * authenticate,
|
|
||||||
void * user_data
|
|
||||||
);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,35 +0,0 @@
|
|||||||
#ifndef WSFS_ADAPTER_SERVER_PROTOCOL_H
|
|
||||||
#define WSFS_ADAPTER_SERVER_PROTOCOL_H
|
|
||||||
|
|
||||||
#include <wsfs/adapter/api.h>
|
|
||||||
#include <wsfs/adapter/authenticate.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfs_server_protocol;
|
|
||||||
struct lws_protocols;
|
|
||||||
|
|
||||||
extern WSFSA_API struct wsfs_server_protocol * wsfs_server_protocol_create(
|
|
||||||
char * mount_point);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_protocol_dispose(
|
|
||||||
struct wsfs_server_protocol * protocol);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_protocol_init_lws(
|
|
||||||
struct wsfs_server_protocol * protocol,
|
|
||||||
struct lws_protocols * lws_protocol);
|
|
||||||
|
|
||||||
extern WSFSA_API void wsfs_server_protocol_add_authenticator(
|
|
||||||
struct wsfs_server_protocol * protocol,
|
|
||||||
char const * type,
|
|
||||||
wsfs_authenticate_fn * authenticate,
|
|
||||||
void * user_data);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,17 +0,0 @@
|
|||||||
#ifndef WSFS_STATUS_H
|
|
||||||
#define WSFS_STATUS_H
|
|
||||||
|
|
||||||
#define WSFS_GOOD 0
|
|
||||||
#define WSFS_BAD 1
|
|
||||||
|
|
||||||
#define WSFS_BAD_NOTIMPLEMENTED 2
|
|
||||||
#define WSFS_BAD_TIMEOUT 3
|
|
||||||
#define WSFS_BAD_BUSY 4
|
|
||||||
#define WSFS_BAD_FORMAT 5
|
|
||||||
|
|
||||||
#define WSFS_BAD_NOENTRY 101
|
|
||||||
#define WSFS_BAD_NOACCESS 102
|
|
||||||
|
|
||||||
typedef int wsfs_status;
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,16 +0,0 @@
|
|||||||
#ifndef WSFSP_PROVIDER_API_H
|
|
||||||
#define WSFSP_PROVIDER_API_H
|
|
||||||
|
|
||||||
#ifndef WSFSP_API
|
|
||||||
#define WSFSP_API
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WSFSP_EXPORT
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define WSFSP_EXPORT __attribute__ ((visibility ("default")))
|
|
||||||
#else
|
|
||||||
#define WSFSP_EXPORT
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||||||
#ifndef WSFS_PROVIDER_CLIENT_H
|
|
||||||
#define WSFS_PROVIDER_CLIENT_H
|
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfsp_client;
|
|
||||||
struct wsfsp_client_config;
|
|
||||||
|
|
||||||
extern WSFSP_API struct wsfsp_client * wsfsp_client_create(
|
|
||||||
struct wsfsp_client_config * config);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_client_connect(
|
|
||||||
struct wsfsp_client * client,
|
|
||||||
char const * url);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_client_disconnect(
|
|
||||||
struct wsfsp_client * client);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_client_dispose(
|
|
||||||
struct wsfsp_client * client);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_client_run(
|
|
||||||
struct wsfsp_client * client);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_client_shutdown(
|
|
||||||
struct wsfsp_client * client);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,88 +0,0 @@
|
|||||||
#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>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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
|
|
@ -1,32 +0,0 @@
|
|||||||
#ifndef WSFS_PROVIDER_CLIENT_PROTOCOL_H
|
|
||||||
#define WSFS_PROVIDER_CLIENT_PROTOCOL_H
|
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfsp_client_protocol;
|
|
||||||
struct wsfsp_provider;
|
|
||||||
struct lws_protocols;
|
|
||||||
|
|
||||||
extern WSFSP_API struct wsfsp_client_protocol * wsfsp_client_protocol_create(
|
|
||||||
struct wsfsp_provider const * provider,
|
|
||||||
void * user_data);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_client_protocol_dispose(
|
|
||||||
struct wsfsp_client_protocol * protocol);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_client_protocol_init_lws(
|
|
||||||
struct wsfsp_client_protocol * protocol,
|
|
||||||
struct lws_protocols * lws_protocol);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,32 +0,0 @@
|
|||||||
#ifndef WSFS_PROVIDER_DIRBUFFER_H
|
|
||||||
#define WSFS_PROVIDER_DIRBUFFER_H
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfsp_dirbuffer;
|
|
||||||
|
|
||||||
extern WSFSP_API struct wsfsp_dirbuffer * wsfsp_dirbuffer_create(void);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_dirbuffer_dispose(
|
|
||||||
struct wsfsp_dirbuffer * buffer);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_dirbuffer_add(
|
|
||||||
struct wsfsp_dirbuffer * buffer,
|
|
||||||
char const * name,
|
|
||||||
ino_t inode);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,22 +0,0 @@
|
|||||||
#ifndef WSFSP_OPERATION_ERROR_H
|
|
||||||
#define WSFSP_OPERATION_ERROR_H
|
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
|
||||||
#include "wsfs/core/status.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfsp_request;
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_respond_error(
|
|
||||||
struct wsfsp_request * request,
|
|
||||||
wsfs_status status);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||||||
#ifndef WSFSP_OPERATION_GETATTR_H
|
|
||||||
#define WSFSP_OPERATION_GETATTR_H
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfsp_request;
|
|
||||||
|
|
||||||
typedef void wsfsp_getattr_fn(
|
|
||||||
struct wsfsp_request * request,
|
|
||||||
ino_t inode,
|
|
||||||
void * user_data);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_respond_getattr(
|
|
||||||
struct wsfsp_request * request,
|
|
||||||
struct stat const * stat);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,32 +0,0 @@
|
|||||||
#ifndef WSFSP_OPERATION_LOOKUP_H
|
|
||||||
#define WSFSP_OPERATION_LOOKUP_H
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfsp_request;
|
|
||||||
|
|
||||||
typedef void wsfsp_lookup_fn(
|
|
||||||
struct wsfsp_request * request,
|
|
||||||
ino_t parent,
|
|
||||||
char const * name,
|
|
||||||
void * user_data);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_respond_lookup(
|
|
||||||
struct wsfsp_request * request,
|
|
||||||
struct stat const * stat);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||||||
#ifndef WSFSP_OPERATION_READDIR_H
|
|
||||||
#define WSFSP_OPERATION_READDIR_H
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "wsfs/provider/api.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct wsfsp_dirbuffer;
|
|
||||||
struct wsfsp_request;
|
|
||||||
|
|
||||||
typedef void wsfsp_readdir_fn(
|
|
||||||
struct wsfsp_request * request,
|
|
||||||
ino_t directory,
|
|
||||||
void * user_data);
|
|
||||||
|
|
||||||
extern WSFSP_API void wsfsp_respond_readdir(
|
|
||||||
struct wsfsp_request * request,
|
|
||||||
struct wsfsp_dirbuffer * dirbuffer);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,13 +0,0 @@
|
|||||||
#ifndef WSFS_ADAPTER_H
|
|
||||||
#define WSFS_ADAPTER_H
|
|
||||||
|
|
||||||
#include <wsfs/core/status.h>
|
|
||||||
|
|
||||||
#include <wsfs/adapter/api.h>
|
|
||||||
#include <wsfs/adapter/server.h>
|
|
||||||
#include <wsfs/adapter/server_config.h>
|
|
||||||
#include <wsfs/adapter/server_protocol.h>
|
|
||||||
#include <wsfs/adapter/authenticate.h>
|
|
||||||
#include <wsfs/adapter/credentials.h>
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,20 +0,0 @@
|
|||||||
#ifndef WSFS_PROVIDER_H
|
|
||||||
#define WSFS_PROVIDER_H
|
|
||||||
|
|
||||||
#include <wsfs/core/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/dirbuffer.h>
|
|
||||||
|
|
||||||
#include <wsfs/provider/operation/error.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>
|
|
||||||
|
|
||||||
#endif
|
|
141
lib/webfuse/adapter/api.c
Normal file
141
lib/webfuse/adapter/api.c
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
#include "webfuse_adapter.h"
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/server.h"
|
||||||
|
#include "webfuse/adapter/impl/server_protocol.h"
|
||||||
|
#include "webfuse/adapter/impl/server_config.h"
|
||||||
|
#include "webfuse/adapter/impl/credentials.h"
|
||||||
|
|
||||||
|
// server
|
||||||
|
|
||||||
|
struct wf_server * wf_server_create(
|
||||||
|
struct wf_server_config * config)
|
||||||
|
{
|
||||||
|
return wf_impl_server_create(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_dispose(
|
||||||
|
struct wf_server * server)
|
||||||
|
{
|
||||||
|
wf_impl_server_dispose(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_run(
|
||||||
|
struct wf_server * server)
|
||||||
|
{
|
||||||
|
wf_impl_server_run(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_shutdown(
|
||||||
|
struct wf_server * server)
|
||||||
|
{
|
||||||
|
wf_impl_server_shutdown(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
// server protocol
|
||||||
|
|
||||||
|
struct wf_server_protocol * wf_server_protocol_create(
|
||||||
|
char * mount_point)
|
||||||
|
{
|
||||||
|
return wf_impl_server_protocol_create(mount_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_protocol_dispose(
|
||||||
|
struct wf_server_protocol * protocol)
|
||||||
|
{
|
||||||
|
wf_impl_server_protocol_dispose(protocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_protocol_init_lws(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
struct lws_protocols * lws_protocol)
|
||||||
|
{
|
||||||
|
wf_impl_server_protocol_init_lws(protocol, lws_protocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_protocol_add_authenticator(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data)
|
||||||
|
{
|
||||||
|
wf_impl_server_protocol_add_authenticator(protocol, type, authenticate, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// server_config
|
||||||
|
|
||||||
|
struct wf_server_config * wf_server_config_create(void)
|
||||||
|
{
|
||||||
|
return wf_impl_server_config_create();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_config_dispose(
|
||||||
|
struct wf_server_config * config)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_dispose(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_config_set_mountpoint(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * mount_point)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_set_mountpoint(config, mount_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_config_set_documentroot(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * document_root)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_set_documentroot(config, document_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_config_set_keypath(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * key_path)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_set_keypath(config, key_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_config_set_certpath(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * cert_path)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_set_certpath(config, cert_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_config_set_vhostname(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * vhost_name)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_set_vhostname(config, vhost_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_config_set_port(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
int port)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_set_port(config, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_server_config_add_authenticator(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_add_authenticator(config, type, authenticate, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// credentials
|
||||||
|
|
||||||
|
char const * wf_credentials_type(
|
||||||
|
struct wf_credentials const * credentials)
|
||||||
|
{
|
||||||
|
return wf_impl_credentials_type(credentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
char const * wf_credentials_get(
|
||||||
|
struct wf_credentials const * credentials,
|
||||||
|
char const * key)
|
||||||
|
{
|
||||||
|
return wf_impl_credentials_get(credentials, key);
|
||||||
|
}
|
@ -1,16 +1,16 @@
|
|||||||
#include "wsfs/adapter/impl/authenticator.h"
|
#include "webfuse/adapter/impl/authenticator.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "wsfs/adapter/impl/credentials.h"
|
#include "webfuse/adapter/impl/credentials.h"
|
||||||
|
|
||||||
struct wsfs_impl_authenticator * wsfs_impl_authenticator_create(
|
struct wf_impl_authenticator * wf_impl_authenticator_create(
|
||||||
char const * type,
|
char const * type,
|
||||||
wsfs_authenticate_fn * authenticate,
|
wf_authenticate_fn * authenticate,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
struct wsfs_impl_authenticator * authenticator = malloc(sizeof(struct wsfs_impl_authenticator));
|
struct wf_impl_authenticator * authenticator = malloc(sizeof(struct wf_impl_authenticator));
|
||||||
if (NULL != authenticator)
|
if (NULL != authenticator)
|
||||||
{
|
{
|
||||||
authenticator->type = strdup(type);
|
authenticator->type = strdup(type);
|
||||||
@ -22,16 +22,16 @@ struct wsfs_impl_authenticator * wsfs_impl_authenticator_create(
|
|||||||
return authenticator;
|
return authenticator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_authenticator_dispose(
|
void wf_impl_authenticator_dispose(
|
||||||
struct wsfs_impl_authenticator * authenticator)
|
struct wf_impl_authenticator * authenticator)
|
||||||
{
|
{
|
||||||
free(authenticator->type);
|
free(authenticator->type);
|
||||||
free(authenticator);
|
free(authenticator);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wsfs_impl_authenticator_autenticate(
|
bool wf_impl_authenticator_autenticate(
|
||||||
struct wsfs_impl_authenticator * authenticator,
|
struct wf_impl_authenticator * authenticator,
|
||||||
struct wsfs_credentials * credentials)
|
struct wf_credentials * credentials)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
|
|
42
lib/webfuse/adapter/impl/authenticator.h
Normal file
42
lib/webfuse/adapter/impl/authenticator.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_AUTHENTICATOR_H
|
||||||
|
#define WF_ADAPTER_IMPL_AUTHENTICATOR_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "webfuse/adapter/authenticate.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_credentials;
|
||||||
|
|
||||||
|
struct wf_impl_authenticator
|
||||||
|
{
|
||||||
|
char * type;
|
||||||
|
wf_authenticate_fn * authenticate;
|
||||||
|
void * user_data;
|
||||||
|
struct wf_impl_authenticator * next;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct wf_impl_authenticator * wf_impl_authenticator_create(
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern void wf_impl_authenticator_dispose(
|
||||||
|
struct wf_impl_authenticator * authenticator);
|
||||||
|
|
||||||
|
extern bool wf_impl_authenticator_autenticate(
|
||||||
|
struct wf_impl_authenticator * authenticator,
|
||||||
|
struct wf_credentials * credentials);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
101
lib/webfuse/adapter/impl/authenticators.c
Normal file
101
lib/webfuse/adapter/impl/authenticators.c
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
#include "webfuse/adapter/impl/authenticators.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/authenticator.h"
|
||||||
|
#include "webfuse/adapter/impl/credentials.h"
|
||||||
|
|
||||||
|
static struct wf_impl_authenticator * wf_impl_authenticators_find(
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
char const * type)
|
||||||
|
{
|
||||||
|
struct wf_impl_authenticator * result = NULL;
|
||||||
|
|
||||||
|
struct wf_impl_authenticator * actual = authenticators->first;
|
||||||
|
while ((NULL == result) && (NULL != actual))
|
||||||
|
{
|
||||||
|
struct wf_impl_authenticator * next = actual->next;
|
||||||
|
if (0 == strcmp(type, actual->type))
|
||||||
|
{
|
||||||
|
result = actual;
|
||||||
|
}
|
||||||
|
|
||||||
|
actual = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_authenticators_init(
|
||||||
|
struct wf_impl_authenticators * authenticators)
|
||||||
|
{
|
||||||
|
authenticators->first = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_authenticators_cleanup(
|
||||||
|
struct wf_impl_authenticators * authenticators)
|
||||||
|
{
|
||||||
|
struct wf_impl_authenticator * actual = authenticators->first;
|
||||||
|
while (NULL != actual)
|
||||||
|
{
|
||||||
|
struct wf_impl_authenticator * next = actual->next;
|
||||||
|
wf_impl_authenticator_dispose(actual);
|
||||||
|
actual = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
authenticators->first = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_authenticators_clone(
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_impl_authenticators * other)
|
||||||
|
{
|
||||||
|
wf_impl_authenticators_init(other);
|
||||||
|
|
||||||
|
struct wf_impl_authenticator * actual = authenticators->first;
|
||||||
|
while (NULL != actual)
|
||||||
|
{
|
||||||
|
struct wf_impl_authenticator * next = actual->next;
|
||||||
|
wf_impl_authenticators_add(other,
|
||||||
|
actual->type, actual->authenticate, actual->user_data);
|
||||||
|
actual = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void wf_impl_authenticators_move(
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_impl_authenticators * other)
|
||||||
|
{
|
||||||
|
other->first = authenticators->first;
|
||||||
|
authenticators->first = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_authenticators_add(
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data)
|
||||||
|
{
|
||||||
|
struct wf_impl_authenticator * authenticator = wf_impl_authenticator_create(type, authenticate, user_data);
|
||||||
|
authenticator->next = authenticators->first;
|
||||||
|
authenticators->first = authenticator;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wf_impl_authenticators_authenticate(
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_credentials * credentials)
|
||||||
|
{
|
||||||
|
bool result = (NULL == authenticators->first);
|
||||||
|
|
||||||
|
if (NULL != credentials)
|
||||||
|
{
|
||||||
|
struct wf_impl_authenticator * authenticator = wf_impl_authenticators_find(authenticators, credentials->type);
|
||||||
|
if (NULL != authenticator)
|
||||||
|
{
|
||||||
|
result = wf_impl_authenticator_autenticate(authenticator, credentials);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
51
lib/webfuse/adapter/impl/authenticators.h
Normal file
51
lib/webfuse/adapter/impl/authenticators.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_AUTHENTICATORS_H
|
||||||
|
#define WF_ADAPTER_IMPL_AUTHENTICATORS_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "webfuse/adapter/authenticate.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_impl_authenticator;
|
||||||
|
struct wf_credentials;
|
||||||
|
|
||||||
|
struct wf_impl_authenticators
|
||||||
|
{
|
||||||
|
struct wf_impl_authenticator * first;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_impl_authenticators_init(
|
||||||
|
struct wf_impl_authenticators * authenticators);
|
||||||
|
|
||||||
|
extern void wf_impl_authenticators_cleanup(
|
||||||
|
struct wf_impl_authenticators * authenticators);
|
||||||
|
|
||||||
|
extern void wf_impl_authenticators_clone(
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_impl_authenticators * other);
|
||||||
|
|
||||||
|
extern void wf_impl_authenticators_move(
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_impl_authenticators * other);
|
||||||
|
|
||||||
|
extern void wf_impl_authenticators_add(
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern bool wf_impl_authenticators_authenticate(
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_credentials * credentials);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -1,8 +1,8 @@
|
|||||||
#include "wsfs/adapter/impl/credentials.h"
|
#include "webfuse/adapter/impl/credentials.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void wsfs_impl_credentials_init(
|
void wf_impl_credentials_init(
|
||||||
struct wsfs_credentials * credentials,
|
struct wf_credentials * credentials,
|
||||||
char const * type,
|
char const * type,
|
||||||
json_t * data)
|
json_t * data)
|
||||||
{
|
{
|
||||||
@ -11,21 +11,21 @@ void wsfs_impl_credentials_init(
|
|||||||
json_incref(credentials->data);
|
json_incref(credentials->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_credentials_cleanup(
|
void wf_impl_credentials_cleanup(
|
||||||
struct wsfs_credentials * credentials)
|
struct wf_credentials * credentials)
|
||||||
{
|
{
|
||||||
free(credentials->type);
|
free(credentials->type);
|
||||||
json_decref(credentials->data);
|
json_decref(credentials->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * wsfs_impl_credentials_type(
|
char const * wf_impl_credentials_type(
|
||||||
struct wsfs_credentials const * credentials)
|
struct wf_credentials const * credentials)
|
||||||
{
|
{
|
||||||
return credentials->type;
|
return credentials->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * wsfs_impl_credentials_get(
|
char const * wf_impl_credentials_get(
|
||||||
struct wsfs_credentials const * credentials,
|
struct wf_credentials const * credentials,
|
||||||
char const * key)
|
char const * key)
|
||||||
{
|
{
|
||||||
char const * result = NULL;
|
char const * result = NULL;
|
36
lib/webfuse/adapter/impl/credentials.h
Normal file
36
lib/webfuse/adapter/impl/credentials.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_CREDENTIALS_H
|
||||||
|
#define WF_ADAPTER_IMPL_CREDENTIALS_H
|
||||||
|
|
||||||
|
#include <jansson.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_credentials
|
||||||
|
{
|
||||||
|
char * type;
|
||||||
|
json_t * data;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_impl_credentials_init(
|
||||||
|
struct wf_credentials * credentials,
|
||||||
|
char const * type,
|
||||||
|
json_t * data);
|
||||||
|
|
||||||
|
extern void wf_impl_credentials_cleanup(
|
||||||
|
struct wf_credentials * credentials);
|
||||||
|
|
||||||
|
extern char const * wf_impl_credentials_type(
|
||||||
|
struct wf_credentials const * credentials);
|
||||||
|
|
||||||
|
extern char const * wf_impl_credentials_get(
|
||||||
|
struct wf_credentials const * credentials,
|
||||||
|
char const * key);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -1,6 +1,6 @@
|
|||||||
#include "wsfs/adapter/impl/filesystem.h"
|
#include "webfuse/adapter/impl/filesystem.h"
|
||||||
#include "wsfs/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operations.h"
|
||||||
#include "wsfs/adapter/impl/jsonrpc/server.h"
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -8,18 +8,18 @@
|
|||||||
|
|
||||||
static struct fuse_lowlevel_ops const filesystem_operations =
|
static struct fuse_lowlevel_ops const filesystem_operations =
|
||||||
{
|
{
|
||||||
.lookup = &wsfs_impl_operation_lookup,
|
.lookup = &wf_impl_operation_lookup,
|
||||||
.getattr = &wsfs_impl_operation_getattr,
|
.getattr = &wf_impl_operation_getattr,
|
||||||
.readdir = &wsfs_impl_operation_readdir,
|
.readdir = &wf_impl_operation_readdir,
|
||||||
.open = &wsfs_impl_operation_open,
|
.open = &wf_impl_operation_open,
|
||||||
.release = &wsfs_impl_operation_close,
|
.release = &wf_impl_operation_close,
|
||||||
.read = &wsfs_impl_operation_read
|
.read = &wf_impl_operation_read
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool wsfs_impl_filesystem_init(
|
bool wf_impl_filesystem_init(
|
||||||
struct wsfs_impl_filesystem * filesystem,
|
struct wf_impl_filesystem * filesystem,
|
||||||
struct wsfs_impl_jsonrpc_server * rpc,
|
struct wf_impl_jsonrpc_server * rpc,
|
||||||
char * mount_point)
|
char * mount_point)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@ -46,8 +46,8 @@ bool wsfs_impl_filesystem_init(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_filesystem_cleanup(
|
void wf_impl_filesystem_cleanup(
|
||||||
struct wsfs_impl_filesystem * filesystem)
|
struct wf_impl_filesystem * filesystem)
|
||||||
{
|
{
|
||||||
if (NULL != filesystem->session)
|
if (NULL != filesystem->session)
|
||||||
{
|
{
|
||||||
@ -61,14 +61,14 @@ void wsfs_impl_filesystem_cleanup(
|
|||||||
fuse_opt_free_args(&filesystem->args);
|
fuse_opt_free_args(&filesystem->args);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wsfs_impl_filesystem_get_fd(
|
int wf_impl_filesystem_get_fd(
|
||||||
struct wsfs_impl_filesystem * filesystem)
|
struct wf_impl_filesystem * filesystem)
|
||||||
{
|
{
|
||||||
return fuse_session_fd(filesystem->session);
|
return fuse_session_fd(filesystem->session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_filesystem_process_request(
|
void wf_impl_filesystem_process_request(
|
||||||
struct wsfs_impl_filesystem * filesystem)
|
struct wf_impl_filesystem * filesystem)
|
||||||
{
|
{
|
||||||
int const result = fuse_session_receive_buf(filesystem->session, &filesystem->buffer);
|
int const result = fuse_session_receive_buf(filesystem->session, &filesystem->buffer);
|
||||||
if (0 < result)
|
if (0 < result)
|
45
lib/webfuse/adapter/impl/filesystem.h
Normal file
45
lib/webfuse/adapter/impl/filesystem.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_FILESYSTEM_H
|
||||||
|
#define WF_ADAPTER_IMPL_FILESYSTEM_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/fuse_wrapper.h"
|
||||||
|
#include "webfuse/adapter/impl/operations.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_impl_jsonrpc_server;
|
||||||
|
|
||||||
|
struct wf_impl_filesystem
|
||||||
|
{
|
||||||
|
struct fuse_args args;
|
||||||
|
struct fuse_session * session;
|
||||||
|
struct fuse_buf buffer;
|
||||||
|
struct wf_impl_operations_context user_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern bool wf_impl_filesystem_init(
|
||||||
|
struct wf_impl_filesystem * filesystem,
|
||||||
|
struct wf_impl_jsonrpc_server * rpc,
|
||||||
|
char * mount_point);
|
||||||
|
|
||||||
|
extern void wf_impl_filesystem_cleanup(
|
||||||
|
struct wf_impl_filesystem * filesystem);
|
||||||
|
|
||||||
|
extern int wf_impl_filesystem_get_fd(
|
||||||
|
struct wf_impl_filesystem * filesystem);
|
||||||
|
|
||||||
|
extern void wf_impl_filesystem_process_request(
|
||||||
|
struct wf_impl_filesystem * filesystem);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef WSFS_ADAPTER_IMPL_FUSE_H
|
#ifndef WF_ADAPTER_IMPL_FUSE_H
|
||||||
#define WSFS_ADAPTER_IMPL_FUSE_H
|
#define WF_ADAPTER_IMPL_FUSE_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
28
lib/webfuse/adapter/impl/jsonrpc/method.c
Normal file
28
lib/webfuse/adapter/impl/jsonrpc/method.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "webfuse/adapter/impl/jsonrpc/method_intern.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
struct wf_impl_jsonrpc_method * wf_impl_jsonrpc_method_create(
|
||||||
|
char const * name,
|
||||||
|
wf_impl_jsonrpc_method_invoke_fn * invoke,
|
||||||
|
void * user_data)
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_method * method = malloc(sizeof(struct wf_impl_jsonrpc_method));
|
||||||
|
if (NULL != method)
|
||||||
|
{
|
||||||
|
method->next = NULL;
|
||||||
|
method->name = strdup(name);
|
||||||
|
method->invoke = invoke;
|
||||||
|
method->user_data = user_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_jsonrpc_method_dispose(
|
||||||
|
struct wf_impl_jsonrpc_method * method)
|
||||||
|
{
|
||||||
|
free(method->name);
|
||||||
|
free(method);
|
||||||
|
}
|
@ -1,25 +1,25 @@
|
|||||||
#ifndef WSFS_ADAPTER_IMPL_JSONRPC_METHOD_H
|
#ifndef WF_ADAPTER_IMPL_JSONRPC_METHOD_H
|
||||||
#define WSFS_ADAPTER_IMPL_JSONRPC_METHOD_H
|
#define WF_ADAPTER_IMPL_JSONRPC_METHOD_H
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include "wsfs/core/status.h"
|
#include "webfuse/core/status.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef bool wsfs_impl_jsonrpc_method_invoke_fn(
|
typedef bool wf_impl_jsonrpc_method_invoke_fn(
|
||||||
void * user_data,
|
void * user_data,
|
||||||
struct json_t const * method_call);
|
struct json_t const * method_call);
|
||||||
|
|
||||||
typedef void wsfs_impl_jsonrpc_method_finished_fn(
|
typedef void wf_impl_jsonrpc_method_finished_fn(
|
||||||
void * user_data,
|
void * user_data,
|
||||||
wsfs_status status,
|
wf_status status,
|
||||||
struct json_t const * result);
|
struct json_t const * result);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
31
lib/webfuse/adapter/impl/jsonrpc/method_intern.h
Normal file
31
lib/webfuse/adapter/impl/jsonrpc/method_intern.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_JSONRPC_METHOD_INTERN_H
|
||||||
|
#define WF_ADAPTER_IMPL_JSONRPC_METHOD_INTERN_H
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/jsonrpc/method.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_impl_jsonrpc_method
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_method * next;
|
||||||
|
char * name;
|
||||||
|
wf_impl_jsonrpc_method_invoke_fn * invoke;
|
||||||
|
void * user_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct wf_impl_jsonrpc_method * wf_impl_jsonrpc_method_create(
|
||||||
|
char const * name,
|
||||||
|
wf_impl_jsonrpc_method_invoke_fn * invoke,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_method_dispose(
|
||||||
|
struct wf_impl_jsonrpc_method * method);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -1,6 +1,6 @@
|
|||||||
#include "wsfs/adapter/impl/jsonrpc/request.h"
|
#include "webfuse/adapter/impl/jsonrpc/request.h"
|
||||||
|
|
||||||
json_t * wsfs_impl_jsonrpc_request_create(
|
json_t * wf_impl_jsonrpc_request_create(
|
||||||
char const * method,
|
char const * method,
|
||||||
int id,
|
int id,
|
||||||
char const * param_info,
|
char const * param_info,
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef WSFS_ADAPTER_IMPL_JSONRPC_REQUEST_H
|
#ifndef WF_ADAPTER_IMPL_JSONRPC_REQUEST_H
|
||||||
#define WSFS_ADAPTER_IMPL_JSONRPC_REQUEST_H
|
#define WF_ADAPTER_IMPL_JSONRPC_REQUEST_H
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -18,7 +18,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern json_t * wsfs_impl_jsonrpc_request_create(
|
extern json_t * wf_impl_jsonrpc_request_create(
|
||||||
char const * method,
|
char const * method,
|
||||||
int id,
|
int id,
|
||||||
char const * param_info,
|
char const * param_info,
|
@ -1,30 +1,30 @@
|
|||||||
#include "wsfs/adapter/impl/jsonrpc/response.h"
|
#include "webfuse/adapter/impl/jsonrpc/response.h"
|
||||||
|
|
||||||
void wsfs_impl_jsonrpc_response_init(
|
void wf_impl_jsonrpc_response_init(
|
||||||
struct wsfs_impl_jsonrpc_response * result,
|
struct wf_impl_jsonrpc_response * result,
|
||||||
char const * buffer,
|
char const * buffer,
|
||||||
size_t length)
|
size_t length)
|
||||||
{
|
{
|
||||||
result->status = WSFS_BAD;
|
result->status = WF_BAD;
|
||||||
result->id = -1;
|
result->id = -1;
|
||||||
result->result = NULL;
|
result->result = NULL;
|
||||||
|
|
||||||
json_t * response = json_loadb(buffer, length, 0, NULL);
|
json_t * response = json_loadb(buffer, length, 0, NULL);
|
||||||
if (NULL == response)
|
if (NULL == response)
|
||||||
{
|
{
|
||||||
result->status = WSFS_BAD_FORMAT;
|
result->status = WF_BAD_FORMAT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
json_t * id_holder = json_object_get(response, "id");
|
json_t * id_holder = json_object_get(response, "id");
|
||||||
if ((NULL == id_holder) || (!json_is_integer(id_holder)))
|
if ((NULL == id_holder) || (!json_is_integer(id_holder)))
|
||||||
{
|
{
|
||||||
result->status = WSFS_BAD_FORMAT;
|
result->status = WF_BAD_FORMAT;
|
||||||
json_decref(response);
|
json_decref(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->status = WSFS_GOOD;
|
result->status = WF_GOOD;
|
||||||
result->id = json_integer_value(id_holder);
|
result->id = json_integer_value(id_holder);
|
||||||
result->result = json_object_get(response, "result");
|
result->result = json_object_get(response, "result");
|
||||||
if (NULL != result->result)
|
if (NULL != result->result)
|
||||||
@ -33,7 +33,7 @@ void wsfs_impl_jsonrpc_response_init(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result->status = WSFS_BAD_FORMAT;
|
result->status = WF_BAD_FORMAT;
|
||||||
|
|
||||||
json_t * error = json_object_get(response, "error");
|
json_t * error = json_object_get(response, "error");
|
||||||
if (NULL != error)
|
if (NULL != error)
|
||||||
@ -49,8 +49,8 @@ void wsfs_impl_jsonrpc_response_init(
|
|||||||
json_decref(response);
|
json_decref(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_jsonrpc_response_cleanup(
|
void wf_impl_jsonrpc_response_cleanup(
|
||||||
struct wsfs_impl_jsonrpc_response * response)
|
struct wf_impl_jsonrpc_response * response)
|
||||||
{
|
{
|
||||||
if (NULL != response->result)
|
if (NULL != response->result)
|
||||||
{
|
{
|
38
lib/webfuse/adapter/impl/jsonrpc/response.h
Normal file
38
lib/webfuse/adapter/impl/jsonrpc/response.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_JSONRPC_RESPONSE_H
|
||||||
|
#define WF_ADAPTER_IMPL_JSONRPC_RESPONSE_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stddef.h>
|
||||||
|
#else
|
||||||
|
#include <cstddef>
|
||||||
|
using std::size_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <jansson.h>
|
||||||
|
#include "webfuse/core/status.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_impl_jsonrpc_response
|
||||||
|
{
|
||||||
|
wf_status status;
|
||||||
|
int id;
|
||||||
|
json_t * result;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_response_init(
|
||||||
|
struct wf_impl_jsonrpc_response * response,
|
||||||
|
char const * buffer,
|
||||||
|
size_t buffer_length);
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_response_cleanup(
|
||||||
|
struct wf_impl_jsonrpc_response * response);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
186
lib/webfuse/adapter/impl/jsonrpc/server.c
Normal file
186
lib/webfuse/adapter/impl/jsonrpc/server.c
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/jsonrpc/method_intern.h"
|
||||||
|
#include "webfuse/adapter/impl/jsonrpc/request.h"
|
||||||
|
#include "webfuse/adapter/impl/jsonrpc/response.h"
|
||||||
|
|
||||||
|
#define WF_DEFAULT_TIMEOUT (10 * 1000)
|
||||||
|
|
||||||
|
static struct wf_impl_jsonrpc_method const * wf_impl_jsonrpc_server_getmethod(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
char const * name)
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_method * method = server->methods;
|
||||||
|
while ((NULL != method) && (0 == strcmp(name, method->name)))
|
||||||
|
{
|
||||||
|
method = method->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wf_impl_jsonrpc_server_timeout(
|
||||||
|
struct wf_impl_timer * timer)
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_server * server = timer->user_data;
|
||||||
|
|
||||||
|
if (server->request.is_pending)
|
||||||
|
{
|
||||||
|
wf_impl_jsonrpc_method_finished_fn * finished = server->request.finished;
|
||||||
|
void * user_data = server->request.user_data;
|
||||||
|
|
||||||
|
server->request.is_pending = false;
|
||||||
|
server->request.id = 0;
|
||||||
|
server->request.user_data = NULL;
|
||||||
|
server->request.finished = NULL;
|
||||||
|
wf_impl_timer_cancel(&server->request.timer);
|
||||||
|
|
||||||
|
finished(user_data, WF_BAD_TIMEOUT, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_jsonrpc_server_init(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
struct wf_impl_timeout_manager * timeout_manager)
|
||||||
|
{
|
||||||
|
server->methods = NULL;
|
||||||
|
server->request.is_pending = false;
|
||||||
|
|
||||||
|
wf_impl_timer_init(&server->request.timer, timeout_manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_jsonrpc_server_cleanup(
|
||||||
|
struct wf_impl_jsonrpc_server * server)
|
||||||
|
{
|
||||||
|
wf_impl_timer_cleanup(&server->request.timer);
|
||||||
|
|
||||||
|
if (server->request.is_pending)
|
||||||
|
{
|
||||||
|
server->request.finished(server->request.user_data, WF_BAD, NULL);
|
||||||
|
server->request.is_pending = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wf_impl_jsonrpc_method * method = server->methods;
|
||||||
|
while (NULL != method)
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_method * next = method->next;
|
||||||
|
method->next = NULL;
|
||||||
|
wf_impl_jsonrpc_method_dispose(method);
|
||||||
|
method = next;
|
||||||
|
}
|
||||||
|
server->methods = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_jsonrpc_server_add(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
char const * name,
|
||||||
|
wf_impl_jsonrpc_method_invoke_fn * invoke,
|
||||||
|
void * user_data)
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_method * method = wf_impl_jsonrpc_method_create(name, invoke, user_data);
|
||||||
|
method->next = server->methods;
|
||||||
|
server->methods = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_jsonrpc_server_invoke(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
wf_impl_jsonrpc_method_finished_fn * finished,
|
||||||
|
void * user_data,
|
||||||
|
char const * method_name,
|
||||||
|
char const * param_info,
|
||||||
|
...
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!server->request.is_pending)
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_method const * method = wf_impl_jsonrpc_server_getmethod(server, method_name);
|
||||||
|
if (NULL != method)
|
||||||
|
{
|
||||||
|
server->request.is_pending = true;
|
||||||
|
server->request.finished = finished;
|
||||||
|
server->request.user_data = user_data;
|
||||||
|
server->request.id = 42;
|
||||||
|
wf_impl_timer_start(&server->request.timer, wf_impl_timepoint_in_msec(WF_DEFAULT_TIMEOUT),
|
||||||
|
&wf_impl_jsonrpc_server_timeout, server);
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, param_info);
|
||||||
|
json_t * request = wf_impl_jsonrpc_request_create(method_name, server->request.id, param_info, args);
|
||||||
|
va_end(args);
|
||||||
|
if (NULL != request)
|
||||||
|
{
|
||||||
|
if (!method->invoke(method->user_data, request))
|
||||||
|
{
|
||||||
|
server->request.is_pending = false;
|
||||||
|
server->request.finished = NULL;
|
||||||
|
server->request.user_data = NULL;
|
||||||
|
server->request.id = 0;
|
||||||
|
wf_impl_timer_cancel(&server->request.timer);
|
||||||
|
|
||||||
|
finished(user_data, WF_BAD, NULL);
|
||||||
|
}
|
||||||
|
json_decref(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finished(user_data, WF_BAD_NOTIMPLEMENTED, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finished(user_data, WF_BAD_BUSY, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_server_notify(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
char const * method_name,
|
||||||
|
char const * param_info,
|
||||||
|
...
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_method const * method = wf_impl_jsonrpc_server_getmethod(server, method_name);
|
||||||
|
if (NULL != method)
|
||||||
|
{
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, param_info);
|
||||||
|
json_t * request = wf_impl_jsonrpc_request_create(method_name, 0, param_info, args);
|
||||||
|
va_end(args);
|
||||||
|
if (NULL != request)
|
||||||
|
{
|
||||||
|
method->invoke(method->user_data, request);
|
||||||
|
json_decref(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wf_impl_jsonrpc_server_onresult(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
char const * message,
|
||||||
|
size_t length)
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_response response;
|
||||||
|
wf_impl_jsonrpc_response_init(&response, message, length);
|
||||||
|
|
||||||
|
if ((server->request.is_pending) && (response.id == server->request.id))
|
||||||
|
{
|
||||||
|
wf_impl_jsonrpc_method_finished_fn * finished = server->request.finished;
|
||||||
|
void * user_data = server->request.user_data;
|
||||||
|
|
||||||
|
server->request.is_pending = false;
|
||||||
|
server->request.id = 0;
|
||||||
|
server->request.user_data = NULL;
|
||||||
|
server->request.finished = NULL;
|
||||||
|
wf_impl_timer_cancel(&server->request.timer);
|
||||||
|
|
||||||
|
finished(user_data, response.status, response.result);
|
||||||
|
}
|
||||||
|
|
||||||
|
wf_impl_jsonrpc_response_cleanup(&response);
|
||||||
|
}
|
||||||
|
|
77
lib/webfuse/adapter/impl/jsonrpc/server.h
Normal file
77
lib/webfuse/adapter/impl/jsonrpc/server.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_JSONRPC_SERVER_H
|
||||||
|
#define WF_ADAPTER_IMPL_JSONRPC_SERVER_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#else
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstddef>
|
||||||
|
using std::size_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <jansson.h>
|
||||||
|
#include "webfuse/adapter/impl/jsonrpc/method.h"
|
||||||
|
#include "webfuse/adapter/impl/time/timeout_manager.h"
|
||||||
|
#include "webfuse/adapter/impl/time/timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_impl_jsonrpc_request
|
||||||
|
{
|
||||||
|
bool is_pending;
|
||||||
|
wf_impl_jsonrpc_method_finished_fn * finished;
|
||||||
|
void * user_data;
|
||||||
|
int id;
|
||||||
|
struct wf_impl_timer timer;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wf_impl_jsonrpc_server
|
||||||
|
{
|
||||||
|
struct wf_impl_jsonrpc_method * methods;
|
||||||
|
struct wf_impl_jsonrpc_request request;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_server_init(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
struct wf_impl_timeout_manager * manager);
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_server_cleanup(
|
||||||
|
struct wf_impl_jsonrpc_server * server);
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_server_add(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
char const * name,
|
||||||
|
wf_impl_jsonrpc_method_invoke_fn * invoke,
|
||||||
|
void * user_data );
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_server_invoke(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
wf_impl_jsonrpc_method_finished_fn * finished,
|
||||||
|
void * user_data,
|
||||||
|
char const * method_name,
|
||||||
|
char const * param_info,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_server_notify(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
char const * method_name,
|
||||||
|
char const * param_info,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
extern void wf_impl_jsonrpc_server_onresult(
|
||||||
|
struct wf_impl_jsonrpc_server * server,
|
||||||
|
char const * message,
|
||||||
|
size_t length);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -1,6 +1,6 @@
|
|||||||
#include "wsfs/adapter/impl/jsonrpc/util.h"
|
#include "webfuse/adapter/impl/jsonrpc/util.h"
|
||||||
|
|
||||||
int wsfs_impl_json_get_int(json_t const * object, char const * key, int default_value)
|
int wf_impl_json_get_int(json_t const * object, char const * key, int default_value)
|
||||||
{
|
{
|
||||||
int result = default_value;
|
int result = default_value;
|
||||||
|
|
17
lib/webfuse/adapter/impl/jsonrpc/util.h
Normal file
17
lib/webfuse/adapter/impl/jsonrpc/util.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_JSON_UTIL_H
|
||||||
|
#define WF_ADAPTER_IMPL_JSON_UTIL_H
|
||||||
|
|
||||||
|
#include <jansson.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int wf_impl_json_get_int(json_t const * object, char const * key, int default_value);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
21
lib/webfuse/adapter/impl/operation/close.c
Normal file
21
lib/webfuse/adapter/impl/operation/close.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include "webfuse/adapter/impl/operations.h"
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <jansson.h>
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
|
#include "webfuse/core/util.h"
|
||||||
|
|
||||||
|
void wf_impl_operation_close(
|
||||||
|
fuse_req_t request,
|
||||||
|
fuse_ino_t inode,
|
||||||
|
struct fuse_file_info * file_info)
|
||||||
|
{
|
||||||
|
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
|
||||||
|
struct wf_impl_jsonrpc_server * rpc = user_data->rpc;
|
||||||
|
|
||||||
|
int handle = (int) (file_info->fh & INT_MAX);
|
||||||
|
wf_impl_jsonrpc_server_notify(rpc, "close", "iii", inode, handle, file_info->flags);
|
||||||
|
fuse_reply_err(request, 0);
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
#include "wsfs/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operations.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -7,11 +7,11 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "wsfs/adapter/impl/jsonrpc/server.h"
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
#include "wsfs/adapter/impl/jsonrpc/util.h"
|
#include "webfuse/adapter/impl/jsonrpc/util.h"
|
||||||
#include "wsfs/core/util.h"
|
#include "webfuse/core/util.h"
|
||||||
|
|
||||||
struct wsfs_impl_operation_getattr_context
|
struct wf_impl_operation_getattr_context
|
||||||
{
|
{
|
||||||
fuse_req_t request;
|
fuse_req_t request;
|
||||||
double timeout;
|
double timeout;
|
||||||
@ -19,12 +19,12 @@ struct wsfs_impl_operation_getattr_context
|
|||||||
gid_t gid;
|
gid_t gid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void wsfs_impl_operation_getattr_finished(
|
static void wf_impl_operation_getattr_finished(
|
||||||
void * user_data,
|
void * user_data,
|
||||||
wsfs_status status,
|
wf_status status,
|
||||||
json_t const * data)
|
json_t const * data)
|
||||||
{
|
{
|
||||||
struct wsfs_impl_operation_getattr_context * context = user_data;
|
struct wf_impl_operation_getattr_context * context = user_data;
|
||||||
|
|
||||||
struct stat buffer;
|
struct stat buffer;
|
||||||
if (NULL != data)
|
if (NULL != data)
|
||||||
@ -50,19 +50,19 @@ static void wsfs_impl_operation_getattr_finished(
|
|||||||
buffer.st_uid = context->uid;
|
buffer.st_uid = context->uid;
|
||||||
buffer.st_gid = context->gid;
|
buffer.st_gid = context->gid;
|
||||||
buffer.st_nlink = 1;
|
buffer.st_nlink = 1;
|
||||||
buffer.st_size = wsfs_impl_json_get_int(data, "size", 0);
|
buffer.st_size = wf_impl_json_get_int(data, "size", 0);
|
||||||
buffer.st_atime = wsfs_impl_json_get_int(data, "atime", 0);
|
buffer.st_atime = wf_impl_json_get_int(data, "atime", 0);
|
||||||
buffer.st_mtime = wsfs_impl_json_get_int(data, "mtime", 0);
|
buffer.st_mtime = wf_impl_json_get_int(data, "mtime", 0);
|
||||||
buffer.st_ctime = wsfs_impl_json_get_int(data, "ctime", 0);
|
buffer.st_ctime = wf_impl_json_get_int(data, "ctime", 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = WSFS_BAD_FORMAT;
|
status = WF_BAD_FORMAT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WSFS_GOOD == status)
|
if (WF_GOOD == status)
|
||||||
{
|
{
|
||||||
fuse_reply_attr(context->request, &buffer, context->timeout);
|
fuse_reply_attr(context->request, &buffer, context->timeout);
|
||||||
}
|
}
|
||||||
@ -74,20 +74,20 @@ static void wsfs_impl_operation_getattr_finished(
|
|||||||
free(context);
|
free(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_operation_getattr (
|
void wf_impl_operation_getattr (
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t inode,
|
fuse_ino_t inode,
|
||||||
struct fuse_file_info * WSFS_UNUSED_PARAM(file_info))
|
struct fuse_file_info * WF_UNUSED_PARAM(file_info))
|
||||||
{
|
{
|
||||||
struct fuse_ctx const * context = fuse_req_ctx(request);
|
struct fuse_ctx const * context = fuse_req_ctx(request);
|
||||||
struct wsfs_impl_operations_context * user_data = fuse_req_userdata(request);
|
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
|
||||||
struct wsfs_impl_jsonrpc_server * rpc = user_data->rpc;
|
struct wf_impl_jsonrpc_server * rpc = user_data->rpc;
|
||||||
|
|
||||||
struct wsfs_impl_operation_getattr_context * getattr_context = malloc(sizeof(struct wsfs_impl_operation_getattr_context));
|
struct wf_impl_operation_getattr_context * getattr_context = malloc(sizeof(struct wf_impl_operation_getattr_context));
|
||||||
getattr_context->request = request;
|
getattr_context->request = request;
|
||||||
getattr_context->uid = context->uid;
|
getattr_context->uid = context->uid;
|
||||||
getattr_context->gid = context->gid;
|
getattr_context->gid = context->gid;
|
||||||
getattr_context->timeout = user_data->timeout;
|
getattr_context->timeout = user_data->timeout;
|
||||||
|
|
||||||
wsfs_impl_jsonrpc_server_invoke(rpc, &wsfs_impl_operation_getattr_finished, getattr_context, "getattr", "i", inode);
|
wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_getattr_finished, getattr_context, "getattr", "i", inode);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
#include "wsfs/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operations.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "wsfs/adapter/impl/jsonrpc/server.h"
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
#include "wsfs/adapter/impl/jsonrpc/util.h"
|
#include "webfuse/adapter/impl/jsonrpc/util.h"
|
||||||
#include "wsfs/core/util.h"
|
#include "webfuse/core/util.h"
|
||||||
|
|
||||||
struct wsfs_impl_operation_lookup_context
|
struct wf_impl_operation_lookup_context
|
||||||
{
|
{
|
||||||
fuse_req_t request;
|
fuse_req_t request;
|
||||||
double timeout;
|
double timeout;
|
||||||
@ -22,13 +22,13 @@ struct wsfs_impl_operation_lookup_context
|
|||||||
gid_t gid;
|
gid_t gid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void wsfs_impl_operation_lookup_finished(
|
static void wf_impl_operation_lookup_finished(
|
||||||
void * user_data,
|
void * user_data,
|
||||||
wsfs_status status,
|
wf_status status,
|
||||||
json_t const * data
|
json_t const * data
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
struct wsfs_impl_operation_lookup_context * context = user_data;
|
struct wf_impl_operation_lookup_context * context = user_data;
|
||||||
struct fuse_entry_param buffer;
|
struct fuse_entry_param buffer;
|
||||||
|
|
||||||
if (NULL != data)
|
if (NULL != data)
|
||||||
@ -60,18 +60,18 @@ static void wsfs_impl_operation_lookup_finished(
|
|||||||
buffer.attr.st_uid = context->uid;
|
buffer.attr.st_uid = context->uid;
|
||||||
buffer.attr.st_gid = context->gid;
|
buffer.attr.st_gid = context->gid;
|
||||||
buffer.attr.st_nlink = 1;
|
buffer.attr.st_nlink = 1;
|
||||||
buffer.attr.st_size = wsfs_impl_json_get_int(data, "size", 0);
|
buffer.attr.st_size = wf_impl_json_get_int(data, "size", 0);
|
||||||
buffer.attr.st_atime = wsfs_impl_json_get_int(data, "atime", 0);
|
buffer.attr.st_atime = wf_impl_json_get_int(data, "atime", 0);
|
||||||
buffer.attr.st_mtime = wsfs_impl_json_get_int(data, "mtime", 0);
|
buffer.attr.st_mtime = wf_impl_json_get_int(data, "mtime", 0);
|
||||||
buffer.attr.st_ctime = wsfs_impl_json_get_int(data, "ctime", 0);
|
buffer.attr.st_ctime = wf_impl_json_get_int(data, "ctime", 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = WSFS_BAD_FORMAT;
|
status = WF_BAD_FORMAT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WSFS_GOOD == status)
|
if (WF_GOOD == status)
|
||||||
{
|
{
|
||||||
fuse_reply_entry(context->request, &buffer);
|
fuse_reply_entry(context->request, &buffer);
|
||||||
}
|
}
|
||||||
@ -83,20 +83,20 @@ static void wsfs_impl_operation_lookup_finished(
|
|||||||
free(context);
|
free(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_operation_lookup (
|
void wf_impl_operation_lookup (
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t parent,
|
fuse_ino_t parent,
|
||||||
char const * name)
|
char const * name)
|
||||||
{
|
{
|
||||||
struct fuse_ctx const * context = fuse_req_ctx(request);
|
struct fuse_ctx const * context = fuse_req_ctx(request);
|
||||||
struct wsfs_impl_operations_context * user_data = fuse_req_userdata(request);
|
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
|
||||||
struct wsfs_impl_jsonrpc_server * rpc = user_data->rpc;
|
struct wf_impl_jsonrpc_server * rpc = user_data->rpc;
|
||||||
|
|
||||||
struct wsfs_impl_operation_lookup_context * lookup_context = malloc(sizeof(struct wsfs_impl_operation_lookup_context));
|
struct wf_impl_operation_lookup_context * lookup_context = malloc(sizeof(struct wf_impl_operation_lookup_context));
|
||||||
lookup_context->request = request;
|
lookup_context->request = request;
|
||||||
lookup_context->uid = context->uid;
|
lookup_context->uid = context->uid;
|
||||||
lookup_context->gid = context->gid;
|
lookup_context->gid = context->gid;
|
||||||
lookup_context->timeout = user_data->timeout;
|
lookup_context->timeout = user_data->timeout;
|
||||||
|
|
||||||
wsfs_impl_jsonrpc_server_invoke(rpc, &wsfs_impl_operation_lookup_finished, lookup_context, "lookup", "is", (int) (parent & INT_MAX), name);
|
wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_lookup_finished, lookup_context, "lookup", "is", (int) (parent & INT_MAX), name);
|
||||||
}
|
}
|
@ -1,16 +1,16 @@
|
|||||||
#include "wsfs/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operations.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
|
|
||||||
#include "wsfs/adapter/impl/jsonrpc/server.h"
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
#include "wsfs/core/util.h"
|
#include "webfuse/core/util.h"
|
||||||
#include "wsfs/core/status.h"
|
#include "webfuse/core/status.h"
|
||||||
|
|
||||||
static void wsfs_impl_operation_open_finished(
|
static void wf_impl_operation_open_finished(
|
||||||
void * user_data,
|
void * user_data,
|
||||||
wsfs_status status,
|
wf_status status,
|
||||||
json_t const * result)
|
json_t const * result)
|
||||||
{
|
{
|
||||||
fuse_req_t request = user_data;
|
fuse_req_t request = user_data;
|
||||||
@ -26,11 +26,11 @@ static void wsfs_impl_operation_open_finished(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = WSFS_BAD_FORMAT;
|
status = WF_BAD_FORMAT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WSFS_GOOD == status)
|
if (WF_GOOD == status)
|
||||||
{
|
{
|
||||||
fuse_reply_open(request, &file_info);
|
fuse_reply_open(request, &file_info);
|
||||||
}
|
}
|
||||||
@ -41,13 +41,13 @@ static void wsfs_impl_operation_open_finished(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_operation_open(
|
void wf_impl_operation_open(
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t inode,
|
fuse_ino_t inode,
|
||||||
struct fuse_file_info * file_info)
|
struct fuse_file_info * file_info)
|
||||||
{
|
{
|
||||||
struct wsfs_impl_operations_context * user_data = fuse_req_userdata(request);
|
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
|
||||||
struct wsfs_impl_jsonrpc_server * rpc = user_data->rpc;
|
struct wf_impl_jsonrpc_server * rpc = user_data->rpc;
|
||||||
|
|
||||||
wsfs_impl_jsonrpc_server_invoke(rpc, &wsfs_impl_operation_open_finished, request, "open", "ii", inode, file_info->flags);
|
wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_open_finished, request, "open", "ii", inode, file_info->flags);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
#include "wsfs/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operations.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -6,17 +6,17 @@
|
|||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <libwebsockets.h>
|
#include <libwebsockets.h>
|
||||||
|
|
||||||
#include "wsfs/adapter/impl/jsonrpc/server.h"
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
|
|
||||||
#define WSFS_MAX_READ_LENGTH 4096
|
#define WF_MAX_READ_LENGTH 4096
|
||||||
|
|
||||||
static char * wsfs_impl_fill_buffer(
|
static char * wf_impl_fill_buffer(
|
||||||
char const * data,
|
char const * data,
|
||||||
char const * format,
|
char const * format,
|
||||||
size_t count,
|
size_t count,
|
||||||
wsfs_status * status)
|
wf_status * status)
|
||||||
{
|
{
|
||||||
*status = WSFS_GOOD;
|
*status = WF_GOOD;
|
||||||
char * buffer = malloc(count + 1);
|
char * buffer = malloc(count + 1);
|
||||||
|
|
||||||
if ((NULL != buffer) && (0 < count))
|
if ((NULL != buffer) && (0 < count))
|
||||||
@ -31,14 +31,14 @@ static char * wsfs_impl_fill_buffer(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*status = WSFS_BAD;
|
*status = WF_BAD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wsfs_impl_operation_read_finished(void * user_data, wsfs_status status, json_t const * data)
|
static void wf_impl_operation_read_finished(void * user_data, wf_status status, json_t const * data)
|
||||||
{
|
{
|
||||||
fuse_req_t request = user_data;
|
fuse_req_t request = user_data;
|
||||||
|
|
||||||
@ -58,15 +58,15 @@ static void wsfs_impl_operation_read_finished(void * user_data, wsfs_status stat
|
|||||||
char const * const format = json_string_value(format_holder);
|
char const * const format = json_string_value(format_holder);
|
||||||
length = (size_t) json_integer_value(count_holder);
|
length = (size_t) json_integer_value(count_holder);
|
||||||
|
|
||||||
buffer = wsfs_impl_fill_buffer(data, format, length, &status);
|
buffer = wf_impl_fill_buffer(data, format, length, &status);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = WSFS_BAD_FORMAT;
|
status = WF_BAD_FORMAT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WSFS_GOOD == status)
|
if (WF_GOOD == status)
|
||||||
{
|
{
|
||||||
fuse_reply_buf(request, buffer, length);
|
fuse_reply_buf(request, buffer, length);
|
||||||
}
|
}
|
||||||
@ -79,17 +79,17 @@ static void wsfs_impl_operation_read_finished(void * user_data, wsfs_status stat
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_operation_read(
|
void wf_impl_operation_read(
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t inode,
|
fuse_ino_t inode,
|
||||||
size_t size,
|
size_t size,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info * file_info)
|
struct fuse_file_info * file_info)
|
||||||
{
|
{
|
||||||
struct wsfs_impl_operations_context * user_data = fuse_req_userdata(request);
|
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
|
||||||
struct wsfs_impl_jsonrpc_server * rpc = user_data->rpc;
|
struct wf_impl_jsonrpc_server * rpc = user_data->rpc;
|
||||||
|
|
||||||
int const length = (size <= WSFS_MAX_READ_LENGTH) ? (int) size : WSFS_MAX_READ_LENGTH;
|
int const length = (size <= WF_MAX_READ_LENGTH) ? (int) size : WF_MAX_READ_LENGTH;
|
||||||
int handle = (file_info->fh & INT_MAX);
|
int handle = (file_info->fh & INT_MAX);
|
||||||
wsfs_impl_jsonrpc_server_invoke(rpc, &wsfs_impl_operation_read_finished, request, "read", "iiii", inode, handle, (int) offset, length);
|
wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_read_finished, request, "read", "iiii", inode, handle, (int) offset, length);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
#include "wsfs/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operations.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -8,43 +8,43 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "wsfs/adapter/impl/jsonrpc/server.h"
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
#include "wsfs/core/util.h"
|
#include "webfuse/core/util.h"
|
||||||
|
|
||||||
|
|
||||||
#define WSFS_DIRBUFFER_INITIAL_SIZE 1024
|
#define WF_DIRBUFFER_INITIAL_SIZE 1024
|
||||||
|
|
||||||
struct wsfs_impl_operation_readdir_context
|
struct wf_impl_operation_readdir_context
|
||||||
{
|
{
|
||||||
fuse_req_t request;
|
fuse_req_t request;
|
||||||
size_t size;
|
size_t size;
|
||||||
off_t offset;
|
off_t offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wsfs_impl_dirbuffer
|
struct wf_impl_dirbuffer
|
||||||
{
|
{
|
||||||
char * data;
|
char * data;
|
||||||
size_t position;
|
size_t position;
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void wsfs_impl_dirbuffer_init(
|
static void wf_impl_dirbuffer_init(
|
||||||
struct wsfs_impl_dirbuffer * buffer)
|
struct wf_impl_dirbuffer * buffer)
|
||||||
{
|
{
|
||||||
buffer->data = malloc(WSFS_DIRBUFFER_INITIAL_SIZE);
|
buffer->data = malloc(WF_DIRBUFFER_INITIAL_SIZE);
|
||||||
buffer->position = 0;
|
buffer->position = 0;
|
||||||
buffer->capacity = WSFS_DIRBUFFER_INITIAL_SIZE;
|
buffer->capacity = WF_DIRBUFFER_INITIAL_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wsfs_impl_dirbuffer_dispose(
|
static void wf_impl_dirbuffer_dispose(
|
||||||
struct wsfs_impl_dirbuffer * buffer)
|
struct wf_impl_dirbuffer * buffer)
|
||||||
{
|
{
|
||||||
free(buffer->data);
|
free(buffer->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wsfs_impl_dirbuffer_add(
|
static void wf_impl_dirbuffer_add(
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
struct wsfs_impl_dirbuffer * buffer,
|
struct wf_impl_dirbuffer * buffer,
|
||||||
char const * name,
|
char const * name,
|
||||||
fuse_ino_t inode)
|
fuse_ino_t inode)
|
||||||
{
|
{
|
||||||
@ -66,20 +66,20 @@ static void wsfs_impl_dirbuffer_add(
|
|||||||
buffer->position += size;
|
buffer->position += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t wsfs_impl_min(size_t a, size_t b)
|
static size_t wf_impl_min(size_t a, size_t b)
|
||||||
{
|
{
|
||||||
return (a < b) ? a : b;
|
return (a < b) ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wsfs_impl_operation_readdir_finished(
|
static void wf_impl_operation_readdir_finished(
|
||||||
void * user_data,
|
void * user_data,
|
||||||
wsfs_status status,
|
wf_status status,
|
||||||
json_t const * result)
|
json_t const * result)
|
||||||
{
|
{
|
||||||
struct wsfs_impl_operation_readdir_context * context = user_data;
|
struct wf_impl_operation_readdir_context * context = user_data;
|
||||||
|
|
||||||
struct wsfs_impl_dirbuffer buffer;
|
struct wf_impl_dirbuffer buffer;
|
||||||
wsfs_impl_dirbuffer_init(&buffer);
|
wf_impl_dirbuffer_init(&buffer);
|
||||||
|
|
||||||
if (NULL != result)
|
if (NULL != result)
|
||||||
{
|
{
|
||||||
@ -100,19 +100,19 @@ static void wsfs_impl_operation_readdir_finished(
|
|||||||
{
|
{
|
||||||
char const * name = json_string_value(name_holder);
|
char const * name = json_string_value(name_holder);
|
||||||
fuse_ino_t entry_inode = (fuse_ino_t) json_integer_value(inode_holder);
|
fuse_ino_t entry_inode = (fuse_ino_t) json_integer_value(inode_holder);
|
||||||
wsfs_impl_dirbuffer_add(context->request, &buffer, name, entry_inode);
|
wf_impl_dirbuffer_add(context->request, &buffer, name, entry_inode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WSFS_GOOD == status)
|
if (WF_GOOD == status)
|
||||||
{
|
{
|
||||||
if (((size_t) context->offset) < buffer.position)
|
if (((size_t) context->offset) < buffer.position)
|
||||||
{
|
{
|
||||||
fuse_reply_buf(context->request, &buffer.data[context->offset],
|
fuse_reply_buf(context->request, &buffer.data[context->offset],
|
||||||
wsfs_impl_min(buffer.position - context->offset, context->size));
|
wf_impl_min(buffer.position - context->offset, context->size));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -125,23 +125,23 @@ static void wsfs_impl_operation_readdir_finished(
|
|||||||
fuse_reply_err(context->request, ENOENT);
|
fuse_reply_err(context->request, ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
wsfs_impl_dirbuffer_dispose(&buffer);
|
wf_impl_dirbuffer_dispose(&buffer);
|
||||||
free(context);
|
free(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_operation_readdir (
|
void wf_impl_operation_readdir (
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t inode,
|
fuse_ino_t inode,
|
||||||
size_t size,
|
size_t size,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info * WSFS_UNUSED_PARAM(file_info))
|
struct fuse_file_info * WF_UNUSED_PARAM(file_info))
|
||||||
{
|
{
|
||||||
struct wsfs_impl_operations_context * user_data = fuse_req_userdata(request);
|
struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
|
||||||
struct wsfs_impl_jsonrpc_server * rpc = user_data->rpc;
|
struct wf_impl_jsonrpc_server * rpc = user_data->rpc;
|
||||||
struct wsfs_impl_operation_readdir_context * readdir_context = malloc(sizeof(struct wsfs_impl_operation_readdir_context));
|
struct wf_impl_operation_readdir_context * readdir_context = malloc(sizeof(struct wf_impl_operation_readdir_context));
|
||||||
readdir_context->request = request;
|
readdir_context->request = request;
|
||||||
readdir_context->size = size;
|
readdir_context->size = size;
|
||||||
readdir_context->offset = offset;
|
readdir_context->offset = offset;
|
||||||
|
|
||||||
wsfs_impl_jsonrpc_server_invoke(rpc, &wsfs_impl_operation_readdir_finished, readdir_context, "readdir", "i", inode);
|
wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_readdir_finished, readdir_context, "readdir", "i", inode);
|
||||||
}
|
}
|
@ -1,48 +1,48 @@
|
|||||||
#ifndef WSFS_ADAPTER_IMPL_OPERATIONS_H
|
#ifndef WF_ADAPTER_IMPL_OPERATIONS_H
|
||||||
#define WSFS_ADAPTER_IMPL_OPERATIONS_H
|
#define WF_ADAPTER_IMPL_OPERATIONS_H
|
||||||
|
|
||||||
#include "wsfs/adapter/impl/fuse_wrapper.h"
|
#include "webfuse/adapter/impl/fuse_wrapper.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct wsfs_impl_jsonrpc_server;
|
struct wf_impl_jsonrpc_server;
|
||||||
|
|
||||||
struct wsfs_impl_operations_context
|
struct wf_impl_operations_context
|
||||||
{
|
{
|
||||||
struct wsfs_impl_jsonrpc_server * rpc;
|
struct wf_impl_jsonrpc_server * rpc;
|
||||||
double timeout;
|
double timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void wsfs_impl_operation_lookup (
|
extern void wf_impl_operation_lookup (
|
||||||
fuse_req_t req,
|
fuse_req_t req,
|
||||||
fuse_ino_t parent,
|
fuse_ino_t parent,
|
||||||
char const * name);
|
char const * name);
|
||||||
|
|
||||||
extern void wsfs_impl_operation_getattr (
|
extern void wf_impl_operation_getattr (
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t inode,
|
fuse_ino_t inode,
|
||||||
struct fuse_file_info *file_info);
|
struct fuse_file_info *file_info);
|
||||||
|
|
||||||
extern void wsfs_impl_operation_readdir (
|
extern void wf_impl_operation_readdir (
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t inode,
|
fuse_ino_t inode,
|
||||||
size_t size,
|
size_t size,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *file_info);
|
struct fuse_file_info *file_info);
|
||||||
|
|
||||||
extern void wsfs_impl_operation_open(
|
extern void wf_impl_operation_open(
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t inode,
|
fuse_ino_t inode,
|
||||||
struct fuse_file_info * file_info);
|
struct fuse_file_info * file_info);
|
||||||
|
|
||||||
extern void wsfs_impl_operation_close(
|
extern void wf_impl_operation_close(
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t inode,
|
fuse_ino_t inode,
|
||||||
struct fuse_file_info * file_info);
|
struct fuse_file_info * file_info);
|
||||||
|
|
||||||
extern void wsfs_impl_operation_read(
|
extern void wf_impl_operation_read(
|
||||||
fuse_req_t request,
|
fuse_req_t request,
|
||||||
fuse_ino_t ino, size_t size, off_t off,
|
fuse_ino_t ino, size_t size, off_t off,
|
||||||
struct fuse_file_info *fi);
|
struct fuse_file_info *fi);
|
@ -1,4 +1,4 @@
|
|||||||
#include "wsfs/adapter/server.h"
|
#include "webfuse/adapter/server.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -8,40 +8,40 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "wsfs/adapter/impl/server_config.h"
|
#include "webfuse/adapter/impl/server_config.h"
|
||||||
#include "wsfs/adapter/impl/server_protocol.h"
|
#include "webfuse/adapter/impl/server_protocol.h"
|
||||||
|
|
||||||
#define WSFS_DISABLE_LWS_LOG 0
|
#define WF_DISABLE_LWS_LOG 0
|
||||||
#define WSFS_SERVER_PROTOCOL_COUNT 3
|
#define WF_SERVER_PROTOCOL_COUNT 3
|
||||||
#define WSFS_SERVER_TIMEOUT (1 * 1000)
|
#define WF_SERVER_TIMEOUT (1 * 1000)
|
||||||
|
|
||||||
struct wsfs_server
|
struct wf_server
|
||||||
{
|
{
|
||||||
struct wsfs_server_config config;
|
struct wf_server_config config;
|
||||||
struct wsfs_server_protocol protocol;
|
struct wf_server_protocol protocol;
|
||||||
struct lws_protocols ws_protocols[WSFS_SERVER_PROTOCOL_COUNT];
|
struct lws_protocols ws_protocols[WF_SERVER_PROTOCOL_COUNT];
|
||||||
struct lws_context * context;
|
struct lws_context * context;
|
||||||
volatile bool shutdown_requested;
|
volatile bool shutdown_requested;
|
||||||
struct lws_http_mount mount;
|
struct lws_http_mount mount;
|
||||||
struct lws_context_creation_info info;
|
struct lws_context_creation_info info;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool wsfs_impl_server_tls_enabled(
|
static bool wf_impl_server_tls_enabled(
|
||||||
struct wsfs_server * server)
|
struct wf_server * server)
|
||||||
{
|
{
|
||||||
return ((server->config.key_path != NULL) && (server->config.cert_path != NULL));
|
return ((server->config.key_path != NULL) && (server->config.cert_path != NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct lws_context * wsfs_impl_server_context_create(
|
static struct lws_context * wf_impl_server_context_create(
|
||||||
struct wsfs_server * server)
|
struct wf_server * server)
|
||||||
{
|
{
|
||||||
lws_set_log_level(WSFS_DISABLE_LWS_LOG, NULL);
|
lws_set_log_level(WF_DISABLE_LWS_LOG, NULL);
|
||||||
|
|
||||||
memset(server->ws_protocols, 0, sizeof(struct lws_protocols) * WSFS_SERVER_PROTOCOL_COUNT);
|
memset(server->ws_protocols, 0, sizeof(struct lws_protocols) * WF_SERVER_PROTOCOL_COUNT);
|
||||||
server->ws_protocols[0].name = "http";
|
server->ws_protocols[0].name = "http";
|
||||||
server->ws_protocols[0].callback = lws_callback_http_dummy;
|
server->ws_protocols[0].callback = lws_callback_http_dummy;
|
||||||
server->ws_protocols[1].name = "fs";
|
server->ws_protocols[1].name = "fs";
|
||||||
wsfs_impl_server_protocol_init_lws(&server->protocol, &server->ws_protocols[1]);
|
wf_impl_server_protocol_init_lws(&server->protocol, &server->ws_protocols[1]);
|
||||||
|
|
||||||
memset(&server->mount, 0, sizeof(struct lws_http_mount));
|
memset(&server->mount, 0, sizeof(struct lws_http_mount));
|
||||||
server->mount.mount_next = NULL,
|
server->mount.mount_next = NULL,
|
||||||
@ -66,7 +66,7 @@ static struct lws_context * wsfs_impl_server_context_create(
|
|||||||
server->info.mounts = NULL;
|
server->info.mounts = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wsfs_impl_server_tls_enabled(server))
|
if (wf_impl_server_tls_enabled(server))
|
||||||
{
|
{
|
||||||
server->info.options |= LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
|
server->info.options |= LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
|
||||||
server->info.ssl_cert_filepath = server->config.cert_path;
|
server->info.ssl_cert_filepath = server->config.cert_path;
|
||||||
@ -78,8 +78,8 @@ static struct lws_context * wsfs_impl_server_context_create(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wsfs_impl_server_check_mountpoint(
|
static bool wf_impl_server_check_mountpoint(
|
||||||
struct wsfs_server_config * config)
|
struct wf_server_config * config)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
@ -98,22 +98,22 @@ static bool wsfs_impl_server_check_mountpoint(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wsfs_server * wsfs_impl_server_create(
|
struct wf_server * wf_impl_server_create(
|
||||||
struct wsfs_server_config * config)
|
struct wf_server_config * config)
|
||||||
{
|
{
|
||||||
struct wsfs_server * server = NULL;
|
struct wf_server * server = NULL;
|
||||||
|
|
||||||
if (wsfs_impl_server_check_mountpoint(config))
|
if (wf_impl_server_check_mountpoint(config))
|
||||||
{
|
{
|
||||||
server = malloc(sizeof(struct wsfs_server));
|
server = malloc(sizeof(struct wf_server));
|
||||||
if (NULL != server)
|
if (NULL != server)
|
||||||
{
|
{
|
||||||
if (wsfs_impl_server_protocol_init(&server->protocol, config->mount_point))
|
if (wf_impl_server_protocol_init(&server->protocol, config->mount_point))
|
||||||
{
|
{
|
||||||
server->shutdown_requested = false;
|
server->shutdown_requested = false;
|
||||||
wsfs_impl_server_config_clone(config, &server->config);
|
wf_impl_server_config_clone(config, &server->config);
|
||||||
wsfs_impl_authenticators_move(&server->config.authenticators, &server->protocol.authenticators);
|
wf_impl_authenticators_move(&server->config.authenticators, &server->protocol.authenticators);
|
||||||
server->context = wsfs_impl_server_context_create(server);
|
server->context = wf_impl_server_context_create(server);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -126,27 +126,27 @@ struct wsfs_server * wsfs_impl_server_create(
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_server_dispose(
|
void wf_impl_server_dispose(
|
||||||
struct wsfs_server * server)
|
struct wf_server * server)
|
||||||
{
|
{
|
||||||
lws_context_destroy(server->context);
|
lws_context_destroy(server->context);
|
||||||
wsfs_impl_server_protocol_cleanup(&server->protocol);
|
wf_impl_server_protocol_cleanup(&server->protocol);
|
||||||
wsfs_impl_server_config_cleanup(&server->config);
|
wf_impl_server_config_cleanup(&server->config);
|
||||||
free(server);
|
free(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_server_run(
|
void wf_impl_server_run(
|
||||||
struct wsfs_server * server)
|
struct wf_server * server)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while ((0 <= n) && (!server->shutdown_requested))
|
while ((0 <= n) && (!server->shutdown_requested))
|
||||||
{
|
{
|
||||||
n = lws_service(server->context, WSFS_SERVER_TIMEOUT);
|
n = lws_service(server->context, WF_SERVER_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsfs_impl_server_shutdown(
|
void wf_impl_server_shutdown(
|
||||||
struct wsfs_server * server)
|
struct wf_server * server)
|
||||||
{
|
{
|
||||||
server->shutdown_requested = true;
|
server->shutdown_requested = true;
|
||||||
}
|
}
|
29
lib/webfuse/adapter/impl/server.h
Normal file
29
lib/webfuse/adapter/impl/server.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_SERVER_H
|
||||||
|
#define WF_ADAPTER_IMPL_SERVER_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_server;
|
||||||
|
struct wf_server_config;
|
||||||
|
|
||||||
|
extern struct wf_server * wf_impl_server_create(
|
||||||
|
struct wf_server_config * config);
|
||||||
|
|
||||||
|
extern void wf_impl_server_dispose(
|
||||||
|
struct wf_server * server);
|
||||||
|
|
||||||
|
extern void wf_impl_server_run(
|
||||||
|
struct wf_server * server);
|
||||||
|
|
||||||
|
extern void wf_impl_server_shutdown(
|
||||||
|
struct wf_server * server);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
127
lib/webfuse/adapter/impl/server_config.c
Normal file
127
lib/webfuse/adapter/impl/server_config.c
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#include "webfuse/adapter/impl/server_config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static char * wf_impl_server_config_strdup(char const * value)
|
||||||
|
{
|
||||||
|
char * result = NULL;
|
||||||
|
if (NULL != value)
|
||||||
|
{
|
||||||
|
result = strdup(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_init(
|
||||||
|
struct wf_server_config * config)
|
||||||
|
{
|
||||||
|
memset(config, 0, sizeof(struct wf_server_config));
|
||||||
|
|
||||||
|
wf_impl_authenticators_init(&config->authenticators);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_cleanup(
|
||||||
|
struct wf_server_config * config)
|
||||||
|
{
|
||||||
|
wf_impl_authenticators_cleanup(&config->authenticators);
|
||||||
|
|
||||||
|
free(config->mount_point);
|
||||||
|
free(config->document_root);
|
||||||
|
free(config->key_path);
|
||||||
|
free(config->cert_path);
|
||||||
|
free(config->vhost_name);
|
||||||
|
|
||||||
|
wf_impl_server_config_init(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_clone(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
struct wf_server_config * clone)
|
||||||
|
{
|
||||||
|
clone->mount_point = wf_impl_server_config_strdup(config->mount_point);
|
||||||
|
clone->document_root = wf_impl_server_config_strdup(config->document_root);
|
||||||
|
clone->key_path = wf_impl_server_config_strdup(config->key_path);
|
||||||
|
clone->cert_path = wf_impl_server_config_strdup(config->cert_path);
|
||||||
|
clone->vhost_name = wf_impl_server_config_strdup(config->vhost_name);
|
||||||
|
clone->port = config->port;
|
||||||
|
|
||||||
|
wf_impl_authenticators_clone(&config->authenticators, &clone->authenticators);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wf_server_config * wf_impl_server_config_create(void)
|
||||||
|
{
|
||||||
|
struct wf_server_config * config = malloc(sizeof(struct wf_server_config));
|
||||||
|
if (NULL != config)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_init(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_dispose(
|
||||||
|
struct wf_server_config * config)
|
||||||
|
{
|
||||||
|
wf_impl_server_config_cleanup(config);
|
||||||
|
free(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_set_mountpoint(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * mount_point)
|
||||||
|
{
|
||||||
|
free(config->mount_point);
|
||||||
|
config->mount_point = strdup(mount_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_set_documentroot(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * document_root)
|
||||||
|
{
|
||||||
|
free(config->document_root);
|
||||||
|
config->document_root = strdup(document_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_set_keypath(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * key_path)
|
||||||
|
{
|
||||||
|
free(config->key_path);
|
||||||
|
config->key_path = strdup(key_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_set_certpath(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * cert_path)
|
||||||
|
{
|
||||||
|
free(config->cert_path);
|
||||||
|
config->cert_path = strdup(cert_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_set_vhostname(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * vhost_name)
|
||||||
|
{
|
||||||
|
free(config->vhost_name);
|
||||||
|
config->vhost_name = strdup(vhost_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_set_port(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
int port)
|
||||||
|
{
|
||||||
|
config->port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_config_add_authenticator(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
wf_impl_authenticators_add(&config->authenticators, type, authenticate, user_data);
|
||||||
|
}
|
||||||
|
|
72
lib/webfuse/adapter/impl/server_config.h
Normal file
72
lib/webfuse/adapter/impl/server_config.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_SERVER_CONFIG_H
|
||||||
|
#define WF_ADAPTER_IMPL_SERVER_CONFIG_H
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/authenticators.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_server_config
|
||||||
|
{
|
||||||
|
char * mount_point;
|
||||||
|
char * document_root;
|
||||||
|
char * key_path;
|
||||||
|
char * cert_path;
|
||||||
|
char * vhost_name;
|
||||||
|
int port;
|
||||||
|
struct wf_impl_authenticators authenticators;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct wf_server_config * wf_impl_server_config_create(void);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_dispose(
|
||||||
|
struct wf_server_config * config);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_init(
|
||||||
|
struct wf_server_config * config);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_cleanup(
|
||||||
|
struct wf_server_config * config);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_clone(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
struct wf_server_config * clone);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_set_mountpoint(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * mount_point);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_set_documentroot(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * document_root);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_set_keypath(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * key_path);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_set_certpath(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * cert_path);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_set_vhostname(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * vhost_name);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_set_port(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
int port);
|
||||||
|
|
||||||
|
extern void wf_impl_server_config_add_authenticator(
|
||||||
|
struct wf_server_config * config,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
166
lib/webfuse/adapter/impl/server_protocol.c
Normal file
166
lib/webfuse/adapter/impl/server_protocol.c
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
#include "webfuse/adapter/impl/server_protocol.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <libwebsockets.h>
|
||||||
|
|
||||||
|
#include "webfuse/core/message.h"
|
||||||
|
#include "webfuse/core/util.h"
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/filesystem.h"
|
||||||
|
|
||||||
|
static int wf_impl_server_protocol_callback(
|
||||||
|
struct lws * wsi,
|
||||||
|
enum lws_callback_reasons reason,
|
||||||
|
void * WF_UNUSED_PARAM(user),
|
||||||
|
void * in,
|
||||||
|
size_t len)
|
||||||
|
{
|
||||||
|
struct lws_protocols const * ws_protocol = lws_get_protocol(wsi);
|
||||||
|
struct wf_server_protocol * protocol = ws_protocol->user;
|
||||||
|
|
||||||
|
wf_impl_timeout_manager_check(&protocol->timeout_manager);
|
||||||
|
struct wf_impl_session * session = wf_impl_session_manager_get(&protocol->session_manager, wsi);
|
||||||
|
|
||||||
|
switch (reason)
|
||||||
|
{
|
||||||
|
case LWS_CALLBACK_PROTOCOL_INIT:
|
||||||
|
{
|
||||||
|
lws_sock_file_fd_type fd;
|
||||||
|
fd.filefd = wf_impl_filesystem_get_fd(&protocol->filesystem);
|
||||||
|
if (!lws_adopt_descriptor_vhost(lws_get_vhost(wsi), LWS_ADOPT_RAW_FILE_DESC, fd, ws_protocol->name, NULL))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error: unable to adopt fd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LWS_CALLBACK_ESTABLISHED:
|
||||||
|
session = wf_impl_session_manager_add(
|
||||||
|
&protocol->session_manager,
|
||||||
|
wsi,
|
||||||
|
&protocol->authenticators,
|
||||||
|
&protocol->rpc);
|
||||||
|
|
||||||
|
if (NULL != session)
|
||||||
|
{
|
||||||
|
wf_impl_session_authenticate(session, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LWS_CALLBACK_CLOSED:
|
||||||
|
wf_impl_session_manager_remove(&protocol->session_manager, wsi);
|
||||||
|
break;
|
||||||
|
case LWS_CALLBACK_SERVER_WRITEABLE:
|
||||||
|
if (NULL != session)
|
||||||
|
{
|
||||||
|
wf_impl_session_onwritable(session);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LWS_CALLBACK_RECEIVE:
|
||||||
|
if (NULL != session)
|
||||||
|
{
|
||||||
|
wf_impl_session_receive(session, in, len);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LWS_CALLBACK_RAW_RX_FILE:
|
||||||
|
wf_impl_filesystem_process_request(&protocol->filesystem);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool wf_impl_server_protocol_invoke(
|
||||||
|
void * user_data,
|
||||||
|
json_t const * request)
|
||||||
|
{
|
||||||
|
struct wf_server_protocol * protocol = user_data;
|
||||||
|
struct wf_impl_session * session = &protocol->session_manager.session;
|
||||||
|
struct wf_message * message = wf_message_create(request);
|
||||||
|
|
||||||
|
bool const result = wf_impl_session_send(session, message);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct wf_server_protocol * wf_impl_server_protocol_create(
|
||||||
|
char * mount_point)
|
||||||
|
{
|
||||||
|
struct wf_server_protocol * protocol = malloc(sizeof(struct wf_server_protocol));
|
||||||
|
if (NULL != protocol)
|
||||||
|
{
|
||||||
|
if (!wf_impl_server_protocol_init(protocol, mount_point))
|
||||||
|
{
|
||||||
|
free(protocol);
|
||||||
|
protocol = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_protocol_dispose(
|
||||||
|
struct wf_server_protocol * protocol)
|
||||||
|
{
|
||||||
|
wf_impl_server_protocol_cleanup(protocol);
|
||||||
|
free(protocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_protocol_init_lws(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
struct lws_protocols * lws_protocol)
|
||||||
|
{
|
||||||
|
lws_protocol->callback = &wf_impl_server_protocol_callback;
|
||||||
|
lws_protocol->per_session_data_size = 0;
|
||||||
|
lws_protocol->user = protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wf_impl_server_protocol_init(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
char * mount_point)
|
||||||
|
{
|
||||||
|
wf_impl_timeout_manager_init(&protocol->timeout_manager);
|
||||||
|
wf_impl_session_manager_init(&protocol->session_manager);
|
||||||
|
wf_impl_authenticators_init(&protocol->authenticators);
|
||||||
|
|
||||||
|
wf_impl_jsonrpc_server_init(&protocol->rpc, &protocol->timeout_manager);
|
||||||
|
wf_impl_jsonrpc_server_add(&protocol->rpc, "lookup", &wf_impl_server_protocol_invoke, protocol);
|
||||||
|
wf_impl_jsonrpc_server_add(&protocol->rpc, "getattr", &wf_impl_server_protocol_invoke, protocol);
|
||||||
|
wf_impl_jsonrpc_server_add(&protocol->rpc, "readdir", &wf_impl_server_protocol_invoke, protocol);
|
||||||
|
wf_impl_jsonrpc_server_add(&protocol->rpc, "open", &wf_impl_server_protocol_invoke, protocol);
|
||||||
|
wf_impl_jsonrpc_server_add(&protocol->rpc, "close", &wf_impl_server_protocol_invoke, protocol);
|
||||||
|
wf_impl_jsonrpc_server_add(&protocol->rpc, "read", &wf_impl_server_protocol_invoke, protocol);
|
||||||
|
|
||||||
|
bool const success = wf_impl_filesystem_init(&protocol->filesystem, &protocol->rpc, mount_point);
|
||||||
|
|
||||||
|
// cleanup on error
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
wf_impl_jsonrpc_server_cleanup(&protocol->rpc);
|
||||||
|
wf_impl_authenticators_cleanup(&protocol->authenticators);
|
||||||
|
wf_impl_timeout_manager_cleanup(&protocol->timeout_manager);
|
||||||
|
wf_impl_session_manager_cleanup(&protocol->session_manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_protocol_cleanup(
|
||||||
|
struct wf_server_protocol * protocol)
|
||||||
|
{
|
||||||
|
wf_impl_filesystem_cleanup(&protocol->filesystem);
|
||||||
|
wf_impl_jsonrpc_server_cleanup(&protocol->rpc);
|
||||||
|
wf_impl_timeout_manager_cleanup(&protocol->timeout_manager);
|
||||||
|
wf_impl_authenticators_cleanup(&protocol->authenticators);
|
||||||
|
wf_impl_session_manager_cleanup(&protocol->session_manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_server_protocol_add_authenticator(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data)
|
||||||
|
{
|
||||||
|
wf_impl_authenticators_add(&protocol->authenticators, type, authenticate, user_data);
|
||||||
|
}
|
53
lib/webfuse/adapter/impl/server_protocol.h
Normal file
53
lib/webfuse/adapter/impl/server_protocol.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_SERVER_PROTOCOL_H
|
||||||
|
#define WF_ADAPTER_IMPL_SERVER_PROTOCOL_H
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/filesystem.h"
|
||||||
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
|
#include "webfuse/adapter/impl/time/timeout_manager.h"
|
||||||
|
#include "webfuse/adapter/impl/authenticators.h"
|
||||||
|
#include "webfuse/adapter/impl/session_manager.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct lws_protocols;
|
||||||
|
|
||||||
|
struct wf_server_protocol
|
||||||
|
{
|
||||||
|
struct wf_impl_timeout_manager timeout_manager;
|
||||||
|
struct wf_impl_filesystem filesystem;
|
||||||
|
struct wf_impl_jsonrpc_server rpc;
|
||||||
|
struct wf_impl_authenticators authenticators;
|
||||||
|
struct wf_impl_session_manager session_manager;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern bool wf_impl_server_protocol_init(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
char * mount_point);
|
||||||
|
|
||||||
|
extern void wf_impl_server_protocol_cleanup(
|
||||||
|
struct wf_server_protocol * protocol);
|
||||||
|
|
||||||
|
extern struct wf_server_protocol * wf_impl_server_protocol_create(
|
||||||
|
char * mount_point);
|
||||||
|
|
||||||
|
extern void wf_impl_server_protocol_dispose(
|
||||||
|
struct wf_server_protocol * protocol);
|
||||||
|
|
||||||
|
extern void wf_impl_server_protocol_init_lws(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
struct lws_protocols * lws_protocol);
|
||||||
|
|
||||||
|
extern void wf_impl_server_protocol_add_authenticator(
|
||||||
|
struct wf_server_protocol * protocol,
|
||||||
|
char const * type,
|
||||||
|
wf_authenticate_fn * authenticate,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
84
lib/webfuse/adapter/impl/session.c
Normal file
84
lib/webfuse/adapter/impl/session.c
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#include "webfuse/adapter/impl/session.h"
|
||||||
|
#include "webfuse/adapter/impl/authenticators.h"
|
||||||
|
#include "webfuse/core/message_queue.h"
|
||||||
|
#include "webfuse/core/message.h"
|
||||||
|
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||||
|
|
||||||
|
#include <libwebsockets.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
void wf_impl_session_init(
|
||||||
|
struct wf_impl_session * session,
|
||||||
|
struct lws * wsi,
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_impl_jsonrpc_server * rpc)
|
||||||
|
{
|
||||||
|
session->wsi = wsi;
|
||||||
|
session->is_authenticated = false;
|
||||||
|
session->authenticators = authenticators;
|
||||||
|
session->rpc = rpc;
|
||||||
|
wf_message_queue_init(&session->queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_session_cleanup(
|
||||||
|
struct wf_impl_session * session)
|
||||||
|
{
|
||||||
|
wf_message_queue_cleanup(&session->queue);
|
||||||
|
session->is_authenticated = false;
|
||||||
|
session->wsi = NULL;
|
||||||
|
session->authenticators = NULL;
|
||||||
|
session->rpc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_session_authenticate(
|
||||||
|
struct wf_impl_session * session,
|
||||||
|
struct wf_credentials * creds)
|
||||||
|
{
|
||||||
|
session->is_authenticated = wf_impl_authenticators_authenticate(session->authenticators, creds);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wf_impl_session_send(
|
||||||
|
struct wf_impl_session * session,
|
||||||
|
struct wf_message * message)
|
||||||
|
{
|
||||||
|
bool result = (session->is_authenticated) && (NULL != session->wsi);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
wf_message_queue_push(&session->queue, message);
|
||||||
|
lws_callback_on_writable(session->wsi);
|
||||||
|
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wf_message_dispose(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_session_onwritable(
|
||||||
|
struct wf_impl_session * session)
|
||||||
|
{
|
||||||
|
if (!wf_message_queue_empty(&session->queue))
|
||||||
|
{
|
||||||
|
struct wf_message * message = wf_message_queue_pop(&session->queue);
|
||||||
|
lws_write(session->wsi, (unsigned char*) message->data, message->length, LWS_WRITE_TEXT);
|
||||||
|
wf_message_dispose(message);
|
||||||
|
|
||||||
|
if (!wf_message_queue_empty(&session->queue))
|
||||||
|
{
|
||||||
|
lws_callback_on_writable(session->wsi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wf_impl_session_receive(
|
||||||
|
struct wf_impl_session * session,
|
||||||
|
char const * data,
|
||||||
|
size_t length)
|
||||||
|
{
|
||||||
|
wf_impl_jsonrpc_server_onresult(session->rpc, data, length);
|
||||||
|
}
|
64
lib/webfuse/adapter/impl/session.h
Normal file
64
lib/webfuse/adapter/impl/session.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_SESSION_H
|
||||||
|
#define WF_ADAPTER_IMPL_SESSION_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#else
|
||||||
|
#include <cstddef>
|
||||||
|
using std::size_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "webfuse/core/message_queue.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct lws;
|
||||||
|
struct wf_message;
|
||||||
|
struct wf_credentials;
|
||||||
|
struct wf_impl_authenticators;
|
||||||
|
struct wf_impl_jsonrpc_server;
|
||||||
|
|
||||||
|
struct wf_impl_session
|
||||||
|
{
|
||||||
|
struct lws * wsi;
|
||||||
|
bool is_authenticated;
|
||||||
|
struct wf_message_queue queue;
|
||||||
|
struct wf_impl_authenticators * authenticators;
|
||||||
|
struct wf_impl_jsonrpc_server * rpc;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_impl_session_init(
|
||||||
|
struct wf_impl_session * session,
|
||||||
|
struct lws * wsi,
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_impl_jsonrpc_server * rpc);
|
||||||
|
|
||||||
|
extern void wf_impl_session_authenticate(
|
||||||
|
struct wf_impl_session * session,
|
||||||
|
struct wf_credentials * creds);
|
||||||
|
|
||||||
|
extern bool wf_impl_session_send(
|
||||||
|
struct wf_impl_session * session,
|
||||||
|
struct wf_message * message);
|
||||||
|
|
||||||
|
extern void wf_impl_session_receive(
|
||||||
|
struct wf_impl_session * session,
|
||||||
|
char const * data,
|
||||||
|
size_t length);
|
||||||
|
|
||||||
|
extern void wf_impl_session_onwritable(
|
||||||
|
struct wf_impl_session * session);
|
||||||
|
|
||||||
|
extern void wf_impl_session_cleanup(
|
||||||
|
struct wf_impl_session * session);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
54
lib/webfuse/adapter/impl/session_manager.c
Normal file
54
lib/webfuse/adapter/impl/session_manager.c
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#include "webfuse/adapter/impl/session_manager.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
void wf_impl_session_manager_init(
|
||||||
|
struct wf_impl_session_manager * manager)
|
||||||
|
{
|
||||||
|
wf_impl_session_init(&manager->session, NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_session_manager_cleanup(
|
||||||
|
struct wf_impl_session_manager * manager)
|
||||||
|
{
|
||||||
|
wf_impl_session_cleanup(&manager->session);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wf_impl_session * wf_impl_session_manager_add(
|
||||||
|
struct wf_impl_session_manager * manager,
|
||||||
|
struct lws * wsi,
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_impl_jsonrpc_server * rpc)
|
||||||
|
{
|
||||||
|
struct wf_impl_session * session = NULL;
|
||||||
|
if (NULL == manager->session.wsi)
|
||||||
|
{
|
||||||
|
session = &manager->session;
|
||||||
|
wf_impl_session_init(&manager->session, wsi, authenticators, rpc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wf_impl_session * wf_impl_session_manager_get(
|
||||||
|
struct wf_impl_session_manager * manager,
|
||||||
|
struct lws * wsi)
|
||||||
|
{
|
||||||
|
struct wf_impl_session * session = NULL;
|
||||||
|
if (wsi == manager->session.wsi)
|
||||||
|
{
|
||||||
|
session = &manager->session;
|
||||||
|
}
|
||||||
|
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_session_manager_remove(
|
||||||
|
struct wf_impl_session_manager * manager,
|
||||||
|
struct lws * wsi)
|
||||||
|
{
|
||||||
|
if (wsi == manager->session.wsi)
|
||||||
|
{
|
||||||
|
wf_impl_session_cleanup(&manager->session);
|
||||||
|
manager->session.wsi = NULL;
|
||||||
|
}
|
||||||
|
}
|
46
lib/webfuse/adapter/impl/session_manager.h
Normal file
46
lib/webfuse/adapter/impl/session_manager.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_SESSION_MANAGER_H
|
||||||
|
#define WF_ADAPTER_IMPL_SESSION_MANAGER_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/session.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct lws;
|
||||||
|
|
||||||
|
struct wf_impl_session_manager
|
||||||
|
{
|
||||||
|
struct wf_impl_session session;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_impl_session_manager_init(
|
||||||
|
struct wf_impl_session_manager * manager);
|
||||||
|
|
||||||
|
extern void wf_impl_session_manager_cleanup(
|
||||||
|
struct wf_impl_session_manager * manager);
|
||||||
|
|
||||||
|
extern struct wf_impl_session * wf_impl_session_manager_add(
|
||||||
|
struct wf_impl_session_manager * manager,
|
||||||
|
struct lws * wsi,
|
||||||
|
struct wf_impl_authenticators * authenticators,
|
||||||
|
struct wf_impl_jsonrpc_server * rpc);
|
||||||
|
|
||||||
|
extern struct wf_impl_session * wf_impl_session_manager_get(
|
||||||
|
struct wf_impl_session_manager * manager,
|
||||||
|
struct lws * wsi);
|
||||||
|
|
||||||
|
extern void wf_impl_session_manager_remove(
|
||||||
|
struct wf_impl_session_manager * manager,
|
||||||
|
struct lws * wsi);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
84
lib/webfuse/adapter/impl/time/timeout_manager.c
Normal file
84
lib/webfuse/adapter/impl/time/timeout_manager.c
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#include "webfuse/adapter/impl/time/timeout_manager_intern.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "webfuse/adapter/impl/time/timer_intern.h"
|
||||||
|
#include "webfuse/adapter/impl/time/timepoint.h"
|
||||||
|
|
||||||
|
void wf_impl_timeout_manager_init(
|
||||||
|
struct wf_impl_timeout_manager * manager)
|
||||||
|
{
|
||||||
|
manager->timers = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_timeout_manager_cleanup(
|
||||||
|
struct wf_impl_timeout_manager * manager)
|
||||||
|
{
|
||||||
|
struct wf_impl_timer * timer = manager->timers;
|
||||||
|
while (NULL != timer)
|
||||||
|
{
|
||||||
|
struct wf_impl_timer * next = timer->next;
|
||||||
|
|
||||||
|
wf_impl_timer_trigger(timer);
|
||||||
|
|
||||||
|
timer = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
manager->timers = NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_timeout_manager_check(
|
||||||
|
struct wf_impl_timeout_manager * manager)
|
||||||
|
{
|
||||||
|
struct wf_impl_timer * timer = manager->timers;
|
||||||
|
while (NULL != timer)
|
||||||
|
{
|
||||||
|
struct wf_impl_timer * next = timer->next;
|
||||||
|
|
||||||
|
if (wf_impl_timer_is_timeout(timer))
|
||||||
|
{
|
||||||
|
wf_impl_timeout_manager_removetimer(manager, timer);
|
||||||
|
wf_impl_timer_trigger(timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
timer = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_timeout_manager_addtimer(
|
||||||
|
struct wf_impl_timeout_manager * manager,
|
||||||
|
struct wf_impl_timer * timer)
|
||||||
|
{
|
||||||
|
if (NULL != manager->timers)
|
||||||
|
{
|
||||||
|
manager->timers->prev = timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
timer->next = manager->timers;
|
||||||
|
timer->prev = NULL;
|
||||||
|
manager->timers = timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_timeout_manager_removetimer(
|
||||||
|
struct wf_impl_timeout_manager * manager,
|
||||||
|
struct wf_impl_timer * timer)
|
||||||
|
{
|
||||||
|
struct wf_impl_timer * prev = timer->prev;
|
||||||
|
struct wf_impl_timer * next = timer->next;
|
||||||
|
|
||||||
|
if (NULL != prev)
|
||||||
|
{
|
||||||
|
prev->next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != next)
|
||||||
|
{
|
||||||
|
next->prev = prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (manager->timers == timer)
|
||||||
|
{
|
||||||
|
manager->timers = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
29
lib/webfuse/adapter/impl/time/timeout_manager.h
Normal file
29
lib/webfuse/adapter/impl/time/timeout_manager.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_TIME_TIMEOUT_MANAGER_H
|
||||||
|
#define WF_ADAPTER_IMPL_TIME_TIMEOUT_MANAGER_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_impl_timer;
|
||||||
|
struct wf_impl_timeout_manager
|
||||||
|
{
|
||||||
|
struct wf_impl_timer * timers;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_impl_timeout_manager_init(
|
||||||
|
struct wf_impl_timeout_manager * manager);
|
||||||
|
|
||||||
|
extern void wf_impl_timeout_manager_cleanup(
|
||||||
|
struct wf_impl_timeout_manager * manager);
|
||||||
|
|
||||||
|
extern void wf_impl_timeout_manager_check(
|
||||||
|
struct wf_impl_timeout_manager * manager);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
24
lib/webfuse/adapter/impl/time/timeout_manager_intern.h
Normal file
24
lib/webfuse/adapter/impl/time/timeout_manager_intern.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_TIME_TIMEOUT_MANAGER_INTERN_H
|
||||||
|
#define WF_ADAPTER_IMPL_TIME_TIMEOUT_MANAGER_INTERN_H
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/time/timeout_manager.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void wf_impl_timeout_manager_addtimer(
|
||||||
|
struct wf_impl_timeout_manager * manager,
|
||||||
|
struct wf_impl_timer * timer);
|
||||||
|
|
||||||
|
extern void wf_impl_timeout_manager_removetimer(
|
||||||
|
struct wf_impl_timeout_manager * manager,
|
||||||
|
struct wf_impl_timer * timer);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
31
lib/webfuse/adapter/impl/time/timepoint.c
Normal file
31
lib/webfuse/adapter/impl/time/timepoint.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include "webfuse/adapter/impl/time/timepoint.h"
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#define WF_MSEC_PER_SEC ((wf_impl_timepoint) 1000)
|
||||||
|
#define WF_NSEC_PER_MSEC ((wf_impl_timepoint) 1000 * 1000)
|
||||||
|
|
||||||
|
wf_impl_timepoint wf_impl_timepoint_now(void)
|
||||||
|
{
|
||||||
|
struct timespec tp;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||||
|
|
||||||
|
wf_impl_timepoint const now = (tp.tv_sec * WF_MSEC_PER_SEC) + (tp.tv_nsec / WF_NSEC_PER_MSEC);
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
|
||||||
|
wf_impl_timepoint wf_impl_timepoint_in_msec(wf_impl_timediff value)
|
||||||
|
{
|
||||||
|
wf_impl_timepoint const now = wf_impl_timepoint_now();
|
||||||
|
wf_impl_timepoint result = now + ((wf_impl_timepoint) value);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wf_impl_timepoint_is_elapsed(wf_impl_timepoint tp)
|
||||||
|
{
|
||||||
|
wf_impl_timepoint const now = wf_impl_timepoint_now();
|
||||||
|
wf_impl_timediff const diff = (wf_impl_timediff) (tp - now);
|
||||||
|
|
||||||
|
return (0 > diff);
|
||||||
|
}
|
31
lib/webfuse/adapter/impl/time/timepoint.h
Normal file
31
lib/webfuse/adapter/impl/time/timepoint.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_TIME_TIMEPOINT_H
|
||||||
|
#define WF_ADAPTER_IMPL_TIME_TIMEPOINT_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#else
|
||||||
|
#include <cinttypes>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef uint64_t wf_impl_timepoint;
|
||||||
|
typedef int64_t wf_impl_timediff;
|
||||||
|
|
||||||
|
extern wf_impl_timepoint wf_impl_timepoint_now(void);
|
||||||
|
|
||||||
|
extern wf_impl_timepoint wf_impl_timepoint_in_msec(
|
||||||
|
wf_impl_timediff value);
|
||||||
|
|
||||||
|
extern bool wf_impl_timepoint_is_elapsed(
|
||||||
|
wf_impl_timepoint timepoint);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
65
lib/webfuse/adapter/impl/time/timer.c
Normal file
65
lib/webfuse/adapter/impl/time/timer.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#include "webfuse/adapter/impl/time/timer_intern.h"
|
||||||
|
#include "webfuse/adapter/impl/time/timeout_manager_intern.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void wf_impl_timer_init(
|
||||||
|
struct wf_impl_timer * timer,
|
||||||
|
struct wf_impl_timeout_manager * manager)
|
||||||
|
{
|
||||||
|
timer->manager = manager;
|
||||||
|
timer->timeout = 0;
|
||||||
|
timer->timeout_handler = NULL;
|
||||||
|
timer->user_data = NULL;
|
||||||
|
timer->prev = NULL;
|
||||||
|
timer->next = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_timer_cleanup(
|
||||||
|
struct wf_impl_timer * timer)
|
||||||
|
{
|
||||||
|
memset(timer, 0, sizeof(struct wf_impl_timer));
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_timer_start(
|
||||||
|
struct wf_impl_timer * timer,
|
||||||
|
wf_impl_timepoint absolute_timeout,
|
||||||
|
wf_impl_timer_timeout_fn * handler,
|
||||||
|
void * user_data)
|
||||||
|
{
|
||||||
|
timer->timeout = absolute_timeout;
|
||||||
|
timer->timeout_handler = handler;
|
||||||
|
timer->user_data = user_data;
|
||||||
|
|
||||||
|
wf_impl_timeout_manager_addtimer(timer->manager, timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_impl_timer_cancel(
|
||||||
|
struct wf_impl_timer * timer)
|
||||||
|
{
|
||||||
|
wf_impl_timeout_manager_removetimer(timer->manager, timer);
|
||||||
|
|
||||||
|
timer->timeout = 0;
|
||||||
|
timer->timeout_handler = NULL;
|
||||||
|
timer->user_data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wf_impl_timer_is_timeout(
|
||||||
|
struct wf_impl_timer * timer)
|
||||||
|
{
|
||||||
|
return wf_impl_timepoint_is_elapsed(timer->timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wf_impl_timer_trigger(
|
||||||
|
struct wf_impl_timer * timer)
|
||||||
|
{
|
||||||
|
if (NULL != timer->timeout_handler)
|
||||||
|
{
|
||||||
|
timer->prev = NULL;
|
||||||
|
timer->next = NULL;
|
||||||
|
|
||||||
|
timer->timeout_handler(timer);
|
||||||
|
}
|
||||||
|
}
|
48
lib/webfuse/adapter/impl/time/timer.h
Normal file
48
lib/webfuse/adapter/impl/time/timer.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_TIME_TIMER_H
|
||||||
|
#define WF_ADAPTER_IMPL_TIME_TIMER_H
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/time/timepoint.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_impl_timer;
|
||||||
|
struct wf_impl_timeout_manager;
|
||||||
|
|
||||||
|
typedef void wf_impl_timer_timeout_fn(struct wf_impl_timer * timer);
|
||||||
|
|
||||||
|
struct wf_impl_timer
|
||||||
|
{
|
||||||
|
struct wf_impl_timeout_manager * manager;
|
||||||
|
wf_impl_timepoint timeout;
|
||||||
|
wf_impl_timer_timeout_fn * timeout_handler;
|
||||||
|
void * user_data;
|
||||||
|
struct wf_impl_timer * next;
|
||||||
|
struct wf_impl_timer * prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_impl_timer_init(
|
||||||
|
struct wf_impl_timer * timer,
|
||||||
|
struct wf_impl_timeout_manager * manager);
|
||||||
|
|
||||||
|
extern void wf_impl_timer_cleanup(
|
||||||
|
struct wf_impl_timer * timer);
|
||||||
|
|
||||||
|
extern void wf_impl_timer_start(
|
||||||
|
struct wf_impl_timer * timer,
|
||||||
|
wf_impl_timepoint absolute_timeout,
|
||||||
|
wf_impl_timer_timeout_fn * handler,
|
||||||
|
void * user_data);
|
||||||
|
|
||||||
|
extern void wf_impl_timer_cancel(
|
||||||
|
struct wf_impl_timer * timer);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
25
lib/webfuse/adapter/impl/time/timer_intern.h
Normal file
25
lib/webfuse/adapter/impl/time/timer_intern.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_TIME_TIMER_INTERN_H
|
||||||
|
#define WF_ADAPTER_IMPL_TIME_TIMER_INTERN_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/time/timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern bool wf_impl_timer_is_timeout(
|
||||||
|
struct wf_impl_timer * timer);
|
||||||
|
|
||||||
|
extern void wf_impl_timer_trigger(
|
||||||
|
struct wf_impl_timer * timer);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user