1
0
mirror of https://github.com/falk-werner/webfuse synced 2024-10-27 20:34:10 +00:00
falk-werner_webfuse/include/webfuse/adapter/server_protocol.h

98 lines
3.8 KiB
C
Raw Normal View History

2020-02-17 20:53:42 +00:00
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/server_protocol.h
/// \brief Provides low level access to libwebsockets protocol.
///
/// By default, libwebfuse encapsulates libwebsockets protocol by \ref
/// wf_server. But sometimes it might come in handy to have access to
/// libwebsockets protocol. This allows to integrate libwebfuse in existing
/// libwebsockets applications.
////////////////////////////////////////////////////////////////////////////////
2019-03-26 22:04:53 +00:00
#ifndef WF_ADAPTER_SERVER_PROTOCOL_H
#define WF_ADAPTER_SERVER_PROTOCOL_H
#include <webfuse/adapter/api.h>
#include <webfuse/adapter/authenticate.h>
2020-02-16 20:03:17 +00:00
#include <webfuse/adapter/mountpoint_factory.h>
2019-03-26 22:04:53 +00:00
#ifdef __cplusplus
extern "C"
{
#endif
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \struct wf_server_protocol
/// \brief Opaque webfuse server protocol.
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
struct wf_server_protocol;
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \struct lws_protocols
/// \brief Forward declaration of libwebsockets protocols structure.
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
struct lws_protocols;
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Creates a new protocol by a mountpoint factory.
///
/// \note This function might be renamed in future releases.
///
/// \note The user is responsible to manage the lifetime of mountpoint factory.
///
/// \param create_mountpoint factory function to create mountpoints
/// \param create_mountpoint_context context of mountpoint factory
//------------------------------------------------------------------------------
extern WF_API struct wf_server_protocol * wf_server_protocol_create(
2020-02-16 20:03:17 +00:00
wf_create_mountpoint_fn * create_mountpoint,
void * create_mountpoint_context);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Disposes a protocol.
///
/// \note Contexts of mountpoint factory and added authenticators are not
/// managed by dispose.
///
/// \param protocol pointer to protocol
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_protocol_dispose(
struct wf_server_protocol * protocol);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Intializes a libwebsockets protocol structure.
///
/// \param protocol pointer to protocol
/// \param lws_protocols pointer to libwebsockets protocol structure
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_protocol_init_lws(
struct wf_server_protocol * protocol,
struct lws_protocols * lws_protocol);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Adds an authenticator.
///
/// Authenticators are used to authenticate users by some provided credentials.
/// Multiple providers can be specified to support different types of
/// credentials.
///
/// \note Adding multiple providers for the same credentials type results
/// in undefined behavior.
///
/// \note The user is responsible to manage the lifetime of user data.
///
/// \param protocol pointer to protocol
/// \param type type of the credentials the authenticator supports
/// \param authenticate function called to authenticate a user
/// \param user_data context of authenticate function
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WF_API void wf_server_protocol_add_authenticator(
struct wf_server_protocol * protocol,
char const * type,
wf_authenticate_fn * authenticate,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif