1
0
mirror of https://github.com/falk-werner/webfuse synced 2025-05-30 22:14:29 +00:00

moves implementation of adapter to impl

This commit is contained in:
Falk Werner 2019-03-24 01:15:29 +01:00
parent 48185776b6
commit 5ff1d5e6a3
57 changed files with 405 additions and 217 deletions

View File

@ -56,29 +56,30 @@ install(FILES include/wsfs/status.h DESTINATION include/wsfs)
# libwsfs-adapter
set(WSFS_ADAPTER_SOURCES
lib/wsfs/adapter/filesystem.c
lib/wsfs/adapter/server.c
lib/wsfs/adapter/server_config.c
lib/wsfs/adapter/server_protocol.c
lib/wsfs/adapter/session.c
lib/wsfs/adapter/session_manager.c
lib/wsfs/adapter/authenticator.c
lib/wsfs/adapter/authenticators.c
lib/wsfs/adapter/credentials.c
lib/wsfs/adapter/time/timepoint.c
lib/wsfs/adapter/time/timer.c
lib/wsfs/adapter/time/timeout_manager.c
lib/wsfs/adapter/operation/lookup.c
lib/wsfs/adapter/operation/getattr.c
lib/wsfs/adapter/operation/readdir.c
lib/wsfs/adapter/operation/open.c
lib/wsfs/adapter/operation/close.c
lib/wsfs/adapter/operation/read.c
lib/wsfs/adapter/jsonrpc/server.c
lib/wsfs/adapter/jsonrpc/method.c
lib/wsfs/adapter/jsonrpc/request.c
lib/wsfs/adapter/jsonrpc/response.c
lib/wsfs/adapter/jsonrpc/util.c
lib/wsfs/adapter/api.c
lib/wsfs/adapter/impl/filesystem.c
lib/wsfs/adapter/impl/server.c
lib/wsfs/adapter/impl/server_config.c
lib/wsfs/adapter/impl/server_protocol.c
lib/wsfs/adapter/impl/session.c
lib/wsfs/adapter/impl/session_manager.c
lib/wsfs/adapter/impl/authenticator.c
lib/wsfs/adapter/impl/authenticators.c
lib/wsfs/adapter/impl/credentials.c
lib/wsfs/adapter/impl/time/timepoint.c
lib/wsfs/adapter/impl/time/timer.c
lib/wsfs/adapter/impl/time/timeout_manager.c
lib/wsfs/adapter/impl/operation/lookup.c
lib/wsfs/adapter/impl/operation/getattr.c
lib/wsfs/adapter/impl/operation/readdir.c
lib/wsfs/adapter/impl/operation/open.c
lib/wsfs/adapter/impl/operation/close.c
lib/wsfs/adapter/impl/operation/read.c
lib/wsfs/adapter/impl/jsonrpc/server.c
lib/wsfs/adapter/impl/jsonrpc/method.c
lib/wsfs/adapter/impl/jsonrpc/request.c
lib/wsfs/adapter/impl/jsonrpc/response.c
lib/wsfs/adapter/impl/jsonrpc/util.c
)
add_library(wsfs-adapter SHARED ${WSFS_ADAPTER_SOURCES} ${WSFS_COMMON_SOURCES})

82
lib/wsfs/adapter/api.c Normal file
View File

@ -0,0 +1,82 @@
#include "wsfs_adapter.h"
#include "wsfs/adapter/impl/credentials.h"
#include "wsfs/adapter/impl/server_config.h"
// server_config
struct wsfs_server_config * wsfs_server_config_create(void)
{
return wsfs_impl_server_config_create();
}
void wsfs_server_config_dispose(
struct wsfs_server_config * config)
{
wsfs_impl_server_config_dispose(config);
}
void wsfs_server_config_set_mountpoint(
struct wsfs_server_config * config,
char const * mount_point)
{
wsfs_impl_server_config_set_mountpoint(config, mount_point);
}
void wsfs_server_config_set_documentroot(
struct wsfs_server_config * config,
char const * document_root)
{
wsfs_impl_server_config_set_documentroot(config, document_root);
}
void wsfs_server_config_set_keypath(
struct wsfs_server_config * config,
char const * key_path)
{
wsfs_impl_server_config_set_keypath(config, key_path);
}
void wsfs_server_config_set_certpath(
struct wsfs_server_config * config,
char const * cert_path)
{
wsfs_impl_server_config_set_certpath(config, cert_path);
}
void wsfs_server_config_set_vhostname(
struct wsfs_server_config * config,
char const * vhost_name)
{
wsfs_impl_server_config_set_vhostname(config, vhost_name);
}
void wsfs_server_config_set_port(
struct wsfs_server_config * config,
int port)
{
wsfs_impl_server_config_set_port(config, port);
}
void wsfs_server_config_add_authenticator(
struct wsfs_server_config * config,
char const * type,
wsfs_authenticate_fn * authenticate,
void * user_data)
{
wsfs_impl_server_config_add_authenticator(config, type, authenticate, user_data);
}
// credentials
char const * wsfs_credentials_type(
struct wsfs_credentials const * credentials)
{
return wsfs_impl_credentials_type(credentials);
}
char const * wsfs_credentials_get(
struct wsfs_credentials const * credentials,
char const * key)
{
return wsfs_impl_credentials_get(credentials, key);
}

View File

@ -1,30 +0,0 @@
#ifndef WSFS_ADAPTER_CREDENTIALS_INTERN_H
#define WSFS_ADAPTER_CREDENTIALS_INTERN_H
#include "wsfs/adapter/credentials.h"
#include <jansson.h>
struct wsfs_credentials
{
char * type;
json_t * data;
};
#ifdef __cplusplus
extern "C"
{
#endif
extern void wsfs_credentials_init(
struct wsfs_credentials * credentials,
char const * type,
json_t * data);
extern void wsfs_credentials_cleanup(
struct wsfs_credentials * credentials);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,9 +1,9 @@
#include "wsfs/adapter/authenticator.h"
#include "wsfs/adapter/impl/authenticator.h"
#include <stdlib.h>
#include <string.h>
#include "wsfs/adapter/credentials_intern.h"
#include "wsfs/adapter/impl/credentials.h"
struct wsfs_authenticator * wsfs_authenticator_create(
char const * type,

View File

@ -1,9 +1,9 @@
#include "wsfs/adapter/authenticators.h"
#include "wsfs/adapter/impl/authenticators.h"
#include <stddef.h>
#include <string.h>
#include "wsfs/adapter/authenticator.h"
#include "wsfs/adapter/credentials_intern.h"
#include "wsfs/adapter/impl/authenticator.h"
#include "wsfs/adapter/impl/credentials.h"
static struct wsfs_authenticator * wsfs_authenticators_find(
struct wsfs_authenticators * authenticators,

View File

@ -1,7 +1,7 @@
#include "wsfs/adapter/credentials_intern.h"
#include "wsfs/adapter/impl/credentials.h"
#include <string.h>
void wsfs_credentials_init(
void wsfs_impl_credentials_init(
struct wsfs_credentials * credentials,
char const * type,
json_t * data)
@ -11,20 +11,20 @@ void wsfs_credentials_init(
json_incref(credentials->data);
}
void wsfs_credentials_cleanup(
void wsfs_impl_credentials_cleanup(
struct wsfs_credentials * credentials)
{
free(credentials->type);
json_decref(credentials->data);
}
char const * wsfs_credentials_type(
char const * wsfs_impl_credentials_type(
struct wsfs_credentials const * credentials)
{
return credentials->type;
}
char const * wsfs_credentials_get(
char const * wsfs_impl_credentials_get(
struct wsfs_credentials const * credentials,
char const * key)
{

View File

@ -0,0 +1,36 @@
#ifndef WSFS_ADAPTER_IMPL_CREDENTIALS_H
#define WSFS_ADAPTER_IMPL_CREDENTIALS_H
#include <jansson.h>
struct wsfs_credentials
{
char * type;
json_t * data;
};
#ifdef __cplusplus
extern "C"
{
#endif
extern void wsfs_impl_credentials_init(
struct wsfs_credentials * credentials,
char const * type,
json_t * data);
extern void wsfs_impl_credentials_cleanup(
struct wsfs_credentials * credentials);
extern char const * wsfs_impl_credentials_type(
struct wsfs_credentials const * credentials);
extern char const * wsfs_impl_credentials_get(
struct wsfs_credentials const * credentials,
char const * key);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,6 +1,6 @@
#include "wsfs/adapter/filesystem.h"
#include "wsfs/adapter/operations.h"
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/impl/filesystem.h"
#include "wsfs/adapter/impl/operations.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#include <stddef.h>
#include <string.h>

View File

@ -5,8 +5,8 @@
#include <stdbool.h>
#endif
#include "wsfs/adapter/fuse_wrapper.h"
#include "wsfs/adapter/operations.h"
#include "wsfs/adapter/impl/fuse_wrapper.h"
#include "wsfs/adapter/impl/operations.h"
struct wsfs_jsonrpc_server;

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/jsonrpc/method_intern.h"
#include "wsfs/adapter/impl/jsonrpc/method_intern.h"
#include <stdlib.h>
#include <string.h>

View File

@ -1,7 +1,7 @@
#ifndef WSFS_ADAPTER_JSONRPC_METHOD_INTERN_H
#define WSFS_ADAPTER_JSONRPC_METHOD_INTERN_H
#include "wsfs/adapter/jsonrpc/method.h"
#include "wsfs/adapter/impl/jsonrpc/method.h"
struct wsfs_jsonrpc_method
{

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/jsonrpc/request.h"
#include "wsfs/adapter/impl/jsonrpc/request.h"
json_t * wsfs_jsonrpc_request_create(
char const * method,

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/jsonrpc/response.h"
#include "wsfs/adapter/impl/jsonrpc/response.h"
void wsfs_jsonrpc_response_init(
struct wsfs_jsonrpc_response * result,

View File

@ -1,9 +1,9 @@
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#include <string.h>
#include "wsfs/adapter/jsonrpc/method_intern.h"
#include "wsfs/adapter/jsonrpc/request.h"
#include "wsfs/adapter/jsonrpc/response.h"
#include "wsfs/adapter/impl/jsonrpc/method_intern.h"
#include "wsfs/adapter/impl/jsonrpc/request.h"
#include "wsfs/adapter/impl/jsonrpc/response.h"
#define WSFS_DEFAULT_TIMEOUT (10 * 1000)

View File

@ -12,9 +12,9 @@ using std::size_t;
#endif
#include <jansson.h>
#include "wsfs/adapter/jsonrpc/method.h"
#include "wsfs/adapter/time/timeout_manager.h"
#include "wsfs/adapter/time/timer.h"
#include "wsfs/adapter/impl/jsonrpc/method.h"
#include "wsfs/adapter/impl/time/timeout_manager.h"
#include "wsfs/adapter/impl/time/timer.h"
struct wsfs_jsonrpc_request

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/jsonrpc/util.h"
#include "wsfs/adapter/impl/jsonrpc/util.h"
int wsfs_json_get_int(json_t const * object, char const * key, int default_value)
{

View File

@ -1,10 +1,10 @@
#include "wsfs/adapter/operations.h"
#include "wsfs/adapter/impl/operations.h"
#include <limits.h>
#include <errno.h>
#include <jansson.h>
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#include "wsfs/util.h"
void wsfs_operation_close(

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/operations.h"
#include "wsfs/adapter/impl/operations.h"
#include <errno.h>
#include <string.h>
@ -7,8 +7,8 @@
#include <sys/stat.h>
#include <unistd.h>
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/jsonrpc/util.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#include "wsfs/adapter/impl/jsonrpc/util.h"
#include "wsfs/util.h"
struct wsfs_operation_getattr_context

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/operations.h"
#include "wsfs/adapter/impl/operations.h"
#include <limits.h>
#include <errno.h>
@ -10,8 +10,8 @@
#include <stdlib.h>
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/jsonrpc/util.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#include "wsfs/adapter/impl/jsonrpc/util.h"
#include "wsfs/util.h"
struct wsfs_operation_lookup_context

View File

@ -1,10 +1,10 @@
#include "wsfs/adapter/operations.h"
#include "wsfs/adapter/impl/operations.h"
#include <string.h>
#include <errno.h>
#include <jansson.h>
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#include "wsfs/util.h"
#include "wsfs/status.h"

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/operations.h"
#include "wsfs/adapter/impl/operations.h"
#include <errno.h>
#include <string.h>
@ -6,7 +6,7 @@
#include <jansson.h>
#include <libwebsockets.h>
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#define WSFS_MAX_READ_LENGTH 4096

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/operations.h"
#include "wsfs/adapter/impl/operations.h"
#include <stdlib.h>
#include <string.h>
@ -8,7 +8,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#include "wsfs/util.h"

View File

@ -1,7 +1,7 @@
#ifndef WSFS_ADAPTER_OPERATIONS
#define WSFS_ADAPTER_OPERATIONS
#include "wsfs/adapter/fuse_wrapper.h"
#include "wsfs/adapter/impl/fuse_wrapper.h"
struct wsfs_jsonrpc_server;

View File

@ -8,8 +8,8 @@
#include <sys/stat.h>
#include <unistd.h>
#include "wsfs/adapter/server_config_intern.h"
#include "wsfs/adapter/server_protocol_intern.h"
#include "wsfs/adapter/impl/server_config.h"
#include "wsfs/adapter/impl/server_protocol_intern.h"
#define WSFS_DISABLE_LWS_LOG 0
#define WSFS_SERVER_PROTOCOL_COUNT 3
@ -111,7 +111,7 @@ struct wsfs_server * wsfs_server_create(
if (wsfs_server_protocol_init(&server->protocol, config->mount_point))
{
server->shutdown_requested = false;
wsfs_server_config_clone(config, &server->config);
wsfs_impl_server_config_clone(config, &server->config);
wsfs_authenticators_move(&server->config.authenticators, &server->protocol.authenticators);
server->context = wsfs_server_context_create(server);
}
@ -131,7 +131,7 @@ void wsfs_server_dispose(
{
lws_context_destroy(server->context);
wsfs_server_protocol_cleanup(&server->protocol);
wsfs_server_config_cleanup(&server->config);
wsfs_impl_server_config_cleanup(&server->config);
free(server);
}

View File

@ -0,0 +1,29 @@
#ifndef WSFS_ADAPTER_SERVER_H
#define WSFS_ADAPTER_SERVER_H
struct wsfs_server;
struct wsfs_server_config;
#ifdef __cplusplus
extern "C"
{
#endif
extern struct wsfs_server * wsfs_server_create(
struct wsfs_server_config * config);
extern void wsfs_server_dispose(
struct wsfs_server * server);
extern void wsfs_server_run(
struct wsfs_server * server);
extern void wsfs_server_shutdown(
struct wsfs_server * server);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/server_config_intern.h"
#include "wsfs/adapter/impl/server_config.h"
#include <stdlib.h>
#include <string.h>
@ -14,7 +14,7 @@ static char * wsfs_server_config_strdup(char const * value)
return result;
}
void wsfs_server_config_init(
void wsfs_impl_server_config_init(
struct wsfs_server_config * config)
{
memset(config, 0, sizeof(struct wsfs_server_config));
@ -22,7 +22,7 @@ void wsfs_server_config_init(
wsfs_authenticators_init(&config->authenticators);
}
void wsfs_server_config_cleanup(
void wsfs_impl_server_config_cleanup(
struct wsfs_server_config * config)
{
wsfs_authenticators_cleanup(&config->authenticators);
@ -33,10 +33,10 @@ void wsfs_server_config_cleanup(
free(config->cert_path);
free(config->vhost_name);
wsfs_server_config_init(config);
wsfs_impl_server_config_init(config);
}
void wsfs_server_config_clone(
void wsfs_impl_server_config_clone(
struct wsfs_server_config * config,
struct wsfs_server_config * clone)
{
@ -50,25 +50,25 @@ void wsfs_server_config_clone(
wsfs_authenticators_clone(&config->authenticators, &clone->authenticators);
}
struct wsfs_server_config * wsfs_server_config_create(void)
struct wsfs_server_config * wsfs_impl_server_config_create(void)
{
struct wsfs_server_config * config = malloc(sizeof(struct wsfs_server_config));
if (NULL != config)
{
wsfs_server_config_init(config);
wsfs_impl_server_config_init(config);
}
return config;
}
void wsfs_server_config_dispose(
void wsfs_impl_server_config_dispose(
struct wsfs_server_config * config)
{
wsfs_server_config_cleanup(config);
wsfs_impl_server_config_cleanup(config);
free(config);
}
void wsfs_server_config_set_mountpoint(
void wsfs_impl_server_config_set_mountpoint(
struct wsfs_server_config * config,
char const * mount_point)
{
@ -76,7 +76,7 @@ void wsfs_server_config_set_mountpoint(
config->mount_point = strdup(mount_point);
}
void wsfs_server_config_set_documentroot(
void wsfs_impl_server_config_set_documentroot(
struct wsfs_server_config * config,
char const * document_root)
{
@ -84,7 +84,7 @@ void wsfs_server_config_set_documentroot(
config->document_root = strdup(document_root);
}
void wsfs_server_config_set_keypath(
void wsfs_impl_server_config_set_keypath(
struct wsfs_server_config * config,
char const * key_path)
{
@ -92,7 +92,7 @@ void wsfs_server_config_set_keypath(
config->key_path = strdup(key_path);
}
void wsfs_server_config_set_certpath(
void wsfs_impl_server_config_set_certpath(
struct wsfs_server_config * config,
char const * cert_path)
{
@ -100,7 +100,7 @@ void wsfs_server_config_set_certpath(
config->cert_path = strdup(cert_path);
}
void wsfs_server_config_set_vhostname(
void wsfs_impl_server_config_set_vhostname(
struct wsfs_server_config * config,
char const * vhost_name)
{
@ -108,14 +108,14 @@ void wsfs_server_config_set_vhostname(
config->vhost_name = strdup(vhost_name);
}
void wsfs_server_config_set_port(
void wsfs_impl_server_config_set_port(
struct wsfs_server_config * config,
int port)
{
config->port = port;
}
void wsfs_server_config_add_authenticator(
void wsfs_impl_server_config_add_authenticator(
struct wsfs_server_config * config,
char const * type,
wsfs_authenticate_fn * authenticate,

View File

@ -0,0 +1,73 @@
#ifndef WSFS_ADAPTER_IMPL_SERVER_CONFIG_H
#define WSFS_ADAPTER_IMPL_SERVER_CONFIG_H
#include "wsfs/adapter/impl/authenticators.h"
struct wsfs_server_config
{
char * mount_point;
char * document_root;
char * key_path;
char * cert_path;
char * vhost_name;
int port;
struct wsfs_authenticators authenticators;
};
#ifdef __cplusplus
extern "C"
{
#endif
extern struct wsfs_server_config * wsfs_impl_server_config_create(void);
extern void wsfs_impl_server_config_dispose(
struct wsfs_server_config * config);
extern void wsfs_impl_server_config_init(
struct wsfs_server_config * config);
extern void wsfs_impl_server_config_cleanup(
struct wsfs_server_config * config);
extern void wsfs_impl_server_config_clone(
struct wsfs_server_config * config,
struct wsfs_server_config * clone);
extern void wsfs_impl_server_config_set_mountpoint(
struct wsfs_server_config * config,
char const * mount_point);
extern void wsfs_impl_server_config_set_documentroot(
struct wsfs_server_config * config,
char const * document_root);
extern void wsfs_impl_server_config_set_keypath(
struct wsfs_server_config * config,
char const * key_path);
extern void wsfs_impl_server_config_set_certpath(
struct wsfs_server_config * config,
char const * cert_path);
extern void wsfs_impl_server_config_set_vhostname(
struct wsfs_server_config * config,
char const * vhost_name);
extern void wsfs_impl_server_config_set_port(
struct wsfs_server_config * config,
int port);
extern void wsfs_impl_server_config_add_authenticator(
struct wsfs_server_config * config,
char const * type,
wsfs_authenticate_fn * authenticate,
void * user_data
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/server_protocol_intern.h"
#include "wsfs/adapter/impl/server_protocol_intern.h"
#include <stdlib.h>
#include <libwebsockets.h>
@ -6,7 +6,7 @@
#include "wsfs/message.h"
#include "wsfs/util.h"
#include "wsfs/adapter/filesystem.h"
#include "wsfs/adapter/impl/filesystem.h"
static int wsfs_server_protocol_callback(
struct lws * wsi,

View File

@ -0,0 +1,34 @@
#ifndef WSFS_ADAPTER_SERVER_PROTOCOL_H
#define WSFS_ADAPTER_SERVER_PROTOCOL_H
#include "wsfs/adapter/authenticate.h"
struct wsfs_server_protocol;
struct lws_protocols;
#ifdef __cplusplus
extern "C"
{
#endif
extern struct wsfs_server_protocol * wsfs_server_protocol_create(
char * mount_point);
extern void wsfs_server_protocol_dispose(
struct wsfs_server_protocol * protocol);
extern void wsfs_server_protocol_init_lws(
struct wsfs_server_protocol * protocol,
struct lws_protocols * lws_protocol);
extern void wsfs_server_protocol_add_authenticator(
struct wsfs_server_protocol * protocol,
char const * type,
wsfs_authenticate_fn * authenticate,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,12 +1,12 @@
#ifndef WSFS_ADAPTER_SERVER_PROTOCOL_INTERN_H
#define WSFS_ADAPTER_SERVER_PROTOCOL_INTERN_H
#include "wsfs/adapter/server_protocol.h"
#include "wsfs/adapter/filesystem.h"
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/time/timeout_manager.h"
#include "wsfs/adapter/authenticators.h"
#include "wsfs/adapter/session_manager.h"
#include "wsfs/adapter/impl/server_protocol.h"
#include "wsfs/adapter/impl/filesystem.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#include "wsfs/adapter/impl/time/timeout_manager.h"
#include "wsfs/adapter/impl/authenticators.h"
#include "wsfs/adapter/impl/session_manager.h"
struct wsfs_server_protocol
{

View File

@ -1,8 +1,8 @@
#include "wsfs/adapter/session.h"
#include "wsfs/adapter/authenticators.h"
#include "wsfs/adapter/impl/session.h"
#include "wsfs/adapter/impl/authenticators.h"
#include "wsfs/message_queue.h"
#include "wsfs/message.h"
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/adapter/impl/jsonrpc/server.h"
#include <libwebsockets.h>
#include <stddef.h>

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/session_manager.h"
#include "wsfs/adapter/impl/session_manager.h"
#include <stddef.h>
void wsfs_session_manager_init(

View File

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

View File

@ -1,8 +1,8 @@
#include "wsfs/adapter/time/timeout_manager_intern.h"
#include "wsfs/adapter/impl/time/timeout_manager_intern.h"
#include <stddef.h>
#include "wsfs/adapter/time/timer_intern.h"
#include "wsfs/adapter/time/timepoint.h"
#include "wsfs/adapter/impl/time/timer_intern.h"
#include "wsfs/adapter/impl/time/timepoint.h"
void wsfs_timeout_manager_init(
struct wsfs_timeout_manager * manager)

View File

@ -1,7 +1,7 @@
#ifndef WSFS_ADAPTER_TIME_TIMEOUT_MANAGER_INTERN_H
#define WSFS_ADAPTER_TIME_TIMEOUT_MANAGER_INTERN_H
#include "wsfs/adapter/time/timeout_manager.h"
#include "wsfs/adapter/impl/time/timeout_manager.h"
#ifdef __cplusplus
extern "C"

View File

@ -1,4 +1,4 @@
#include "wsfs/adapter/time/timepoint.h"
#include "wsfs/adapter/impl/time/timepoint.h"
#include <time.h>

View File

@ -1,5 +1,5 @@
#include "wsfs/adapter/time/timer_intern.h"
#include "wsfs/adapter/time/timeout_manager_intern.h"
#include "wsfs/adapter/impl/time/timer_intern.h"
#include "wsfs/adapter/impl/time/timeout_manager_intern.h"
#include <stddef.h>
#include <string.h>

View File

@ -1,7 +1,7 @@
#ifndef WSFS_ADAPTER_TIME_TIMER_H
#define WSFS_ADAPTER_TIME_TIMER_H
#include "wsfs/adapter/time/timepoint.h"
#include "wsfs/adapter/impl/time/timepoint.h"
struct wsfs_timer;
struct wsfs_timeout_manager;

View File

@ -5,7 +5,7 @@
#include <stdbool.h>
#endif
#include "wsfs/adapter/time/timer.h"
#include "wsfs/adapter/impl/time/timer.h"
#ifdef __cplusplus
extern "C"

View File

@ -1,37 +0,0 @@
#ifndef WSFS_ADAPTER_SERVER_CONFIG_INTERN_H
#define WSFS_ADAPTER_SERVER_CONFIG_INTERN_H
#include "wsfs/adapter/server_config.h"
#include "wsfs/adapter/authenticators.h"
struct wsfs_server_config
{
char * mount_point;
char * document_root;
char * key_path;
char * cert_path;
char * vhost_name;
int port;
struct wsfs_authenticators authenticators;
};
#ifdef __cplusplus
extern "C"
{
#endif
extern void wsfs_server_config_init(
struct wsfs_server_config * config);
extern void wsfs_server_config_cleanup(
struct wsfs_server_config * config);
extern void wsfs_server_config_clone(
struct wsfs_server_config * config,
struct wsfs_server_config * clone);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2,7 +2,7 @@
#define MOCK_AUTHENTICATOR_H
#include <gmock/gmock.h>
#include "wsfs/adapter/authenticator.h"
#include "wsfs/adapter/impl/authenticator.h"
namespace wsfs_test
{

View File

@ -3,8 +3,8 @@
#include "mock_authenticator.hpp"
#include "wsfs/adapter/authenticator.h"
#include "wsfs/adapter/credentials_intern.h"
#include "wsfs/adapter/impl/authenticator.h"
#include "wsfs/adapter/impl/credentials.h"
using ::testing::Return;
using ::testing::_;
@ -20,7 +20,7 @@ TEST(Authenticator, Authenticate)
set_authenticator(&mock);
struct wsfs_credentials creds;
wsfs_credentials_init(&creds, "username", nullptr);
wsfs_impl_credentials_init(&creds, "username", nullptr);
char dummy[] = "usr_data";
void * user_data = reinterpret_cast<void*>(dummy);
@ -37,7 +37,7 @@ TEST(Authenticator, Authenticate)
ASSERT_TRUE(result);
wsfs_authenticator_dispose(authenticator);
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_cleanup(&creds);
}
TEST(Authenticator, SkipAuthenticationWithWrongType)
@ -46,7 +46,7 @@ TEST(Authenticator, SkipAuthenticationWithWrongType)
set_authenticator(&mock);
struct wsfs_credentials creds;
wsfs_credentials_init(&creds, "username", nullptr);
wsfs_impl_credentials_init(&creds, "username", nullptr);
EXPECT_CALL(mock, authenticate(_, _))
.Times(0);
@ -59,5 +59,5 @@ TEST(Authenticator, SkipAuthenticationWithWrongType)
ASSERT_FALSE(result);
wsfs_authenticator_dispose(authenticator);
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_cleanup(&creds);
}

View File

@ -1,8 +1,8 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "wsfs/adapter/authenticators.h"
#include "wsfs/adapter/credentials_intern.h"
#include "wsfs/adapter/impl/authenticators.h"
#include "wsfs/adapter/impl/credentials.h"
#include "mock_authenticator.hpp"
using ::testing::_;
@ -68,7 +68,7 @@ TEST(Authenticators, Move)
TEST(Authenticators, AuthenticateWithoutAuthenticators)
{
struct wsfs_credentials creds;
wsfs_credentials_init(&creds, "username", nullptr);
wsfs_impl_credentials_init(&creds, "username", nullptr);
struct wsfs_authenticators authenticators;
wsfs_authenticators_init(&authenticators);
@ -80,7 +80,7 @@ TEST(Authenticators, AuthenticateWithoutAuthenticators)
ASSERT_TRUE(result);
wsfs_authenticators_cleanup(&authenticators);
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_cleanup(&creds);
}
TEST(Authenticators, FailToAuthenticateWithoutCredentials)
@ -101,7 +101,7 @@ TEST(Authenticators, FailToAuthenticateWithoutCredentials)
TEST(Authenticators, AuthenticateWithMultipleCredentials)
{
struct wsfs_credentials creds;
wsfs_credentials_init(&creds, "username", nullptr);
wsfs_impl_credentials_init(&creds, "username", nullptr);
MockAuthenticator username_mock;
set_authenticator(1, &username_mock);
@ -123,13 +123,13 @@ TEST(Authenticators, AuthenticateWithMultipleCredentials)
ASSERT_TRUE(result);
wsfs_authenticators_cleanup(&authenticators);
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_cleanup(&creds);
}
TEST(Authenticators, FailedAuthenticateWithWrongType)
{
struct wsfs_credentials creds;
wsfs_credentials_init(&creds, "token", nullptr);
wsfs_impl_credentials_init(&creds, "token", nullptr);
MockAuthenticator username_mock;
set_authenticator(1, &username_mock);
@ -150,5 +150,5 @@ TEST(Authenticators, FailedAuthenticateWithWrongType)
ASSERT_FALSE(result);
wsfs_authenticators_cleanup(&authenticators);
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_cleanup(&creds);
}

View File

@ -1,15 +1,15 @@
#include <gtest/gtest.h>
#include "wsfs/adapter/credentials_intern.h"
#include "wsfs/adapter/impl/credentials.h"
#include <jansson.h>
TEST(Credentials, Type)
{
struct wsfs_credentials creds;
wsfs_credentials_init(&creds, "test", nullptr);
ASSERT_STREQ("test", wsfs_credentials_type(&creds));
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_init(&creds, "test", nullptr);
ASSERT_STREQ("test", wsfs_impl_credentials_type(&creds));
wsfs_impl_credentials_cleanup(&creds);
}
TEST(Credentials, Get)
@ -19,12 +19,12 @@ TEST(Credentials, Get)
json_object_set_new(data, "username", json_string("bob"));
json_object_set_new(data, "password", json_string("<secret>"));
wsfs_credentials_init(&creds, "username", data);
ASSERT_STREQ("username", wsfs_credentials_type(&creds));
ASSERT_STREQ("bob", wsfs_credentials_get(&creds, "username"));
ASSERT_STREQ("<secret>", wsfs_credentials_get(&creds, "password"));
wsfs_impl_credentials_init(&creds, "username", data);
ASSERT_STREQ("username", wsfs_impl_credentials_type(&creds));
ASSERT_STREQ("bob", wsfs_impl_credentials_get(&creds, "username"));
ASSERT_STREQ("<secret>", wsfs_impl_credentials_get(&creds, "password"));
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_cleanup(&creds);
json_decref(data);
}
@ -33,12 +33,12 @@ TEST(Credentials, FailedToGetNonexistingValue)
struct wsfs_credentials creds;
json_t * data = json_object();
wsfs_credentials_init(&creds, "username", data);
ASSERT_STREQ("username", wsfs_credentials_type(&creds));
ASSERT_STREQ(nullptr, wsfs_credentials_get(&creds, "username"));
ASSERT_STREQ(nullptr, wsfs_credentials_get(&creds, "password"));
wsfs_impl_credentials_init(&creds, "username", data);
ASSERT_STREQ("username", wsfs_impl_credentials_type(&creds));
ASSERT_STREQ(nullptr, wsfs_impl_credentials_get(&creds, "username"));
ASSERT_STREQ(nullptr, wsfs_impl_credentials_get(&creds, "password"));
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_cleanup(&creds);
json_decref(data);
}
@ -46,12 +46,12 @@ TEST(Credentials, FailedToGetWithoutData)
{
struct wsfs_credentials creds;
wsfs_credentials_init(&creds, "username", nullptr);
ASSERT_STREQ("username", wsfs_credentials_type(&creds));
ASSERT_STREQ(nullptr, wsfs_credentials_get(&creds, "username"));
ASSERT_STREQ(nullptr, wsfs_credentials_get(&creds, "password"));
wsfs_impl_credentials_init(&creds, "username", nullptr);
ASSERT_STREQ("username", wsfs_impl_credentials_type(&creds));
ASSERT_STREQ(nullptr, wsfs_impl_credentials_get(&creds, "username"));
ASSERT_STREQ(nullptr, wsfs_impl_credentials_get(&creds, "password"));
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_cleanup(&creds);
}
TEST(Credentials, FailedToGetWrongDataType)
@ -59,12 +59,12 @@ TEST(Credentials, FailedToGetWrongDataType)
struct wsfs_credentials creds;
json_t * data = json_string("invalid_creds");
wsfs_credentials_init(&creds, "username", data);
ASSERT_STREQ("username", wsfs_credentials_type(&creds));
ASSERT_STREQ(nullptr, wsfs_credentials_get(&creds, "username"));
ASSERT_STREQ(nullptr, wsfs_credentials_get(&creds, "password"));
wsfs_impl_credentials_init(&creds, "username", data);
ASSERT_STREQ("username", wsfs_impl_credentials_type(&creds));
ASSERT_STREQ(nullptr, wsfs_impl_credentials_get(&creds, "username"));
ASSERT_STREQ(nullptr, wsfs_impl_credentials_get(&creds, "password"));
wsfs_credentials_cleanup(&creds);
wsfs_impl_credentials_cleanup(&creds);
json_decref(data);
}

View File

@ -1,7 +1,7 @@
#include <string>
#include <gtest/gtest.h>
#include "wsfs/adapter/jsonrpc/response.h"
#include "wsfs/adapter/impl/jsonrpc/response.h"
static void wsfs_response_parse_str(

View File

@ -1,7 +1,7 @@
#include <gtest/gtest.h>
#include "msleep.hpp"
#include "wsfs/adapter/time/timepoint.h"
#include "wsfs/adapter/impl/time/timepoint.h"
using wsfs_test::msleep;

View File

@ -3,8 +3,8 @@
#include <cstddef>
#include "msleep.hpp"
#include "wsfs/adapter/time/timer.h"
#include "wsfs/adapter/time/timeout_manager.h"
#include "wsfs/adapter/impl/time/timer.h"
#include "wsfs/adapter/impl/time/timeout_manager.h"
using std::size_t;
using wsfs_test::msleep;