made headers C++ compatible ; added basic server test

pull/2/head
Falk Werner 5 years ago
parent 7f8365811f
commit aa41fb3a6e

@ -72,6 +72,7 @@ pkg_check_modules(GTEST gtest_main)
add_executable(alltests
test-src/test_response_parser.cc
test-src/test_server.cc
)
target_link_libraries(alltests PUBLIC fuse-wsfs ${EXTRA_LIBS} ${GTEST_LIBRARIES})

@ -1,8 +1,16 @@
#ifndef _WSFS_FUSE_H
#define _WSFS_FUSE_H
#ifdef __cplusplus
extern "C" {
#endif
#define FUSE_USE_VERSION 31
#include <fuse.h>
#ifdef __cplusplus
}
#endif
#endif

@ -1,9 +1,16 @@
#ifndef _WSFS_JSONRPC_H
#define _WSFS_JSONRPC_H
#ifndef __cplusplus
#include <stdarg.h>
#include <stddef.h>
#include <stdbool.h>
#else
#include <cstdarg>
#include <cstddef>
using std::size_t;
#endif
#include <jansson.h>
#include "wsfs/status.h"
@ -12,6 +19,10 @@ struct wsfs_jsonrpc;
typedef char * wsfs_create_message_fn(size_t size);
typedef bool wsfs_send_message_fn(char * message, size_t length, void * user_data);
#ifdef __cplusplus
extern "C" {
#endif
extern struct wsfs_jsonrpc * wsfs_jsonrpc_create(
wsfs_create_message_fn * create_message,
wsfs_send_message_fn * send_message,
@ -37,5 +48,9 @@ extern void wsfs_jsonrpc_on_message(
size_t length,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -3,6 +3,10 @@
#include "wsfs/fuse_wrapper.h"
#ifdef __cplusplus
extern "C" {
#endif
extern void wsfs_operations_init(
struct fuse_operations * operations);
@ -33,6 +37,10 @@ extern int wsfs_operation_read(
size_t buffer_size,
off_t offset,
struct fuse_file_info * file_info);
#ifdef __cplusplus
}
#endif
#endif

@ -1,13 +1,20 @@
#ifndef _WSFS_PROTOCOL_H
#define _WSFS_PROTOCOL_H
#ifndef __cplusplus
#include <stdbool.h>
#endif
#include <libwebsockets.h>
#include <pthread.h>
struct wsfs_protocol;
struct wsfs_server;
#ifdef __cplusplus
extern "C" {
#endif
extern struct wsfs_protocol * wsfs_protocol_create(
struct wsfs_server * server);
@ -32,6 +39,10 @@ extern bool wsfs_protocol_send(
size_t length,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,7 +1,13 @@
#ifndef _WSFS_RESPONSE_PARSER_H
#define _WFSF_RESPONSE_PARSER_H
#ifndef __cplusplus
#include <stddef.h>
#else
#include <cstddef>
using std::size_t;
#endif
#include <jansson.h>
#include "wsfs/status.h"
@ -12,10 +18,18 @@ struct wsfs_response
json_t * result;
};
#ifdef __cplusplus
extern "C" {
#endif
extern void wsfs_response_parse(
char const * buffer,
size_t buffer_length,
struct wsfs_response * response);
#ifdef __cplusplus
}
#endif
#endif

@ -1,7 +1,12 @@
#ifndef _WSFS_SERVER_H
#define _WSFS_SERVER_H
#ifndef __cplusplus
#include <stddef.h>
#else
#include <cstddef>
using std::size_t;
#endif
struct wsfs_server;
struct wsfs_jsonrpc;
@ -15,6 +20,10 @@ struct wsfs_server_config
int port;
};
#ifdef __cplusplus
extern "C" {
#endif
extern void wsfs_server_config_clear(
struct wsfs_server_config * config);
@ -38,5 +47,9 @@ extern void wsfs_server_handle_message(
char const * message,
size_t length);
#ifdef __cplusplus
}
#endif
#endif

@ -13,7 +13,15 @@
typedef int wsfs_status;
#ifdef __cplusplus
extern "C" {
#endif
extern int wsfs_status_to_rc(wsfs_status status);
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,11 @@
#include <gtest/gtest.h>
#include "wsfs/server.h"
TEST(server, create_dispose)
{
wsfs_server_config config = {nullptr, nullptr, nullptr, nullptr, 0};
wsfs_server * server = wsfs_server_create(&config);
ASSERT_NE(nullptr, server);
wsfs_server_dispose(server);
}
Loading…
Cancel
Save