mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
added provider api
This commit is contained in:
parent
32829a9f76
commit
39874f733a
@ -96,6 +96,41 @@ install(FILES include/wsfs.h DESTINATION include)
|
||||
install(DIRECTORY include/wsfs DESTINATION include)
|
||||
install(FILES "${PROJECT_BINARY_DIR}/libfuse-wsfs.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig)
|
||||
|
||||
#libwsfs-provider
|
||||
|
||||
set(WSFS_PROVIDER_SOURCES
|
||||
lib/wsfsp/client.c
|
||||
)
|
||||
|
||||
add_library(wsfs-provider SHARED ${WSFS_PROVIDER_SOURCES})
|
||||
|
||||
set_target_properties(wsfs-provider PROPERTIES VERSION ${PROJECT_VERSION})
|
||||
set_target_properties(wsfs-provider PROPERTIES SOVERSION 0)
|
||||
set_target_properties(wsfs-provider PROPERTIES C_VISIBILITY_PRESET hidden)
|
||||
set_target_properties(wsfs-provider PROPERTIES COMPILE_DEFINITIONS "WSFSP_API=WSFSP_EXPORT")
|
||||
|
||||
target_include_directories(wsfs-provider PUBLIC lib ${EXTRA_INCLUDE_DIRS})
|
||||
target_compile_options(wsfs-provider PUBLIC ${EXTRA_CFLAGS})
|
||||
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/libwsfs-provider.pc"
|
||||
"prefix=\"${CMAKE_INSTALL_PREFIX}\"
|
||||
exec_prefix=\${prefix}
|
||||
libdir=\${exec_prefix}/lib${LIB_SUFFIX}
|
||||
includedir=\${prefix}/include
|
||||
Name: libwsfs-provider
|
||||
Description: Provider library for websockets filesystem
|
||||
Version: ${PROJECT_VERSION}
|
||||
|
||||
Libs: -L\${libdir} -lwsfs-provider -l${LWS_LIBRARIES} -l${JANSSON_LIBRARIES}
|
||||
Cflags: -I\${includedir}"
|
||||
)
|
||||
|
||||
install(TARGETS wsfs-provider DESTINATION lib${LIB_SUFFIX})
|
||||
install(FILES include/wsfs_provider.h DESTINATION include)
|
||||
install(DIRECTORY include/wsfsp DESTINATION include)
|
||||
install(FILES "${PROJECT_BINARY_DIR}/libwsfs-provider.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig)
|
||||
|
||||
|
||||
# app
|
||||
|
||||
if(NOT WITHOUT_EXAMPLE)
|
||||
|
9
include/wsfs_provider.h
Normal file
9
include/wsfs_provider.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef _WSFSP_H
|
||||
#define _WSFSP_H
|
||||
|
||||
#include "wsfsp/api.h"
|
||||
#include "wsfsp/provider.h"
|
||||
#include "wsfsp/client.h"
|
||||
#include "wsfsp/client_protocol.h"
|
||||
|
||||
#endif
|
16
include/wsfsp/api.h
Normal file
16
include/wsfsp/api.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _WSFSP_API_H
|
||||
#define _WSFSP_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
|
44
include/wsfsp/client.h
Normal file
44
include/wsfsp/client.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef _WSFSP_CLIENT_H
|
||||
#define _WSFSP_CLIENT_H
|
||||
|
||||
#include "wsfs/api.h"
|
||||
|
||||
struct wsfs_provider;
|
||||
struct wsfs_provider_client_config;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern WSFS_API struct wsfs_provider_client * wsfs_provider_client_create(
|
||||
struct wsfs_provider * provider,
|
||||
void * user_data);
|
||||
|
||||
extern WSFS_API void wsfs_provider_client_connect(
|
||||
struct wsfs_provider_client * client,
|
||||
char const * url);
|
||||
|
||||
extern WSFS_API void wsfs_provider_client_disconnect(
|
||||
struct wsfs_provider_client * client);
|
||||
|
||||
extern WSFS_API void wsfs_provider_client_settimeout(
|
||||
struct wsfs_provider_client * client,
|
||||
unsigned int timepoint);
|
||||
|
||||
extern WSFS_API void wsfs_provider_client_dispose(
|
||||
struct wsfs_provider_client * client);
|
||||
|
||||
extern WSFS_API void wsfs_provider_client_run(
|
||||
struct wsfs_provider_client * client);
|
||||
|
||||
extern WSFS_API void wsfs_provider_client_shutdown(
|
||||
struct wsfs_provider_client * client);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
32
include/wsfsp/client_protocol.h
Normal file
32
include/wsfsp/client_protocol.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef _WSFSP_CLIENT_PROTOCOL_H
|
||||
#define _WSFSP_CLIENT_PROTOCOL_H
|
||||
|
||||
#include "wsfs/api.h"
|
||||
|
||||
struct wsfsp_client_protocol;
|
||||
struct wsfsp_provider;
|
||||
struct lws_protocols;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern WSFSP_API struct wsfsp_client_protocol * wsfsp_client_protocol_create(
|
||||
struct wsfsp_provider const * provider,
|
||||
void * user_data);
|
||||
|
||||
extern WSFSÜ_API void wsfsp_client_protocol_dispose(
|
||||
struct wsfsp_client_protocol * protocol);
|
||||
|
||||
extern WSFSÜ_API void wsfsp_client_protocol_init_lws(
|
||||
struct wsfs_provider_client_protocol * protocol,
|
||||
struct lws_protocols * lws_protocol);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
114
include/wsfsp/provider.h
Normal file
114
include/wsfsp/provider.h
Normal file
@ -0,0 +1,114 @@
|
||||
#ifndef _WSFSp_H
|
||||
#define _WSFSp_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <cstddef>
|
||||
#include <cinttypes>
|
||||
using std::size_t;
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
struct wsfsp_request;
|
||||
struct wsfs_dirbuffer;
|
||||
|
||||
typedef void wsfsp_lookup_fn(
|
||||
struct wsfsp_request * request,
|
||||
ino_t parent,
|
||||
char const * name,
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_getattr_fn(
|
||||
struct wsfsp_request * request,
|
||||
ino_t inode,
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_readdir_fn(
|
||||
struct wsfsp_request * request,
|
||||
ino_t directory,
|
||||
struct wsfsp_dirbuffer * dirbuffer,
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_open_fn(
|
||||
struct wsfsp_request * request,
|
||||
ino_t inode,
|
||||
int flags,
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_close_fn(
|
||||
ino_t inode,
|
||||
uint32_t handle,
|
||||
int flags,
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_read_fn(
|
||||
struct wsfsp_request * request,
|
||||
ino_t inode,
|
||||
uint32_t handle,
|
||||
size_t offset,
|
||||
size_t length,
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_connected_fn(
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_disconnected_fn(
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_ontimer_fn(
|
||||
void * user_data);
|
||||
|
||||
struct wsfsüp
|
||||
{
|
||||
wsfsp_connected_fn * connected;
|
||||
wsfsp_disconnected_fn * connected;
|
||||
wsfsp_ontimer_fn * ontimer;
|
||||
wsfsp_lookup_fn * lookup;
|
||||
wsfsp_getattr_fn * getattr;
|
||||
wsfsp_readdir_fn * readdir;
|
||||
wsfsp_open_fn * open;
|
||||
wsfsp_close_fn * close;
|
||||
wsfsp_read_fn * read;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_respond_error(
|
||||
struct wsfsp_request * request,
|
||||
int status);
|
||||
|
||||
extern void wsfsp_respond_lookup(
|
||||
struct wsfsp_request * request,
|
||||
struct wsfs_stat const * stat);
|
||||
|
||||
extern void wsfsp_respond_getattr(
|
||||
struct wsfsp_request * request,
|
||||
struct stat const * stat);
|
||||
|
||||
extern void wsfsp_respond_readdir(
|
||||
struct wsfsp_request * request,
|
||||
struct wsfsp_dirbuffer * dirbuffer);
|
||||
|
||||
extern void wsfsp_respond_open(
|
||||
struct wsfsp_request * request,
|
||||
uint32_t handle);
|
||||
|
||||
extern void wsfsp_respond_read(
|
||||
struct wsfsp_request * request,
|
||||
char const * data,
|
||||
size_t length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
2
lib/wsfsp/client.c
Normal file
2
lib/wsfsp/client.c
Normal file
@ -0,0 +1,2 @@
|
||||
#include "wsfsp/client.h"
|
||||
|
Loading…
Reference in New Issue
Block a user