Merge branch 'remove_provider' of https://github.com/falk-werner/webfuse into remove_provider

pull/79/head
Falk Werner 4 years ago
commit 8f33258fae

@ -1,10 +1,10 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/api.h
/// \file webfuse/api.h
/// \brief API define for webfuse adapter.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_API_H
#define WF_ADAPTER_API_H
#ifndef WF_API_H
#define WF_API_H
//------------------------------------------------------------------------------
/// \def WF_API

@ -1,10 +1,10 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/authenticate.h
/// \file webfuse/authenticate.h
/// \brief Authenticate function.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_AUTHENTICATE_H
#define WF_ADAPTER_AUTHENTICATE_H
#ifndef WF_AUTHENTICATE_H
#define WF_AUTHENTICATE_H
#ifndef __cplusplus
#include <stdbool.h>

@ -1,13 +1,13 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/client.h
/// \file webfuse/client.h
/// \brief Adapter client.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_CLIENT_H
#define WF_ADAPTER_CLIENT_H
#ifndef WF_CLIENT_H
#define WF_CLIENT_H
#include <webfuse/adapter/api.h>
#include <webfuse/adapter/client_callback.h>
#include <webfuse/api.h>
#include <webfuse/client_callback.h>
#ifdef __cplusplus
extern "C"

@ -1,10 +1,10 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/client_callbak.h
/// \file webfuse/client_callbak.h
/// \brief Callback of adapter clients.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_CLIENT_CALLBACK_H
#define WF_ADAPTER_CLIENT_CALLBACK_H
#ifndef WF_CLIENT_CALLBACK_H
#define WF_CLIENT_CALLBACK_H
#ifdef __cplusplus
extern "C"

@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/client_tslconfig.h
/// \file webfuse/client_tslconfig.h
/// \brief Configuration of TLS (Transport Layer Security) for adapter clients.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_CLIENT_TLSCONFIG_H
#define WF_ADAPTER_CLIENT_TLSCONFIG_H
#ifndef WF_CLIENT_TLSCONFIG_H
#define WF_CLIENT_TLSCONFIG_H
#include <webfuse/adapter/api.h>
#include <webfuse/api.h>
#ifdef __cplusplus
extern "C"

@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/credentials.h
/// \file webfuse/credentials.h
/// \brief Credentials used for user authentication.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_CREDENTIALS_H
#define WF_ADAPTER_CREDENTIALS_H
#ifndef WF_CREDENTIALS_H
#define WF_CREDENTIALS_H
#include "webfuse/adapter/api.h"
#include "webfuse/api.h"
#ifdef __cplusplus
extern "C"

@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/mountpoint.h
/// \file webfuse/mountpoint.h
/// \brief Mointpoint.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_MOUNTPOINT_H
#define WF_ADAPTER_MOUNTPOINT_H
#ifndef WF_MOUNTPOINT_H
#define WF_MOUNTPOINT_H
#include <webfuse/adapter/api.h>
#include <webfuse/api.h>
#ifdef __cplusplus
extern "C"

@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/mountpoint_factory.h
/// \file webfuse/mountpoint_factory.h
/// \brief Defines a factory function to create mointpoints.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_MOUNTPOINT_FACTORY_H
#define WF_ADAPTER_MOUNTPOINT_FACTORY_H
#ifndef WF_MOUNTPOINT_FACTORY_H
#define WF_MOUNTPOINT_FACTORY_H
#include <webfuse/adapter/api.h>
#include <webfuse/api.h>
#ifdef __cplusplus
extern "C"

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////////////
/// \file protocol_names.h
/// \file webufse/protocol_names.h
/// \brief Names of websocket protocol.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_PROTOCOL_NAMES_H

@ -1,32 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/api.h
/// \brief API define for webfuse provider.
////////////////////////////////////////////////////////////////////////////////
#ifndef WFP_PROVIDER_API_H
#define WFP_PROVIDER_API_H
//------------------------------------------------------------------------------
/// \def WFP_API
/// \brief Marks public symbols of libwebfuse_provider.
//------------------------------------------------------------------------------
#ifndef WFP_API
#define WFP_API
#endif
//------------------------------------------------------------------------------
/// \def WFP_EXPORT
/// \brief Marks exported symbols as visible.
///
/// Set WFP_API to WFP_EXPORT when building libwebfuse_provider.so to export
/// public symbols.
//------------------------------------------------------------------------------
#ifndef WFP_EXPORT
#ifdef __GNUC__
#define WFP_EXPORT __attribute__ ((visibility ("default")))
#else
#define WFP_EXPORT
#endif
#endif
#endif

@ -1,105 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/client.h
/// \brief Webfuse provider client.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_PROVIDER_CLIENT_H
#define WF_PROVIDER_CLIENT_H
#include "webfuse/provider/api.h"
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \struct wfp_client
/// \brief Webfuse provider client.
//------------------------------------------------------------------------------
struct wfp_client;
struct wfp_client_config;
//------------------------------------------------------------------------------
/// \brief Creates a webfuse provider client.
///
/// \note Client configuration is not managed by the client.
///
/// \param config pointer to client configuration.
/// \return newly created client or NULL in case of an error.
//------------------------------------------------------------------------------
extern WFP_API struct wfp_client * wfp_client_create(
struct wfp_client_config * config);
//------------------------------------------------------------------------------
/// \brief Connects the client to a remote webfuse adapter server.
///
/// \note This call starts to establish a connection. A callback is invoked,
/// when the connection is estanlished.
///
/// \param client pointer to client
/// \param url URL of remote webfuse adapter server
///
/// \see wfp_connected_fn
/// \see wfp_client_config_set_onconnected
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_connect(
struct wfp_client * client,
char const * url);
//------------------------------------------------------------------------------
/// \brief Disconnects a connected client.
///
/// \note This call starts to disconnect the connection. A callback is invoked
/// when conntection is disconnected.
///
/// \param client pointer to client
///
/// \see wfp_disconnected_fn
/// \see wfp_client_config_set_ondisconnected
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_disconnect(
struct wfp_client * client);
//------------------------------------------------------------------------------
/// \brief Disposes a client.
///
/// \note Client configuration is not managed by client.
///
/// \param client pointer to client
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_dispose(
struct wfp_client * client);
//------------------------------------------------------------------------------
/// \brief Triggers the client.
///
/// This function must be invoked in a loop while the client is running. It
/// makes the server wait for the next event and processes it.
///
/// \param client pointer to client
///
/// \see wfp_client_interrupt
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_service(
struct wfp_client * client);
//------------------------------------------------------------------------------
/// \brief interrupt wfp_client_service
///
/// This function can be called from another thread.
///
/// \param client pointer to client
///
/// \see wfp_client_service
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_interrupt(
struct wfp_client * client);
#ifdef __cplusplus
}
#endif
#endif

@ -1,240 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/client_config.h
/// \brief Client configuration of webfuse provider.
////////////////////////////////////////////////////////////////////////////////
#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>
#include <webfuse/provider/credentials.h>
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \struct wfp_client_config
/// \brief Provider client configuration object.
///
/// Holds configuration of webfuse provider client.
//------------------------------------------------------------------------------
struct wfp_client_config;
//------------------------------------------------------------------------------
/// \brief Callback to signal when the client's connection is established.
///
/// \param user_data user defined context
//------------------------------------------------------------------------------
typedef void wfp_connected_fn(
void * user_data);
//------------------------------------------------------------------------------
/// \brief Callback to signal when a client's connection is disconnected.
///
/// \param user_data user defined context
//------------------------------------------------------------------------------
typedef void wfp_disconnected_fn(
void * user_data);
//------------------------------------------------------------------------------
/// \brief Creates a new client configuration.
///
/// \return newly created client configuration
//------------------------------------------------------------------------------
extern WFP_API struct wfp_client_config * wfp_client_config_create(void);
//------------------------------------------------------------------------------
/// \brief Disposes a client configuration.
///
/// \note The user defined context is not managed by the client configuration.
///
/// \param config pointer to client configuration
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_dispose(
struct wfp_client_config * config);
//------------------------------------------------------------------------------
/// \brief Sets a user defined context.
///
/// \note The user is responsible to manage the lifetime of user data.
///
/// \param config pointer to client configuration
/// \param user_data user defined context
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_userdata(
struct wfp_client_config * config,
void * user_data);
//------------------------------------------------------------------------------
/// \brief Sets the path to clients private key.
///
/// \note To enable TLS both, private key and certificate, must be specified.
/// Otherwise, TLS is not used.
///
/// \param config pointer to client configuration
/// \param key_path path of clients private key (pem file)
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_keypath(
struct wfp_client_config * config,
char const * key_path);
//------------------------------------------------------------------------------
/// \brief Sets the path of clients certificate.
///
/// \note To enable TLS both, private key and certificate, must be specified.
/// Otherwise, TLS is not used.
///
/// \param config pointer to client configuration
/// \param cert_path path of the clients certificate (pem file)
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_certpath(
struct wfp_client_config * config,
char const * cert_path);
//------------------------------------------------------------------------------
/// \brief Sets the path of ca file to verify servers.
///
/// \note To enable TLS both, private key and certificate, must be specified.
/// Otherwise, TLS is not used.
///
/// \param config pointer to client configuration
/// \param ca_filepath path of the ca file (pem file)
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_ca_filepath(
struct wfp_client_config * config,
char const * ca_filepath);
//------------------------------------------------------------------------------
/// \brief Sets the onconnected handler.
///
/// The handler is invoked, when the client's conntection is established.
///
/// \param config pointer to client configuration
/// \param handler pointer to handler
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_onconnected(
struct wfp_client_config * config,
wfp_connected_fn * handler);
//------------------------------------------------------------------------------
/// \brief Sets ondisconnected handler
///
/// The handler is invoked, when the client's conntection is lost.
///
/// \param config pointer to client configuration
/// \param handler pointer to handler
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_ondisconnected(
struct wfp_client_config * config,
wfp_disconnected_fn * handler);
//------------------------------------------------------------------------------
/// \brief Sets onlookup handler.
///
/// The handler is invoked, when the identifier of a file is requested.
///
/// \param config pointer to client configuration
/// \param handler pointer to handler
///
/// \see wfp_lookup_fn
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_onlookup(
struct wfp_client_config * config,
wfp_lookup_fn * handler);
//------------------------------------------------------------------------------
/// \brief Sets ongetattr handler.
///
/// The handler is invoked, when attributes of a file are requested.
///
/// \param config pointer to client configuration
/// \param handler pointer to handler
///
/// \see wfp_getattr_fn
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_ongetattr(
struct wfp_client_config * config,
wfp_getattr_fn * handler);
//------------------------------------------------------------------------------
/// \brief Sets onreaddir handler.
///
/// The handler is invoked, when the contents of directory are requested-
///
/// \param config pointer to client configuration
/// \param handler pointer to handler
///
/// \see wfp_readdir_fn
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_onreaddir(
struct wfp_client_config * config,
wfp_readdir_fn * handler);
//------------------------------------------------------------------------------
/// \brief Sets onopen handler.
///
/// The handler is invoked, whe a file should be opened.
///
/// \param config pointer to client configuration
/// \param handler pointer to handler
///
/// \see wfp_open_fn
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_onopen(
struct wfp_client_config * config,
wfp_open_fn * handler);
//------------------------------------------------------------------------------
/// \brief Sets onclose handler.
///
/// The handler is invoked, when a file is closed.
///
/// \param config pointer to client configuration
/// \param handler pointer to handler
///
/// \see wfp_close_fn
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_onclose(
struct wfp_client_config * config,
wfp_close_fn * handler);
//------------------------------------------------------------------------------
/// \brief Sets onread handler.
///
/// The handler is invoked, when a files content is requested.
///
/// \param config pointer to client configuration
/// \param handler pointer to handler
///
/// \see wfp_read_fn
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_set_onread(
struct wfp_client_config * config,
wfp_read_fn * handler);
//------------------------------------------------------------------------------
/// \brief Enabled authentication.
///
/// \param config pointer to client configuration
/// \param get_credentials pointer to function providing credentials when
// needed.
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_config_enable_authentication(
struct wfp_client_config * config,
wfp_get_credentials_fn * get_credentials);
#ifdef __cplusplus
}
#endif
#endif

@ -1,117 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/client_protocol.h
/// \brief Provides low level access to libwebsockets protocol.
///
/// By default, libwebfuse encapsulates libwebsockets protocol by \ref
/// wfp_client. But sometimes it might come in handy to have access to
/// libwebsockets protocol. This allows to integrate libwebfuse in existing
/// libwebsockets applications.
////////////////////////////////////////////////////////////////////////////////
#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
/// \brief Opaque webfuse client protocol..
//------------------------------------------------------------------------------
struct wfp_client_protocol;
//------------------------------------------------------------------------------
/// \struct lws_protocols
/// \brief Forward declaration of libwebsockets protocols structure.
//------------------------------------------------------------------------------
struct lws_protocols;
//------------------------------------------------------------------------------
/// \struct lws_context
/// \brief Forward declaration of libwebsockets context structure.
//------------------------------------------------------------------------------
struct lws_context;
//------------------------------------------------------------------------------
/// \struct wfp_client_config
/// \copydoc wfp_client_config
//------------------------------------------------------------------------------
struct wfp_client_config;
//------------------------------------------------------------------------------
/// \brief Creates a new webfuse provider client protocol.
///
/// \note The user is responsible to manage lifetime of \arg config.
///
/// \note TLS configuration is ignored, since TLS is managed by libwebsockets.
///
/// \param config pointer to client config
/// \return newly created protocol
//------------------------------------------------------------------------------
extern WFP_API struct wfp_client_protocol * wfp_client_protocol_create(
struct wfp_client_config const * config);
//------------------------------------------------------------------------------
/// \brief Disposes a protocol.
///
/// \note The user defined context is not managed by the protocol.
///
/// \param protocol pointer to protocol.
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_protocol_dispose(
struct wfp_client_protocol * protocol);
//------------------------------------------------------------------------------
/// \brief Initialized libwebsockets protocol structure.
///
/// \param protocol pointer to protocol
/// \param lws_protocol pointer to libwebsockets protocol structure.
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_protocol_init_lws(
struct wfp_client_protocol * protocol,
struct lws_protocols * lws_protocol);
//------------------------------------------------------------------------------
/// \brief Connects the protocol to a remote webfuse adapter server.
///
/// \note This call starts to establish a connection. A callback is invoked,
/// when the connection is estanlished.
///
/// \param protocol pointer to protocol
/// \param context lws context
/// \param url URL of remote webfuse adapter server
///
/// \see wfp_connected_fn
/// \see wfp_client_config_set_onconnected
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_protocol_connect(
struct wfp_client_protocol * protocol,
struct lws_context * context,
char const * url);
//------------------------------------------------------------------------------
/// \brief Disconnects the protocol from a remote webfuse adapter server.
///
/// \note This call starts to disconnect. A callback is invoked,
/// when the connection is estanlished.
///
/// \param protocol pointer to protocol
///
/// \see wfp_connected_fn
/// \see wfp_client_config_set_ondisconnected
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_protocol_disconnect(
struct wfp_client_protocol * protocol);
#ifdef __cplusplus
}
#endif
#endif

@ -1,30 +0,0 @@
#ifndef WF_PROVIDER_CREDENTIALS_H
#define WF_PROVIDER_CREDENTIALS_H
#include <webfuse/provider/api.h>
#ifdef __cplusplus
extern "C"
{
#endif
struct wfp_credentials;
typedef void wfp_get_credentials_fn(
struct wfp_credentials * credentials,
void * user_data);
extern WFP_API void wfp_credentials_set_type(
struct wfp_credentials * credentials,
char const * type);
extern WFP_API void wfp_credentials_add(
struct wfp_credentials * credentials,
char const * key,
char const * value);
#ifdef __cplusplus
}
#endif
#endif

@ -1,60 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/dirbuffer.h
/// \brief Buffer used for directory listing.
////////////////////////////////////////////////////////////////////////////////
#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
/// \brief Buffer used for directory listing.
///
/// \see wfp_respond_readdir
//------------------------------------------------------------------------------
struct wfp_dirbuffer;
//------------------------------------------------------------------------------
/// \brief Creates a new dir buffer.
///
/// \return newly created dir buffer.
//------------------------------------------------------------------------------
extern WFP_API struct wfp_dirbuffer * wfp_dirbuffer_create(void);
//------------------------------------------------------------------------------
/// \brief Disposes a dir buffer.
///
/// \param buffer pointer to dir buffer
//------------------------------------------------------------------------------
extern WFP_API void wfp_dirbuffer_dispose(
struct wfp_dirbuffer * buffer);
//------------------------------------------------------------------------------
/// \brief Adds an entry to dir buffer.
///
/// \param buffer pointer to dir buffer
/// \param name name of the entry (file or directory)
/// \param inode inode of the entry
//------------------------------------------------------------------------------
extern WFP_API void wfp_dirbuffer_add(
struct wfp_dirbuffer * buffer,
char const * name,
ino_t inode);
#ifdef __cplusplus
}
#endif
#endif

@ -1,46 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/operation/close.h
/// \brief Provider's close callback.
////////////////////////////////////////////////////////////////////////////////
#ifndef WFP_OPERATION_CLOSE_H
#define WFP_OPERATION_CLOSE_H
#ifndef __cplusplus
#include <inttypes.h>
#else
#include <cinttypes>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "webfuse/provider/api.h"
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \brief Callback invoked when a file is invoked.
///
/// This function does not respond.
///
/// \param inode inode of file to close
/// \param handle handle of file to close
/// \param flags file close flags
/// \param user_data user defined context
//------------------------------------------------------------------------------
typedef void wfp_close_fn(
ino_t inode,
uint32_t handle,
int flags,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,36 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/operation/error.h
/// \brief Respond with error code.
////////////////////////////////////////////////////////////////////////////////
#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;
//------------------------------------------------------------------------------
/// \brief Respond to a request with an error.
///
/// A client's callback must respond with exactly one responde, either with a
/// valid reponse regarding to the concrete request or with an error response.
///
/// \param request pointer to request
/// \param status error code
//------------------------------------------------------------------------------
extern WFP_API void wfp_respond_error(
struct wfp_request * request,
wf_status status);
#ifdef __cplusplus
}
#endif
#endif

@ -1,55 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/operation/getattr.h
/// \brief Get file attributes.
////////////////////////////////////////////////////////////////////////////////
#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;
//------------------------------------------------------------------------------
/// \brief Get file attributes.
///
/// \note After this function is called, exactly one response must be sent,
/// either via \ref wfp_respond_getattr or via \ref wfp_respond_error.
///
/// \param request pointer to request
/// \param inode inode of file to get attributes
/// \param user_data user defined context
///
/// \see wfp_respond_getattr
/// \see wfp_respond_error
//------------------------------------------------------------------------------
typedef void wfp_getattr_fn(
struct wfp_request * request,
ino_t inode,
void * user_data);
//------------------------------------------------------------------------------
/// \brief Respond to a get attributes request.
///
/// \param request pointer to request
/// \param stat file attributes
//------------------------------------------------------------------------------
extern WFP_API void wfp_respond_getattr(
struct wfp_request * request,
struct stat const * stat);
#ifdef __cplusplus
}
#endif
#endif

@ -1,57 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/operation/lookup.h
/// \brief Lookup file.
////////////////////////////////////////////////////////////////////////////////
#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;
//------------------------------------------------------------------------------
/// \brief Lookup a file or directory.
///
/// \note After this function is called, exactly one response must be sent,
/// either via \ref wfp_respond_lookup or via \ref wfp_respond_error.
///
/// \param request pointer to request
/// \param parent inode of parent
/// \param name name of the filesystem object to lookup
/// \param user_data pointer to user defined context
///
/// \see wfp_respond_lookup
/// \see wfp_respond_error
//------------------------------------------------------------------------------
typedef void wfp_lookup_fn(
struct wfp_request * request,
ino_t parent,
char const * name,
void * user_data);
//------------------------------------------------------------------------------
/// \brief Respond to lookup request.
///
/// \param request pointer to request
/// \param stat attributes of filesystem object
//------------------------------------------------------------------------------
extern WFP_API void wfp_respond_lookup(
struct wfp_request * request,
struct stat const * stat);
#ifdef __cplusplus
}
#endif
#endif

@ -1,63 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/operation/open.h
/// \brief Open a file.
////////////////////////////////////////////////////////////////////////////////
#ifndef WFP_OPERATION_OPEN_H
#define WFP_OPERATION_OPEN_H
#ifndef __cplusplus
#include <inttypes.h>
#else
#include <cinttypes>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "webfuse/provider/api.h"
#ifdef __cplusplus
extern "C"
{
#endif
struct wfp_request;
//------------------------------------------------------------------------------
/// \brief Open a file.
///
/// \note After this function is called, exactly one response must be sent,
/// either via \ref wfp_respond_open or via \ref wfp_respond_error.
///
/// \param request pointer to request
/// \param inode inode of the file to open
/// \param flags file open flags
/// \param user_data user defined context
///
/// \see wfp_respond_open
/// \see wfp_respond_error
//------------------------------------------------------------------------------
typedef void wfp_open_fn(
struct wfp_request * request,
ino_t inode,
int flags,
void * user_data);
//------------------------------------------------------------------------------
/// \brief Respond to open file.
///
/// \param request pointer to request
/// \param handle handle of the opened file
//------------------------------------------------------------------------------
extern WFP_API void wfp_respond_open(
struct wfp_request * request,
uint32_t handle);
#ifdef __cplusplus
}
#endif
#endif

@ -1,76 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/operation/read.h
/// \brief Read contents of a file.
////////////////////////////////////////////////////////////////////////////////
#ifndef WFP_OPERATION_READ_H
#define WFP_OPERATION_READ_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>
#include "webfuse/provider/api.h"
#ifdef __cplusplus
extern "C"
{
#endif
struct wfp_request;
//------------------------------------------------------------------------------
/// \brief Requests content of a file.
///
/// On success, up to \arg length bytes should be returned via \ref
/// wfp_respond_read.
///
/// \note After this function is called, exactly one response must be sent,
/// either via \ref wfp_respond_read or via \ref wfp_respond_error.
///
/// \param request pointer to request
/// \param inode inode of the file to read
/// \param handle handle of the file to read (returned by open)
/// \param offset offset within the file where to start reading
/// \param length amount of bytes to read
/// \param user_data used defined context
///
/// \see wfp_respond_read
/// \see wfp_respond_error
//------------------------------------------------------------------------------
typedef void wfp_read_fn(
struct wfp_request * request,
ino_t inode,
uint32_t handle,
size_t offset,
size_t length,
void * user_data);
//------------------------------------------------------------------------------
/// \brief Respond to read.
///
/// \note The user is responsible to manage lifetime of \arg data.
///
/// \param request pointer to request
/// \param data data read from file
/// \param length amount of bytes read
//------------------------------------------------------------------------------
extern WFP_API void wfp_respond_read(
struct wfp_request * request,
char const * data,
size_t length);
#ifdef __cplusplus
}
#endif
#endif

@ -1,58 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file provider/operation/readdir.h
/// \brief List directory contents.
////////////////////////////////////////////////////////////////////////////////
#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;
//------------------------------------------------------------------------------
/// \brief Requests the contents of a directory.
///
/// \note After this function is called, exactly one response must be sent,
/// either via \ref wfp_respond_readdir or via \ref wfp_respond_error.
///
/// \param request pointer to request
/// \param directory inode of directory to list
/// \param user_data user defined context
///
/// \see wfp_respond_readdir
/// \see wfp_respond_error
//------------------------------------------------------------------------------
typedef void wfp_readdir_fn(
struct wfp_request * request,
ino_t directory,
void * user_data);
//------------------------------------------------------------------------------
/// \brief Respond to list directory contents.
///
/// \note The user is responsible to manage dirbuffe, p.e. to dispose
/// it after this function is called.
///
/// \param request pointer to request
/// \param dirbuffer contains contents of directory
//------------------------------------------------------------------------------
extern WFP_API void wfp_respond_readdir(
struct wfp_request * request,
struct wfp_dirbuffer * dirbuffer);
#ifdef __cplusplus
}
#endif
#endif

@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/server.h
/// \file webfuse/server.h
/// \brief Adapter server.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_SERVER_H
#define WF_ADAPTER_SERVER_H
#ifndef WF_SERVER_H
#define WF_SERVER_H
#include "webfuse/adapter/api.h"
#include "webfuse/api.h"
#ifdef __cplusplus
extern "C"

@ -1,14 +1,14 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/server_config.h
/// \file webfuse/server_config.h
/// \brief Server configuration.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_SERVER_CONFIG_H
#define WF_ADAPTER_SERVER_CONFIG_H
#ifndef WF_SERVER_CONFIG_H
#define WF_SERVER_CONFIG_H
#include "webfuse/adapter/api.h"
#include "webfuse/adapter/authenticate.h"
#include "webfuse/adapter/mountpoint_factory.h"
#include "webfuse/api.h"
#include "webfuse/authenticate.h"
#include "webfuse/mountpoint_factory.h"
#ifdef __cplusplus
extern "C"

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/server_protocol.h
/// \file webfuse/server_protocol.h
/// \brief Provides low level access to libwebsockets protocol.
///
/// By default, libwebfuse encapsulates libwebsockets protocol by \ref
@ -8,12 +8,12 @@
/// libwebsockets applications.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_SERVER_PROTOCOL_H
#define WF_ADAPTER_SERVER_PROTOCOL_H
#ifndef WF_SERVER_PROTOCOL_H
#define WF_SERVER_PROTOCOL_H
#include <webfuse/adapter/api.h>
#include <webfuse/adapter/authenticate.h>
#include <webfuse/adapter/mountpoint_factory.h>
#include <webfuse/api.h>
#include <webfuse/authenticate.h>
#include <webfuse/mountpoint_factory.h>
#ifdef __cplusplus
extern "C"

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////////////
/// \file status.h
/// \file webfuse/status.h
/// \brief Generic status code.
////////////////////////////////////////////////////////////////////////////////

@ -0,0 +1,25 @@
////////////////////////////////////////////////////////////////////////////////
/// \file webfuse/webfuse.h
/// \brief Convenience header to include all functionality of libfuse_adapter.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_WEBFUSE_H
#define WF_WEBFUSE_H
#include <webfuse/status.h>
#include <webfuse/protocol_names.h>
#include <webfuse/api.h>
#include <webfuse/server.h>
#include <webfuse/server_config.h>
#include <webfuse/server_protocol.h>
#include <webfuse/authenticate.h>
#include <webfuse/credentials.h>
#include <webfuse/mountpoint.h>
#include <webfuse/client.h>
#include <webfuse/client_callback.h>
#include <webfuse/client_tlsconfig.h>
#endif

@ -1,25 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file webfuse_adapter.h
/// \brief Convenience header to include all functionality of libfuse_adapter.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_H
#define WF_ADAPTER_H
#include <webfuse/core/status.h>
#include <webfuse/core/protocol_names.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>
#include <webfuse/adapter/mountpoint.h>
#include <webfuse/adapter/client.h>
#include <webfuse/adapter/client_callback.h>
#include <webfuse/adapter/client_tlsconfig.h>
#endif

@ -1,27 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file webfuse_provider.h
/// \brief Convenience header to include all functionality of libfuse_provider.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_PROVIDER_H
#define WF_PROVIDER_H
#include <webfuse/core/status.h>
#include <webfuse/core/protocol_names.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/credentials.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,15 +1,15 @@
#include "webfuse_adapter.h"
#include "webfuse/webfuse.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"
#include "webfuse/adapter/impl/mountpoint.h"
#include "webfuse/impl/server.h"
#include "webfuse/impl/server_protocol.h"
#include "webfuse/impl/server_config.h"
#include "webfuse/impl/credentials.h"
#include "webfuse/impl/mountpoint.h"
#include "webfuse/core/util.h"
#include "webfuse/adapter/impl/client.h"
#include "webfuse/adapter/impl/client_tlsconfig.h"
#include "webfuse/impl/client.h"
#include "webfuse/impl/client_tlsconfig.h"
// server

@ -2,7 +2,7 @@
#define WF_JSON_UTIL_H
#include <jansson.h>
#include "webfuse/core/status.h"
#include "webfuse/status.h"
#ifdef __cplusplus
extern "C"

@ -1,7 +1,7 @@
#include "webfuse/core/jsonrpc/proxy_intern.h"
#include "webfuse/core/jsonrpc/response_intern.h"
#include "webfuse/core/jsonrpc/error.h"
#include "webfuse/core/status.h"
#include "webfuse/status.h"
#include "webfuse/core/timer/timer.h"

@ -1,6 +1,6 @@
#include "webfuse/core/jsonrpc/response_intern.h"
#include "webfuse/core/jsonrpc/error.h"
#include "webfuse/core/status.h"
#include "webfuse/status.h"
bool
wf_jsonrpc_is_response(

@ -1,7 +1,7 @@
#include "webfuse/core/jsonrpc/server.h"
#include "webfuse/core/jsonrpc/method.h"
#include "webfuse/core/jsonrpc/request.h"
#include "webfuse/core/status.h"
#include "webfuse/status.h"
#include "webfuse/core/util.h"
#include <stdlib.h>

@ -1,7 +1,7 @@
#ifndef WF_STATUS_INTERN_H
#define WF_STATUS_INTERN_H
#include "webfuse/core/status.h"
#include "webfuse/status.h"
#ifdef __cplusplus
extern "C" {

@ -1,9 +1,9 @@
#include "webfuse/adapter/impl/authenticator.h"
#include "webfuse/impl/authenticator.h"
#include <stdlib.h>
#include <string.h>
#include "webfuse/adapter/impl/credentials.h"
#include "webfuse/impl/credentials.h"
struct wf_impl_authenticator * wf_impl_authenticator_create(
char const * type,

@ -5,7 +5,7 @@
#include <stdbool.h>
#endif
#include "webfuse/adapter/authenticate.h"
#include "webfuse/authenticate.h"
#ifdef __cplusplus
extern "C"

@ -1,9 +1,9 @@
#include "webfuse/adapter/impl/authenticators.h"
#include "webfuse/impl/authenticators.h"
#include <stddef.h>
#include <string.h>
#include "webfuse/adapter/impl/authenticator.h"
#include "webfuse/adapter/impl/credentials.h"
#include "webfuse/impl/authenticator.h"
#include "webfuse/impl/credentials.h"
static struct wf_impl_authenticator * wf_impl_authenticators_find(
struct wf_impl_authenticators * authenticators,

@ -5,7 +5,7 @@
#include <stdbool.h>
#endif
#include "webfuse/adapter/authenticate.h"
#include "webfuse/authenticate.h"
#ifdef __cplusplus
extern "C"

@ -1,6 +1,6 @@
#include "webfuse/adapter/impl/client.h"
#include "webfuse/adapter/impl/client_protocol.h"
#include "webfuse/adapter/impl/client_tlsconfig.h"
#include "webfuse/impl/client.h"
#include "webfuse/impl/client_protocol.h"
#include "webfuse/impl/client_tlsconfig.h"
#include "webfuse/core/lws_log.h"
#include <libwebsockets.h>

@ -2,7 +2,7 @@
#define WF_ADAPTER_IMPL_CLIENT_H
#include "webfuse/adapter/client_callback.h"
#include "webfuse/client_callback.h"
#ifdef __cplusplus
extern "C"

@ -1,9 +1,9 @@
#include "webfuse/adapter/impl/client_protocol.h"
#include "webfuse/adapter/client_callback.h"
#include "webfuse/adapter/impl/credentials.h"
#include "webfuse/adapter/impl/filesystem.h"
#include "webfuse/adapter/impl/mountpoint.h"
#include "webfuse/core/protocol_names.h"
#include "webfuse/impl/client_protocol.h"
#include "webfuse/client_callback.h"
#include "webfuse/impl/credentials.h"
#include "webfuse/impl/filesystem.h"
#include "webfuse/impl/mountpoint.h"
#include "webfuse/protocol_names.h"
#include "webfuse/core/url.h"
#include "webfuse/core/util.h"
#include "webfuse/core/timer/manager.h"

@ -1,7 +1,7 @@
#ifndef WF_ADAPTER_IMPL_CLIENT_PROTOCOL_H
#define WF_ADAPTER_IMPL_CLIENT_PROTOCOL_H
#include "webfuse/adapter/client_callback.h"
#include "webfuse/client_callback.h"
#include "webfuse/core/slist.h"
#ifndef __cplusplus

@ -1,4 +1,4 @@
#include "webfuse/adapter/impl/client_tlsconfig.h"
#include "webfuse/impl/client_tlsconfig.h"
#include <stdlib.h>
#include <string.h>

@ -1,4 +1,4 @@
#include "webfuse/adapter/impl/credentials.h"
#include "webfuse/impl/credentials.h"
#include <string.h>
void wf_impl_credentials_init_default(

@ -1,13 +1,13 @@
#include "webfuse/adapter/impl/filesystem.h"
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/adapter/impl/operation/open.h"
#include "webfuse/adapter/impl/operation/close.h"
#include "webfuse/adapter/impl/operation/read.h"
#include "webfuse/adapter/impl/operation/readdir.h"
#include "webfuse/adapter/impl/operation/getattr.h"
#include "webfuse/adapter/impl/operation/lookup.h"
#include "webfuse/adapter/impl/session.h"
#include "webfuse/adapter/impl/mountpoint.h"
#include "webfuse/impl/filesystem.h"
#include "webfuse/impl/operation/context.h"
#include "webfuse/impl/operation/open.h"
#include "webfuse/impl/operation/close.h"
#include "webfuse/impl/operation/read.h"
#include "webfuse/impl/operation/readdir.h"
#include "webfuse/impl/operation/getattr.h"
#include "webfuse/impl/operation/lookup.h"
#include "webfuse/impl/session.h"
#include "webfuse/impl/mountpoint.h"
#include <libwebsockets.h>

@ -5,8 +5,8 @@
#include <stdbool.h>
#endif
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/impl/fuse_wrapper.h"
#include "webfuse/impl/operation/context.h"
#include "webfuse/core/slist.h"
#ifdef __cplusplus

@ -1,4 +1,4 @@
#include "webfuse/adapter/impl/mountpoint.h"
#include "webfuse/impl/mountpoint.h"
#include <stdlib.h>
#include <string.h>

@ -1,7 +1,7 @@
#ifndef WF_IMPL_MOUNTPOINT_H
#define WF_IMPL_MOUNTPOINT_H
#include "webfuse/adapter/mountpoint.h"
#include "webfuse/mountpoint.h"
#ifdef __cplusplus
extern "C"

@ -1,4 +1,4 @@
#include "webfuse/adapter/impl/mountpoint_factory.h"
#include "webfuse/impl/mountpoint_factory.h"
#include <stddef.h>
void

@ -1,7 +1,7 @@
#ifndef WF_ADAPTER_IMPL_MOUNTPOINT_FACTORY_H
#define WF_ADAPTER_IMPL_MOUNTPOINT_FACTORY_H
#include "webfuse/adapter/mountpoint_factory.h"
#include "webfuse/mountpoint_factory.h"
#include <stdbool.h>
#ifdef __cplusplus

@ -1,5 +1,5 @@
#include "webfuse/adapter/impl/operation/close.h"
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/impl/operation/close.h"
#include "webfuse/impl/operation/context.h"
#include <limits.h>
#include <errno.h>

@ -1,7 +1,7 @@
#ifndef WF_ADAPTER_IMPL_OPERATION_CLOSE_H
#define WF_ADAPTER_IMPL_OPERATION_CLOSE_H
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/impl/fuse_wrapper.h"
#ifdef __cplusplus
extern "C"

@ -1,6 +1,6 @@
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/adapter/impl/session_manager.h"
#include "webfuse/adapter/impl/session.h"
#include "webfuse/impl/operation/context.h"
#include "webfuse/impl/session_manager.h"
#include "webfuse/impl/session.h"
#include <stddef.h>
struct wf_jsonrpc_proxy * wf_impl_operation_context_get_proxy(

@ -1,7 +1,7 @@
#ifndef WF_ADAPTER_IMPL_OPERATION_CONTEXT_H
#define WF_ADAPTER_IMPL_OPERATION_CONTEXT_H
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/impl/fuse_wrapper.h"
#ifdef __cplusplus
extern "C" {

@ -1,5 +1,5 @@
#include "webfuse/adapter/impl/operation/getattr.h"
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/impl/operation/getattr.h"
#include "webfuse/impl/operation/context.h"
#include <errno.h>
#include <string.h>

@ -1,7 +1,7 @@
#ifndef WF_ADAPTER_IMPL_OPERATION_GETATTR_H
#define WF_ADAPTER_IMPL_OPERATION_GETATTR_H
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/impl/fuse_wrapper.h"
#include <jansson.h>
#include <sys/types.h>

@ -1,5 +1,5 @@
#include "webfuse/adapter/impl/operation/lookup.h"
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/impl/operation/lookup.h"
#include "webfuse/impl/operation/context.h"
#include <limits.h>
#include <errno.h>

@ -1,7 +1,7 @@
#ifndef WF_ADAPTER_IMPL_OPERATION_LOOKUP_H
#define WF_ADAPTER_IMPL_OPERATION_LOOKUP_H
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/impl/fuse_wrapper.h"
#include <jansson.h>
#include <sys/types.h>

@ -1,9 +1,9 @@
#include "webfuse/adapter/impl/operation/open.h"
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/impl/operation/open.h"
#include "webfuse/impl/operation/context.h"
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/util.h"
#include "webfuse/core/status.h"
#include "webfuse/status.h"
#include "webfuse/core/json_util.h"
#include <string.h>

@ -1,7 +1,7 @@
#ifndef WF_ADAPTER_IMPL_OPERATION_OPEN_H
#define WF_ADAPTER_IMPL_OPERATION_OPEN_H
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/impl/fuse_wrapper.h"
#include <jansson.h>
#ifdef __cplusplus

@ -1,5 +1,5 @@
#include "webfuse/adapter/impl/operation/read.h"
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/impl/operation/read.h"
#include "webfuse/impl/operation/context.h"
#include <errno.h>
#include <string.h>

@ -1,8 +1,8 @@
#ifndef WF_ADAPTER_IMPL_OPERATION_READ_H
#define WF_ADAPTER_IMPL_OPERATION_READ_H
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/core/status.h"
#include "webfuse/impl/fuse_wrapper.h"
#include "webfuse/status.h"
#include <jansson.h>

@ -1,5 +1,5 @@
#include "webfuse/adapter/impl/operation/readdir.h"
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/impl/operation/readdir.h"
#include "webfuse/impl/operation/context.h"
#include <stdlib.h>
#include <string.h>

@ -1,7 +1,7 @@
#ifndef WF_ADAPTER_IMPL_OPERATION_READDIR_H
#define WF_ADAPTER_IMPL_OPERATION_READDIR_H
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/impl/fuse_wrapper.h"
#include <jansson.h>
#ifdef __cplusplus

@ -1,4 +1,4 @@
#include "webfuse/adapter/server.h"
#include "webfuse/server.h"
#include <stdlib.h>
#include <stdbool.h>
@ -8,8 +8,8 @@
#include <sys/stat.h>
#include <unistd.h>
#include "webfuse/adapter/impl/server_config.h"
#include "webfuse/adapter/impl/server_protocol.h"
#include "webfuse/impl/server_config.h"
#include "webfuse/impl/server_protocol.h"
#include "webfuse/core/lws_log.h"
#define WF_SERVER_PROTOCOL_COUNT 3

@ -1,4 +1,4 @@
#include "webfuse/adapter/impl/server_config.h"
#include "webfuse/impl/server_config.h"
#include <stdlib.h>
#include <string.h>

@ -1,8 +1,8 @@
#ifndef WF_ADAPTER_IMPL_SERVER_CONFIG_H
#define WF_ADAPTER_IMPL_SERVER_CONFIG_H
#include "webfuse/adapter/impl/authenticators.h"
#include "webfuse/adapter/impl/mountpoint_factory.h"
#include "webfuse/impl/authenticators.h"
#include "webfuse/impl/mountpoint_factory.h"
#ifdef __cplusplus
extern "C" {

@ -1,4 +1,4 @@
#include "webfuse/adapter/impl/server_protocol.h"
#include "webfuse/impl/server_protocol.h"
#include <stdlib.h>
#include <ctype.h>
@ -6,9 +6,9 @@
#include "webfuse/core/message.h"
#include "webfuse/core/util.h"
#include "webfuse/core/protocol_names.h"
#include "webfuse/protocol_names.h"
#include "webfuse/adapter/impl/credentials.h"
#include "webfuse/impl/credentials.h"
#include "webfuse/core/status_intern.h"
#include "webfuse/core/jsonrpc/request.h"

@ -1,9 +1,9 @@
#ifndef WF_ADAPTER_IMPL_SERVER_PROTOCOL_H
#define WF_ADAPTER_IMPL_SERVER_PROTOCOL_H
#include "webfuse/adapter/impl/authenticators.h"
#include "webfuse/adapter/impl/mountpoint_factory.h"
#include "webfuse/adapter/impl/session_manager.h"
#include "webfuse/impl/authenticators.h"
#include "webfuse/impl/mountpoint_factory.h"
#include "webfuse/impl/session_manager.h"
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/jsonrpc/server.h"

@ -1,9 +1,9 @@
#include "webfuse/adapter/impl/session.h"
#include "webfuse/adapter/impl/authenticators.h"
#include "webfuse/impl/session.h"
#include "webfuse/impl/authenticators.h"
#include "webfuse/core/message_queue.h"
#include "webfuse/core/message.h"
#include "webfuse/adapter/impl/mountpoint_factory.h"
#include "webfuse/adapter/impl/mountpoint.h"
#include "webfuse/impl/mountpoint_factory.h"
#include "webfuse/impl/mountpoint.h"
#include "webfuse/core/container_of.h"
#include "webfuse/core/util.h"

@ -10,7 +10,7 @@ using std::size_t;
#endif
#include "webfuse/core/message_queue.h"
#include "webfuse/adapter/impl/filesystem.h"
#include "webfuse/impl/filesystem.h"
#include "webfuse/core/slist.h"
#include "webfuse/core/jsonrpc/proxy.h"

@ -1,4 +1,4 @@
#include "webfuse/adapter/impl/session_manager.h"
#include "webfuse/impl/session_manager.h"
#include "webfuse/core/util.h"
#include "webfuse/core/container_of.h"
#include <stddef.h>

@ -5,8 +5,8 @@
#include <stdbool.h>
#endif
#include "webfuse/adapter/impl/session.h"
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/impl/session.h"
#include "webfuse/impl/fuse_wrapper.h"
#include "webfuse/core/slist.h"
#ifdef __cplusplus

@ -1,281 +0,0 @@
#include "webfuse_provider.h"
#include "webfuse/provider/impl/request.h"
#include "webfuse/provider/impl/operation/getattr.h"
#include "webfuse/provider/impl/operation/lookup.h"
#include "webfuse/provider/impl/operation/readdir.h"
#include "webfuse/provider/impl/operation/open.h"
#include "webfuse/provider/impl/operation/close.h"
#include "webfuse/provider/impl/operation/read.h"
#include "webfuse/provider/impl/client_protocol.h"
#include "webfuse/provider/impl/client_config.h"
#include "webfuse/provider/impl/client.h"
#include "webfuse/provider/impl/dirbuffer.h"
#include "webfuse/provider/impl/credentials.h"
#include "webfuse/core/util.h"
// respond
void wfp_respond_error(
struct wfp_request * request,
wf_status status)
{
wfp_impl_respond_error(request, status);
}
void wfp_respond_getattr(
struct wfp_request * request,
struct stat const * stat)
{
wfp_impl_respond_getattr(request, stat);
}
void wfp_respond_lookup(
struct wfp_request * request,
struct stat const * stat)
{
wfp_impl_respond_lookup(request, stat);
}
void wfp_respond_open(
struct wfp_request * request,
uint32_t handle)
{
wfp_impl_respond_open(request, handle);
}
void wfp_respond_read(
struct wfp_request * request,
char const * data,
size_t length)
{
wfp_impl_respond_read(request, data, length);
}
void wfp_respond_readdir(
struct wfp_request * request,
struct wfp_dirbuffer * dirbuffer)
{
wfp_impl_respond_readdir(request, dirbuffer);
}
// config
struct wfp_client_config * wfp_client_config_create(void)
{
return wfp_impl_client_config_create();
}
void wfp_client_config_dispose(
struct wfp_client_config * config)
{
wfp_impl_client_config_dispose(config);
}
void wfp_client_config_set_userdata(
struct wfp_client_config * config,
void * user_data)
{
wfp_impl_client_config_set_userdata(config, user_data);
}
void wfp_client_config_set_keypath(
struct wfp_client_config * config,
char const * key_path)
{
wfp_impl_client_config_set_keypath(config, key_path);
}
void wfp_client_config_set_certpath(
struct wfp_client_config * config,
char const * cert_path)
{
wfp_impl_client_config_set_certpath(config, cert_path);
}
void wfp_client_config_set_ca_filepath(
struct wfp_client_config * config,
char const * ca_filepath)
{
wfp_impl_client_config_set_ca_filepath(config, ca_filepath);
}
void wfp_client_config_set_onconnected(
struct wfp_client_config * config,
wfp_connected_fn * handler)
{
wfp_impl_client_config_set_onconnected(config, handler);
}
void wfp_client_config_set_ondisconnected(
struct wfp_client_config * config,
wfp_disconnected_fn * handler)
{
wfp_impl_client_config_set_ondisconnected(config, handler);
}
void wfp_client_config_set_onlookup(
struct wfp_client_config * config,
wfp_lookup_fn * handler)
{
wfp_impl_client_config_set_onlookup(config, handler);
}
void wfp_client_config_set_ongetattr(
struct wfp_client_config * config,
wfp_getattr_fn * handler)
{
wfp_impl_client_config_set_ongetattr(config, handler);
}
void wfp_client_config_set_onreaddir(
struct wfp_client_config * config,
wfp_readdir_fn * handler)
{
wfp_impl_client_config_set_onreaddir(config, handler);
}
void wfp_client_config_set_onopen(
struct wfp_client_config * config,
wfp_open_fn * handler)
{
wfp_impl_client_config_set_onopen(config, handler);
}
void wfp_client_config_set_onclose(
struct wfp_client_config * config,
wfp_close_fn * handler)
{
wfp_impl_client_config_set_onclose(config, handler);
}
void wfp_client_config_set_onread(
struct wfp_client_config * config,
wfp_read_fn * handler)
{
wfp_impl_client_config_set_onread(config, handler);
}
void wfp_client_config_enable_authentication(
struct wfp_client_config * config,
wfp_get_credentials_fn * get_credentials)
{
wfp_impl_client_config_enable_authentication(config, get_credentials);
}
// protocol
struct wfp_client_protocol * wfp_client_protocol_create(
struct wfp_client_config const * config)
{
return wfp_impl_client_protocol_create(config);
}
void wfp_client_protocol_dispose(
struct wfp_client_protocol * protocol)
{
wfp_impl_client_protocol_dispose(protocol);
}
void wfp_client_protocol_init_lws(
struct wfp_client_protocol * protocol,
struct lws_protocols * lws_protocol)
{
wfp_impl_client_protocol_init_lws(protocol, lws_protocol);
}
void wfp_client_protocol_connect(
struct wfp_client_protocol * protocol,
struct lws_context * context,
char const * url)
{
wfp_impl_client_protocol_connect(protocol, context, url);
}
void wfp_client_protocol_disconnect(
struct wfp_client_protocol * protocol)
{
wfp_impl_client_protocol_disconnect(protocol);
}
// client
struct wfp_client * wfp_client_create(
struct wfp_client_config * config)
{
return wfp_impl_client_create(config);
}
void wfp_client_connect(
struct wfp_client * client,
char const * url)
{
wfp_impl_client_connect(client, url);
}
void wfp_client_disconnect(
struct wfp_client * client)
{
wfp_impl_client_disconnect(client);
}
void wfp_client_dispose(
struct wfp_client * client)
{
wfp_impl_client_dispose(client);
}
void wfp_client_service(
struct wfp_client * client)
{
wfp_impl_client_service(client);
}
void wfp_client_interrupt(
struct wfp_client * client)
{
wfp_impl_client_interrupt(client);
}
// dirbuffer
struct wfp_dirbuffer * wfp_dirbuffer_create(void)
{
return wfp_impl_dirbuffer_create();
}
void wfp_dirbuffer_dispose(
struct wfp_dirbuffer * buffer)
{
wfp_impl_dirbuffer_dispose(buffer);
}
void wfp_dirbuffer_add(
struct wfp_dirbuffer * buffer,
char const * name,
ino_t inode)
{
wfp_impl_dirbuffer_add(buffer, name, inode);
}
// credentials
void wfp_credentials_set_type(
struct wfp_credentials * credentials,
char const * type)
{
wfp_impl_credentials_set_type(credentials, type);
}
void wfp_credentials_add(
struct wfp_credentials * credentials,
char const * key,
char const * value)
{
wfp_impl_credentials_add(credentials, key, value);
}

@ -1,95 +0,0 @@
#include "webfuse/provider/impl/client.h"
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <libwebsockets.h>
#include "webfuse/provider/impl/provider.h"
#include "webfuse/provider/impl/client_protocol.h"
#include "webfuse/provider/impl/client_config.h"
#include "webfuse/core/lws_log.h"
#define WFP_CLIENT_PROTOCOL_COUNT 2
struct wfp_client
{
struct wfp_client_protocol protocol;
struct lws_context_creation_info info;
struct lws_protocols protocols[WFP_CLIENT_PROTOCOL_COUNT];
struct lws_context * context;
char * key_path;
char * cert_path;
};
struct wfp_client * wfp_impl_client_create(
struct wfp_client_config * config)
{
wf_lwslog_disable();
struct wfp_client * client = malloc(sizeof(struct wfp_client));
wfp_impl_client_protocol_init(&client->protocol, &config->provider, config->user_data);
memset(client->protocols, 0, sizeof(struct lws_protocols) * WFP_CLIENT_PROTOCOL_COUNT);
wfp_impl_client_protocol_init_lws(&client->protocol, &client->protocols[0]);
memset(&client->info, 0, sizeof(struct lws_context_creation_info));
client->info.port = CONTEXT_PORT_NO_LISTEN;
client->info.protocols = client->protocols;
client->info.uid = -1;
client->info.gid = -1;
if ((NULL != config->cert_path) && (NULL != config->key_path))
{
client->info.options |= LWS_SERVER_OPTION_EXPLICIT_VHOSTS;
}
client->context = lws_create_context(&client->info);
if ((NULL != config->cert_path) && (NULL != config->key_path))
{
struct lws_vhost * vhost = lws_create_vhost(client->context, &client->info);
client->info.options |= LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
client->info.client_ssl_cert_filepath = config->cert_path;
client->info.client_ssl_private_key_filepath = config->key_path;
client->info.client_ssl_ca_filepath = config->ca_filepath;
lws_init_vhost_client_ssl(&client->info, vhost);
}
return client;
}
void wfp_impl_client_dispose(
struct wfp_client * client)
{
lws_context_destroy(client->context);
wfp_impl_client_protocol_cleanup(&client->protocol);
free(client);
}
void wfp_impl_client_connect(
struct wfp_client * client,
char const * url)
{
wfp_impl_client_protocol_connect(&client->protocol, client->context, url);
}
void wfp_impl_client_disconnect(
struct wfp_client * client)
{
wfp_impl_client_protocol_disconnect(&client->protocol);
}
void wfp_impl_client_service(
struct wfp_client * client)
{
lws_service(client->context, 0);
}
void wfp_impl_client_interrupt(
struct wfp_client * client)
{
lws_cancel_service(client->context);
}

@ -1,48 +0,0 @@
#ifndef WF_PROVIDER_IMPL_CLIENT_H
#define WF_PROVIDER_IMPL_CLIENT_H
#ifndef __cplusplus
#include <stdbool.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
struct wfp_client;
struct wfp_client_config;
extern struct wfp_client * wfp_impl_client_create(
struct wfp_client_config * config);
extern void wfp_impl_client_set_keypath(
struct wfp_client * client,
char * key_path);
extern void wfp_impl_client_set_certpath(
struct wfp_client * client,
char * cert_path);
extern void wfp_impl_client_connect(
struct wfp_client * client,
char const * url);
extern void wfp_impl_client_disconnect(
struct wfp_client * client);
extern void wfp_impl_client_dispose(
struct wfp_client * client);
extern void wfp_impl_client_service(
struct wfp_client * client);
extern void wfp_impl_client_interrupt(
struct wfp_client * client);
#ifdef __cplusplus
}
#endif
#endif

@ -1,119 +0,0 @@
#include "webfuse/provider/impl/client_config.h"
#include "webfuse/provider/impl/provider.h"
#include <stdlib.h>
#include <string.h>
struct wfp_client_config * wfp_impl_client_config_create(void)
{
struct wfp_client_config * config = malloc(sizeof(struct wfp_client_config));
wfp_impl_provider_init(&config->provider);
config->user_data = NULL;
config->key_path = NULL;
config->cert_path = NULL;
config->ca_filepath = NULL;
return config;
}
void wfp_impl_client_config_dispose(
struct wfp_client_config * config)
{
free(config->key_path);
free(config->cert_path);
free(config->ca_filepath);
free(config);
}
void wfp_impl_client_config_set_userdata(
struct wfp_client_config * config,
void * user_data)
{
config->user_data = user_data;
}
void wfp_impl_client_config_set_keypath(
struct wfp_client_config * config,
char const * key_path)
{
free(config->key_path);
config->key_path = strdup(key_path);
}
void wfp_impl_client_config_set_certpath(
struct wfp_client_config * config,
char const * cert_path)
{
free(config->cert_path);
config->cert_path = strdup(cert_path);
}
void wfp_impl_client_config_set_ca_filepath(
struct wfp_client_config * config,
char const * ca_filepath)
{
free(config->ca_filepath);
config->ca_filepath = strdup(ca_filepath);
}
void wfp_impl_client_config_set_onconnected(
struct wfp_client_config * config,
wfp_connected_fn * handler)
{
config->provider.connected = handler;
}
void wfp_impl_client_config_set_ondisconnected(
struct wfp_client_config * config,
wfp_disconnected_fn * handler)
{
config->provider.disconnected = handler;
}
void wfp_impl_client_config_set_onlookup(
struct wfp_client_config * config,
wfp_lookup_fn * handler)
{
config->provider.lookup = handler;
}
void wfp_impl_client_config_set_ongetattr(
struct wfp_client_config * config,
wfp_getattr_fn * handler)
{
config->provider.getattr = handler;
}
void wfp_impl_client_config_set_onreaddir(
struct wfp_client_config * config,
wfp_readdir_fn * handler)
{
config->provider.readdir = handler;
}
void wfp_impl_client_config_set_onopen(
struct wfp_client_config * config,
wfp_open_fn * handler)
{
config->provider.open = handler;
}
void wfp_impl_client_config_set_onclose(
struct wfp_client_config * config,
wfp_close_fn * handler)
{
config->provider.close = handler;
}
void wfp_impl_client_config_set_onread(
struct wfp_client_config * config,
wfp_read_fn * handler)
{
config->provider.read = handler;
}
void wfp_impl_client_config_enable_authentication(
struct wfp_client_config * config,
wfp_get_credentials_fn * get_credentials)
{
config->provider.get_credentials = get_credentials;
}

@ -1,82 +0,0 @@
#ifndef WF_PROVIDER_IMPL_CLIENT_CONFIG_H
#define WF_PROVIDER_IMPL_CLIENT_CONFIG_H
#include "webfuse/provider/client_config.h"
#include "webfuse/provider/impl/provider.h"
#ifdef __cplusplus
extern "C"
{
#endif
struct wfp_client_config
{
struct wfp_provider provider;
void * user_data;
char * key_path;
char * cert_path;
char * ca_filepath;
};
extern struct wfp_client_config * wfp_impl_client_config_create(void);
extern void wfp_impl_client_config_dispose(
struct wfp_client_config * config);
extern void wfp_impl_client_config_set_userdata(
struct wfp_client_config * config,
void * user_data);
extern void wfp_impl_client_config_set_keypath(
struct wfp_client_config * config,
char const * key_path);
extern void wfp_impl_client_config_set_certpath(
struct wfp_client_config * config,
char const * cert_path);
extern void wfp_impl_client_config_set_ca_filepath(
struct wfp_client_config * config,
char const * ca_filepath);
extern void wfp_impl_client_config_set_onconnected(
struct wfp_client_config * config,
wfp_connected_fn * handler);
extern void wfp_impl_client_config_set_ondisconnected(
struct wfp_client_config * config,
wfp_disconnected_fn * handler);
extern void wfp_impl_client_config_set_onlookup(
struct wfp_client_config * config,
wfp_lookup_fn * handler);
extern void wfp_impl_client_config_set_ongetattr(
struct wfp_client_config * config,
wfp_getattr_fn * handler);
extern void wfp_impl_client_config_set_onreaddir(
struct wfp_client_config * config,
wfp_readdir_fn * handler);
extern void wfp_impl_client_config_set_onopen(
struct wfp_client_config * config,
wfp_open_fn * handler);
extern void wfp_impl_client_config_set_onclose(
struct wfp_client_config * config,
wfp_close_fn * handler);
extern void wfp_impl_client_config_set_onread(
struct wfp_client_config * config,
wfp_read_fn * handler);
extern void wfp_impl_client_config_enable_authentication(
struct wfp_client_config * config,
wfp_get_credentials_fn * get_credentials);
#ifdef __cplusplus
}
#endif
#endif

@ -1,340 +0,0 @@
#include "webfuse/provider/impl/client_protocol.h"
#include <stdlib.h>
#include <string.h>
#include <libwebsockets.h>
#include <jansson.h>
#include "webfuse/provider/impl/client_config.h"
#include "webfuse/provider/impl/provider.h"
#include "webfuse/provider/impl/credentials.h"
#include "webfuse/core/util.h"
#include "webfuse/core/message.h"
#include "webfuse/core/message_queue.h"
#include "webfuse/core/container_of.h"
#include "webfuse/core/url.h"
#include "webfuse/core/protocol_names.h"
#include "webfuse/core/timer/manager.h"
#include "webfuse/core/jsonrpc/response.h"
#include "webfuse/core/jsonrpc/request.h"
#include "webfuse/core/jsonrpc/proxy.h"
#define WF_DEFAULT_TIMEOUT (10 * 1000)
static void wfp_impl_client_protocol_respond(
json_t * response,
void * user_data)
{
struct wfp_client_protocol * protocol = (struct wfp_client_protocol *) user_data;
struct wf_message * message = wf_message_create(response);
if (NULL != message)
{
wf_slist_append(&protocol->messages, &message->item);
lws_callback_on_writable(protocol->wsi);
}
}
static void wfp_impl_client_protocol_process(
struct wfp_client_protocol * protocol,
char const * data,
size_t length)
{
json_t * message = json_loadb(data, length, 0, NULL);
if (NULL != message)
{
if (wf_jsonrpc_is_response(message))
{
wf_jsonrpc_proxy_onresult(protocol->proxy, message);
}
if (wf_jsonrpc_is_request(message))
{
struct wfp_impl_invokation_context context =
{
.provider = &protocol->provider,
.user_data = protocol->user_data,
.request = &protocol->request
};
wfp_impl_provider_invoke(&context, message);
}
json_decref(message);
}
}
static void
wfp_impl_client_protocol_on_add_filesystem_finished(
void * user_data,
json_t const * result,
json_t const * WF_UNUSED_PARAM(error))
{
struct wfp_client_protocol * protocol = user_data;
if (NULL == protocol->wsi) { return; }
if (NULL != result)
{
protocol->is_connected = true;
protocol->provider.connected(protocol->user_data);
}
else
{
protocol->is_shutdown_requested = true;
lws_callback_on_writable(protocol->wsi);
}
}
static void wfp_impl_client_protocol_add_filesystem(
struct wfp_client_protocol * protocol)
{
wf_jsonrpc_proxy_invoke(
protocol->proxy,
&wfp_impl_client_protocol_on_add_filesystem_finished,
protocol,
"add_filesystem",
"s",
"cprovider");
}
static void
wfp_impl_client_protocol_on_authenticate_finished(
void * user_data,
json_t const * result,
json_t const * WF_UNUSED_PARAM(error))
{
struct wfp_client_protocol * protocol = user_data;
if (NULL == protocol->wsi) { return; }
if (NULL != result)
{
wfp_impl_client_protocol_add_filesystem(protocol);
}
else
{
protocol->is_shutdown_requested = true;
lws_callback_on_writable(protocol->wsi);
}
}
static void wfp_impl_client_protocol_authenticate(
struct wfp_client_protocol * protocol)
{
struct wfp_credentials credentials;
wfp_impl_credentials_init(&credentials);
protocol->provider.get_credentials(&credentials, protocol->user_data);
char const * cred_type = wfp_impl_credentials_get_type(&credentials);
json_t * creds = wfp_impl_credentials_get(&credentials);
json_incref(creds);
wf_jsonrpc_proxy_invoke(
protocol->proxy,
&wfp_impl_client_protocol_on_authenticate_finished,
protocol,
"authenticate",
"sj",
cred_type, creds);
wfp_impl_credentials_cleanup(&credentials);
}
static void wfp_impl_client_protocol_handshake(
struct wfp_client_protocol * protocol)
{
if (wfp_impl_provider_is_authentication_enabled(&protocol->provider))
{
wfp_impl_client_protocol_authenticate(protocol);
}
else
{
wfp_impl_client_protocol_add_filesystem(protocol);
}
}
static int wfp_impl_client_protocol_callback(
struct lws * wsi,
enum lws_callback_reasons reason,
void * WF_UNUSED_PARAM(user),
void * in,
size_t len)
{
int result = 0;
struct lws_protocols const * ws_protocol = lws_get_protocol(wsi);
struct wfp_client_protocol * protocol = (NULL != ws_protocol) ? ws_protocol->user: NULL;
if (NULL != protocol)
{
wf_timer_manager_check(protocol->timer_manager);
switch (reason)
{
case LWS_CALLBACK_CLIENT_ESTABLISHED:
wfp_impl_client_protocol_handshake(protocol);
break;
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
protocol->is_connected = false;
protocol->provider.disconnected(protocol->user_data);
break;
case LWS_CALLBACK_CLIENT_CLOSED:
protocol->is_connected = false;
protocol->provider.disconnected(protocol->user_data);
protocol->wsi = NULL;
break;
case LWS_CALLBACK_CLIENT_RECEIVE:
wfp_impl_client_protocol_process(protocol, in, len);
break;
case LWS_CALLBACK_SERVER_WRITEABLE:
// fall-through
case LWS_CALLBACK_CLIENT_WRITEABLE:
if (wsi == protocol->wsi)
{
if (protocol->is_shutdown_requested)
{
result = 1;
}
else if (!wf_slist_empty(&protocol->messages))
{
struct wf_slist_item * item = wf_slist_remove_first(&protocol->messages);
struct wf_message * message = wf_container_of(item, struct wf_message, item);
lws_write(wsi, (unsigned char*) message->data, message->length, LWS_WRITE_TEXT);
wf_message_dispose(message);
if (!wf_slist_empty(&protocol->messages))
{
lws_callback_on_writable(wsi);
}
}
}
break;
default:
break;
}
}
return result;
}
static bool wfp_impl_client_protocol_send(
json_t * request,
void * user_data)
{
bool result = false;
struct wfp_client_protocol * protocol = user_data;
struct wf_message * message = wf_message_create(request);
if (NULL != message)
{
wf_slist_append(&protocol->messages, &message->item);
lws_callback_on_writable(protocol->wsi);
result = true;
}
return result;
}
void wfp_impl_client_protocol_init(
struct wfp_client_protocol * protocol,
struct wfp_provider const * provider,
void * user_data)
{
protocol->is_connected = false;
protocol->is_shutdown_requested = false;
wf_slist_init(&protocol->messages);
protocol->wsi = NULL;
protocol->request.respond = &wfp_impl_client_protocol_respond;
protocol->request.user_data = protocol;
protocol->timer_manager = wf_timer_manager_create();
protocol->proxy = wf_jsonrpc_proxy_create(protocol->timer_manager, WF_DEFAULT_TIMEOUT, &wfp_impl_client_protocol_send, protocol);
protocol->user_data = user_data;
wfp_impl_provider_init_from_prototype(&protocol->provider, provider);
}
void wfp_impl_client_protocol_cleanup(
struct wfp_client_protocol * protocol)
{
wf_jsonrpc_proxy_dispose(protocol->proxy);
wf_timer_manager_dispose(protocol->timer_manager);
wf_message_queue_cleanup(&protocol->messages);
}
struct wfp_client_protocol * wfp_impl_client_protocol_create(
struct wfp_client_config const * config)
{
struct wfp_client_protocol * protocol = malloc(sizeof(struct wfp_client_protocol));
wfp_impl_client_protocol_init(protocol, &config->provider, config->user_data);
return protocol;
}
void wfp_impl_client_protocol_dispose(
struct wfp_client_protocol * protocol)
{
wfp_impl_client_protocol_cleanup(protocol);
free(protocol);
}
void wfp_impl_client_protocol_init_lws(
struct wfp_client_protocol * protocol,
struct lws_protocols * lws_protocol)
{
lws_protocol->name = WF_PROTOCOL_NAME_PROVIDER_CLIENT;
lws_protocol->callback = &wfp_impl_client_protocol_callback;
lws_protocol->per_session_data_size = 0;
lws_protocol->user = protocol;
}
void wfp_impl_client_protocol_connect(
struct wfp_client_protocol * protocol,
struct lws_context * context,
char const * url)
{
struct wf_url url_data;
bool const success = wf_url_init(&url_data, url);
if (success)
{
struct lws_client_connect_info info;
memset(&info, 0, sizeof(struct lws_client_connect_info));
info.context = context;
info.port = url_data.port;
info.address = url_data.host;
info.path = url_data.path;
info.host = info.address;
info.origin = info.address;
info.ssl_connection = (url_data.use_tls) ? LCCSCF_USE_SSL : 0;
info.protocol = WF_PROTOCOL_NAME_ADAPTER_SERVER;
info.local_protocol_name = WF_PROTOCOL_NAME_PROVIDER_CLIENT;
info.pwsi = &protocol->wsi;
lws_client_connect_via_info(&info);
wf_url_cleanup(&url_data);
}
else
{
protocol->provider.disconnected(protocol->user_data);
}
}
void wfp_impl_client_protocol_disconnect(
struct wfp_client_protocol * protocol)
{
if (protocol->is_connected)
{
protocol->is_shutdown_requested = true;
lws_callback_on_writable(protocol->wsi);
}
else
{
protocol->provider.disconnected(protocol->user_data);
}
}

@ -1,63 +0,0 @@
#ifndef WF_PROVIDER_IMPL_CLIENT_PROTOCOL_H
#define WF_PROVIDER_IMPL_CLIENT_PROTOCOL_H
#include "webfuse/provider/impl/provider.h"
#include "webfuse/provider/impl/request.h"
#include "webfuse/core/slist.h"
#ifdef __cplusplus
extern "C"
{
#endif
struct wfp_client_config;
struct lws_protocols;
struct lws_context;
struct wf_jsonrpc_proxy;
struct wf_timer_manager;
struct wfp_client_protocol
{
bool is_connected;
bool is_shutdown_requested;
struct wfp_request request;
struct wfp_provider provider;
void * user_data;
struct lws * wsi;
struct wf_timer_manager * timer_manager;
struct wf_jsonrpc_proxy * proxy;
struct wf_slist messages;
};
extern void wfp_impl_client_protocol_init(
struct wfp_client_protocol * protocol,
struct wfp_provider const * provider,
void * user_data);
extern void wfp_impl_client_protocol_cleanup(
struct wfp_client_protocol * protocol);
extern struct wfp_client_protocol * wfp_impl_client_protocol_create(
struct wfp_client_config const * config);
extern void wfp_impl_client_protocol_dispose(
struct wfp_client_protocol * protocol);
extern void wfp_impl_client_protocol_init_lws(
struct wfp_client_protocol * protocol,
struct lws_protocols * lws_protocol);
extern void wfp_impl_client_protocol_connect(
struct wfp_client_protocol * protocol,
struct lws_context * context,
char const * url);
extern void wfp_impl_client_protocol_disconnect(
struct wfp_client_protocol * protocol);
#ifdef __cplusplus
}
#endif
#endif

@ -1,46 +0,0 @@
#include "webfuse/provider/impl/credentials.h"
#include <stdlib.h>
#include <string.h>
void wfp_impl_credentials_init(
struct wfp_credentials * credentials)
{
credentials->type = NULL;
credentials->contents = json_object();
}
void wfp_impl_credentials_cleanup(
struct wfp_credentials * credentials)
{
free(credentials->type);
json_decref(credentials->contents);
}
void wfp_impl_credentials_set_type(
struct wfp_credentials * credentials,
char const * type)
{
free(credentials->type);
credentials->type = strdup(type);
}
void wfp_impl_credentials_add(
struct wfp_credentials * credentials,
char const * key,
char const * value)
{
json_object_set_new(credentials->contents, key, json_string(value));
}
char const * wfp_impl_credentials_get_type(
struct wfp_credentials * credentials)
{
return credentials->type;
}
json_t * wfp_impl_credentials_get(
struct wfp_credentials * credentials)
{
return credentials->contents;
}

@ -1,43 +0,0 @@
#ifndef WF_PROVIDER_IMPL_CREDENTIALS_H
#define WF_PROVIDER_IMPL_CREDENTIALS_H
#include "webfuse/provider/credentials.h"
#include <jansson.h>
#ifdef __cplusplus
extern "C"
{
#endif
struct wfp_credentials
{
char * type;
json_t * contents;
};
extern void wfp_impl_credentials_init(
struct wfp_credentials * credentials);
extern void wfp_impl_credentials_cleanup(
struct wfp_credentials * credentials);
extern void wfp_impl_credentials_set_type(
struct wfp_credentials * credentials,
char const * type);
extern void wfp_impl_credentials_add(
struct wfp_credentials * credentials,
char const * key,
char const * value);
extern char const * wfp_impl_credentials_get_type(
struct wfp_credentials * credentials);
extern json_t * wfp_impl_credentials_get(
struct wfp_credentials * credentials);
#ifdef __cplusplus
}
#endif
#endif

@ -1,42 +0,0 @@
#include "webfuse/provider/impl/dirbuffer.h"
#include <stdlib.h>
struct wfp_dirbuffer * wfp_impl_dirbuffer_create(void)
{
struct wfp_dirbuffer * buffer = malloc(sizeof(struct wfp_dirbuffer));
buffer->entries = json_array();
return buffer;
}
void wfp_impl_dirbuffer_dispose(
struct wfp_dirbuffer * buffer)
{
if (NULL != buffer->entries)
{
json_decref(buffer->entries);
}
free(buffer);
}
void wfp_impl_dirbuffer_add(
struct wfp_dirbuffer * buffer,
char const * name,
ino_t inode)
{
json_t * entry = json_object();
json_object_set_new(entry, "name", json_string(name));
json_object_set_new(entry, "inode", json_integer(inode));
json_array_append_new(buffer->entries, entry);
}
json_t * wfp_impl_dirbuffer_take(
struct wfp_dirbuffer * buffer)
{
json_t * entries = buffer->entries;
buffer->entries = NULL;
return entries;
}

@ -1,37 +0,0 @@
#ifndef WF_PROVIDER_IMPL_DIRBUFFER_H
#define WF_PROVIDER_IMPL_DIRBUFFER_H
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <jansson.h>
#ifdef __cplusplus
extern "C"
{
#endif
struct wfp_dirbuffer
{
json_t * entries;
};
extern struct wfp_dirbuffer * wfp_impl_dirbuffer_create(void);
extern void wfp_impl_dirbuffer_dispose(
struct wfp_dirbuffer * buffer);
extern void wfp_impl_dirbuffer_add(
struct wfp_dirbuffer * buffer,
char const * name,
ino_t inode);
extern json_t * wfp_impl_dirbuffer_take(
struct wfp_dirbuffer * buffer);
#ifdef __cplusplus
}
#endif
#endif

@ -1,38 +0,0 @@
#include "webfuse/provider/impl/operation/close.h"
#include <limits.h>
#include "webfuse/core/util.h"
void wfp_impl_close(
struct wfp_impl_invokation_context * context,
json_t * params,
int WF_UNUSED_PARAM(id))
{
size_t const param_count = json_array_size(params);
if (4 == param_count)
{
json_t * inode_holder = json_array_get(params, 1);
json_t * handle_holder = json_array_get(params, 2);
json_t * flags_holder = json_array_get(params, 3);
if (json_is_integer(inode_holder) &&
json_is_integer(handle_holder) &&
json_is_integer(flags_holder))
{
ino_t inode = (ino_t) json_integer_value(inode_holder);
uint32_t handle = (uint32_t) (json_integer_value(handle_holder) & UINT32_MAX);
int flags = json_integer_value(flags_holder);
context->provider->close(inode, handle, flags, context->user_data);
}
}
}
void wfp_impl_close_default(
ino_t WF_UNUSED_PARAM(inode),
uint32_t WF_UNUSED_PARAM(handle),
int WF_UNUSED_PARAM(flags),
void * WF_UNUSED_PARAM(user_data))
{
// empty
}

@ -1,26 +0,0 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_CLOSE_H
#define WF_PROVIDER_IMPL_OPERATION_CLOSE_H
#include "webfuse/provider/impl/provider.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern void wfp_impl_close(
struct wfp_impl_invokation_context * context,
json_t * params,
int id);
extern void wfp_impl_close_default(
ino_t inode,
uint32_t handle,
int flags,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,22 +0,0 @@
#ifndef WFP_OPERATION_IMPL_ERROR_H
#define WFP_OPERATION_IMPL_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_impl_respond_error(
struct wfp_request * request,
wf_status status);
#ifdef __cplusplus
}
#endif
#endif

@ -1,64 +0,0 @@
#include "webfuse/provider/impl/operation/getattr.h"
#include <stdbool.h>
#include "webfuse/provider/impl/operation/error.h"
#include "webfuse/provider/impl/request.h"
#include "webfuse/core/util.h"
void wfp_impl_getattr(
struct wfp_impl_invokation_context * context,
json_t * params,
int id)
{
size_t const count = json_array_size(params);
if (2 == count)
{
json_t * inode_holder = json_array_get(params, 1);
if (json_is_integer(inode_holder))
{
ino_t inode = (ino_t) json_integer_value(inode_holder);
struct wfp_request * request = wfp_impl_request_create(context->request, id);
context->provider->getattr(request, inode, context->user_data);
}
}
}
void wfp_impl_getattr_default(
struct wfp_request * request,
ino_t WF_UNUSED_PARAM(inode),
void * WF_UNUSED_PARAM(user_data))
{
wfp_impl_respond_error(request, WF_BAD_NOENTRY);
}
void wfp_impl_respond_getattr(
struct wfp_request * request,
struct stat const * stat)
{
bool const is_file = (0 != (stat->st_mode & S_IFREG));
bool const is_dir = (0 != (stat->st_mode & S_IFDIR));
json_t * result = json_object();
json_object_set_new(result, "inode", json_integer(stat->st_ino));
json_object_set_new(result, "mode", json_integer(stat->st_mode & 0777));
json_object_set_new(result, "atime", json_integer(stat->st_atime));
json_object_set_new(result, "mtime", json_integer(stat->st_mtime));
json_object_set_new(result, "ctime", json_integer(stat->st_ctime));
if (is_file)
{
json_object_set_new(result, "type", json_string("file"));
json_object_set_new(result, "size", json_integer(stat->st_size));
}
if (is_dir)
{
json_object_set_new(result, "type", json_string("dir"));
}
wfp_impl_respond(request, result);
}

@ -1,29 +0,0 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_GETATTR_H
#define WF_PROVIDER_IMPL_OPERATION_GETATTR_H
#include "webfuse/provider/impl/provider.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern void wfp_impl_respond_getattr(
struct wfp_request * request,
struct stat const * stat);
extern void wfp_impl_getattr(
struct wfp_impl_invokation_context * context,
json_t * params,
int id);
extern void wfp_impl_getattr_default(
struct wfp_request * request,
ino_t inode,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,68 +0,0 @@
#include "webfuse/provider/impl/operation/lookup.h"
#include <stdbool.h>
#include "webfuse/provider/impl/operation/error.h"
#include "webfuse/provider/impl/request.h"
#include "webfuse/core/util.h"
void wfp_impl_lookup(
struct wfp_impl_invokation_context * context,
json_t * params,
int id)
{
size_t const count = json_array_size(params);
if (3 == count)
{
json_t * inode_holder = json_array_get(params, 1);
json_t * name_holder = json_array_get(params, 2);
if (json_is_integer(inode_holder) &&
json_is_string(name_holder))
{
ino_t inode = json_integer_value(inode_holder);
char const * name = json_string_value(name_holder);
struct wfp_request * request = wfp_impl_request_create(context->request, id);
context->provider->lookup(request, inode, name, context->user_data);
}
}
}
void wfp_impl_respond_lookup(
struct wfp_request * request,
struct stat const * stat)
{
bool const is_file = (0 != (stat->st_mode & S_IFREG));
bool const is_dir = (0 != (stat->st_mode & S_IFDIR));
json_t * result = json_object();
json_object_set_new(result, "inode", json_integer(stat->st_ino));
json_object_set_new(result, "mode", json_integer(stat->st_mode & 0777));
json_object_set_new(result, "atime", json_integer(stat->st_atime));
json_object_set_new(result, "mtime", json_integer(stat->st_mtime));
json_object_set_new(result, "ctime", json_integer(stat->st_ctime));
if (is_file)
{
json_object_set_new(result, "type", json_string("file"));
json_object_set_new(result, "size", json_integer(stat->st_size));
}
if (is_dir)
{
json_object_set_new(result, "type", json_string("dir"));
}
wfp_impl_respond(request, result);
}
void wfp_impl_lookup_default(
struct wfp_request * request,
ino_t WF_UNUSED_PARAM(parent),
char const * WF_UNUSED_PARAM(name),
void * WF_UNUSED_PARAM(user_data))
{
wfp_impl_respond_error(request, WF_BAD_NOENTRY);
}

@ -1,30 +0,0 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_LOOKUP_H
#define WF_PROVIDER_IMPL_OPERATION_LOOKUP_H
#include "webfuse/provider/impl/provider.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern void wfp_impl_respond_lookup(
struct wfp_request * request,
struct stat const * stat);
extern void wfp_impl_lookup(
struct wfp_impl_invokation_context * context,
json_t * params,
int id);
extern void wfp_impl_lookup_default(
struct wfp_request * request,
ino_t parent,
char const * name,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,47 +0,0 @@
#include "webfuse/provider/impl/operation/open.h"
#include "webfuse/provider/impl/operation/error.h"
#include "webfuse/provider/impl/request.h"
#include "webfuse/core/util.h"
void wfp_impl_open(
struct wfp_impl_invokation_context * context,
json_t * params,
int id)
{
size_t const count = json_array_size(params);
if (3 == count)
{
json_t * inode_holder = json_array_get(params, 1);
json_t * flags_holder = json_array_get(params, 2);
if (json_is_integer(inode_holder) &&
json_is_integer(flags_holder))
{
ino_t inode = (ino_t) json_integer_value(inode_holder);
int flags = (ino_t) json_integer_value(flags_holder);
struct wfp_request * request = wfp_impl_request_create(context->request, id);
context->provider->open(request, inode, flags, context->user_data);
}
}
}
void wfp_impl_open_default(
struct wfp_request * request,
ino_t WF_UNUSED_PARAM(inode),
int WF_UNUSED_PARAM(flags),
void * WF_UNUSED_PARAM(user_data))
{
wfp_impl_respond_error(request, WF_BAD_NOENTRY);
}
void wfp_impl_respond_open(
struct wfp_request * request,
uint32_t handle)
{
json_t * result = json_object();
json_object_set_new(result, "handle", json_integer((int) handle));
wfp_impl_respond(request, result);
}

@ -1,30 +0,0 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_OPEN_H
#define WF_PROVIDER_IMPL_OPERATION_OPEN_H
#include "webfuse/provider/impl/provider.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern void wfp_impl_respond_open(
struct wfp_request * request,
uint32_t handle);
extern void wfp_impl_open(
struct wfp_impl_invokation_context * context,
json_t * params,
int id);
extern void wfp_impl_open_default(
struct wfp_request * request,
ino_t inode,
int flags,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,78 +0,0 @@
#include "webfuse/provider/impl/operation/read.h"
#include <stdlib.h>
#include "webfuse/provider/impl/operation/error.h"
#include "webfuse/provider/impl/request.h"
#include "webfuse/core/util.h"
#include "webfuse/core/base64.h"
void wfp_impl_read(
struct wfp_impl_invokation_context * context,
json_t * params,
int id)
{
size_t const count = json_array_size(params);
if (5 == count)
{
json_t * inode_holder = json_array_get(params, 1);
json_t * handle_holder = json_array_get(params, 2);
json_t * offset_holder = json_array_get(params, 3);
json_t * length_holder = json_array_get(params, 4);
if (json_is_integer(inode_holder) &&
json_is_integer(handle_holder) &&
json_is_integer(offset_holder) &&
json_is_integer(length_holder))
{
ino_t inode = (ino_t) json_integer_value(inode_holder);
int handle = json_integer_value(handle_holder);
size_t offset = json_integer_value(offset_holder);
size_t length = json_integer_value(length_holder);
struct wfp_request * request = wfp_impl_request_create(context->request, id);
context->provider->read(request, inode, handle, offset, length, context->user_data);
}
}
}
void wfp_impl_read_default(
struct wfp_request * request,
ino_t WF_UNUSED_PARAM(inode),
uint32_t WF_UNUSED_PARAM(handle),
size_t WF_UNUSED_PARAM(offset),
size_t WF_UNUSED_PARAM(length),
void * WF_UNUSED_PARAM(user_data))
{
wfp_impl_respond_error(request, WF_BAD_NOENTRY);
}
void wfp_impl_respond_read(
struct wfp_request * request,
char const * data,
size_t length)
{
if (0 < length)
{
size_t const size = wf_base64_encoded_size(length) + 1;
char * buffer = malloc(size);
wf_base64_encode((uint8_t const *) data, length, buffer, size);
json_t * result = json_object();
json_object_set_new(result, "data", json_string(buffer));
json_object_set_new(result, "format", json_string("base64"));
json_object_set_new(result, "count", json_integer((int) length));
wfp_impl_respond(request, result);
free(buffer);
}
else
{
json_t * result = json_object();
json_object_set_new(result, "data", json_string(""));
json_object_set_new(result, "format", json_string("identity"));
json_object_set_new(result, "count", json_integer(0));
wfp_impl_respond(request, result);
}
}

@ -1,33 +0,0 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_READ_H
#define WF_PROVIDER_IMPL_OPERATION_READ_H
#include "webfuse/provider/impl/provider.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern void wfp_impl_respond_read(
struct wfp_request * request,
char const * data,
size_t length);
extern void wfp_impl_read(
struct wfp_impl_invokation_context * context,
json_t * params,
int id);
extern void wfp_impl_read_default(
struct wfp_request * request,
ino_t inode,
uint32_t handle,
size_t offset,
size_t length,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save