Merge pull request #79 from falk-werner/remove_provider

Remove provider
pull/80/head
Falk Werner 4 years ago committed by GitHub
commit d2adf0cffb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,7 @@ webfuse combines libwebsockets and libfuse. It allows ot attach a remote filesys
- [Motivation](#Motivation)
- [Fellow Repositories](#Fellow-Repositories)
- [Known Implementations](#Known-Implementations)
- [Concept](#Concept)
- [Similar Projects](#Similar-Projects)
- [Further Documentation](#Further-Documentation)
@ -35,7 +36,16 @@ webfuse solves this problem by using the [WebSocket](https://en.wikipedia.org/wi
- **[webfuse-example](https://github.com/falk-werner/webfuse-example)**: Example of webfuse
- **[webfused](https://github.com/falk-werner/webfused)**: Reference implementation of webfuse daemon
- **[webfuse-provider](https://github.com/falk-werner/webfuse-provider)**: Reference implementation of webfuse provider
- **[webfuse-provider](https://github.com/falk-werner/webfuse-provider)**: webfuse provider library (C/C++)
- **[webfuse-js](https://github.com/falk-werner/webfuse-js)**: webfuse provider library (JavaScript))
## Known Implementations
| Implementation | Language | Adatper/Server | Adapter/Client | Provider/Server | Provider/Client |
| ------------------------------------------------------------------- | ---------- | ------------- | -------------- | --------------- | --------------- |
| [webfuse](https://github.com/falk-werner/webfuse) | C/C++ | ✔ | ✔ | - | - |
| [webfuse-provider](https://github.com/falk-werner/webfuse-provider) | C/C++ | - | - | - | ✔ |
| [webfuse-js](https://github.com/falk-werner/webfuse-js) | JavaScript | - | - | - | ✔ |
## Concept
@ -54,11 +64,10 @@ A reference implementation of such a daemon is provided within the examples. The
### Adapters and Providers
In webfuse, an adapter is a component that adapts the libfuse API to a websocket interface.
Currently, libwebfuse implements only a server based adapter - a websocket server, that allows clients to connect a remote file system which
is represented via libfuse on the server side.
Currently, libwebfuse provides both, server based and client based adapters.
In webfuse, a provider is a component that provides a filesystem via websocket interface.
Currently, libwebfuse implements only a client based provider - a websocket client that provides a local filesystem to a remote server.
Take a look at [known implementations](#Known-Implementations) to find provider libraries.
## Similar Projects

@ -6,6 +6,8 @@
* Remove CMake support (change build system to meson)
* Make argument credentials const in `wf_authenticate_fn`
* Moved provider library into [separate project](https://github.com/falk-werner/webfuse-provider)
* Renamed library (libwebfuse_adapter -> libwebfuse)
### New Features

@ -0,0 +1,13 @@
{
lws realloc
Helgrind:Race
fun:_realloc
fun:lws_realloc
}
{
lws zalloc
Helgrind:Race
fun:_realloc
fun:lws_zalloc
}

@ -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/impl/util/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

@ -1,18 +0,0 @@
#include "webfuse/core/lws_log.h"
#include <stdbool.h>
#include <libwebsockets.h>
#define WF_LWSLOG_DISABLE 0
static bool wf_lwslog_is_diabled = false;
void wf_lwslog_disable(void)
{
if (!wf_lwslog_is_diabled)
{
lws_set_log_level(WF_LWSLOG_DISABLE, NULL);
wf_lwslog_is_diabled = true;
}
}

@ -1,15 +0,0 @@
#ifndef WF_LWS_LOG_H
#define WF_LWS_LOG_H
#ifdef __cplusplus
extern "C"
{
#endif
extern void wf_lwslog_disable(void);
#ifdef __cplusplus
}
#endif
#endif

@ -1,17 +0,0 @@
#include "webfuse/core/message_queue.h"
#include "webfuse/core/message.h"
#include "webfuse/core/container_of.h"
void wf_message_queue_cleanup(
struct wf_slist * queue)
{
struct wf_slist_item * item = wf_slist_first(queue);
while (NULL != item)
{
struct wf_slist_item * next = item->next;
struct wf_message * message = wf_container_of(item, struct wf_message, item);
wf_message_dispose(message);
item = next;
}
wf_slist_init(queue);
}

@ -1,19 +0,0 @@
#ifndef WF_STATUS_INTERN_H
#define WF_STATUS_INTERN_H
#include "webfuse/core/status.h"
#ifdef __cplusplus
extern "C" {
#endif
extern int wf_status_to_rc(wf_status status);
extern char const * wf_status_tostring(wf_status status);
#ifdef __cplusplus
}
#endif
#endif

@ -1,31 +0,0 @@
#include "webfuse/core/timer/timepoint.h"
#include <time.h>
#define WF_TIMER_MSEC_PER_SEC ((wf_timer_timepoint) 1000)
#define WF_TIMER_NSEC_PER_MSEC ((wf_timer_timepoint) 1000 * 1000)
wf_timer_timepoint wf_timer_timepoint_now(void)
{
struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp);
wf_timer_timepoint const now = (tp.tv_sec * WF_TIMER_MSEC_PER_SEC) + (tp.tv_nsec / WF_TIMER_NSEC_PER_MSEC);
return now;
}
wf_timer_timepoint wf_timer_timepoint_in_msec(wf_timer_timediff value)
{
wf_timer_timepoint const now = wf_timer_timepoint_now();
wf_timer_timepoint result = now + ((wf_timer_timepoint) value);
return result;
}
bool wf_timer_timepoint_is_elapsed(wf_timer_timepoint tp)
{
wf_timer_timepoint const now = wf_timer_timepoint_now();
wf_timer_timediff const diff = (wf_timer_timediff) (tp - now);
return (0 > diff);
}

@ -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,7 +1,7 @@
#include "webfuse/adapter/impl/client.h"
#include "webfuse/adapter/impl/client_protocol.h"
#include "webfuse/adapter/impl/client_tlsconfig.h"
#include "webfuse/core/lws_log.h"
#include "webfuse/impl/client.h"
#include "webfuse/impl/client_protocol.h"
#include "webfuse/impl/client_tlsconfig.h"
#include "webfuse/impl/util/lws_log.h"
#include <libwebsockets.h>
@ -25,7 +25,7 @@ wf_impl_client_create(
wf_client_callback_fn * callback,
void * user_data)
{
wf_lwslog_disable();
wf_impl_lwslog_disable();
struct wf_client * client = malloc(sizeof(struct wf_client));
wf_impl_client_tlsconfig_init(&client->tls);

@ -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,18 +1,18 @@
#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/core/url.h"
#include "webfuse/core/util.h"
#include "webfuse/core/timer/manager.h"
#include "webfuse/core/jsonrpc/response.h"
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/message.h"
#include "webfuse/core/message_queue.h"
#include "webfuse/core/container_of.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/impl/util/url.h"
#include "webfuse/impl/util/util.h"
#include "webfuse/impl/timer/manager.h"
#include "webfuse/impl/jsonrpc/response.h"
#include "webfuse/impl/jsonrpc/proxy.h"
#include "webfuse/impl/message.h"
#include "webfuse/impl/message_queue.h"
#include "webfuse/impl/util/container_of.h"
#include <stddef.h>
@ -35,9 +35,9 @@ wf_impl_client_protocol_process(
json_t * message = json_loadb(data, length, 0, NULL);
if (NULL != message)
{
if (wf_jsonrpc_is_response(message))
if (wf_impl_jsonrpc_is_response(message))
{
wf_jsonrpc_proxy_onresult(protocol->proxy, message);
wf_impl_jsonrpc_proxy_onresult(protocol->proxy, message);
}
json_decref(message);
@ -54,10 +54,10 @@ wf_impl_client_protocol_send(
if (NULL != protocol->wsi)
{
struct wf_message * message = wf_message_create(request);
struct wf_message * message = wf_impl_message_create(request);
if (NULL != message)
{
wf_slist_append(&protocol->messages, &message->item);
wf_impl_slist_append(&protocol->messages, &message->item);
lws_callback_on_writable(protocol->wsi);
result = true;
}
@ -95,7 +95,7 @@ wf_impl_client_protocol_on_add_filesystem_finished(
if (json_is_string(id))
{
char const * name = json_string_value(id);
struct wf_mountpoint * mountpoint = wf_mountpoint_create(context->local_path);
struct wf_mountpoint * mountpoint = wf_impl_mountpoint_create(context->local_path);
protocol->filesystem = wf_impl_filesystem_create(protocol->wsi,protocol->proxy, name, mountpoint);
if (NULL != protocol->filesystem)
{
@ -103,7 +103,7 @@ wf_impl_client_protocol_on_add_filesystem_finished(
}
else
{
wf_mountpoint_dispose(mountpoint);
wf_impl_mountpoint_dispose(mountpoint);
}
}
}
@ -126,7 +126,7 @@ static int wf_impl_client_protocol_lws_callback(
if (NULL != protocol)
{
wf_timer_manager_check(protocol->timer_manager);
wf_impl_timer_manager_check(protocol->timer_manager);
switch (reason)
{
@ -156,14 +156,14 @@ static int wf_impl_client_protocol_lws_callback(
{
result = 1;
}
else if (!wf_slist_empty(&protocol->messages))
else if (!wf_impl_slist_empty(&protocol->messages))
{
struct wf_slist_item * item = wf_slist_remove_first(&protocol->messages);
struct wf_slist_item * item = wf_impl_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);
wf_impl_message_dispose(message);
if (!wf_slist_empty(&protocol->messages))
if (!wf_impl_slist_empty(&protocol->messages))
{
lws_callback_on_writable(wsi);
}
@ -196,9 +196,9 @@ wf_impl_client_protocol_init(
protocol->user_data = user_data;
protocol->filesystem = NULL;
wf_slist_init(&protocol->messages);
protocol->timer_manager = wf_timer_manager_create();
protocol->proxy = wf_jsonrpc_proxy_create(protocol->timer_manager, WF_DEFAULT_TIMEOUT, &wf_impl_client_protocol_send, protocol);
wf_impl_slist_init(&protocol->messages);
protocol->timer_manager = wf_impl_timer_manager_create();
protocol->proxy = wf_impl_jsonrpc_proxy_create(protocol->timer_manager, WF_DEFAULT_TIMEOUT, &wf_impl_client_protocol_send, protocol);
protocol->callback(protocol->user_data, WF_CLIENT_INIT, NULL);
}
@ -209,9 +209,9 @@ wf_impl_client_protocol_cleanup(
{
protocol->callback(protocol->user_data, WF_CLIENT_CLEANUP, NULL);
wf_jsonrpc_proxy_dispose(protocol->proxy);
wf_timer_manager_dispose(protocol->timer_manager);
wf_message_queue_cleanup(&protocol->messages);
wf_impl_jsonrpc_proxy_dispose(protocol->proxy);
wf_impl_timer_manager_dispose(protocol->timer_manager);
wf_impl_message_queue_cleanup(&protocol->messages);
if (NULL != protocol->filesystem)
{
@ -247,7 +247,7 @@ wf_impl_client_protocol_connect(
char const * url)
{
struct wf_url url_data;
bool const success = wf_url_init(&url_data, url);
bool const success = wf_impl_url_init(&url_data, url);
if (success)
{
struct lws_client_connect_info info;
@ -264,7 +264,7 @@ wf_impl_client_protocol_connect(
info.pwsi = &protocol->wsi;
lws_client_connect_via_info(&info);
wf_url_cleanup(&url_data);
wf_impl_url_cleanup(&url_data);
}
else
{
@ -297,7 +297,7 @@ wf_impl_client_protocol_authenticate(
protocol->callback(protocol->user_data, WF_CLIENT_AUTHENTICATE_GET_CREDENTIALS, &creds);
json_incref(creds.data);
wf_jsonrpc_proxy_invoke(
wf_impl_jsonrpc_proxy_invoke(
protocol->proxy,
&wf_impl_client_protocol_on_authenticate_finished,
protocol,
@ -320,7 +320,7 @@ wf_impl_client_protocol_add_filesystem(
context->protocol = protocol;
context->local_path = strdup(local_path);
wf_jsonrpc_proxy_invoke(
wf_impl_jsonrpc_proxy_invoke(
protocol->proxy,
&wf_impl_client_protocol_on_add_filesystem_finished,
context,

@ -1,8 +1,8 @@
#ifndef WF_ADAPTER_IMPL_CLIENT_PROTOCOL_H
#define WF_ADAPTER_IMPL_CLIENT_PROTOCOL_H
#include "webfuse/adapter/client_callback.h"
#include "webfuse/core/slist.h"
#include "webfuse/client_callback.h"
#include "webfuse/impl/util/slist.h"
#ifndef __cplusplus
#include <stdbool.h>

@ -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,9 +5,9 @@
#include <stdbool.h>
#endif
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include "webfuse/adapter/impl/operation/context.h"
#include "webfuse/core/slist.h"
#include "webfuse/impl/fuse_wrapper.h"
#include "webfuse/impl/operation/context.h"
#include "webfuse/impl/util/slist.h"
#ifdef __cplusplus
extern "C"

@ -1,7 +1,7 @@
#include "webfuse/core/jsonrpc/error.h"
#include "webfuse/impl/jsonrpc/error.h"
json_t *
wf_jsonrpc_error(
wf_impl_jsonrpc_error(
int code,
char const * message)
{
@ -13,13 +13,13 @@ wf_jsonrpc_error(
}
void
wf_jsonrpc_propate_error(
wf_impl_jsonrpc_propate_error(
wf_jsonrpc_proxy_finished_fn * finised,
void * user_data,
int code,
char const * message)
{
json_t * error = wf_jsonrpc_error(code, message);
json_t * error = wf_impl_jsonrpc_error(code, message);
finised(user_data, NULL, error);
json_decref(error);

@ -1,8 +1,8 @@
#ifndef WF_JSONRPC_ERROR_H
#define WF_JSONRPC_ERROR_H
#ifndef WF_IMPL_JSONRPC_ERROR_H
#define WF_IMPL_JSONRPC_ERROR_H
#include <jansson.h>
#include "webfuse/core/jsonrpc/proxy_finished_fn.h"
#include "webfuse/impl/jsonrpc/proxy_finished_fn.h"
#ifdef __cplusplus
extern "C"
@ -10,12 +10,12 @@ extern "C"
#endif
extern json_t *
wf_jsonrpc_error(
wf_impl_jsonrpc_error(
int code,
char const * message);
extern void
wf_jsonrpc_propate_error(
wf_impl_jsonrpc_propate_error(
wf_jsonrpc_proxy_finished_fn * finised,
void * user_data,
int code,

@ -1,8 +1,8 @@
#include "webfuse/core/jsonrpc/method.h"
#include "webfuse/impl/jsonrpc/method.h"
#include <stdlib.h>
#include <string.h>
struct wf_jsonrpc_method * wf_jsonrpc_method_create(
struct wf_jsonrpc_method * wf_impl_jsonrpc_method_create(
char const * method_name,
wf_jsonrpc_method_invoke_fn * invoke,
void * user_data)
@ -16,7 +16,7 @@ struct wf_jsonrpc_method * wf_jsonrpc_method_create(
return method;
}
void wf_jsonrpc_method_dispose(
void wf_impl_jsonrpc_method_dispose(
struct wf_jsonrpc_method * method)
{
free(method->name);

@ -1,7 +1,7 @@
#ifndef WF_JSONRPC_METHOD_H
#define WF_JSONRPC_METHOD_H
#ifndef WF_IMPL_JSONRPC_METHOD_H
#define WF_IMPL_JSONRPC_METHOD_H
#include "webfuse/core/jsonrpc/method_invoke_fn.h"
#include "webfuse/impl/jsonrpc/method_invoke_fn.h"
#ifdef __cplusplus
extern "C"
@ -17,13 +17,13 @@ struct wf_jsonrpc_method
};
extern struct wf_jsonrpc_method *
wf_jsonrpc_method_create(
wf_impl_jsonrpc_method_create(
char const * method_name,
wf_jsonrpc_method_invoke_fn * invoke,
void * user_data);
extern void
wf_jsonrpc_method_dispose(
wf_impl_jsonrpc_method_dispose(
struct wf_jsonrpc_method * method);
#ifdef __cplusplus

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_METHOD_INVOKE_FN_H
#define WF_JSONRPC_METHOD_INVOKE_FN_H
#ifndef WF_IMPL_JSONRPC_METHOD_INVOKE_FN_H
#define WF_IMPL_JSONRPC_METHOD_INVOKE_FN_H
#include <jansson.h>

@ -1,34 +1,34 @@
#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/impl/jsonrpc/proxy_intern.h"
#include "webfuse/impl/jsonrpc/response_intern.h"
#include "webfuse/impl/jsonrpc/error.h"
#include "webfuse/status.h"
#include "webfuse/core/timer/timer.h"
#include "webfuse/impl/timer/timer.h"
#include <stdlib.h>
#include <string.h>
struct wf_jsonrpc_proxy *
wf_jsonrpc_proxy_create(
wf_impl_jsonrpc_proxy_create(
struct wf_timer_manager * manager,
int timeout,
wf_jsonrpc_send_fn * send,
void * user_data)
{
struct wf_jsonrpc_proxy * proxy = malloc(sizeof(struct wf_jsonrpc_proxy));
wf_jsonrpc_proxy_init(proxy, manager, timeout, send, user_data);
wf_impl_jsonrpc_proxy_init(proxy, manager, timeout, send, user_data);
return proxy;
}
void wf_jsonrpc_proxy_dispose(
void wf_impl_jsonrpc_proxy_dispose(
struct wf_jsonrpc_proxy * proxy)
{
wf_jsonrpc_proxy_cleanup(proxy);
wf_impl_jsonrpc_proxy_cleanup(proxy);
free(proxy);
}
static void wf_jsonrpc_proxy_on_timeout(
static void wf_impl_jsonrpc_proxy_on_timeout(
struct wf_timer * timer, void * proxy_ptr)
{
struct wf_jsonrpc_proxy * proxy = proxy_ptr;
@ -42,13 +42,13 @@ static void wf_jsonrpc_proxy_on_timeout(
proxy->request.id = 0;
proxy->request.user_data = NULL;
proxy->request.finished = NULL;
wf_timer_cancel(timer);
wf_impl_timer_cancel(timer);
wf_jsonrpc_propate_error(finished, user_data, WF_BAD_TIMEOUT, "Timeout");
wf_impl_jsonrpc_propate_error(finished, user_data, WF_BAD_TIMEOUT, "Timeout");
}
}
static json_t * wf_jsonrpc_request_create(
static json_t * wf_impl_jsonrpc_request_create(
char const * method,
int id,
char const * param_info,
@ -98,7 +98,7 @@ static json_t * wf_jsonrpc_request_create(
return request;
}
void wf_jsonrpc_proxy_init(
void wf_impl_jsonrpc_proxy_init(
struct wf_jsonrpc_proxy * proxy,
struct wf_timer_manager * timeout_manager,
int timeout,
@ -109,11 +109,11 @@ void wf_jsonrpc_proxy_init(
proxy->timeout = timeout;
proxy->user_data = user_data;
proxy->request.is_pending = false;
proxy->request.timer = wf_timer_create(timeout_manager,
&wf_jsonrpc_proxy_on_timeout, proxy);
proxy->request.timer = wf_impl_timer_create(timeout_manager,
&wf_impl_jsonrpc_proxy_on_timeout, proxy);
}
void wf_jsonrpc_proxy_cleanup(
void wf_impl_jsonrpc_proxy_cleanup(
struct wf_jsonrpc_proxy * proxy)
{
if (proxy->request.is_pending)
@ -125,15 +125,15 @@ void wf_jsonrpc_proxy_cleanup(
proxy->request.finished = NULL;
proxy->request.user_data = NULL;
proxy->request.id = 0;
wf_timer_cancel(proxy->request.timer);
wf_impl_timer_cancel(proxy->request.timer);
wf_jsonrpc_propate_error(finished, user_data, WF_BAD, "Bad: cancelled pending request during shutdown");
wf_impl_jsonrpc_propate_error(finished, user_data, WF_BAD, "Bad: cancelled pending request during shutdown");
}
wf_timer_dispose(proxy->request.timer);
wf_impl_timer_dispose(proxy->request.timer);
}
void wf_jsonrpc_proxy_vinvoke(
void wf_impl_jsonrpc_proxy_vinvoke(
struct wf_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished,
void * user_data,
@ -147,9 +147,9 @@ void wf_jsonrpc_proxy_vinvoke(
proxy->request.finished = finished;
proxy->request.user_data = user_data;
proxy->request.id = 42;
wf_timer_start(proxy->request.timer, proxy->timeout);
wf_impl_timer_start(proxy->request.timer, proxy->timeout);
json_t * request = wf_jsonrpc_request_create(method_name, proxy->request.id, param_info, args);
json_t * request = wf_impl_jsonrpc_request_create(method_name, proxy->request.id, param_info, args);
bool const is_send = ((NULL != request) && (proxy->send(request, proxy->user_data)));
if (!is_send)
@ -158,9 +158,9 @@ void wf_jsonrpc_proxy_vinvoke(
proxy->request.finished = NULL;
proxy->request.user_data = NULL;
proxy->request.id = 0;
wf_timer_cancel(proxy->request.timer);
wf_impl_timer_cancel(proxy->request.timer);
wf_jsonrpc_propate_error(finished, user_data, WF_BAD, "Bad: requenst is not sent");
wf_impl_jsonrpc_propate_error(finished, user_data, WF_BAD, "Bad: requenst is not sent");
}
if (NULL != request)
@ -170,17 +170,17 @@ void wf_jsonrpc_proxy_vinvoke(
}
else
{
wf_jsonrpc_propate_error(finished, user_data, WF_BAD_BUSY, "Busy");
wf_impl_jsonrpc_propate_error(finished, user_data, WF_BAD_BUSY, "Busy");
}
}
extern void wf_jsonrpc_proxy_vnotify(
extern void wf_impl_jsonrpc_proxy_vnotify(
struct wf_jsonrpc_proxy * proxy,
char const * method_name,
char const * param_info,
va_list args)
{
json_t * request = wf_jsonrpc_request_create(method_name, 0, param_info, args);
json_t * request = wf_impl_jsonrpc_request_create(method_name, 0, param_info, args);
if (NULL != request)
{
@ -190,12 +190,12 @@ extern void wf_jsonrpc_proxy_vnotify(
}
void wf_jsonrpc_proxy_onresult(
void wf_impl_jsonrpc_proxy_onresult(
struct wf_jsonrpc_proxy * proxy,
json_t * message)
{
struct wf_jsonrpc_response response;
wf_jsonrpc_response_init(&response, message);
wf_impl_jsonrpc_response_init(&response, message);
if ((proxy->request.is_pending) && (response.id == proxy->request.id))
{
@ -206,11 +206,10 @@ void wf_jsonrpc_proxy_onresult(
proxy->request.id = 0;
proxy->request.user_data = NULL;
proxy->request.finished = NULL;
wf_timer_cancel(proxy->request.timer);
wf_impl_timer_cancel(proxy->request.timer);
finished(user_data, response.result, response.error);
}
wf_jsonrpc_response_cleanup(&response);
wf_impl_jsonrpc_response_cleanup(&response);
}

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_PROXY_H
#define WF_JSONRPC_PROXY_H
#ifndef WF_IMPL_JSONRPC_PROXY_H
#define WF_IMPL_JSONRPC_PROXY_H
#ifndef __cplusplus
#include <stdarg.h>
@ -12,8 +12,8 @@ using std::size_t;
#endif
#include <jansson.h>
#include "webfuse/core/jsonrpc/send_fn.h"
#include "webfuse/core/jsonrpc/proxy_finished_fn.h"
#include "webfuse/impl/jsonrpc/send_fn.h"
#include "webfuse/impl/jsonrpc/proxy_finished_fn.h"
#ifdef __cplusplus
extern "C" {
@ -23,13 +23,13 @@ struct wf_jsonrpc_proxy;
struct wf_timer_manager;
extern struct wf_jsonrpc_proxy *
wf_jsonrpc_proxy_create(
wf_impl_jsonrpc_proxy_create(
struct wf_timer_manager * manager,
int timeout,
wf_jsonrpc_send_fn * send,
void * user_data);
extern void wf_jsonrpc_proxy_dispose(
extern void wf_impl_jsonrpc_proxy_dispose(
struct wf_jsonrpc_proxy * proxy);
//------------------------------------------------------------------------------
@ -46,7 +46,7 @@ extern void wf_jsonrpc_proxy_dispose(
/// \param param_info types of the param (s = string, i = integer, j = json)
/// \param ... params
//------------------------------------------------------------------------------
extern void wf_jsonrpc_proxy_invoke(
extern void wf_impl_jsonrpc_proxy_invoke(
struct wf_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished,
void * user_data,
@ -55,14 +55,14 @@ extern void wf_jsonrpc_proxy_invoke(
...
);
extern void wf_jsonrpc_proxy_notify(
extern void wf_impl_jsonrpc_proxy_notify(
struct wf_jsonrpc_proxy * proxy,
char const * method_name,
char const * param_info,
...
);
extern void wf_jsonrpc_proxy_onresult(
extern void wf_impl_jsonrpc_proxy_onresult(
struct wf_jsonrpc_proxy * proxy,
json_t * message);

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_PROXY_FINISHED_FN_H
#define WF_JSONRPC_PROXY_FINISHED_FN_H
#ifndef WF_IMPL_JSONRPC_PROXY_FINISHED_FN_H
#define WF_IMPL_JSONRPC_PROXY_FINISHED_FN_H
#include <jansson.h>

@ -1,9 +1,9 @@
#ifndef WF_JSONRPC_PROXY_INTERN_H
#define WF_JSONRPC_PROXY_INTERN_H
#ifndef WF_IMPL_JSONRPC_PROXY_INTERN_H
#define WF_IMPL_JSONRPC_PROXY_INTERN_H
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/jsonrpc/proxy_finished_fn.h"
#include "webfuse/core/jsonrpc/send_fn.h"
#include "webfuse/impl/jsonrpc/proxy.h"
#include "webfuse/impl/jsonrpc/proxy_finished_fn.h"
#include "webfuse/impl/jsonrpc/send_fn.h"
#ifdef __cplusplus
extern "C"
@ -30,7 +30,7 @@ struct wf_jsonrpc_proxy
};
extern void
wf_jsonrpc_proxy_init(
wf_impl_jsonrpc_proxy_init(
struct wf_jsonrpc_proxy * proxy,
struct wf_timer_manager * manager,
int timeout,
@ -38,10 +38,10 @@ wf_jsonrpc_proxy_init(
void * user_data);
extern void
wf_jsonrpc_proxy_cleanup(
wf_impl_jsonrpc_proxy_cleanup(
struct wf_jsonrpc_proxy * proxy);
extern void wf_jsonrpc_proxy_vinvoke(
extern void wf_impl_jsonrpc_proxy_vinvoke(
struct wf_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished,
void * user_data,
@ -49,7 +49,7 @@ extern void wf_jsonrpc_proxy_vinvoke(
char const * param_info,
va_list args);
extern void wf_jsonrpc_proxy_vnotify(
extern void wf_impl_jsonrpc_proxy_vnotify(
struct wf_jsonrpc_proxy * proxy,
char const * method_name,
char const * param_info,

@ -1,6 +1,6 @@
#include "webfuse/core/jsonrpc/proxy_intern.h"
#include "webfuse/impl/jsonrpc/proxy_intern.h"
void wf_jsonrpc_proxy_invoke(
void wf_impl_jsonrpc_proxy_invoke(
struct wf_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished,
void * user_data,
@ -10,11 +10,11 @@ void wf_jsonrpc_proxy_invoke(
{
va_list args;
va_start(args, param_info);
wf_jsonrpc_proxy_vinvoke(proxy, finished, user_data, method_name, param_info, args);
wf_impl_jsonrpc_proxy_vinvoke(proxy, finished, user_data, method_name, param_info, args);
va_end(args);
}
extern void wf_jsonrpc_proxy_notify(
extern void wf_impl_jsonrpc_proxy_notify(
struct wf_jsonrpc_proxy * proxy,
char const * method_name,
char const * param_info,
@ -23,6 +23,6 @@ extern void wf_jsonrpc_proxy_notify(
{
va_list args;
va_start(args, param_info);
wf_jsonrpc_proxy_vnotify(proxy, method_name, param_info, args);
wf_impl_jsonrpc_proxy_vnotify(proxy, method_name, param_info, args);
va_end(args);
}

@ -1,5 +1,5 @@
#include "webfuse/core/jsonrpc/request.h"
#include "webfuse/core/jsonrpc/error.h"
#include "webfuse/impl/jsonrpc/request.h"
#include "webfuse/impl/jsonrpc/error.h"
#include <stdlib.h>
struct wf_jsonrpc_request
@ -10,7 +10,7 @@ struct wf_jsonrpc_request
};
bool
wf_jsonrpc_is_request(
wf_impl_jsonrpc_is_request(
json_t * message)
{
json_t * id = json_object_get(message, "id");
@ -23,7 +23,7 @@ wf_jsonrpc_is_request(
struct wf_jsonrpc_request *
wf_jsonrpc_request_create(
wf_impl_jsonrpc_request_create(
int id,
wf_jsonrpc_send_fn * send,
void * user_data)
@ -37,14 +37,14 @@ wf_jsonrpc_request_create(
}
void
wf_jsonrpc_request_dispose(
wf_impl_jsonrpc_request_dispose(
struct wf_jsonrpc_request * request)
{
free(request);
}
void *
wf_jsonrpc_request_get_userdata(
wf_impl_jsonrpc_request_get_userdata(
struct wf_jsonrpc_request * request)
{
return request->user_data;
@ -52,7 +52,7 @@ wf_jsonrpc_request_get_userdata(
void
wf_jsonrpc_respond(
wf_impl_jsonrpc_respond(
struct wf_jsonrpc_request * request,
json_t * result)
{
@ -62,20 +62,19 @@ wf_jsonrpc_respond(
request->send(response, request->user_data);
json_decref(response);
wf_jsonrpc_request_dispose(request);
wf_impl_jsonrpc_request_dispose(request);
}
void wf_jsonrpc_respond_error(
void wf_impl_jsonrpc_respond_error(
struct wf_jsonrpc_request * request,
int code,
char const * message)
{
json_t * response = json_object();
json_object_set_new(response, "error", wf_jsonrpc_error(code, message));
json_object_set_new(response, "error", wf_impl_jsonrpc_error(code, message));
json_object_set_new(response, "id", json_integer(request->id));
request->send(response, request->user_data);
json_decref(response);
wf_jsonrpc_request_dispose(request);
wf_impl_jsonrpc_request_dispose(request);
}

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_REQUEST_H
#define WF_JSONRPC_REQUEST_H
#ifndef WF_IMPL_JSONRPC_REQUEST_H
#define WF_IMPL_JSONRPC_REQUEST_H
#ifndef __cplusplus
#include <stdarg.h>
@ -12,7 +12,7 @@ using std::size_t;
#endif
#include <jansson.h>
#include "webfuse/core/jsonrpc/send_fn.h"
#include "webfuse/impl/jsonrpc/send_fn.h"
#ifdef __cplusplus
extern "C"
@ -21,26 +21,26 @@ extern "C"
struct wf_jsonrpc_request;
extern bool wf_jsonrpc_is_request(
extern bool wf_impl_jsonrpc_is_request(
json_t * message);
extern struct wf_jsonrpc_request *
wf_jsonrpc_request_create(
wf_impl_jsonrpc_request_create(
int id,
wf_jsonrpc_send_fn * send,
void * user_data);
extern void wf_jsonrpc_request_dispose(
extern void wf_impl_jsonrpc_request_dispose(
struct wf_jsonrpc_request * request);
extern void * wf_jsonrpc_request_get_userdata(
extern void * wf_impl_jsonrpc_request_get_userdata(
struct wf_jsonrpc_request * request);
extern void wf_jsonrpc_respond(
extern void wf_impl_jsonrpc_respond(
struct wf_jsonrpc_request * request,
json_t * result);
extern void wf_jsonrpc_respond_error(
extern void wf_impl_jsonrpc_respond_error(
struct wf_jsonrpc_request * request,
int code,
char const * message);

@ -1,9 +1,9 @@
#include "webfuse/core/jsonrpc/response_intern.h"
#include "webfuse/core/jsonrpc/error.h"
#include "webfuse/core/status.h"
#include "webfuse/impl/jsonrpc/response_intern.h"
#include "webfuse/impl/jsonrpc/error.h"
#include "webfuse/status.h"
bool
wf_jsonrpc_is_response(
wf_impl_jsonrpc_is_response(
json_t * message)
{
json_t * id = json_object_get(message, "id");
@ -16,7 +16,7 @@ wf_jsonrpc_is_response(
void
wf_jsonrpc_response_init(
wf_impl_jsonrpc_response_init(
struct wf_jsonrpc_response * result,
json_t * response)
{
@ -27,7 +27,7 @@ wf_jsonrpc_response_init(
json_t * id_holder = json_object_get(response, "id");
if (!json_is_integer(id_holder))
{
result->error = wf_jsonrpc_error(WF_BAD_FORMAT, "invalid format: missing id");
result->error = wf_impl_jsonrpc_error(WF_BAD_FORMAT, "invalid format: missing id");
return;
}
@ -47,13 +47,13 @@ wf_jsonrpc_response_init(
}
else
{
result->error = wf_jsonrpc_error(WF_BAD_FORMAT, "invalid format: invalid error object");
result->error = wf_impl_jsonrpc_error(WF_BAD_FORMAT, "invalid format: invalid error object");
}
}
}
void
wf_jsonrpc_response_cleanup(
wf_impl_jsonrpc_response_cleanup(
struct wf_jsonrpc_response * response)
{
if (NULL != response->result)

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_RESPONSE_H
#define WF_JSONRPC_RESPONSE_H
#ifndef WF_IMPL_JSONRPC_RESPONSE_H
#define WF_IMPL_JSONRPC_RESPONSE_H
#ifndef __cplusplus
#include <stdbool.h>
@ -12,7 +12,7 @@ extern "C"
{
#endif
extern bool wf_jsonrpc_is_response(
extern bool wf_impl_jsonrpc_is_response(
json_t * message);
#ifdef __cplusplus

@ -1,7 +1,7 @@
#ifndef WF_JSONRPC_RESPONSE_INTERN_H
#define WF_JSONRPC_RESPONSE_INTERN_H
#ifndef WF_IMPL_JSONRPC_RESPONSE_INTERN_H
#define WF_IMPL_JSONRPC_RESPONSE_INTERN_H
#include "webfuse/core/jsonrpc/response.h"
#include "webfuse/impl/jsonrpc/response.h"
#ifndef __cplusplus
#include <stddef.h>
@ -21,11 +21,11 @@ struct wf_jsonrpc_response
int id;
};
extern void wf_jsonrpc_response_init(
extern void wf_impl_jsonrpc_response_init(
struct wf_jsonrpc_response * response,
json_t * message);
extern void wf_jsonrpc_response_cleanup(
extern void wf_impl_jsonrpc_response_cleanup(
struct wf_jsonrpc_response * response);
#ifdef __cplusplus

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_SEND_FN_H
#define WF_JSONRPC_SEND_FN_H
#ifndef WF_IMPL_JSONRPC_SEND_FN_H
#define WF_IMPL_JSONRPC_SEND_FN_H
#ifndef __cplusplus
#include <stdbool.h>

@ -1,8 +1,8 @@
#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/core/util.h"
#include "webfuse/impl/jsonrpc/server.h"
#include "webfuse/impl/jsonrpc/method.h"
#include "webfuse/impl/jsonrpc/request.h"
#include "webfuse/status.h"
#include "webfuse/impl/util/util.h"
#include <stdlib.h>
#include <string.h>
@ -13,79 +13,79 @@ struct wf_jsonrpc_server
};
static void
wf_jsonrpc_server_init(
wf_impl_jsonrpc_server_init(
struct wf_jsonrpc_server * server);
static void
wf_jsonrpc_server_cleanup(
wf_impl_jsonrpc_server_cleanup(
struct wf_jsonrpc_server * server);
struct wf_jsonrpc_server *
wf_jsonrpc_server_create(void)
wf_impl_jsonrpc_server_create(void)
{
struct wf_jsonrpc_server * server = malloc(sizeof(struct wf_jsonrpc_server));
wf_jsonrpc_server_init(server);
wf_impl_jsonrpc_server_init(server);
return server;
}
void
wf_jsonrpc_server_dispose(
wf_impl_jsonrpc_server_dispose(
struct wf_jsonrpc_server * server)
{
wf_jsonrpc_server_cleanup(server);
wf_impl_jsonrpc_server_cleanup(server);
free(server);
}
static void wf_jsonrpc_server_init(
static void wf_impl_jsonrpc_server_init(
struct wf_jsonrpc_server * server)
{
server->methods = NULL;
}
static void wf_jsonrpc_server_cleanup(
static void wf_impl_jsonrpc_server_cleanup(
struct wf_jsonrpc_server * server)
{
struct wf_jsonrpc_method * current = server->methods;
while (NULL != current)
{
struct wf_jsonrpc_method * next = current->next;
wf_jsonrpc_method_dispose(current);
wf_impl_jsonrpc_method_dispose(current);
current = next;
}
server->methods = NULL;
}
void wf_jsonrpc_server_add(
void wf_impl_jsonrpc_server_add(
struct wf_jsonrpc_server * server,
char const * method_name,
wf_jsonrpc_method_invoke_fn * invoke,
void * user_data)
{
struct wf_jsonrpc_method * method = wf_jsonrpc_method_create(method_name, invoke, user_data);
struct wf_jsonrpc_method * method = wf_impl_jsonrpc_method_create(method_name, invoke, user_data);
method->next = server->methods;
server->methods = method;
}
static void wf_jsonrpc_server_invalid_method_invoke(
static void wf_impl_jsonrpc_server_invalid_method_invoke(
struct wf_jsonrpc_request * request,
char const * WF_UNUSED_PARAM(method_name),
json_t * WF_UNUSED_PARAM(params),
void * WF_UNUSED_PARAM(user_data))
{
wf_jsonrpc_respond_error(request, WF_BAD_NOTIMPLEMENTED, "not implemented");
wf_impl_jsonrpc_respond_error(request, WF_BAD_NOTIMPLEMENTED, "not implemented");
}
static struct wf_jsonrpc_method const wf_jsonrpc_server_invalid_method =
static struct wf_jsonrpc_method const wf_impl_jsonrpc_server_invalid_method =
{
.next = NULL,
.name = "<invalid>",
.invoke = &wf_jsonrpc_server_invalid_method_invoke,
.invoke = &wf_impl_jsonrpc_server_invalid_method_invoke,
.user_data = NULL
};
static struct wf_jsonrpc_method const *
wf_jsonrpc_server_get_method(
wf_impl_jsonrpc_server_get_method(
struct wf_jsonrpc_server * server,
char const * method_name)
{
@ -100,10 +100,10 @@ wf_jsonrpc_server_get_method(
current = current->next;
}
return &wf_jsonrpc_server_invalid_method;
return &wf_impl_jsonrpc_server_invalid_method;
}
void wf_jsonrpc_server_process(
void wf_impl_jsonrpc_server_process(
struct wf_jsonrpc_server * server,
json_t * request_data,
wf_jsonrpc_send_fn * send,
@ -119,8 +119,8 @@ void wf_jsonrpc_server_process(
{
char const * method_name = json_string_value(method_holder);
int id = json_integer_value(id_holder);
struct wf_jsonrpc_request * request = wf_jsonrpc_request_create(id, send, user_data);
struct wf_jsonrpc_method const * method = wf_jsonrpc_server_get_method(server, method_name);
struct wf_jsonrpc_request * request = wf_impl_jsonrpc_request_create(id, send, user_data);
struct wf_jsonrpc_method const * method = wf_impl_jsonrpc_server_get_method(server, method_name);
method->invoke(request, method_name, params, method->user_data);
}

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_SERVER_H
#define WF_JSONRPC_SERVER_H
#ifndef WF_IMPL_JSONRPC_SERVER_H
#define WF_IMPL_JSONRPC_SERVER_H
#ifndef __cplusplus
#include <stdarg.h>
@ -9,8 +9,8 @@
#endif
#include <jansson.h>
#include "webfuse/core/jsonrpc/method_invoke_fn.h"
#include "webfuse/core/jsonrpc/send_fn.h"
#include "webfuse/impl/jsonrpc/method_invoke_fn.h"
#include "webfuse/impl/jsonrpc/send_fn.h"
#ifdef __cplusplus
extern "C"
@ -20,19 +20,19 @@ extern "C"
struct wf_jsonrpc_server;
extern struct wf_jsonrpc_server *
wf_jsonrpc_server_create(void);
wf_impl_jsonrpc_server_create(void);
extern void
wf_jsonrpc_server_dispose(
wf_impl_jsonrpc_server_dispose(
struct wf_jsonrpc_server * server);
extern void wf_jsonrpc_server_add(
extern void wf_impl_jsonrpc_server_add(
struct wf_jsonrpc_server * server,
char const * method_name,
wf_jsonrpc_method_invoke_fn * invoke,
void * user_data);
extern void wf_jsonrpc_server_process(
extern void wf_impl_jsonrpc_server_process(
struct wf_jsonrpc_server * server,
json_t * request,
wf_jsonrpc_send_fn * send,

@ -1,9 +1,9 @@
#include "webfuse/core/message.h"
#include "webfuse/impl/message.h"
#include <stdlib.h>
#include <libwebsockets.h>
extern struct wf_message * wf_message_create(json_t const * value)
extern struct wf_message * wf_impl_message_create(json_t const * value)
{
struct wf_message * message = NULL;
size_t const length = json_dumpb(value, NULL, 0, JSON_COMPACT);
@ -21,7 +21,7 @@ extern struct wf_message * wf_message_create(json_t const * value)
return message;
}
void wf_message_dispose(
void wf_impl_message_dispose(
struct wf_message * message)
{
free(message);

@ -1,5 +1,5 @@
#ifndef WF_MESSAGE_H
#define WF_MESSAGE_H
#ifndef WF_IMPL_MESSAGE_H
#define WF_IMPL_MESSAGE_H
#ifndef __cplusplus
#include <stddef.h>
@ -9,7 +9,7 @@ using std::size_t;
#endif
#include <jansson.h>
#include "webfuse/core/slist.h"
#include "webfuse/impl/util/slist.h"
struct wf_message
{
@ -23,10 +23,10 @@ extern "C"
{
#endif
extern struct wf_message * wf_message_create(
extern struct wf_message * wf_impl_message_create(
json_t const * value);
extern void wf_message_dispose(
extern void wf_impl_message_dispose(
struct wf_message * message);
#ifdef __cplusplus

@ -0,0 +1,17 @@
#include "webfuse/impl/message_queue.h"
#include "webfuse/impl/message.h"
#include "webfuse/impl/util/container_of.h"
void wf_impl_message_queue_cleanup(
struct wf_slist * queue)
{
struct wf_slist_item * item = wf_impl_slist_first(queue);
while (NULL != item)
{
struct wf_slist_item * next = item->next;
struct wf_message * message = wf_container_of(item, struct wf_message, item);
wf_impl_message_dispose(message);
item = next;
}
wf_impl_slist_init(queue);
}

@ -1,5 +1,5 @@
#ifndef WF_MESSAGE_QUEUE_H
#define WF_MESSAGE_QUEUE_H
#ifndef WF_IMPL_MESSAGE_QUEUE_H
#define WF_IMPL_MESSAGE_QUEUE_H
#ifdef __cplusplus
extern "C"
@ -8,7 +8,7 @@ extern "C"
struct wf_slist;
extern void wf_message_queue_cleanup(
extern void wf_impl_message_queue_cleanup(
struct wf_slist * queue);

@ -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,12 +1,11 @@
#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>
#include <jansson.h>
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/util.h"
#include "webfuse/impl/jsonrpc/proxy.h"
void wf_impl_operation_close(
fuse_req_t request,
@ -19,7 +18,7 @@ void wf_impl_operation_close(
if (NULL != rpc)
{
int handle = (int) (file_info->fh & INT_MAX);
wf_jsonrpc_proxy_notify(rpc, "close", "siii", user_data->name, inode, handle, file_info->flags);
wf_impl_jsonrpc_proxy_notify(rpc, "close", "siii", user_data->name, inode, handle, file_info->flags);
}
fuse_reply_err(request, 0);

@ -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>
@ -8,9 +8,9 @@
#include <sys/stat.h>
#include <unistd.h>
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/json_util.h"
#include "webfuse/core/util.h"
#include "webfuse/impl/jsonrpc/proxy.h"
#include "webfuse/impl/util/json_util.h"
#include "webfuse/impl/util/util.h"
void wf_impl_operation_getattr_finished(
void * user_data,
@ -85,7 +85,7 @@ void wf_impl_operation_getattr (
getattr_context->gid = context->gid;
getattr_context->timeout = user_data->timeout;
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_getattr_finished, getattr_context, "getattr", "si", user_data->name, inode);
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_getattr_finished, getattr_context, "getattr", "si", user_data->name, inode);
}
else
{

@ -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>
@ -11,9 +11,9 @@
#include <stdlib.h>
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/json_util.h"
#include "webfuse/core/util.h"
#include "webfuse/impl/jsonrpc/proxy.h"
#include "webfuse/impl/util/json_util.h"
#include "webfuse/impl/util/util.h"
void wf_impl_operation_lookup_finished(
void * user_data,
@ -95,7 +95,7 @@ void wf_impl_operation_lookup (
lookup_context->gid = context->gid;
lookup_context->timeout = user_data->timeout;
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_lookup_finished, lookup_context, "lookup", "sis", user_data->name, (int) (parent & INT_MAX), name);
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_lookup_finished, lookup_context, "lookup", "sis", user_data->name, (int) (parent & INT_MAX), name);
}
else
{

@ -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,10 +1,10 @@
#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/core/json_util.h"
#include "webfuse/impl/jsonrpc/proxy.h"
#include "webfuse/impl/util/util.h"
#include "webfuse/status.h"
#include "webfuse/impl/util/json_util.h"
#include <string.h>
#include <errno.h>
@ -53,7 +53,7 @@ void wf_impl_operation_open(
if (NULL != rpc)
{
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_open_finished, request, "open", "sii", user_data->name, inode, file_info->flags);
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_open_finished, request, "open", "sii", user_data->name, inode, file_info->flags);
}
else
{

@ -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,14 +1,14 @@
#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>
#include <limits.h>
#include <jansson.h>
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/base64.h"
#include "webfuse/core/json_util.h"
#include "webfuse/impl/jsonrpc/proxy.h"
#include "webfuse/impl/util/base64.h"
#include "webfuse/impl/util/json_util.h"
#define WF_MAX_READ_LENGTH 4096
@ -37,7 +37,7 @@ char * wf_impl_fill_buffer(
}
else if (0 == strcmp("base64", format))
{
size_t result = wf_base64_decode(data, data_size, (uint8_t *) buffer, count);
size_t result = wf_impl_base64_decode(data, data_size, (uint8_t *) buffer, count);
if (result != count)
{
*status = WF_BAD;
@ -118,7 +118,7 @@ void wf_impl_operation_read(
{
int const length = (size <= WF_MAX_READ_LENGTH) ? (int) size : WF_MAX_READ_LENGTH;
int handle = (file_info->fh & INT_MAX);
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_read_finished, request, "read", "siiii", user_data->name, (int) inode, handle, (int) offset, length);
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_read_finished, request, "read", "siiii", user_data->name, (int) inode, handle, (int) offset, length);
}
else
{

@ -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>
@ -9,9 +9,9 @@
#include <sys/stat.h>
#include <unistd.h>
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/util.h"
#include "webfuse/core/json_util.h"
#include "webfuse/impl/jsonrpc/proxy.h"
#include "webfuse/impl/util/util.h"
#include "webfuse/impl/util/json_util.h"
#define WF_DIRBUFFER_INITIAL_SIZE 1024
@ -151,7 +151,7 @@ void wf_impl_operation_readdir (
readdir_context->size = size;
readdir_context->offset = offset;
wf_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_readdir_finished, readdir_context, "readdir", "si", user_data->name, inode);
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_readdir_finished, readdir_context, "readdir", "si", user_data->name, inode);
}
else
{

@ -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,9 +8,9 @@
#include <sys/stat.h>
#include <unistd.h>
#include "webfuse/adapter/impl/server_config.h"
#include "webfuse/adapter/impl/server_protocol.h"
#include "webfuse/core/lws_log.h"
#include "webfuse/impl/server_config.h"
#include "webfuse/impl/server_protocol.h"
#include "webfuse/impl/util/lws_log.h"
#define WF_SERVER_PROTOCOL_COUNT 3
@ -34,7 +34,7 @@ static bool wf_impl_server_tls_enabled(
static struct lws_context * wf_impl_server_context_create(
struct wf_server * server)
{
wf_lwslog_disable();
wf_impl_lwslog_disable();
memset(server->ws_protocols, 0, sizeof(struct lws_protocols) * WF_SERVER_PROTOCOL_COUNT);
server->ws_protocols[0].name = "http";

@ -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,19 +1,19 @@
#include "webfuse/adapter/impl/server_protocol.h"
#include "webfuse/impl/server_protocol.h"
#include <stdlib.h>
#include <ctype.h>
#include <libwebsockets.h>
#include "webfuse/core/message.h"
#include "webfuse/core/util.h"
#include "webfuse/core/protocol_names.h"
#include "webfuse/impl/message.h"
#include "webfuse/impl/util/util.h"
#include "webfuse/protocol_names.h"
#include "webfuse/adapter/impl/credentials.h"
#include "webfuse/core/status_intern.h"
#include "webfuse/impl/credentials.h"
#include "webfuse/impl/status.h"
#include "webfuse/core/jsonrpc/request.h"
#include "webfuse/core/timer/manager.h"
#include "webfuse/core/timer/timer.h"
#include "webfuse/impl/jsonrpc/request.h"
#include "webfuse/impl/timer/manager.h"
#include "webfuse/impl/timer/timer.h"
static int wf_impl_server_protocol_callback(
struct lws * wsi,
@ -27,7 +27,7 @@ static int wf_impl_server_protocol_callback(
if (ws_protocol->callback != &wf_impl_server_protocol_callback) { return 0; }
struct wf_server_protocol * protocol = ws_protocol->user;
wf_timer_manager_check(protocol->timer_manager);
wf_impl_timer_manager_check(protocol->timer_manager);
struct wf_impl_session * session = wf_impl_session_manager_get(&protocol->session_manager, wsi);
switch (reason)
@ -127,7 +127,7 @@ static void wf_impl_server_protocol_authenticate(
struct wf_credentials creds;
wf_impl_credentials_init(&creds, type, creds_holder);
struct wf_impl_session * session = wf_jsonrpc_request_get_userdata(request);
struct wf_impl_session * session = wf_impl_jsonrpc_request_get_userdata(request);
result = wf_impl_session_authenticate(session, &creds);
wf_impl_credentials_cleanup(&creds);
@ -137,11 +137,11 @@ static void wf_impl_server_protocol_authenticate(
if (result)
{
json_t * result = json_object();
wf_jsonrpc_respond(request, result);
wf_impl_jsonrpc_respond(request, result);
}
else
{
wf_jsonrpc_respond_error(request, WF_BAD_ACCESS_DENIED, wf_status_tostring(WF_BAD_ACCESS_DENIED));
wf_impl_jsonrpc_respond_error(request, WF_BAD_ACCESS_DENIED, wf_impl_status_tostring(WF_BAD_ACCESS_DENIED));
}
}
@ -166,7 +166,7 @@ static void wf_impl_server_protocol_add_filesystem(
json_t * params,
void * WF_UNUSED_PARAM(user_data))
{
struct wf_impl_session * session = wf_jsonrpc_request_get_userdata(request);
struct wf_impl_session * session = wf_impl_jsonrpc_request_get_userdata(request);
wf_status status = (session->is_authenticated) ? WF_GOOD : WF_BAD_ACCESS_DENIED;
char const * name = NULL;
@ -200,11 +200,11 @@ static void wf_impl_server_protocol_add_filesystem(
{
json_t * result = json_object();
json_object_set_new(result, "id", json_string(name));
wf_jsonrpc_respond(request, result);
wf_impl_jsonrpc_respond(request, result);
}
else
{
wf_jsonrpc_respond_error(request, status, wf_status_tostring(status));
wf_impl_jsonrpc_respond_error(request, status, wf_impl_status_tostring(status));
}
@ -218,13 +218,13 @@ void wf_impl_server_protocol_init(
wf_impl_mountpoint_factory_clone(mountpoint_factory, &protocol->mountpoint_factory);
protocol->timer_manager = wf_timer_manager_create();
protocol->timer_manager = wf_impl_timer_manager_create();
wf_impl_session_manager_init(&protocol->session_manager);
wf_impl_authenticators_init(&protocol->authenticators);
protocol->server = wf_jsonrpc_server_create();
wf_jsonrpc_server_add(protocol->server, "authenticate", &wf_impl_server_protocol_authenticate, protocol);
wf_jsonrpc_server_add(protocol->server, "add_filesystem", &wf_impl_server_protocol_add_filesystem, protocol);
protocol->server = wf_impl_jsonrpc_server_create();
wf_impl_jsonrpc_server_add(protocol->server, "authenticate", &wf_impl_server_protocol_authenticate, protocol);
wf_impl_jsonrpc_server_add(protocol->server, "add_filesystem", &wf_impl_server_protocol_add_filesystem, protocol);
}
void wf_impl_server_protocol_cleanup(
@ -232,8 +232,8 @@ void wf_impl_server_protocol_cleanup(
{
protocol->is_operational = false;
wf_jsonrpc_server_dispose(protocol->server);
wf_timer_manager_dispose(protocol->timer_manager);
wf_impl_jsonrpc_server_dispose(protocol->server);
wf_impl_timer_manager_dispose(protocol->timer_manager);
wf_impl_authenticators_cleanup(&protocol->authenticators);
wf_impl_session_manager_cleanup(&protocol->session_manager);
wf_impl_mountpoint_factory_cleanup(&protocol->mountpoint_factory);

@ -1,11 +1,11 @@
#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/core/jsonrpc/proxy.h"
#include "webfuse/core/jsonrpc/server.h"
#include "webfuse/impl/authenticators.h"
#include "webfuse/impl/mountpoint_factory.h"
#include "webfuse/impl/session_manager.h"
#include "webfuse/impl/jsonrpc/proxy.h"
#include "webfuse/impl/jsonrpc/server.h"
#ifndef __cplusplus
#include <stdbool.h>

@ -1,16 +1,16 @@
#include "webfuse/adapter/impl/session.h"
#include "webfuse/adapter/impl/authenticators.h"
#include "webfuse/core/message_queue.h"
#include "webfuse/core/message.h"
#include "webfuse/adapter/impl/mountpoint_factory.h"
#include "webfuse/adapter/impl/mountpoint.h"
#include "webfuse/impl/session.h"
#include "webfuse/impl/authenticators.h"
#include "webfuse/impl/message_queue.h"
#include "webfuse/impl/message.h"
#include "webfuse/impl/mountpoint_factory.h"
#include "webfuse/impl/mountpoint.h"
#include "webfuse/core/container_of.h"
#include "webfuse/core/util.h"
#include "webfuse/impl/util/container_of.h"
#include "webfuse/impl/util/util.h"
#include "webfuse/core/jsonrpc/proxy.h"
#include "webfuse/core/jsonrpc/request.h"
#include "webfuse/core/jsonrpc/response.h"
#include "webfuse/impl/jsonrpc/proxy.h"
#include "webfuse/impl/jsonrpc/request.h"
#include "webfuse/impl/jsonrpc/response.h"
#include <libwebsockets.h>
#include <stddef.h>
@ -23,20 +23,20 @@ static bool wf_impl_session_send(
void * user_data)
{
struct wf_impl_session * session = user_data;
struct wf_message * message = wf_message_create(request);
struct wf_message * message = wf_impl_message_create(request);
bool result = (session->is_authenticated || wf_jsonrpc_is_response(request)) && (NULL != session->wsi);
bool result = (session->is_authenticated || wf_impl_jsonrpc_is_response(request)) && (NULL != session->wsi);
if (result)
{
wf_slist_append(&session->messages, &message->item);
wf_impl_slist_append(&session->messages, &message->item);
lws_callback_on_writable(session->wsi);
result = true;
}
else
{
wf_message_dispose(message);
wf_impl_message_dispose(message);
}
return result;
@ -51,15 +51,15 @@ struct wf_impl_session * wf_impl_session_create(
{
struct wf_impl_session * session = malloc(sizeof(struct wf_impl_session));
wf_slist_init(&session->filesystems);
wf_impl_slist_init(&session->filesystems);
session->wsi = wsi;
session->is_authenticated = false;
session->authenticators = authenticators;
session->server = server;
session->mountpoint_factory = mountpoint_factory;
session->rpc = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &wf_impl_session_send, session);
wf_slist_init(&session->messages);
session->rpc = wf_impl_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &wf_impl_session_send, session);
wf_impl_slist_init(&session->messages);
return session;
}
@ -67,7 +67,7 @@ struct wf_impl_session * wf_impl_session_create(
static void wf_impl_session_dispose_filesystems(
struct wf_slist * filesystems)
{
struct wf_slist_item * item = wf_slist_first(filesystems);
struct wf_slist_item * item = wf_impl_slist_first(filesystems);
while (NULL != item)
{
struct wf_slist_item * next = item->next;
@ -81,8 +81,8 @@ static void wf_impl_session_dispose_filesystems(
void wf_impl_session_dispose(
struct wf_impl_session * session)
{
wf_jsonrpc_proxy_dispose(session->rpc);
wf_message_queue_cleanup(&session->messages);
wf_impl_jsonrpc_proxy_dispose(session->rpc);
wf_impl_message_queue_cleanup(&session->messages);
wf_impl_session_dispose_filesystems(&session->filesystems);
free(session);
@ -112,7 +112,7 @@ bool wf_impl_session_add_filesystem(
result = (NULL != filesystem);
if (result)
{
wf_slist_append(&session->filesystems, &filesystem->item);
wf_impl_slist_append(&session->filesystems, &filesystem->item);
}
}
@ -132,14 +132,14 @@ bool wf_impl_session_add_filesystem(
void wf_impl_session_onwritable(
struct wf_impl_session * session)
{
if (!wf_slist_empty(&session->messages))
if (!wf_impl_slist_empty(&session->messages))
{
struct wf_slist_item * item = wf_slist_remove_first(&session->messages);
struct wf_slist_item * item = wf_impl_slist_remove_first(&session->messages);
struct wf_message * message = wf_container_of(item, struct wf_message, item);
lws_write(session->wsi, (unsigned char*) message->data, message->length, LWS_WRITE_TEXT);
wf_message_dispose(message);
wf_impl_message_dispose(message);
if (!wf_slist_empty(&session->messages))
if (!wf_impl_slist_empty(&session->messages))
{
lws_callback_on_writable(session->wsi);
}
@ -155,13 +155,13 @@ void wf_impl_session_receive(
json_t * message = json_loadb(data, length, 0, NULL);
if (NULL != message)
{
if (wf_jsonrpc_is_response(message))
if (wf_impl_jsonrpc_is_response(message))
{
wf_jsonrpc_proxy_onresult(session->rpc, message);
wf_impl_jsonrpc_proxy_onresult(session->rpc, message);
}
else if (wf_jsonrpc_is_request(message))
else if (wf_impl_jsonrpc_is_request(message))
{
wf_jsonrpc_server_process(session->server, message, &wf_impl_session_send, session);
wf_impl_jsonrpc_server_process(session->server, message, &wf_impl_session_send, session);
}
json_decref(message);
@ -175,7 +175,7 @@ static struct wf_impl_filesystem * wf_impl_session_get_filesystem(
{
struct wf_impl_filesystem * result = NULL;
struct wf_slist_item * item = wf_slist_first(&session->filesystems);
struct wf_slist_item * item = wf_impl_slist_first(&session->filesystems);
while (NULL != item)
{
struct wf_slist_item * next = item->next;

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

Loading…
Cancel
Save