switched prefix to wfp for old wf stuff

pull/2/head
Falk Werner 4 years ago
parent 2f80ebffcc
commit 83b76a1a5a

@ -193,7 +193,7 @@ static void fs_lookup(
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }
@ -215,7 +215,7 @@ static void fs_getattr(
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }
@ -247,7 +247,7 @@ static void fs_readdir(
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }
@ -268,12 +268,12 @@ static void fs_open(
} }
else else
{ {
wfp_respond_error(request, WF_BAD_ACCESS_DENIED); wfp_respond_error(request, WFP_BAD_ACCESS_DENIED);
} }
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }
@ -305,12 +305,12 @@ static void fs_read(
} }
else else
{ {
wfp_respond_error(request, WF_BAD); wfp_respond_error(request, WFP_BAD);
} }
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }

@ -255,7 +255,7 @@ static void static_filesystem_lookup(
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }
@ -276,7 +276,7 @@ static void static_filesystem_getattr(
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }
@ -308,7 +308,7 @@ static void static_filesystem_readdir(
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }
@ -329,12 +329,12 @@ static void static_filesystem_open(
} }
else else
{ {
wfp_respond_error(request, WF_BAD_ACCESS_DENIED); wfp_respond_error(request, WFP_BAD_ACCESS_DENIED);
} }
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }
@ -361,7 +361,7 @@ static void static_filesystem_read(
} }
else else
{ {
wfp_respond_error(request, WF_BAD_NOENTRY); wfp_respond_error(request, WFP_BAD_NOENTRY);
} }
} }

@ -3,8 +3,8 @@
/// \brief Webfuse provider client. /// \brief Webfuse provider client.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef WF_PROVIDER_CLIENT_H #ifndef WFP_PROVIDER_CLIENT_H
#define WF_PROVIDER_CLIENT_H #define WFP_PROVIDER_CLIENT_H
#include "webfuse_provider/api.h" #include "webfuse_provider/api.h"

@ -3,8 +3,8 @@
/// \brief Client configuration of webfuse provider. /// \brief Client configuration of webfuse provider.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef WF_PROVIDER_CLIENT_CONFIG_H #ifndef WFP_PROVIDER_CLIENT_CONFIG_H
#define WF_PROVIDER_CLIENT_CONFIG_H #define WFP_PROVIDER_CLIENT_CONFIG_H
#include <webfuse_provider/api.h> #include <webfuse_provider/api.h>

@ -8,8 +8,8 @@
/// libwebsockets applications. /// libwebsockets applications.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef WF_PROVIDER_CLIENT_PROTOCOL_H #ifndef WFP_PROVIDER_CLIENT_PROTOCOL_H
#define WF_PROVIDER_CLIENT_PROTOCOL_H #define WFP_PROVIDER_CLIENT_PROTOCOL_H
#include "webfuse_provider/api.h" #include "webfuse_provider/api.h"

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_CREDENTIALS_H #ifndef WFP_PROVIDER_CREDENTIALS_H
#define WF_PROVIDER_CREDENTIALS_H #define WFP_PROVIDER_CREDENTIALS_H
#include <webfuse_provider/api.h> #include <webfuse_provider/api.h>

@ -3,8 +3,8 @@
/// \brief Buffer used for directory listing. /// \brief Buffer used for directory listing.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef WF_PROVIDER_DIRBUFFER_H #ifndef WFP_PROVIDER_DIRBUFFER_H
#define WF_PROVIDER_DIRBUFFER_H #define WFP_PROVIDER_DIRBUFFER_H
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>

@ -27,7 +27,7 @@ struct wfp_request;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
extern WFP_API void wfp_respond_error( extern WFP_API void wfp_respond_error(
struct wfp_request * request, struct wfp_request * request,
wf_status status); wfp_status status);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -2,32 +2,32 @@
/// \file protocol_names.h /// \file protocol_names.h
/// \brief Names of websocket protocol. /// \brief Names of websocket protocol.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef WF_PROTOCOL_NAMES_H #ifndef WFP_PROTOCOL_NAMES_H
#define WF_PROTOCOL_NAMES_H #define WFP_PROTOCOL_NAMES_H
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/// \def WF_PROTOCOL_NAME_ADAPTER_SERVER /// \def WFP_PROTOCOL_NAME_ADAPTER_SERVER
/// \brief Name of the websocket protocol an adapter server is running. /// \brief Name of the websocket protocol an adapter server is running.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define WF_PROTOCOL_NAME_ADAPTER_SERVER ("webfuse-adapter-server") #define WFP_PROTOCOL_NAME_ADAPTER_SERVER ("webfuse-adapter-server")
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/// \def WF_PROTOCOL_NAME_ADAPTER_CLIENT /// \def WFP_PROTOCOL_NAME_ADAPTER_CLIENT
/// \brief Name of the websocket protocol an adapter client is running. /// \brief Name of the websocket protocol an adapter client is running.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define WF_PROTOCOL_NAME_ADAPTER_CLIENT ("webfuse-adapter-client") #define WFP_PROTOCOL_NAME_ADAPTER_CLIENT ("webfuse-adapter-client")
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/// \def WF_PROTOCOL_NAME_PROVIDER_CLIENT /// \def WFP_PROTOCOL_NAME_PROVIDER_CLIENT
/// \brief Name of the websocket protocol an provider client is running. /// \brief Name of the websocket protocol an provider client is running.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define WF_PROTOCOL_NAME_PROVIDER_CLIENT ("webfuse-provider-client") #define WFP_PROTOCOL_NAME_PROVIDER_CLIENT ("webfuse-provider-client")
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/// \def WF_PROTOCOL_NAME_PROVIDER_SERVER /// \def WFP_PROTOCOL_NAME_PROVIDER_SERVER
/// \brief Name of the websocket protocol an provider server is running. /// \brief Name of the websocket protocol an provider server is running.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define WF_PROTOCOL_NAME_PROVIDER_SERVER ("webfuse-provider-server") #define WFP_PROTOCOL_NAME_PROVIDER_SERVER ("webfuse-provider-server")
#endif #endif

@ -3,21 +3,21 @@
/// \brief Generic status code. /// \brief Generic status code.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef WF_STATUS_H #ifndef WFP_STATUS_H
#define WF_STATUS_H #define WFP_STATUS_H
#define WF_GOOD 0 ///< Positive status code. #define WFP_GOOD 0 ///< Positive status code.
#define WF_BAD 1 ///< Generic negative status code. #define WFP_BAD 1 ///< Generic negative status code.
#define WF_BAD_NOTIMPLEMENTED 2 ///< The called function is not implemented (yet). #define WFP_BAD_NOTIMPLEMENTED 2 ///< The called function is not implemented (yet).
#define WF_BAD_TIMEOUT 3 ///< A timeout occured. #define WFP_BAD_TIMEOUT 3 ///< A timeout occured.
#define WF_BAD_BUSY 4 ///< Resource is busy, try again later. #define WFP_BAD_BUSY 4 ///< Resource is busy, try again later.
#define WF_BAD_FORMAT 5 ///< Invalid format. #define WFP_BAD_FORMAT 5 ///< Invalid format.
#define WF_BAD_NOENTRY 101 ///< Entry not found. #define WFP_BAD_NOENTRY 101 ///< Entry not found.
#define WF_BAD_ACCESS_DENIED 102 ///< Access is denied. #define WFP_BAD_ACCESS_DENIED 102 ///< Access is denied.
/// Status code. /// Status code.
typedef int wf_status; typedef int wfp_status;
#endif #endif

@ -3,8 +3,8 @@
/// \brief Convenience header to include all functionality of libfuse_provider. /// \brief Convenience header to include all functionality of libfuse_provider.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef WF_PROVIDER_H #ifndef WFP_PROVIDER_H
#define WF_PROVIDER_H #define WFP_PROVIDER_H
#include <webfuse_provider/status.h> #include <webfuse_provider/status.h>
#include <webfuse_provider/protocol_names.h> #include <webfuse_provider/protocol_names.h>

@ -19,7 +19,7 @@
void wfp_respond_error( void wfp_respond_error(
struct wfp_request * request, struct wfp_request * request,
wf_status status) wfp_status status)
{ {
wfp_impl_respond_error(request, status); wfp_impl_respond_error(request, status);
} }

@ -1,6 +1,6 @@
#include "webfuse_provider/impl/base64.h" #include "webfuse_provider/impl/base64.h"
static const uint8_t wf_base64_decode_table[256] = { static const uint8_t wfp_base64_decode_table[256] = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F // 0 1 2 3 4 5 6 7 8 9 A B C D E F
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 0 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 0
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 1 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 1
@ -22,12 +22,12 @@ static const uint8_t wf_base64_decode_table[256] = {
size_t wf_base64_encoded_size(size_t length) size_t wfp_base64_encoded_size(size_t length)
{ {
return ((length + 2) / 3) * 4; return ((length + 2) / 3) * 4;
} }
size_t wf_base64_encode( size_t wfp_base64_encode(
uint8_t const * data, uint8_t const * data,
size_t length, size_t length,
char * buffer, char * buffer,
@ -36,7 +36,7 @@ size_t wf_base64_encode(
// 0 1 2 3 4 5 6 // 0 1 2 3 4 5 6
// 0123456789012345678901234567890123456789012345678901234567890123 // 0123456789012345678901234567890123456789012345678901234567890123
static char const table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static char const table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
size_t const length_needed = wf_base64_encoded_size(length); size_t const length_needed = wfp_base64_encoded_size(length);
if (buffer_size < length_needed) if (buffer_size < length_needed)
{ {
return 0; return 0;
@ -78,7 +78,7 @@ size_t wf_base64_encode(
return out_pos; return out_pos;
} }
size_t wf_base64_decoded_size(char const * data, size_t length) size_t wfp_base64_decoded_size(char const * data, size_t length)
{ {
size_t result = 0; size_t result = 0;
if ((length > 0) && ((length % 4) == 0)) if ((length > 0) && ((length % 4) == 0))
@ -98,14 +98,14 @@ size_t wf_base64_decoded_size(char const * data, size_t length)
return result; return result;
} }
size_t wf_base64_decode( size_t wfp_base64_decode(
char const * data, char const * data,
size_t length, size_t length,
uint8_t * buffer, uint8_t * buffer,
size_t buffer_size) size_t buffer_size)
{ {
uint8_t const * table = wf_base64_decode_table; uint8_t const * table = wfp_base64_decode_table;
size_t needed_size = wf_base64_decoded_size(data, length); size_t needed_size = wfp_base64_decoded_size(data, length);
if ((0 == needed_size) || (buffer_size < needed_size)) if ((0 == needed_size) || (buffer_size < needed_size))
{ {
return 0; return 0;
@ -146,9 +146,9 @@ size_t wf_base64_decode(
return out_pos; return out_pos;
} }
extern bool wf_base64_isvalid(char const * data, size_t length) extern bool wfp_base64_isvalid(char const * data, size_t length)
{ {
uint8_t const * table = wf_base64_decode_table; uint8_t const * table = wfp_base64_decode_table;
if ((length == 0) || ((length % 4) != 0)) if ((length == 0) || ((length % 4) != 0))
{ {

@ -1,5 +1,5 @@
#ifndef WF_BASE64_H #ifndef WFP_BASE64_H
#define WF_BASE64_H #define WFP_BASE64_H
#ifndef __cplusplus #ifndef __cplusplus
#include <inttypes.h> #include <inttypes.h>
@ -15,23 +15,23 @@ extern "C"
{ {
#endif #endif
extern size_t wf_base64_encoded_size(size_t length); extern size_t wfp_base64_encoded_size(size_t length);
extern size_t wf_base64_encode( extern size_t wfp_base64_encode(
uint8_t const * data, uint8_t const * data,
size_t length, size_t length,
char * buffer, char * buffer,
size_t buffer_size); size_t buffer_size);
extern size_t wf_base64_decoded_size(char const * data, size_t length); extern size_t wfp_base64_decoded_size(char const * data, size_t length);
extern size_t wf_base64_decode( extern size_t wfp_base64_decode(
char const * data, char const * data,
size_t length, size_t length,
uint8_t * buffer, uint8_t * buffer,
size_t buffer_size); size_t buffer_size);
extern bool wf_base64_isvalid(char const * data, size_t length); extern bool wfp_base64_isvalid(char const * data, size_t length);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -27,7 +27,7 @@ struct wfp_client
struct wfp_client * wfp_impl_client_create( struct wfp_client * wfp_impl_client_create(
struct wfp_client_config * config) struct wfp_client_config * config)
{ {
wf_lwslog_disable(); wfp_lwslog_disable();
struct wfp_client * client = malloc(sizeof(struct wfp_client)); struct wfp_client * client = malloc(sizeof(struct wfp_client));
wfp_impl_client_protocol_init(&client->protocol, &config->provider, config->user_data); wfp_impl_client_protocol_init(&client->protocol, &config->provider, config->user_data);

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

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_CLIENT_CONFIG_H #ifndef WFP_PROVIDER_IMPL_CLIENT_CONFIG_H
#define WF_PROVIDER_IMPL_CLIENT_CONFIG_H #define WFP_PROVIDER_IMPL_CLIENT_CONFIG_H
#include "webfuse_provider/client_config.h" #include "webfuse_provider/client_config.h"
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"

@ -22,7 +22,7 @@
#include "webfuse_provider/impl/jsonrpc/request.h" #include "webfuse_provider/impl/jsonrpc/request.h"
#include "webfuse_provider/impl/jsonrpc/proxy.h" #include "webfuse_provider/impl/jsonrpc/proxy.h"
#define WF_DEFAULT_TIMEOUT (10 * 1000) #define WFP_DEFAULT_TIMEOUT (10 * 1000)
static void wfp_impl_client_protocol_respond( static void wfp_impl_client_protocol_respond(
json_t * response, json_t * response,
@ -30,10 +30,10 @@ static void wfp_impl_client_protocol_respond(
{ {
struct wfp_client_protocol * protocol = (struct wfp_client_protocol *) user_data; struct wfp_client_protocol * protocol = (struct wfp_client_protocol *) user_data;
struct wf_message * message = wf_message_create(response); struct wfp_message * message = wfp_message_create(response);
if (NULL != message) if (NULL != message)
{ {
wf_slist_append(&protocol->messages, &message->item); wfp_slist_append(&protocol->messages, &message->item);
lws_callback_on_writable(protocol->wsi); lws_callback_on_writable(protocol->wsi);
} }
} }
@ -46,12 +46,12 @@ static void wfp_impl_client_protocol_process(
json_t * message = json_loadb(data, length, 0, NULL); json_t * message = json_loadb(data, length, 0, NULL);
if (NULL != message) if (NULL != message)
{ {
if (wf_jsonrpc_is_response(message)) if (wfp_jsonrpc_is_response(message))
{ {
wf_jsonrpc_proxy_onresult(protocol->proxy, message); wfp_jsonrpc_proxy_onresult(protocol->proxy, message);
} }
if (wf_jsonrpc_is_request(message)) if (wfp_jsonrpc_is_request(message))
{ {
struct wfp_impl_invokation_context context = struct wfp_impl_invokation_context context =
{ {
@ -71,7 +71,7 @@ static void
wfp_impl_client_protocol_on_add_filesystem_finished( wfp_impl_client_protocol_on_add_filesystem_finished(
void * user_data, void * user_data,
json_t const * result, json_t const * result,
json_t const * WF_UNUSED_PARAM(error)) json_t const * WFP_UNUSED_PARAM(error))
{ {
struct wfp_client_protocol * protocol = user_data; struct wfp_client_protocol * protocol = user_data;
if (NULL == protocol->wsi) { return; } if (NULL == protocol->wsi) { return; }
@ -91,7 +91,7 @@ wfp_impl_client_protocol_on_add_filesystem_finished(
static void wfp_impl_client_protocol_add_filesystem( static void wfp_impl_client_protocol_add_filesystem(
struct wfp_client_protocol * protocol) struct wfp_client_protocol * protocol)
{ {
wf_jsonrpc_proxy_invoke( wfp_jsonrpc_proxy_invoke(
protocol->proxy, protocol->proxy,
&wfp_impl_client_protocol_on_add_filesystem_finished, &wfp_impl_client_protocol_on_add_filesystem_finished,
protocol, protocol,
@ -104,7 +104,7 @@ static void
wfp_impl_client_protocol_on_authenticate_finished( wfp_impl_client_protocol_on_authenticate_finished(
void * user_data, void * user_data,
json_t const * result, json_t const * result,
json_t const * WF_UNUSED_PARAM(error)) json_t const * WFP_UNUSED_PARAM(error))
{ {
struct wfp_client_protocol * protocol = user_data; struct wfp_client_protocol * protocol = user_data;
if (NULL == protocol->wsi) { return; } if (NULL == protocol->wsi) { return; }
@ -132,7 +132,7 @@ static void wfp_impl_client_protocol_authenticate(
json_t * creds = wfp_impl_credentials_get(&credentials); json_t * creds = wfp_impl_credentials_get(&credentials);
json_incref(creds); json_incref(creds);
wf_jsonrpc_proxy_invoke( wfp_jsonrpc_proxy_invoke(
protocol->proxy, protocol->proxy,
&wfp_impl_client_protocol_on_authenticate_finished, &wfp_impl_client_protocol_on_authenticate_finished,
protocol, protocol,
@ -159,7 +159,7 @@ static void wfp_impl_client_protocol_handshake(
static int wfp_impl_client_protocol_callback( static int wfp_impl_client_protocol_callback(
struct lws * wsi, struct lws * wsi,
enum lws_callback_reasons reason, enum lws_callback_reasons reason,
void * WF_UNUSED_PARAM(user), void * WFP_UNUSED_PARAM(user),
void * in, void * in,
size_t len) size_t len)
{ {
@ -169,7 +169,7 @@ static int wfp_impl_client_protocol_callback(
if (NULL != protocol) if (NULL != protocol)
{ {
wf_timer_manager_check(protocol->timer_manager); wfp_timer_manager_check(protocol->timer_manager);
switch (reason) switch (reason)
{ {
@ -197,14 +197,14 @@ static int wfp_impl_client_protocol_callback(
{ {
result = 1; result = 1;
} }
else if (!wf_slist_empty(&protocol->messages)) else if (!wfp_slist_empty(&protocol->messages))
{ {
struct wf_slist_item * item = wf_slist_remove_first(&protocol->messages); struct wfp_slist_item * item = wfp_slist_remove_first(&protocol->messages);
struct wf_message * message = wf_container_of(item, struct wf_message, item); struct wfp_message * message = wfp_container_of(item, struct wfp_message, item);
lws_write(wsi, (unsigned char*) message->data, message->length, LWS_WRITE_TEXT); lws_write(wsi, (unsigned char*) message->data, message->length, LWS_WRITE_TEXT);
wf_message_dispose(message); wfp_message_dispose(message);
if (!wf_slist_empty(&protocol->messages)) if (!wfp_slist_empty(&protocol->messages))
{ {
lws_callback_on_writable(wsi); lws_callback_on_writable(wsi);
} }
@ -226,10 +226,10 @@ static bool wfp_impl_client_protocol_send(
bool result = false; bool result = false;
struct wfp_client_protocol * protocol = user_data; struct wfp_client_protocol * protocol = user_data;
struct wf_message * message = wf_message_create(request); struct wfp_message * message = wfp_message_create(request);
if (NULL != message) if (NULL != message)
{ {
wf_slist_append(&protocol->messages, &message->item); wfp_slist_append(&protocol->messages, &message->item);
lws_callback_on_writable(protocol->wsi); lws_callback_on_writable(protocol->wsi);
result = true; result = true;
} }
@ -244,15 +244,15 @@ void wfp_impl_client_protocol_init(
{ {
protocol->is_connected = false; protocol->is_connected = false;
protocol->is_shutdown_requested = false; protocol->is_shutdown_requested = false;
wf_slist_init(&protocol->messages); wfp_slist_init(&protocol->messages);
protocol->wsi = NULL; protocol->wsi = NULL;
protocol->request.respond = &wfp_impl_client_protocol_respond; protocol->request.respond = &wfp_impl_client_protocol_respond;
protocol->request.user_data = protocol; protocol->request.user_data = protocol;
protocol->timer_manager = wf_timer_manager_create(); protocol->timer_manager = wfp_timer_manager_create();
protocol->proxy = wf_jsonrpc_proxy_create(protocol->timer_manager, WF_DEFAULT_TIMEOUT, &wfp_impl_client_protocol_send, protocol); protocol->proxy = wfp_jsonrpc_proxy_create(protocol->timer_manager, WFP_DEFAULT_TIMEOUT, &wfp_impl_client_protocol_send, protocol);
protocol->user_data = user_data; protocol->user_data = user_data;
wfp_impl_provider_init_from_prototype(&protocol->provider, provider); wfp_impl_provider_init_from_prototype(&protocol->provider, provider);
@ -261,9 +261,9 @@ void wfp_impl_client_protocol_init(
void wfp_impl_client_protocol_cleanup( void wfp_impl_client_protocol_cleanup(
struct wfp_client_protocol * protocol) struct wfp_client_protocol * protocol)
{ {
wf_jsonrpc_proxy_dispose(protocol->proxy); wfp_jsonrpc_proxy_dispose(protocol->proxy);
wf_timer_manager_dispose(protocol->timer_manager); wfp_timer_manager_dispose(protocol->timer_manager);
wf_message_queue_cleanup(&protocol->messages); wfp_message_queue_cleanup(&protocol->messages);
} }
struct wfp_client_protocol * wfp_impl_client_protocol_create( struct wfp_client_protocol * wfp_impl_client_protocol_create(
@ -286,7 +286,7 @@ void wfp_impl_client_protocol_init_lws(
struct wfp_client_protocol * protocol, struct wfp_client_protocol * protocol,
struct lws_protocols * lws_protocol) struct lws_protocols * lws_protocol)
{ {
lws_protocol->name = WF_PROTOCOL_NAME_PROVIDER_CLIENT; lws_protocol->name = WFP_PROTOCOL_NAME_PROVIDER_CLIENT;
lws_protocol->callback = &wfp_impl_client_protocol_callback; lws_protocol->callback = &wfp_impl_client_protocol_callback;
lws_protocol->per_session_data_size = 0; lws_protocol->per_session_data_size = 0;
lws_protocol->user = protocol; lws_protocol->user = protocol;
@ -297,8 +297,8 @@ void wfp_impl_client_protocol_connect(
struct lws_context * context, struct lws_context * context,
char const * url) char const * url)
{ {
struct wf_url url_data; struct wfp_url url_data;
bool const success = wf_url_init(&url_data, url); bool const success = wfp_url_init(&url_data, url);
if (success) if (success)
{ {
struct lws_client_connect_info info; struct lws_client_connect_info info;
@ -310,13 +310,13 @@ void wfp_impl_client_protocol_connect(
info.host = info.address; info.host = info.address;
info.origin = info.address; info.origin = info.address;
info.ssl_connection = (url_data.use_tls) ? LCCSCF_USE_SSL : 0; info.ssl_connection = (url_data.use_tls) ? LCCSCF_USE_SSL : 0;
info.protocol = WF_PROTOCOL_NAME_ADAPTER_SERVER; info.protocol = WFP_PROTOCOL_NAME_ADAPTER_SERVER;
info.local_protocol_name = WF_PROTOCOL_NAME_PROVIDER_CLIENT; info.local_protocol_name = WFP_PROTOCOL_NAME_PROVIDER_CLIENT;
info.pwsi = &protocol->wsi; info.pwsi = &protocol->wsi;
lws_client_connect_via_info(&info); lws_client_connect_via_info(&info);
wf_url_cleanup(&url_data); wfp_url_cleanup(&url_data);
} }
else else
{ {

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_CLIENT_PROTOCOL_H #ifndef WFP_PROVIDER_IMPL_CLIENT_PROTOCOL_H
#define WF_PROVIDER_IMPL_CLIENT_PROTOCOL_H #define WFP_PROVIDER_IMPL_CLIENT_PROTOCOL_H
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"
#include "webfuse_provider/impl/request.h" #include "webfuse_provider/impl/request.h"
@ -14,8 +14,8 @@ extern "C"
struct wfp_client_config; struct wfp_client_config;
struct lws_protocols; struct lws_protocols;
struct lws_context; struct lws_context;
struct wf_jsonrpc_proxy; struct wfp_jsonrpc_proxy;
struct wf_timer_manager; struct wfp_timer_manager;
struct wfp_client_protocol struct wfp_client_protocol
{ {
@ -25,9 +25,9 @@ struct wfp_client_protocol
struct wfp_provider provider; struct wfp_provider provider;
void * user_data; void * user_data;
struct lws * wsi; struct lws * wsi;
struct wf_timer_manager * timer_manager; struct wfp_timer_manager * timer_manager;
struct wf_jsonrpc_proxy * proxy; struct wfp_jsonrpc_proxy * proxy;
struct wf_slist messages; struct wfp_slist messages;
}; };
extern void wfp_impl_client_protocol_init( extern void wfp_impl_client_protocol_init(

@ -1,5 +1,5 @@
#ifndef WF_CONTAINER_OF_H #ifndef WFP_CONTAINER_OF_H
#define WF_CONTAINER_OF_H #define WFP_CONTAINER_OF_H
#ifndef __cplusplus #ifndef __cplusplus
#include <stddef.h> #include <stddef.h>
@ -8,13 +8,13 @@
#endif #endif
#ifdef __GNUC__ #ifdef __GNUC__
#define wf_container_of(pointer, type, member) \ #define wfp_container_of(pointer, type, member) \
({ \ ({ \
const typeof( ((type *)0)->member ) * __member = (pointer); \ const typeof( ((type *)0)->member ) * __member = (pointer); \
(type *)( (char *)__member - offsetof(type, member) ); \ (type *)( (char *)__member - offsetof(type, member) ); \
}) })
#else #else
#define wf_container_of(pointer, type, member) \ #define wfp_container_of(pointer, type, member) \
(type *) (((char *) pointer) - offsetof(type, member)) (type *) (((char *) pointer) - offsetof(type, member))
#endif #endif

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_CREDENTIALS_H #ifndef WFP_PROVIDER_IMPL_CREDENTIALS_H
#define WF_PROVIDER_IMPL_CREDENTIALS_H #define WFP_PROVIDER_IMPL_CREDENTIALS_H
#include "webfuse_provider/credentials.h" #include "webfuse_provider/credentials.h"
#include <jansson.h> #include <jansson.h>

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_DIRBUFFER_H #ifndef WFP_PROVIDER_IMPL_DIRBUFFER_H
#define WF_PROVIDER_IMPL_DIRBUFFER_H #define WFP_PROVIDER_IMPL_DIRBUFFER_H
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>

@ -1,6 +1,6 @@
#include "webfuse_provider/impl/json_util.h" #include "webfuse_provider/impl/json_util.h"
int wf_impl_json_get_int(json_t const * object, char const * key, int default_value) int wfp_impl_json_get_int(json_t const * object, char const * key, int default_value)
{ {
int result = default_value; int result = default_value;
@ -13,14 +13,14 @@ int wf_impl_json_get_int(json_t const * object, char const * key, int default_va
return result; return result;
} }
wf_status wfp_status
wf_impl_jsonrpc_get_status( wfp_impl_jsonrpc_get_status(
json_t const * error) json_t const * error)
{ {
wf_status status = WF_GOOD; wfp_status status = WFP_GOOD;
if (NULL != error) if (NULL != error)
{ {
status = wf_impl_json_get_int(error, "code", WF_BAD_FORMAT); status = wfp_impl_json_get_int(error, "code", WFP_BAD_FORMAT);
} }
return status; return status;

@ -1,5 +1,5 @@
#ifndef WF_JSON_UTIL_H #ifndef WFP_JSON_UTIL_H
#define WF_JSON_UTIL_H #define WFP_JSON_UTIL_H
#include <jansson.h> #include <jansson.h>
#include "webfuse_provider/status.h" #include "webfuse_provider/status.h"
@ -10,13 +10,13 @@ extern "C"
#endif #endif
extern int extern int
wf_impl_json_get_int( wfp_impl_json_get_int(
json_t const * object, json_t const * object,
char const * key, char const * key,
int default_value); int default_value);
extern wf_status extern wfp_status
wf_impl_jsonrpc_get_status( wfp_impl_jsonrpc_get_status(
json_t const * error); json_t const * error);
#ifdef __cplusplus #ifdef __cplusplus

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

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_ERROR_H #ifndef WFP_JSONRPC_ERROR_H
#define WF_JSONRPC_ERROR_H #define WFP_JSONRPC_ERROR_H
#include <jansson.h> #include <jansson.h>
#include "webfuse_provider/impl/jsonrpc/proxy_finished_fn.h" #include "webfuse_provider/impl/jsonrpc/proxy_finished_fn.h"
@ -10,13 +10,13 @@ extern "C"
#endif #endif
extern json_t * extern json_t *
wf_jsonrpc_error( wfp_jsonrpc_error(
int code, int code,
char const * message); char const * message);
extern void extern void
wf_jsonrpc_propate_error( wfp_jsonrpc_propate_error(
wf_jsonrpc_proxy_finished_fn * finised, wfp_jsonrpc_proxy_finished_fn * finised,
void * user_data, void * user_data,
int code, int code,
char const * message); char const * message);

@ -2,12 +2,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
struct wf_jsonrpc_method * wf_jsonrpc_method_create( struct wfp_jsonrpc_method * wfp_jsonrpc_method_create(
char const * method_name, char const * method_name,
wf_jsonrpc_method_invoke_fn * invoke, wfp_jsonrpc_method_invoke_fn * invoke,
void * user_data) void * user_data)
{ {
struct wf_jsonrpc_method * method = malloc(sizeof(struct wf_jsonrpc_method)); struct wfp_jsonrpc_method * method = malloc(sizeof(struct wfp_jsonrpc_method));
method->next = NULL; method->next = NULL;
method->name = strdup(method_name); method->name = strdup(method_name);
method->invoke = invoke; method->invoke = invoke;
@ -16,8 +16,8 @@ struct wf_jsonrpc_method * wf_jsonrpc_method_create(
return method; return method;
} }
void wf_jsonrpc_method_dispose( void wfp_jsonrpc_method_dispose(
struct wf_jsonrpc_method * method) struct wfp_jsonrpc_method * method)
{ {
free(method->name); free(method->name);
free(method); free(method);

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_METHOD_H #ifndef WFP_JSONRPC_METHOD_H
#define WF_JSONRPC_METHOD_H #define WFP_JSONRPC_METHOD_H
#include "webfuse_provider/impl/jsonrpc/method_invoke_fn.h" #include "webfuse_provider/impl/jsonrpc/method_invoke_fn.h"
@ -8,23 +8,23 @@ extern "C"
{ {
#endif #endif
struct wf_jsonrpc_method struct wfp_jsonrpc_method
{ {
struct wf_jsonrpc_method * next; struct wfp_jsonrpc_method * next;
char * name; char * name;
wf_jsonrpc_method_invoke_fn * invoke; wfp_jsonrpc_method_invoke_fn * invoke;
void * user_data; void * user_data;
}; };
extern struct wf_jsonrpc_method * extern struct wfp_jsonrpc_method *
wf_jsonrpc_method_create( wfp_jsonrpc_method_create(
char const * method_name, char const * method_name,
wf_jsonrpc_method_invoke_fn * invoke, wfp_jsonrpc_method_invoke_fn * invoke,
void * user_data); void * user_data);
extern void extern void
wf_jsonrpc_method_dispose( wfp_jsonrpc_method_dispose(
struct wf_jsonrpc_method * method); struct wfp_jsonrpc_method * method);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_METHOD_INVOKE_FN_H #ifndef WFP_JSONRPC_METHOD_INVOKE_FN_H
#define WF_JSONRPC_METHOD_INVOKE_FN_H #define WFP_JSONRPC_METHOD_INVOKE_FN_H
#include <jansson.h> #include <jansson.h>
@ -8,10 +8,10 @@ extern "C"
{ {
#endif #endif
struct wf_jsonrpc_request; struct wfp_jsonrpc_request;
typedef void wf_jsonrpc_method_invoke_fn( typedef void wfp_jsonrpc_method_invoke_fn(
struct wf_jsonrpc_request * request, struct wfp_jsonrpc_request * request,
char const * method_name, char const * method_name,
json_t * params, json_t * params,
void * user_data); void * user_data);

@ -8,47 +8,47 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
struct wf_jsonrpc_proxy * struct wfp_jsonrpc_proxy *
wf_jsonrpc_proxy_create( wfp_jsonrpc_proxy_create(
struct wf_timer_manager * manager, struct wfp_timer_manager * manager,
int timeout, int timeout,
wf_jsonrpc_send_fn * send, wfp_jsonrpc_send_fn * send,
void * user_data) void * user_data)
{ {
struct wf_jsonrpc_proxy * proxy = malloc(sizeof(struct wf_jsonrpc_proxy)); struct wfp_jsonrpc_proxy * proxy = malloc(sizeof(struct wfp_jsonrpc_proxy));
wf_jsonrpc_proxy_init(proxy, manager, timeout, send, user_data); wfp_jsonrpc_proxy_init(proxy, manager, timeout, send, user_data);
return proxy; return proxy;
} }
void wf_jsonrpc_proxy_dispose( void wfp_jsonrpc_proxy_dispose(
struct wf_jsonrpc_proxy * proxy) struct wfp_jsonrpc_proxy * proxy)
{ {
wf_jsonrpc_proxy_cleanup(proxy); wfp_jsonrpc_proxy_cleanup(proxy);
free(proxy); free(proxy);
} }
static void wf_jsonrpc_proxy_on_timeout( static void wfp_jsonrpc_proxy_on_timeout(
struct wf_timer * timer, void * proxy_ptr) struct wfp_timer * timer, void * proxy_ptr)
{ {
struct wf_jsonrpc_proxy * proxy = proxy_ptr; struct wfp_jsonrpc_proxy * proxy = proxy_ptr;
if (proxy->request.is_pending) if (proxy->request.is_pending)
{ {
wf_jsonrpc_proxy_finished_fn * finished = proxy->request.finished; wfp_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
void * user_data = proxy->request.user_data; void * user_data = proxy->request.user_data;
proxy->request.is_pending = false; proxy->request.is_pending = false;
proxy->request.id = 0; proxy->request.id = 0;
proxy->request.user_data = NULL; proxy->request.user_data = NULL;
proxy->request.finished = NULL; proxy->request.finished = NULL;
wf_timer_cancel(timer); wfp_timer_cancel(timer);
wf_jsonrpc_propate_error(finished, user_data, WF_BAD_TIMEOUT, "Timeout"); wfp_jsonrpc_propate_error(finished, user_data, WFP_BAD_TIMEOUT, "Timeout");
} }
} }
static json_t * wf_jsonrpc_request_create( static json_t * wfp_jsonrpc_request_create(
char const * method, char const * method,
int id, int id,
char const * param_info, char const * param_info,
@ -98,44 +98,44 @@ static json_t * wf_jsonrpc_request_create(
return request; return request;
} }
void wf_jsonrpc_proxy_init( void wfp_jsonrpc_proxy_init(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
struct wf_timer_manager * timeout_manager, struct wfp_timer_manager * timeout_manager,
int timeout, int timeout,
wf_jsonrpc_send_fn * send, wfp_jsonrpc_send_fn * send,
void * user_data) void * user_data)
{ {
proxy->send = send; proxy->send = send;
proxy->timeout = timeout; proxy->timeout = timeout;
proxy->user_data = user_data; proxy->user_data = user_data;
proxy->request.is_pending = false; proxy->request.is_pending = false;
proxy->request.timer = wf_timer_create(timeout_manager, proxy->request.timer = wfp_timer_create(timeout_manager,
&wf_jsonrpc_proxy_on_timeout, proxy); &wfp_jsonrpc_proxy_on_timeout, proxy);
} }
void wf_jsonrpc_proxy_cleanup( void wfp_jsonrpc_proxy_cleanup(
struct wf_jsonrpc_proxy * proxy) struct wfp_jsonrpc_proxy * proxy)
{ {
if (proxy->request.is_pending) if (proxy->request.is_pending)
{ {
void * user_data = proxy->request.user_data; void * user_data = proxy->request.user_data;
wf_jsonrpc_proxy_finished_fn * finished = proxy->request.finished; wfp_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
proxy->request.is_pending = false; proxy->request.is_pending = false;
proxy->request.finished = NULL; proxy->request.finished = NULL;
proxy->request.user_data = NULL; proxy->request.user_data = NULL;
proxy->request.id = 0; proxy->request.id = 0;
wf_timer_cancel(proxy->request.timer); wfp_timer_cancel(proxy->request.timer);
wf_jsonrpc_propate_error(finished, user_data, WF_BAD, "Bad: cancelled pending request during shutdown"); wfp_jsonrpc_propate_error(finished, user_data, WFP_BAD, "Bad: cancelled pending request during shutdown");
} }
wf_timer_dispose(proxy->request.timer); wfp_timer_dispose(proxy->request.timer);
} }
void wf_jsonrpc_proxy_vinvoke( void wfp_jsonrpc_proxy_vinvoke(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished, wfp_jsonrpc_proxy_finished_fn * finished,
void * user_data, void * user_data,
char const * method_name, char const * method_name,
char const * param_info, char const * param_info,
@ -147,9 +147,9 @@ void wf_jsonrpc_proxy_vinvoke(
proxy->request.finished = finished; proxy->request.finished = finished;
proxy->request.user_data = user_data; proxy->request.user_data = user_data;
proxy->request.id = 42; proxy->request.id = 42;
wf_timer_start(proxy->request.timer, proxy->timeout); wfp_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 = wfp_jsonrpc_request_create(method_name, proxy->request.id, param_info, args);
bool const is_send = ((NULL != request) && (proxy->send(request, proxy->user_data))); bool const is_send = ((NULL != request) && (proxy->send(request, proxy->user_data)));
if (!is_send) if (!is_send)
@ -158,9 +158,9 @@ void wf_jsonrpc_proxy_vinvoke(
proxy->request.finished = NULL; proxy->request.finished = NULL;
proxy->request.user_data = NULL; proxy->request.user_data = NULL;
proxy->request.id = 0; proxy->request.id = 0;
wf_timer_cancel(proxy->request.timer); wfp_timer_cancel(proxy->request.timer);
wf_jsonrpc_propate_error(finished, user_data, WF_BAD, "Bad: requenst is not sent"); wfp_jsonrpc_propate_error(finished, user_data, WFP_BAD, "Bad: requenst is not sent");
} }
if (NULL != request) if (NULL != request)
@ -170,17 +170,17 @@ void wf_jsonrpc_proxy_vinvoke(
} }
else else
{ {
wf_jsonrpc_propate_error(finished, user_data, WF_BAD_BUSY, "Busy"); wfp_jsonrpc_propate_error(finished, user_data, WFP_BAD_BUSY, "Busy");
} }
} }
extern void wf_jsonrpc_proxy_vnotify( extern void wfp_jsonrpc_proxy_vnotify(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
char const * method_name, char const * method_name,
char const * param_info, char const * param_info,
va_list args) va_list args)
{ {
json_t * request = wf_jsonrpc_request_create(method_name, 0, param_info, args); json_t * request = wfp_jsonrpc_request_create(method_name, 0, param_info, args);
if (NULL != request) if (NULL != request)
{ {
@ -190,27 +190,27 @@ extern void wf_jsonrpc_proxy_vnotify(
} }
void wf_jsonrpc_proxy_onresult( void wfp_jsonrpc_proxy_onresult(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
json_t * message) json_t * message)
{ {
struct wf_jsonrpc_response response; struct wfp_jsonrpc_response response;
wf_jsonrpc_response_init(&response, message); wfp_jsonrpc_response_init(&response, message);
if ((proxy->request.is_pending) && (response.id == proxy->request.id)) if ((proxy->request.is_pending) && (response.id == proxy->request.id))
{ {
wf_jsonrpc_proxy_finished_fn * finished = proxy->request.finished; wfp_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
void * user_data = proxy->request.user_data; void * user_data = proxy->request.user_data;
proxy->request.is_pending = false; proxy->request.is_pending = false;
proxy->request.id = 0; proxy->request.id = 0;
proxy->request.user_data = NULL; proxy->request.user_data = NULL;
proxy->request.finished = NULL; proxy->request.finished = NULL;
wf_timer_cancel(proxy->request.timer); wfp_timer_cancel(proxy->request.timer);
finished(user_data, response.result, response.error); finished(user_data, response.result, response.error);
} }
wf_jsonrpc_response_cleanup(&response); wfp_jsonrpc_response_cleanup(&response);
} }

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_PROXY_H #ifndef WFP_JSONRPC_PROXY_H
#define WF_JSONRPC_PROXY_H #define WFP_JSONRPC_PROXY_H
#ifndef __cplusplus #ifndef __cplusplus
#include <stdarg.h> #include <stdarg.h>
@ -19,18 +19,18 @@ using std::size_t;
extern "C" { extern "C" {
#endif #endif
struct wf_jsonrpc_proxy; struct wfp_jsonrpc_proxy;
struct wf_timer_manager; struct wfp_timer_manager;
extern struct wf_jsonrpc_proxy * extern struct wfp_jsonrpc_proxy *
wf_jsonrpc_proxy_create( wfp_jsonrpc_proxy_create(
struct wf_timer_manager * manager, struct wfp_timer_manager * manager,
int timeout, int timeout,
wf_jsonrpc_send_fn * send, wfp_jsonrpc_send_fn * send,
void * user_data); void * user_data);
extern void wf_jsonrpc_proxy_dispose( extern void wfp_jsonrpc_proxy_dispose(
struct wf_jsonrpc_proxy * proxy); struct wfp_jsonrpc_proxy * proxy);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/// \brief Invokes a method. /// \brief Invokes a method.
@ -46,24 +46,24 @@ extern void wf_jsonrpc_proxy_dispose(
/// \param param_info types of the param (s = string, i = integer, j = json) /// \param param_info types of the param (s = string, i = integer, j = json)
/// \param ... params /// \param ... params
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
extern void wf_jsonrpc_proxy_invoke( extern void wfp_jsonrpc_proxy_invoke(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished, wfp_jsonrpc_proxy_finished_fn * finished,
void * user_data, void * user_data,
char const * method_name, char const * method_name,
char const * param_info, char const * param_info,
... ...
); );
extern void wf_jsonrpc_proxy_notify( extern void wfp_jsonrpc_proxy_notify(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
char const * method_name, char const * method_name,
char const * param_info, char const * param_info,
... ...
); );
extern void wf_jsonrpc_proxy_onresult( extern void wfp_jsonrpc_proxy_onresult(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
json_t * message); json_t * message);
#ifdef __cplusplus #ifdef __cplusplus

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_PROXY_FINISHED_FN_H #ifndef WFP_JSONRPC_PROXY_FINISHED_FN_H
#define WF_JSONRPC_PROXY_FINISHED_FN_H #define WFP_JSONRPC_PROXY_FINISHED_FN_H
#include <jansson.h> #include <jansson.h>
@ -8,7 +8,7 @@ extern "C"
{ {
#endif #endif
typedef void wf_jsonrpc_proxy_finished_fn( typedef void wfp_jsonrpc_proxy_finished_fn(
void * user_data, void * user_data,
json_t const * result, json_t const * result,
json_t const * error); json_t const * error);

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_PROXY_INTERN_H #ifndef WFP_JSONRPC_PROXY_INTERN_H
#define WF_JSONRPC_PROXY_INTERN_H #define WFP_JSONRPC_PROXY_INTERN_H
#include "webfuse_provider/impl/jsonrpc/proxy.h" #include "webfuse_provider/impl/jsonrpc/proxy.h"
#include "webfuse_provider/impl/jsonrpc/proxy_finished_fn.h" #include "webfuse_provider/impl/jsonrpc/proxy_finished_fn.h"
@ -10,47 +10,47 @@ extern "C"
{ {
#endif #endif
struct wf_timer; struct wfp_timer;
struct wf_jsonrpc_request struct wfp_jsonrpc_request
{ {
bool is_pending; bool is_pending;
wf_jsonrpc_proxy_finished_fn * finished; wfp_jsonrpc_proxy_finished_fn * finished;
void * user_data; void * user_data;
int id; int id;
struct wf_timer * timer; struct wfp_timer * timer;
}; };
struct wf_jsonrpc_proxy struct wfp_jsonrpc_proxy
{ {
struct wf_jsonrpc_request request; struct wfp_jsonrpc_request request;
int timeout; int timeout;
wf_jsonrpc_send_fn * send; wfp_jsonrpc_send_fn * send;
void * user_data; void * user_data;
}; };
extern void extern void
wf_jsonrpc_proxy_init( wfp_jsonrpc_proxy_init(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
struct wf_timer_manager * manager, struct wfp_timer_manager * manager,
int timeout, int timeout,
wf_jsonrpc_send_fn * send, wfp_jsonrpc_send_fn * send,
void * user_data); void * user_data);
extern void extern void
wf_jsonrpc_proxy_cleanup( wfp_jsonrpc_proxy_cleanup(
struct wf_jsonrpc_proxy * proxy); struct wfp_jsonrpc_proxy * proxy);
extern void wf_jsonrpc_proxy_vinvoke( extern void wfp_jsonrpc_proxy_vinvoke(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished, wfp_jsonrpc_proxy_finished_fn * finished,
void * user_data, void * user_data,
char const * method_name, char const * method_name,
char const * param_info, char const * param_info,
va_list args); va_list args);
extern void wf_jsonrpc_proxy_vnotify( extern void wfp_jsonrpc_proxy_vnotify(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
char const * method_name, char const * method_name,
char const * param_info, char const * param_info,
va_list args); va_list args);

@ -1,8 +1,8 @@
#include "webfuse_provider/impl/jsonrpc/proxy_intern.h" #include "webfuse_provider/impl/jsonrpc/proxy_intern.h"
void wf_jsonrpc_proxy_invoke( void wfp_jsonrpc_proxy_invoke(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished, wfp_jsonrpc_proxy_finished_fn * finished,
void * user_data, void * user_data,
char const * method_name, char const * method_name,
char const * param_info, char const * param_info,
@ -10,12 +10,12 @@ void wf_jsonrpc_proxy_invoke(
{ {
va_list args; va_list args;
va_start(args, param_info); va_start(args, param_info);
wf_jsonrpc_proxy_vinvoke(proxy, finished, user_data, method_name, param_info, args); wfp_jsonrpc_proxy_vinvoke(proxy, finished, user_data, method_name, param_info, args);
va_end(args); va_end(args);
} }
extern void wf_jsonrpc_proxy_notify( extern void wfp_jsonrpc_proxy_notify(
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
char const * method_name, char const * method_name,
char const * param_info, char const * param_info,
... ...
@ -23,6 +23,6 @@ extern void wf_jsonrpc_proxy_notify(
{ {
va_list args; va_list args;
va_start(args, param_info); va_start(args, param_info);
wf_jsonrpc_proxy_vnotify(proxy, method_name, param_info, args); wfp_jsonrpc_proxy_vnotify(proxy, method_name, param_info, args);
va_end(args); va_end(args);
} }

@ -2,15 +2,15 @@
#include "webfuse_provider/impl/jsonrpc/error.h" #include "webfuse_provider/impl/jsonrpc/error.h"
#include <stdlib.h> #include <stdlib.h>
struct wf_jsonrpc_request struct wfp_jsonrpc_request
{ {
int id; int id;
wf_jsonrpc_send_fn * send; wfp_jsonrpc_send_fn * send;
void * user_data; void * user_data;
}; };
bool bool
wf_jsonrpc_is_request( wfp_jsonrpc_is_request(
json_t * message) json_t * message)
{ {
json_t * id = json_object_get(message, "id"); json_t * id = json_object_get(message, "id");
@ -22,13 +22,13 @@ wf_jsonrpc_is_request(
} }
struct wf_jsonrpc_request * struct wfp_jsonrpc_request *
wf_jsonrpc_request_create( wfp_jsonrpc_request_create(
int id, int id,
wf_jsonrpc_send_fn * send, wfp_jsonrpc_send_fn * send,
void * user_data) void * user_data)
{ {
struct wf_jsonrpc_request * request = malloc(sizeof(struct wf_jsonrpc_request)); struct wfp_jsonrpc_request * request = malloc(sizeof(struct wfp_jsonrpc_request));
request->id = id; request->id = id;
request->send = send; request->send = send;
request->user_data = user_data; request->user_data = user_data;
@ -37,23 +37,23 @@ wf_jsonrpc_request_create(
} }
void void
wf_jsonrpc_request_dispose( wfp_jsonrpc_request_dispose(
struct wf_jsonrpc_request * request) struct wfp_jsonrpc_request * request)
{ {
free(request); free(request);
} }
void * void *
wf_jsonrpc_request_get_userdata( wfp_jsonrpc_request_get_userdata(
struct wf_jsonrpc_request * request) struct wfp_jsonrpc_request * request)
{ {
return request->user_data; return request->user_data;
} }
void void
wf_jsonrpc_respond( wfp_jsonrpc_respond(
struct wf_jsonrpc_request * request, struct wfp_jsonrpc_request * request,
json_t * result) json_t * result)
{ {
json_t * response = json_object(); json_t * response = json_object();
@ -62,20 +62,20 @@ wf_jsonrpc_respond(
request->send(response, request->user_data); request->send(response, request->user_data);
json_decref(response); json_decref(response);
wf_jsonrpc_request_dispose(request); wfp_jsonrpc_request_dispose(request);
} }
void wf_jsonrpc_respond_error( void wfp_jsonrpc_respond_error(
struct wf_jsonrpc_request * request, struct wfp_jsonrpc_request * request,
int code, int code,
char const * message) char const * message)
{ {
json_t * response = json_object(); json_t * response = json_object();
json_object_set_new(response, "error", wf_jsonrpc_error(code, message)); json_object_set_new(response, "error", wfp_jsonrpc_error(code, message));
json_object_set_new(response, "id", json_integer(request->id)); json_object_set_new(response, "id", json_integer(request->id));
request->send(response, request->user_data); request->send(response, request->user_data);
json_decref(response); json_decref(response);
wf_jsonrpc_request_dispose(request); wfp_jsonrpc_request_dispose(request);
} }

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_REQUEST_H #ifndef WFP_JSONRPC_REQUEST_H
#define WF_JSONRPC_REQUEST_H #define WFP_JSONRPC_REQUEST_H
#ifndef __cplusplus #ifndef __cplusplus
#include <stdarg.h> #include <stdarg.h>
@ -19,29 +19,29 @@ extern "C"
{ {
#endif #endif
struct wf_jsonrpc_request; struct wfp_jsonrpc_request;
extern bool wf_jsonrpc_is_request( extern bool wfp_jsonrpc_is_request(
json_t * message); json_t * message);
extern struct wf_jsonrpc_request * extern struct wfp_jsonrpc_request *
wf_jsonrpc_request_create( wfp_jsonrpc_request_create(
int id, int id,
wf_jsonrpc_send_fn * send, wfp_jsonrpc_send_fn * send,
void * user_data); void * user_data);
extern void wf_jsonrpc_request_dispose( extern void wfp_jsonrpc_request_dispose(
struct wf_jsonrpc_request * request); struct wfp_jsonrpc_request * request);
extern void * wf_jsonrpc_request_get_userdata( extern void * wfp_jsonrpc_request_get_userdata(
struct wf_jsonrpc_request * request); struct wfp_jsonrpc_request * request);
extern void wf_jsonrpc_respond( extern void wfp_jsonrpc_respond(
struct wf_jsonrpc_request * request, struct wfp_jsonrpc_request * request,
json_t * result); json_t * result);
extern void wf_jsonrpc_respond_error( extern void wfp_jsonrpc_respond_error(
struct wf_jsonrpc_request * request, struct wfp_jsonrpc_request * request,
int code, int code,
char const * message); char const * message);

@ -3,7 +3,7 @@
#include "webfuse_provider/status.h" #include "webfuse_provider/status.h"
bool bool
wf_jsonrpc_is_response( wfp_jsonrpc_is_response(
json_t * message) json_t * message)
{ {
json_t * id = json_object_get(message, "id"); json_t * id = json_object_get(message, "id");
@ -16,8 +16,8 @@ wf_jsonrpc_is_response(
void void
wf_jsonrpc_response_init( wfp_jsonrpc_response_init(
struct wf_jsonrpc_response * result, struct wfp_jsonrpc_response * result,
json_t * response) json_t * response)
{ {
result->id = -1; result->id = -1;
@ -27,7 +27,7 @@ wf_jsonrpc_response_init(
json_t * id_holder = json_object_get(response, "id"); json_t * id_holder = json_object_get(response, "id");
if (!json_is_integer(id_holder)) if (!json_is_integer(id_holder))
{ {
result->error = wf_jsonrpc_error(WF_BAD_FORMAT, "invalid format: missing id"); result->error = wfp_jsonrpc_error(WFP_BAD_FORMAT, "invalid format: missing id");
return; return;
} }
@ -47,14 +47,14 @@ wf_jsonrpc_response_init(
} }
else else
{ {
result->error = wf_jsonrpc_error(WF_BAD_FORMAT, "invalid format: invalid error object"); result->error = wfp_jsonrpc_error(WFP_BAD_FORMAT, "invalid format: invalid error object");
} }
} }
} }
void void
wf_jsonrpc_response_cleanup( wfp_jsonrpc_response_cleanup(
struct wf_jsonrpc_response * response) struct wfp_jsonrpc_response * response)
{ {
if (NULL != response->result) if (NULL != response->result)
{ {

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

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_RESPONSE_INTERN_H #ifndef WFP_JSONRPC_RESPONSE_INTERN_H
#define WF_JSONRPC_RESPONSE_INTERN_H #define WFP_JSONRPC_RESPONSE_INTERN_H
#include "webfuse_provider/impl/jsonrpc/response.h" #include "webfuse_provider/impl/jsonrpc/response.h"
@ -14,19 +14,19 @@ using std::size_t;
extern "C" { extern "C" {
#endif #endif
struct wf_jsonrpc_response struct wfp_jsonrpc_response
{ {
json_t * result; json_t * result;
json_t * error; json_t * error;
int id; int id;
}; };
extern void wf_jsonrpc_response_init( extern void wfp_jsonrpc_response_init(
struct wf_jsonrpc_response * response, struct wfp_jsonrpc_response * response,
json_t * message); json_t * message);
extern void wf_jsonrpc_response_cleanup( extern void wfp_jsonrpc_response_cleanup(
struct wf_jsonrpc_response * response); struct wfp_jsonrpc_response * response);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_SEND_FN_H #ifndef WFP_JSONRPC_SEND_FN_H
#define WF_JSONRPC_SEND_FN_H #define WFP_JSONRPC_SEND_FN_H
#ifndef __cplusplus #ifndef __cplusplus
#include <stdbool.h> #include <stdbool.h>
@ -12,7 +12,7 @@ extern "C"
{ {
#endif #endif
typedef bool wf_jsonrpc_send_fn( typedef bool wfp_jsonrpc_send_fn(
json_t * request, json_t * request,
void * user_data); void * user_data);

@ -7,89 +7,89 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
struct wf_jsonrpc_server struct wfp_jsonrpc_server
{ {
struct wf_jsonrpc_method * methods; struct wfp_jsonrpc_method * methods;
}; };
static void static void
wf_jsonrpc_server_init( wfp_jsonrpc_server_init(
struct wf_jsonrpc_server * server); struct wfp_jsonrpc_server * server);
static void static void
wf_jsonrpc_server_cleanup( wfp_jsonrpc_server_cleanup(
struct wf_jsonrpc_server * server); struct wfp_jsonrpc_server * server);
struct wf_jsonrpc_server * struct wfp_jsonrpc_server *
wf_jsonrpc_server_create(void) wfp_jsonrpc_server_create(void)
{ {
struct wf_jsonrpc_server * server = malloc(sizeof(struct wf_jsonrpc_server)); struct wfp_jsonrpc_server * server = malloc(sizeof(struct wfp_jsonrpc_server));
wf_jsonrpc_server_init(server); wfp_jsonrpc_server_init(server);
return server; return server;
} }
void void
wf_jsonrpc_server_dispose( wfp_jsonrpc_server_dispose(
struct wf_jsonrpc_server * server) struct wfp_jsonrpc_server * server)
{ {
wf_jsonrpc_server_cleanup(server); wfp_jsonrpc_server_cleanup(server);
free(server); free(server);
} }
static void wf_jsonrpc_server_init( static void wfp_jsonrpc_server_init(
struct wf_jsonrpc_server * server) struct wfp_jsonrpc_server * server)
{ {
server->methods = NULL; server->methods = NULL;
} }
static void wf_jsonrpc_server_cleanup( static void wfp_jsonrpc_server_cleanup(
struct wf_jsonrpc_server * server) struct wfp_jsonrpc_server * server)
{ {
struct wf_jsonrpc_method * current = server->methods; struct wfp_jsonrpc_method * current = server->methods;
while (NULL != current) while (NULL != current)
{ {
struct wf_jsonrpc_method * next = current->next; struct wfp_jsonrpc_method * next = current->next;
wf_jsonrpc_method_dispose(current); wfp_jsonrpc_method_dispose(current);
current = next; current = next;
} }
server->methods = NULL; server->methods = NULL;
} }
void wf_jsonrpc_server_add( void wfp_jsonrpc_server_add(
struct wf_jsonrpc_server * server, struct wfp_jsonrpc_server * server,
char const * method_name, char const * method_name,
wf_jsonrpc_method_invoke_fn * invoke, wfp_jsonrpc_method_invoke_fn * invoke,
void * user_data) void * user_data)
{ {
struct wf_jsonrpc_method * method = wf_jsonrpc_method_create(method_name, invoke, user_data); struct wfp_jsonrpc_method * method = wfp_jsonrpc_method_create(method_name, invoke, user_data);
method->next = server->methods; method->next = server->methods;
server->methods = method; server->methods = method;
} }
static void wf_jsonrpc_server_invalid_method_invoke( static void wfp_jsonrpc_server_invalid_method_invoke(
struct wf_jsonrpc_request * request, struct wfp_jsonrpc_request * request,
char const * WF_UNUSED_PARAM(method_name), char const * WFP_UNUSED_PARAM(method_name),
json_t * WF_UNUSED_PARAM(params), json_t * WFP_UNUSED_PARAM(params),
void * WF_UNUSED_PARAM(user_data)) void * WFP_UNUSED_PARAM(user_data))
{ {
wf_jsonrpc_respond_error(request, WF_BAD_NOTIMPLEMENTED, "not implemented"); wfp_jsonrpc_respond_error(request, WFP_BAD_NOTIMPLEMENTED, "not implemented");
} }
static struct wf_jsonrpc_method const wf_jsonrpc_server_invalid_method = static struct wfp_jsonrpc_method const wfp_jsonrpc_server_invalid_method =
{ {
.next = NULL, .next = NULL,
.name = "<invalid>", .name = "<invalid>",
.invoke = &wf_jsonrpc_server_invalid_method_invoke, .invoke = &wfp_jsonrpc_server_invalid_method_invoke,
.user_data = NULL .user_data = NULL
}; };
static struct wf_jsonrpc_method const * static struct wfp_jsonrpc_method const *
wf_jsonrpc_server_get_method( wfp_jsonrpc_server_get_method(
struct wf_jsonrpc_server * server, struct wfp_jsonrpc_server * server,
char const * method_name) char const * method_name)
{ {
struct wf_jsonrpc_method const * current = server->methods; struct wfp_jsonrpc_method const * current = server->methods;
while (NULL != current) while (NULL != current)
{ {
if (0 == strcmp(method_name, current->name)) if (0 == strcmp(method_name, current->name))
@ -100,13 +100,13 @@ wf_jsonrpc_server_get_method(
current = current->next; current = current->next;
} }
return &wf_jsonrpc_server_invalid_method; return &wfp_jsonrpc_server_invalid_method;
} }
void wf_jsonrpc_server_process( void wfp_jsonrpc_server_process(
struct wf_jsonrpc_server * server, struct wfp_jsonrpc_server * server,
json_t * request_data, json_t * request_data,
wf_jsonrpc_send_fn * send, wfp_jsonrpc_send_fn * send,
void * user_data) void * user_data)
{ {
json_t * method_holder = json_object_get(request_data, "method"); json_t * method_holder = json_object_get(request_data, "method");
@ -119,8 +119,8 @@ void wf_jsonrpc_server_process(
{ {
char const * method_name = json_string_value(method_holder); char const * method_name = json_string_value(method_holder);
int id = json_integer_value(id_holder); int id = json_integer_value(id_holder);
struct wf_jsonrpc_request * request = wf_jsonrpc_request_create(id, send, user_data); struct wfp_jsonrpc_request * request = wfp_jsonrpc_request_create(id, send, user_data);
struct wf_jsonrpc_method const * method = wf_jsonrpc_server_get_method(server, method_name); struct wfp_jsonrpc_method const * method = wfp_jsonrpc_server_get_method(server, method_name);
method->invoke(request, method_name, params, method->user_data); method->invoke(request, method_name, params, method->user_data);
} }

@ -1,5 +1,5 @@
#ifndef WF_JSONRPC_SERVER_H #ifndef WFP_JSONRPC_SERVER_H
#define WF_JSONRPC_SERVER_H #define WFP_JSONRPC_SERVER_H
#ifndef __cplusplus #ifndef __cplusplus
#include <stdarg.h> #include <stdarg.h>
@ -17,25 +17,25 @@ extern "C"
{ {
#endif #endif
struct wf_jsonrpc_server; struct wfp_jsonrpc_server;
extern struct wf_jsonrpc_server * extern struct wfp_jsonrpc_server *
wf_jsonrpc_server_create(void); wfp_jsonrpc_server_create(void);
extern void extern void
wf_jsonrpc_server_dispose( wfp_jsonrpc_server_dispose(
struct wf_jsonrpc_server * server); struct wfp_jsonrpc_server * server);
extern void wf_jsonrpc_server_add( extern void wfp_jsonrpc_server_add(
struct wf_jsonrpc_server * server, struct wfp_jsonrpc_server * server,
char const * method_name, char const * method_name,
wf_jsonrpc_method_invoke_fn * invoke, wfp_jsonrpc_method_invoke_fn * invoke,
void * user_data); void * user_data);
extern void wf_jsonrpc_server_process( extern void wfp_jsonrpc_server_process(
struct wf_jsonrpc_server * server, struct wfp_jsonrpc_server * server,
json_t * request, json_t * request,
wf_jsonrpc_send_fn * send, wfp_jsonrpc_send_fn * send,
void * user_data); void * user_data);
#ifdef __cplusplus #ifdef __cplusplus

@ -2,16 +2,16 @@
#include <stdbool.h> #include <stdbool.h>
#include <libwebsockets.h> #include <libwebsockets.h>
#define WF_LWSLOG_DISABLE 0 #define WFP_LWSLOG_DISABLE 0
static bool wf_lwslog_is_diabled = false; static bool wfp_lwslog_is_diabled = false;
void wf_lwslog_disable(void) void wfp_lwslog_disable(void)
{ {
if (!wf_lwslog_is_diabled) if (!wfp_lwslog_is_diabled)
{ {
lws_set_log_level(WF_LWSLOG_DISABLE, NULL); lws_set_log_level(WFP_LWSLOG_DISABLE, NULL);
wf_lwslog_is_diabled = true; wfp_lwslog_is_diabled = true;
} }
} }

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

@ -3,16 +3,16 @@
#include <stdlib.h> #include <stdlib.h>
#include <libwebsockets.h> #include <libwebsockets.h>
extern struct wf_message * wf_message_create(json_t const * value) extern struct wfp_message * wfp_message_create(json_t const * value)
{ {
struct wf_message * message = NULL; struct wfp_message * message = NULL;
size_t const length = json_dumpb(value, NULL, 0, JSON_COMPACT); size_t const length = json_dumpb(value, NULL, 0, JSON_COMPACT);
if (0 < length) if (0 < length)
{ {
char * data = malloc(sizeof(struct wf_message) + LWS_PRE + length); char * data = malloc(sizeof(struct wfp_message) + LWS_PRE + length);
message = (struct wf_message *) data; message = (struct wfp_message *) data;
message->data = &data[sizeof(struct wf_message) + LWS_PRE]; message->data = &data[sizeof(struct wfp_message) + LWS_PRE];
message->length = length; message->length = length;
json_dumpb(value, message->data, length, JSON_COMPACT); json_dumpb(value, message->data, length, JSON_COMPACT);
@ -21,8 +21,8 @@ extern struct wf_message * wf_message_create(json_t const * value)
return message; return message;
} }
void wf_message_dispose( void wfp_message_dispose(
struct wf_message * message) struct wfp_message * message)
{ {
free(message); free(message);
} }

@ -1,5 +1,5 @@
#ifndef WF_MESSAGE_H #ifndef WFP_MESSAGE_H
#define WF_MESSAGE_H #define WFP_MESSAGE_H
#ifndef __cplusplus #ifndef __cplusplus
#include <stddef.h> #include <stddef.h>
@ -11,9 +11,9 @@ using std::size_t;
#include <jansson.h> #include <jansson.h>
#include "webfuse_provider/impl/slist.h" #include "webfuse_provider/impl/slist.h"
struct wf_message struct wfp_message
{ {
struct wf_slist_item item; struct wfp_slist_item item;
char * data; char * data;
size_t length; size_t length;
}; };
@ -23,11 +23,11 @@ extern "C"
{ {
#endif #endif
extern struct wf_message * wf_message_create( extern struct wfp_message * wfp_message_create(
json_t const * value); json_t const * value);
extern void wf_message_dispose( extern void wfp_message_dispose(
struct wf_message * message); struct wfp_message * message);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -2,16 +2,16 @@
#include "webfuse_provider/impl/message.h" #include "webfuse_provider/impl/message.h"
#include "webfuse_provider/impl/container_of.h" #include "webfuse_provider/impl/container_of.h"
void wf_message_queue_cleanup( void wfp_message_queue_cleanup(
struct wf_slist * queue) struct wfp_slist * queue)
{ {
struct wf_slist_item * item = wf_slist_first(queue); struct wfp_slist_item * item = wfp_slist_first(queue);
while (NULL != item) while (NULL != item)
{ {
struct wf_slist_item * next = item->next; struct wfp_slist_item * next = item->next;
struct wf_message * message = wf_container_of(item, struct wf_message, item); struct wfp_message * message = wfp_container_of(item, struct wfp_message, item);
wf_message_dispose(message); wfp_message_dispose(message);
item = next; item = next;
} }
wf_slist_init(queue); wfp_slist_init(queue);
} }

@ -1,15 +1,15 @@
#ifndef WF_MESSAGE_QUEUE_H #ifndef WFP_MESSAGE_QUEUE_H
#define WF_MESSAGE_QUEUE_H #define WFP_MESSAGE_QUEUE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
struct wf_slist; struct wfp_slist;
extern void wf_message_queue_cleanup( extern void wfp_message_queue_cleanup(
struct wf_slist * queue); struct wfp_slist * queue);
#ifdef __cplusplus #ifdef __cplusplus

@ -5,7 +5,7 @@
void wfp_impl_close( void wfp_impl_close(
struct wfp_impl_invokation_context * context, struct wfp_impl_invokation_context * context,
json_t * params, json_t * params,
int WF_UNUSED_PARAM(id)) int WFP_UNUSED_PARAM(id))
{ {
size_t const param_count = json_array_size(params); size_t const param_count = json_array_size(params);
if (4 == param_count) if (4 == param_count)
@ -29,10 +29,10 @@ void wfp_impl_close(
} }
void wfp_impl_close_default( void wfp_impl_close_default(
ino_t WF_UNUSED_PARAM(inode), ino_t WFP_UNUSED_PARAM(inode),
uint32_t WF_UNUSED_PARAM(handle), uint32_t WFP_UNUSED_PARAM(handle),
int WF_UNUSED_PARAM(flags), int WFP_UNUSED_PARAM(flags),
void * WF_UNUSED_PARAM(user_data)) void * WFP_UNUSED_PARAM(user_data))
{ {
// empty // empty
} }

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_CLOSE_H #ifndef WFP_PROVIDER_IMPL_OPERATION_CLOSE_H
#define WF_PROVIDER_IMPL_OPERATION_CLOSE_H #define WFP_PROVIDER_IMPL_OPERATION_CLOSE_H
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"

@ -13,7 +13,7 @@ struct wfp_request;
extern WFP_API void wfp_impl_respond_error( extern WFP_API void wfp_impl_respond_error(
struct wfp_request * request, struct wfp_request * request,
wf_status status); wfp_status status);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -29,10 +29,10 @@ void wfp_impl_getattr(
void wfp_impl_getattr_default( void wfp_impl_getattr_default(
struct wfp_request * request, struct wfp_request * request,
ino_t WF_UNUSED_PARAM(inode), ino_t WFP_UNUSED_PARAM(inode),
void * WF_UNUSED_PARAM(user_data)) void * WFP_UNUSED_PARAM(user_data))
{ {
wfp_impl_respond_error(request, WF_BAD_NOENTRY); wfp_impl_respond_error(request, WFP_BAD_NOENTRY);
} }
void wfp_impl_respond_getattr( void wfp_impl_respond_getattr(

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_GETATTR_H #ifndef WFP_PROVIDER_IMPL_OPERATION_GETATTR_H
#define WF_PROVIDER_IMPL_OPERATION_GETATTR_H #define WFP_PROVIDER_IMPL_OPERATION_GETATTR_H
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"

@ -59,10 +59,10 @@ void wfp_impl_respond_lookup(
void wfp_impl_lookup_default( void wfp_impl_lookup_default(
struct wfp_request * request, struct wfp_request * request,
ino_t WF_UNUSED_PARAM(parent), ino_t WFP_UNUSED_PARAM(parent),
char const * WF_UNUSED_PARAM(name), char const * WFP_UNUSED_PARAM(name),
void * WF_UNUSED_PARAM(user_data)) void * WFP_UNUSED_PARAM(user_data))
{ {
wfp_impl_respond_error(request, WF_BAD_NOENTRY); wfp_impl_respond_error(request, WFP_BAD_NOENTRY);
} }

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_LOOKUP_H #ifndef WFP_PROVIDER_IMPL_OPERATION_LOOKUP_H
#define WF_PROVIDER_IMPL_OPERATION_LOOKUP_H #define WFP_PROVIDER_IMPL_OPERATION_LOOKUP_H
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"

@ -29,11 +29,11 @@ void wfp_impl_open(
void wfp_impl_open_default( void wfp_impl_open_default(
struct wfp_request * request, struct wfp_request * request,
ino_t WF_UNUSED_PARAM(inode), ino_t WFP_UNUSED_PARAM(inode),
int WF_UNUSED_PARAM(flags), int WFP_UNUSED_PARAM(flags),
void * WF_UNUSED_PARAM(user_data)) void * WFP_UNUSED_PARAM(user_data))
{ {
wfp_impl_respond_error(request, WF_BAD_NOENTRY); wfp_impl_respond_error(request, WFP_BAD_NOENTRY);
} }
void wfp_impl_respond_open( void wfp_impl_respond_open(

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_OPEN_H #ifndef WFP_PROVIDER_IMPL_OPERATION_OPEN_H
#define WF_PROVIDER_IMPL_OPERATION_OPEN_H #define WFP_PROVIDER_IMPL_OPERATION_OPEN_H
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"

@ -38,13 +38,13 @@ void wfp_impl_read(
void wfp_impl_read_default( void wfp_impl_read_default(
struct wfp_request * request, struct wfp_request * request,
ino_t WF_UNUSED_PARAM(inode), ino_t WFP_UNUSED_PARAM(inode),
uint32_t WF_UNUSED_PARAM(handle), uint32_t WFP_UNUSED_PARAM(handle),
size_t WF_UNUSED_PARAM(offset), size_t WFP_UNUSED_PARAM(offset),
size_t WF_UNUSED_PARAM(length), size_t WFP_UNUSED_PARAM(length),
void * WF_UNUSED_PARAM(user_data)) void * WFP_UNUSED_PARAM(user_data))
{ {
wfp_impl_respond_error(request, WF_BAD_NOENTRY); wfp_impl_respond_error(request, WFP_BAD_NOENTRY);
} }
void wfp_impl_respond_read( void wfp_impl_respond_read(
@ -54,9 +54,9 @@ void wfp_impl_respond_read(
{ {
if (0 < length) if (0 < length)
{ {
size_t const size = wf_base64_encoded_size(length) + 1; size_t const size = wfp_base64_encoded_size(length) + 1;
char * buffer = malloc(size); char * buffer = malloc(size);
wf_base64_encode((uint8_t const *) data, length, buffer, size); wfp_base64_encode((uint8_t const *) data, length, buffer, size);
json_t * result = json_object(); json_t * result = json_object();
json_object_set_new(result, "data", json_string(buffer)); json_object_set_new(result, "data", json_string(buffer));

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_READ_H #ifndef WFP_PROVIDER_IMPL_OPERATION_READ_H
#define WF_PROVIDER_IMPL_OPERATION_READ_H #define WFP_PROVIDER_IMPL_OPERATION_READ_H
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"

@ -26,10 +26,10 @@ void wfp_impl_readdir(
void wfp_impl_readdir_default( void wfp_impl_readdir_default(
struct wfp_request * request, struct wfp_request * request,
ino_t WF_UNUSED_PARAM(directory), ino_t WFP_UNUSED_PARAM(directory),
void * WF_UNUSED_PARAM(user_data)) void * WFP_UNUSED_PARAM(user_data))
{ {
wfp_impl_respond_error(request, WF_BAD_NOENTRY); wfp_impl_respond_error(request, WFP_BAD_NOENTRY);
} }
void wfp_impl_respond_readdir( void wfp_impl_respond_readdir(

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_OPERATION_READDIR_H #ifndef WFP_PROVIDER_IMPL_OPERATION_READDIR_H
#define WF_PROVIDER_IMPL_OPERATION_READDIR_H #define WFP_PROVIDER_IMPL_OPERATION_READDIR_H
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"

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

@ -37,7 +37,7 @@ extern void wfp_impl_respond(
void wfp_impl_respond_error( void wfp_impl_respond_error(
struct wfp_request * request, struct wfp_request * request,
wf_status status) wfp_status status)
{ {
json_t * response = json_object(); json_t * response = json_object();
json_t * error = json_object(); json_t * error = json_object();

@ -1,5 +1,5 @@
#ifndef WF_PROVIDER_IMPL_REQUEST_H #ifndef WFP_PROVIDER_IMPL_REQUEST_H
#define WF_PROVIDER_IMPL_REQUEST_H #define WFP_PROVIDER_IMPL_REQUEST_H
#include <jansson.h> #include <jansson.h>
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"
@ -23,7 +23,7 @@ struct wfp_request
extern void wfp_impl_respond_error( extern void wfp_impl_respond_error(
struct wfp_request * request, struct wfp_request * request,
wf_status status); wfp_status status);
extern struct wfp_request * wfp_impl_request_create( extern struct wfp_request * wfp_impl_request_create(
struct wfp_request * prototype, struct wfp_request * prototype,

@ -1,46 +1,46 @@
#include "webfuse_provider/impl/slist.h" #include "webfuse_provider/impl/slist.h"
#include <stddef.h> #include <stddef.h>
void wf_slist_init( void wfp_slist_init(
struct wf_slist * list) struct wfp_slist * list)
{ {
list->head.next = NULL; list->head.next = NULL;
list->last = &list->head; list->last = &list->head;
} }
bool wf_slist_empty( bool wfp_slist_empty(
struct wf_slist * list) struct wfp_slist * list)
{ {
return (list->last == &list->head); return (list->last == &list->head);
} }
struct wf_slist_item * wf_slist_first( struct wfp_slist_item * wfp_slist_first(
struct wf_slist * list) struct wfp_slist * list)
{ {
return list->head.next; return list->head.next;
} }
void wf_slist_append( void wfp_slist_append(
struct wf_slist * list, struct wfp_slist * list,
struct wf_slist_item * item) struct wfp_slist_item * item)
{ {
item->next = NULL; item->next = NULL;
list->last->next = item; list->last->next = item;
list->last = item; list->last = item;
} }
struct wf_slist_item * wf_slist_remove_first( struct wfp_slist_item * wfp_slist_remove_first(
struct wf_slist * list) struct wfp_slist * list)
{ {
return wf_slist_remove_after(list, &list->head); return wfp_slist_remove_after(list, &list->head);
} }
struct wf_slist_item * wf_slist_remove_after( struct wfp_slist_item * wfp_slist_remove_after(
struct wf_slist * list, struct wfp_slist * list,
struct wf_slist_item * prev) struct wfp_slist_item * prev)
{ {
struct wf_slist_item * result = prev->next; struct wfp_slist_item * result = prev->next;
if (NULL != result) if (NULL != result)
{ {

@ -1,5 +1,5 @@
#ifndef WF_SLIST_H #ifndef WFP_SLIST_H
#define WF_SLIST_H #define WFP_SLIST_H
#ifndef __cplusplus #ifndef __cplusplus
#include <stdbool.h> #include <stdbool.h>
@ -10,36 +10,36 @@ extern "C"
{ {
#endif #endif
struct wf_slist_item struct wfp_slist_item
{ {
struct wf_slist_item * next; struct wfp_slist_item * next;
}; };
struct wf_slist struct wfp_slist
{ {
struct wf_slist_item head; struct wfp_slist_item head;
struct wf_slist_item * last; struct wfp_slist_item * last;
}; };
extern void wf_slist_init( extern void wfp_slist_init(
struct wf_slist * list); struct wfp_slist * list);
extern bool wf_slist_empty( extern bool wfp_slist_empty(
struct wf_slist * list); struct wfp_slist * list);
extern struct wf_slist_item * wf_slist_first( extern struct wfp_slist_item * wfp_slist_first(
struct wf_slist * list); struct wfp_slist * list);
extern void wf_slist_append( extern void wfp_slist_append(
struct wf_slist * list, struct wfp_slist * list,
struct wf_slist_item * item); struct wfp_slist_item * item);
extern struct wf_slist_item * wf_slist_remove_first( extern struct wfp_slist_item * wfp_slist_remove_first(
struct wf_slist * list); struct wfp_slist * list);
extern struct wf_slist_item * wf_slist_remove_after( extern struct wfp_slist_item * wfp_slist_remove_after(
struct wf_slist * list, struct wfp_slist * list,
struct wf_slist_item * prev); struct wfp_slist_item * prev);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -2,33 +2,33 @@
#include <errno.h> #include <errno.h>
int wf_status_to_rc(wf_status status) int wfp_status_to_rc(wfp_status status)
{ {
switch(status) switch(status)
{ {
case WF_GOOD: return 0; case WFP_GOOD: return 0;
case WF_BAD_NOTIMPLEMENTED: return -ENOSYS; case WFP_BAD_NOTIMPLEMENTED: return -ENOSYS;
case WF_BAD_TIMEOUT: return -ETIMEDOUT; case WFP_BAD_TIMEOUT: return -ETIMEDOUT;
case WF_BAD_BUSY: return -ENOENT; case WFP_BAD_BUSY: return -ENOENT;
case WF_BAD_FORMAT: return -ENOENT; case WFP_BAD_FORMAT: return -ENOENT;
case WF_BAD_NOENTRY: return -ENOENT; case WFP_BAD_NOENTRY: return -ENOENT;
case WF_BAD_ACCESS_DENIED: return -EACCES; case WFP_BAD_ACCESS_DENIED: return -EACCES;
default: return -ENOENT; default: return -ENOENT;
} }
} }
char const * wf_status_tostring(wf_status status) char const * wfp_status_tostring(wfp_status status)
{ {
switch(status) switch(status)
{ {
case WF_GOOD: return "Good"; case WFP_GOOD: return "Good";
case WF_BAD: return "Bad"; case WFP_BAD: return "Bad";
case WF_BAD_NOTIMPLEMENTED: return "Bad (not implemented)"; case WFP_BAD_NOTIMPLEMENTED: return "Bad (not implemented)";
case WF_BAD_TIMEOUT: return "Bad (timeout)"; case WFP_BAD_TIMEOUT: return "Bad (timeout)";
case WF_BAD_BUSY: return "Bad (busy)"; case WFP_BAD_BUSY: return "Bad (busy)";
case WF_BAD_FORMAT: return "Bad (format)"; case WFP_BAD_FORMAT: return "Bad (format)";
case WF_BAD_NOENTRY: return "Bad (no entry)"; case WFP_BAD_NOENTRY: return "Bad (no entry)";
case WF_BAD_ACCESS_DENIED: return "Bad (access denied)"; case WFP_BAD_ACCESS_DENIED: return "Bad (access denied)";
default: return "Bad (unknown)"; default: return "Bad (unknown)";
} }
} }

@ -1,5 +1,5 @@
#ifndef WF_STATUS_INTERN_H #ifndef WFP_STATUS_INTERN_H
#define WF_STATUS_INTERN_H #define WFP_STATUS_INTERN_H
#include "webfuse_provider/status.h" #include "webfuse_provider/status.h"
@ -7,9 +7,9 @@
extern "C" { extern "C" {
#endif #endif
extern int wf_status_to_rc(wf_status status); extern int wfp_status_to_rc(wfp_status status);
extern char const * wf_status_tostring(wf_status status); extern char const * wfp_status_tostring(wfp_status status);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -5,30 +5,30 @@
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
struct wf_timer_manager struct wfp_timer_manager
{ {
struct wf_timer * timers; struct wfp_timer * timers;
}; };
struct wf_timer_manager * struct wfp_timer_manager *
wf_timer_manager_create(void) wfp_timer_manager_create(void)
{ {
struct wf_timer_manager * manager = malloc(sizeof(struct wf_timer_manager)); struct wfp_timer_manager * manager = malloc(sizeof(struct wfp_timer_manager));
manager->timers = NULL; manager->timers = NULL;
return manager; return manager;
} }
void void
wf_timer_manager_dispose( wfp_timer_manager_dispose(
struct wf_timer_manager * manager) struct wfp_timer_manager * manager)
{ {
struct wf_timer * timer = manager->timers; struct wfp_timer * timer = manager->timers;
while (NULL != timer) while (NULL != timer)
{ {
struct wf_timer * next = timer->next; struct wfp_timer * next = timer->next;
wf_timer_trigger(timer); wfp_timer_trigger(timer);
timer = next; timer = next;
} }
@ -36,27 +36,27 @@ wf_timer_manager_dispose(
} }
void wf_timer_manager_check( void wfp_timer_manager_check(
struct wf_timer_manager * manager) struct wfp_timer_manager * manager)
{ {
struct wf_timer * timer = manager->timers; struct wfp_timer * timer = manager->timers;
while (NULL != timer) while (NULL != timer)
{ {
struct wf_timer * next = timer->next; struct wfp_timer * next = timer->next;
if (wf_timer_is_timeout(timer)) if (wfp_timer_is_timeout(timer))
{ {
wf_timer_manager_removetimer(manager, timer); wfp_timer_manager_removetimer(manager, timer);
wf_timer_trigger(timer); wfp_timer_trigger(timer);
} }
timer = next; timer = next;
} }
} }
void wf_timer_manager_addtimer( void wfp_timer_manager_addtimer(
struct wf_timer_manager * manager, struct wfp_timer_manager * manager,
struct wf_timer * timer) struct wfp_timer * timer)
{ {
if (NULL != manager->timers) if (NULL != manager->timers)
{ {
@ -68,12 +68,12 @@ void wf_timer_manager_addtimer(
manager->timers = timer; manager->timers = timer;
} }
void wf_timer_manager_removetimer( void wfp_timer_manager_removetimer(
struct wf_timer_manager * manager, struct wfp_timer_manager * manager,
struct wf_timer * timer) struct wfp_timer * timer)
{ {
struct wf_timer * prev = timer->prev; struct wfp_timer * prev = timer->prev;
struct wf_timer * next = timer->next; struct wfp_timer * next = timer->next;
if (NULL != prev) if (NULL != prev)
{ {

@ -1,23 +1,23 @@
#ifndef WF_TIMER_MANAGER_H #ifndef WFP_TIMER_MANAGER_H
#define WF_TIMER_MANAGER_H #define WFP_TIMER_MANAGER_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
struct wf_timer_manager; struct wfp_timer_manager;
extern struct wf_timer_manager * extern struct wfp_timer_manager *
wf_timer_manager_create(void); wfp_timer_manager_create(void);
extern void extern void
wf_timer_manager_dispose( wfp_timer_manager_dispose(
struct wf_timer_manager * manager); struct wfp_timer_manager * manager);
extern void extern void
wf_timer_manager_check( wfp_timer_manager_check(
struct wf_timer_manager * manager); struct wfp_timer_manager * manager);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -1,5 +1,5 @@
#ifndef WF_TIMER_MANAGER_INTERN_H #ifndef WFP_TIMER_MANAGER_INTERN_H
#define WF_TIMER_MANAGER_INTERN_H #define WFP_TIMER_MANAGER_INTERN_H
#include "webfuse_provider/impl/timer/manager.h" #include "webfuse_provider/impl/timer/manager.h"
@ -8,15 +8,15 @@ extern "C"
{ {
#endif #endif
struct wf_timer; struct wfp_timer;
extern void wf_timer_manager_addtimer( extern void wfp_timer_manager_addtimer(
struct wf_timer_manager * manager, struct wfp_timer_manager * manager,
struct wf_timer * timer); struct wfp_timer * timer);
extern void wf_timer_manager_removetimer( extern void wfp_timer_manager_removetimer(
struct wf_timer_manager * manager, struct wfp_timer_manager * manager,
struct wf_timer * timer); struct wfp_timer * timer);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -1,15 +1,15 @@
#ifndef WF_TIMER_ON_TIMER_FN_H #ifndef WFP_TIMER_ON_TIMER_FN_H
#define WF_TIMER_ON_TIMER_FN_H #define WFP_TIMER_ON_TIMER_FN_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
struct wf_timer; struct wfp_timer;
typedef void wf_timer_on_timer_fn( typedef void wfp_timer_on_timer_fn(
struct wf_timer * timer, struct wfp_timer * timer,
void * user_data); void * user_data);
#ifdef __cplusplus #ifdef __cplusplus

@ -2,30 +2,30 @@
#include <time.h> #include <time.h>
#define WF_TIMER_MSEC_PER_SEC ((wf_timer_timepoint) 1000) #define WFP_TIMER_MSEC_PER_SEC ((wfp_timer_timepoint) 1000)
#define WF_TIMER_NSEC_PER_MSEC ((wf_timer_timepoint) 1000 * 1000) #define WFP_TIMER_NSEC_PER_MSEC ((wfp_timer_timepoint) 1000 * 1000)
wf_timer_timepoint wf_timer_timepoint_now(void) wfp_timer_timepoint wfp_timer_timepoint_now(void)
{ {
struct timespec tp; struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &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); wfp_timer_timepoint const now = (tp.tv_sec * WFP_TIMER_MSEC_PER_SEC) + (tp.tv_nsec / WFP_TIMER_NSEC_PER_MSEC);
return now; return now;
} }
wf_timer_timepoint wf_timer_timepoint_in_msec(wf_timer_timediff value) wfp_timer_timepoint wfp_timer_timepoint_in_msec(wfp_timer_timediff value)
{ {
wf_timer_timepoint const now = wf_timer_timepoint_now(); wfp_timer_timepoint const now = wfp_timer_timepoint_now();
wf_timer_timepoint result = now + ((wf_timer_timepoint) value); wfp_timer_timepoint result = now + ((wfp_timer_timepoint) value);
return result; return result;
} }
bool wf_timer_timepoint_is_elapsed(wf_timer_timepoint tp) bool wfp_timer_timepoint_is_elapsed(wfp_timer_timepoint tp)
{ {
wf_timer_timepoint const now = wf_timer_timepoint_now(); wfp_timer_timepoint const now = wfp_timer_timepoint_now();
wf_timer_timediff const diff = (wf_timer_timediff) (tp - now); wfp_timer_timediff const diff = (wfp_timer_timediff) (tp - now);
return (0 > diff); return (0 > diff);
} }

@ -1,5 +1,5 @@
#ifndef WF_TIMER_TIMEPOINT_H #ifndef WFP_TIMER_TIMEPOINT_H
#define WF_TIMER_TIMEPOINT_H #define WFP_TIMER_TIMEPOINT_H
#ifndef __cplusplus #ifndef __cplusplus
#include <stdbool.h> #include <stdbool.h>
@ -13,16 +13,16 @@ extern "C"
{ {
#endif #endif
typedef uint64_t wf_timer_timepoint; typedef uint64_t wfp_timer_timepoint;
typedef int64_t wf_timer_timediff; typedef int64_t wfp_timer_timediff;
extern wf_timer_timepoint wf_timer_timepoint_now(void); extern wfp_timer_timepoint wfp_timer_timepoint_now(void);
extern wf_timer_timepoint wf_timer_timepoint_in_msec( extern wfp_timer_timepoint wfp_timer_timepoint_in_msec(
wf_timer_timediff value); wfp_timer_timediff value);
extern bool wf_timer_timepoint_is_elapsed( extern bool wfp_timer_timepoint_is_elapsed(
wf_timer_timepoint timepoint); wfp_timer_timepoint timepoint);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -6,13 +6,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
struct wf_timer * struct wfp_timer *
wf_timer_create( wfp_timer_create(
struct wf_timer_manager * manager, struct wfp_timer_manager * manager,
wf_timer_on_timer_fn * on_timer, wfp_timer_on_timer_fn * on_timer,
void * user_data) void * user_data)
{ {
struct wf_timer * timer = malloc(sizeof(struct wf_timer)); struct wfp_timer * timer = malloc(sizeof(struct wfp_timer));
timer->manager = manager; timer->manager = manager;
timer->timeout = 0; timer->timeout = 0;
timer->on_timer = on_timer; timer->on_timer = on_timer;
@ -24,38 +24,38 @@ wf_timer_create(
} }
void void
wf_timer_dispose( wfp_timer_dispose(
struct wf_timer * timer) struct wfp_timer * timer)
{ {
free(timer); free(timer);
} }
void wf_timer_start( void wfp_timer_start(
struct wf_timer * timer, struct wfp_timer * timer,
int timeout_ms) int timeout_ms)
{ {
timer->timeout = wf_timer_timepoint_in_msec(timeout_ms); timer->timeout = wfp_timer_timepoint_in_msec(timeout_ms);
wf_timer_manager_addtimer(timer->manager, timer); wfp_timer_manager_addtimer(timer->manager, timer);
} }
void wf_timer_cancel( void wfp_timer_cancel(
struct wf_timer * timer) struct wfp_timer * timer)
{ {
wf_timer_manager_removetimer(timer->manager, timer); wfp_timer_manager_removetimer(timer->manager, timer);
timer->timeout = 0; timer->timeout = 0;
} }
bool wf_timer_is_timeout( bool wfp_timer_is_timeout(
struct wf_timer * timer) struct wfp_timer * timer)
{ {
return wf_timer_timepoint_is_elapsed(timer->timeout); return wfp_timer_timepoint_is_elapsed(timer->timeout);
} }
void wf_timer_trigger( void wfp_timer_trigger(
struct wf_timer * timer) struct wfp_timer * timer)
{ {
if (0 != timer->on_timer) if (0 != timer->on_timer)
{ {

@ -1,5 +1,5 @@
#ifndef WF_TIMER_TIMER_H #ifndef WFP_TIMER_TIMER_H
#define WF_TIMER_TIMER_H #define WFP_TIMER_TIMER_H
#include "webfuse_provider/impl/timer/on_timer_fn.h" #include "webfuse_provider/impl/timer/on_timer_fn.h"
@ -8,27 +8,27 @@ extern "C"
{ {
#endif #endif
struct wf_timer; struct wfp_timer;
struct wf_timer_manager; struct wfp_timer_manager;
extern struct wf_timer * extern struct wfp_timer *
wf_timer_create( wfp_timer_create(
struct wf_timer_manager * manager, struct wfp_timer_manager * manager,
wf_timer_on_timer_fn * on_timer, wfp_timer_on_timer_fn * on_timer,
void * user_data); void * user_data);
extern void extern void
wf_timer_dispose( wfp_timer_dispose(
struct wf_timer * timer); struct wfp_timer * timer);
extern void extern void
wf_timer_start( wfp_timer_start(
struct wf_timer * timer, struct wfp_timer * timer,
int timeout_ms); int timeout_ms);
extern void extern void
wf_timer_cancel( wfp_timer_cancel(
struct wf_timer * timer); struct wfp_timer * timer);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -1,5 +1,5 @@
#ifndef WF_TIMER_TIMER_H #ifndef WFP_TIMER_TIMER_H
#define WF_TIMER_TIMER_H #define WFP_TIMER_TIMER_H
#include "webfuse_provider/impl/timer/timer.h" #include "webfuse_provider/impl/timer/timer.h"
#include "webfuse_provider/impl/timer/on_timer_fn.h" #include "webfuse_provider/impl/timer/on_timer_fn.h"
@ -14,21 +14,21 @@ extern "C"
{ {
#endif #endif
struct wf_timer struct wfp_timer
{ {
struct wf_timer_manager * manager; struct wfp_timer_manager * manager;
wf_timer_timepoint timeout; wfp_timer_timepoint timeout;
wf_timer_on_timer_fn * on_timer; wfp_timer_on_timer_fn * on_timer;
void * user_data; void * user_data;
struct wf_timer * next; struct wfp_timer * next;
struct wf_timer * prev; struct wfp_timer * prev;
}; };
extern bool wf_timer_is_timeout( extern bool wfp_timer_is_timeout(
struct wf_timer * timer); struct wfp_timer * timer);
extern void wf_timer_trigger( extern void wfp_timer_trigger(
struct wf_timer * timer); struct wfp_timer * timer);
#ifdef __cplusplus #ifdef __cplusplus

@ -3,7 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
struct wf_url_protocol struct wfp_url_protocol
{ {
char const * name; char const * name;
size_t name_length; size_t name_length;
@ -11,11 +11,11 @@ struct wf_url_protocol
bool use_tls; bool use_tls;
}; };
static bool wf_url_readprotocol( static bool wfp_url_readprotocol(
struct wf_url * url, struct wfp_url * url,
char const * * data) char const * * data)
{ {
static struct wf_url_protocol const known_protocols[] = static struct wfp_url_protocol const known_protocols[] =
{ {
{"ws://", 5, 80, false}, {"ws://", 5, 80, false},
{"wss://", 6, 443, true} {"wss://", 6, 443, true}
@ -25,7 +25,7 @@ static bool wf_url_readprotocol(
bool found = false; bool found = false;
for(size_t i = 0; (!found) && (i < count); i++) for(size_t i = 0; (!found) && (i < count); i++)
{ {
struct wf_url_protocol const * protocol = &known_protocols[i]; struct wfp_url_protocol const * protocol = &known_protocols[i];
if (0 == strncmp(*data, protocol->name, protocol->name_length)) if (0 == strncmp(*data, protocol->name, protocol->name_length))
{ {
url->port = protocol->default_port; url->port = protocol->default_port;
@ -38,8 +38,8 @@ static bool wf_url_readprotocol(
return found; return found;
} }
static bool wf_url_readhost( static bool wfp_url_readhost(
struct wf_url * url, struct wfp_url * url,
char const * * data) char const * * data)
{ {
char * end = strpbrk(*data, ":/"); char * end = strpbrk(*data, ":/");
@ -55,8 +55,8 @@ static bool wf_url_readhost(
return result; return result;
} }
static bool wf_url_readport( static bool wfp_url_readport(
struct wf_url * url, struct wfp_url * url,
char const * * data) char const * * data)
{ {
bool result; bool result;
@ -81,8 +81,8 @@ static bool wf_url_readport(
return result; return result;
} }
static bool wf_url_readpath( static bool wfp_url_readpath(
struct wf_url * url, struct wfp_url * url,
char const * * data) char const * * data)
{ {
bool const result = ('/' == **data); bool const result = ('/' == **data);
@ -93,33 +93,33 @@ static bool wf_url_readpath(
} }
bool wf_url_init( bool wfp_url_init(
struct wf_url * url, struct wfp_url * url,
char const * value) char const * value)
{ {
memset(url, 0, sizeof(struct wf_url)); memset(url, 0, sizeof(struct wfp_url));
char const * data = value; char const * data = value;
bool const result = bool const result =
wf_url_readprotocol(url, &data) && wfp_url_readprotocol(url, &data) &&
wf_url_readhost(url, &data) && wfp_url_readhost(url, &data) &&
wf_url_readport(url, &data) && wfp_url_readport(url, &data) &&
wf_url_readpath(url, &data) wfp_url_readpath(url, &data)
; ;
if (!result) if (!result)
{ {
wf_url_cleanup(url); wfp_url_cleanup(url);
} }
return result; return result;
} }
void wf_url_cleanup( void wfp_url_cleanup(
struct wf_url * url) struct wfp_url * url)
{ {
free(url->host); free(url->host);
free(url->path); free(url->path);
memset(url, 0, sizeof(struct wf_url)); memset(url, 0, sizeof(struct wfp_url));
} }

@ -1,5 +1,5 @@
#ifndef WF_URL_H #ifndef WFP_URL_H
#define WF_URL_H #define WFP_URL_H
#ifndef __cplusplus #ifndef __cplusplus
#include <stdbool.h> #include <stdbool.h>
@ -9,7 +9,7 @@
extern "C" extern "C"
{ {
#endif #endif
struct wf_url struct wfp_url
{ {
char * host; char * host;
int port; int port;
@ -17,12 +17,12 @@ struct wf_url
bool use_tls; bool use_tls;
}; };
extern bool wf_url_init( extern bool wfp_url_init(
struct wf_url * url, struct wfp_url * url,
char const * value); char const * value);
extern void wf_url_cleanup( extern void wfp_url_cleanup(
struct wf_url * url); struct wfp_url * url);
#ifdef __cplusplus #ifdef __cplusplus

@ -1,10 +1,10 @@
#ifndef WF_UTIL_H #ifndef WFP_UTIL_H
#define WF_UTIL_H #define WFP_UTIL_H
#ifdef __GNUC__ #ifdef __GNUC__
#define WF_UNUSED_PARAM(param) param __attribute__((unused)) #define WFP_UNUSED_PARAM(param) param __attribute__((unused))
#else #else
#define WF_UNUSED_PARAM(param) #define WFP_UNUSED_PARAM(param)
#endif #endif
#endif #endif

@ -146,16 +146,16 @@ alltests = executable('alltests',
'test/webfuse_provider/tests/provider/operation/test_read.cc', 'test/webfuse_provider/tests/provider/operation/test_read.cc',
'test/webfuse_provider/tests/provider/operation/test_readdir.cc', 'test/webfuse_provider/tests/provider/operation/test_readdir.cc',
link_args: [ link_args: [
'-Wl,--wrap=wf_timer_manager_create', '-Wl,--wrap=wfp_timer_manager_create',
'-Wl,--wrap=wf_timer_manager_dispose', '-Wl,--wrap=wfp_timer_manager_dispose',
'-Wl,--wrap=wf_timer_manager_check', '-Wl,--wrap=wfp_timer_manager_check',
'-Wl,--wrap=wf_timer_create', '-Wl,--wrap=wfp_timer_create',
'-Wl,--wrap=wf_timer_dispose', '-Wl,--wrap=wfp_timer_dispose',
'-Wl,--wrap=wf_timer_start', '-Wl,--wrap=wfp_timer_start',
'-Wl,--wrap=wf_timer_cancel', '-Wl,--wrap=wfp_timer_cancel',
'-Wl,--wrap=wf_impl_operation_context_get_proxy', '-Wl,--wrap=wfp_impl_operation_context_get_proxy',
'-Wl,--wrap=wf_jsonrpc_proxy_vinvoke', '-Wl,--wrap=wfp_jsonrpc_proxy_vinvoke',
'-Wl,--wrap=wf_jsonrpc_proxy_vnotify', '-Wl,--wrap=wfp_jsonrpc_proxy_vnotify',
], ],
include_directories: ['include', 'lib', 'test'], include_directories: ['include', 'lib', 'test'],
dependencies: [ dependencies: [

@ -1,4 +1,4 @@
#ifndef WF_JSON_MATCHER_HPP #ifndef WFP_JSON_MATCHER_HPP
#define FW_JSON_MATCHER_HPP #define FW_JSON_MATCHER_HPP
#include <gtest/gtest.h> #include <gtest/gtest.h>

@ -1,5 +1,5 @@
#ifndef WF_LOOKUP_MATCHER_HPP #ifndef WFP_LOOKUP_MATCHER_HPP
#define WF_LOOKUP_MATCHER_HPP #define WFP_LOOKUP_MATCHER_HPP
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <jansson.h> #include <jansson.h>

@ -1,5 +1,5 @@
#ifndef WF_MOCK_INVOKATION_HANDLER_HPP #ifndef WFP_MOCK_INVOKATION_HANDLER_HPP
#define WF_MOCK_INVOKATION_HANDLER_HPP #define WFP_MOCK_INVOKATION_HANDLER_HPP
#include "webfuse/utils/ws_server2.hpp" #include "webfuse/utils/ws_server2.hpp"
#include <gtest/gtest.h> #include <gtest/gtest.h>

@ -5,15 +5,15 @@ extern "C"
{ {
static webfuse_test::MockJsonRpcProxy * webfuse_test_MockJsonRpcProxy = nullptr; static webfuse_test::MockJsonRpcProxy * webfuse_test_MockJsonRpcProxy = nullptr;
WF_WRAP_VFUNC5(webfuse_test_MockJsonRpcProxy, void, wf_jsonrpc_proxy_vinvoke, WFP_WRAP_VFUNC5(webfuse_test_MockJsonRpcProxy, void, wfp_jsonrpc_proxy_vinvoke,
struct wf_jsonrpc_proxy *, struct wfp_jsonrpc_proxy *,
wf_jsonrpc_proxy_finished_fn *, wfp_jsonrpc_proxy_finished_fn *,
void *, void *,
char const *, char const *,
char const *); char const *);
WF_WRAP_VFUNC3(webfuse_test_MockJsonRpcProxy, void, wf_jsonrpc_proxy_vnotify, WFP_WRAP_VFUNC3(webfuse_test_MockJsonRpcProxy, void, wfp_jsonrpc_proxy_vnotify,
struct wf_jsonrpc_proxy *, struct wfp_jsonrpc_proxy *,
char const *, char const *,
char const *); char const *);
} }

@ -12,14 +12,14 @@ class MockJsonRpcProxy
public: public:
MockJsonRpcProxy(); MockJsonRpcProxy();
virtual ~MockJsonRpcProxy(); virtual ~MockJsonRpcProxy();
MOCK_METHOD5(wf_jsonrpc_proxy_vinvoke, void ( MOCK_METHOD5(wfp_jsonrpc_proxy_vinvoke, void (
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished, wfp_jsonrpc_proxy_finished_fn * finished,
void * user_data, void * user_data,
char const * method_name, char const * method_name,
char const * param_info)); char const * param_info));
MOCK_METHOD3(wf_jsonrpc_proxy_vnotify, void ( MOCK_METHOD3(wfp_jsonrpc_proxy_vnotify, void (
struct wf_jsonrpc_proxy * proxy, struct wfp_jsonrpc_proxy * proxy,
char const * method_name, char const * method_name,
char const * param_info)); char const * param_info));

@ -5,9 +5,9 @@ extern "C"
{ {
static webfuse_test::MockOperationContext * webfuse_test_MockOperationContext = nullptr; static webfuse_test::MockOperationContext * webfuse_test_MockOperationContext = nullptr;
WF_WRAP_FUNC1(webfuse_test_MockOperationContext, WFP_WRAP_FUNC1(webfuse_test_MockOperationContext,
struct wf_jsonrpc_proxy *, wf_impl_operation_context_get_proxy, struct wfp_jsonrpc_proxy *, wfp_impl_operation_context_get_proxy,
struct wf_impl_operation_context *); struct wfp_impl_operation_context *);
} }

@ -12,8 +12,8 @@ class MockOperationContext
public: public:
MockOperationContext(); MockOperationContext();
virtual ~MockOperationContext(); virtual ~MockOperationContext();
MOCK_METHOD1(wf_impl_operation_context_get_proxy, wf_jsonrpc_proxy * ( MOCK_METHOD1(wfp_impl_operation_context_get_proxy, wfp_jsonrpc_proxy * (
struct wf_impl_operation_context * context)); struct wfp_impl_operation_context * context));
}; };

@ -1,5 +1,5 @@
#ifndef WF_MOCK_PROVIDER_HPP #ifndef WFP_MOCK_PROVIDER_HPP
#define WF_MOCK_PROVIDER_HPP #define WFP_MOCK_PROVIDER_HPP
#include "webfuse_provider/impl/provider.h" #include "webfuse_provider/impl/provider.h"
#include <gmock/gmock.h> #include <gmock/gmock.h>

@ -41,7 +41,7 @@ static void webfuse_test_iproviderclient_onlookup(
} }
catch (...) catch (...)
{ {
wfp_respond_error(request, WF_BAD); wfp_respond_error(request, WFP_BAD);
} }
} }
@ -65,7 +65,7 @@ static void webfuse_test_iproviderclient_ongetattr(
} }
catch (...) catch (...)
{ {
wfp_respond_error(request, WF_BAD); wfp_respond_error(request, WFP_BAD);
} }
} }
@ -89,7 +89,7 @@ static void webfuse_test_iproviderclient_onreaddir(
} }
catch (...) catch (...)
{ {
wfp_respond_error(request, WF_BAD); wfp_respond_error(request, WFP_BAD);
} }
wfp_dirbuffer_dispose(buffer); wfp_dirbuffer_dispose(buffer);
@ -116,7 +116,7 @@ static void webfuse_test_iproviderclient_onopen(
} }
catch (...) catch (...)
{ {
wfp_respond_error(request, WF_BAD); wfp_respond_error(request, WFP_BAD);
} }
} }
@ -154,7 +154,7 @@ static void webfuse_test_iproviderclient_onread(
} }
catch (...) catch (...)
{ {
wfp_respond_error(request, WF_BAD); wfp_respond_error(request, WFP_BAD);
} }
delete[] data; delete[] data;
@ -181,14 +181,14 @@ static void webfuse_test_iproviderclient_get_credentials(
namespace webfuse_test namespace webfuse_test
{ {
ProviderClientException::ProviderClientException(wf_status error_code) ProviderClientException::ProviderClientException(wfp_status error_code)
: runtime_error("ProviderClientException") : runtime_error("ProviderClientException")
, error_code_(error_code) , error_code_(error_code)
{ {
} }
wf_status ProviderClientException::GetErrorCode() wfp_status ProviderClientException::GetErrorCode()
{ {
return error_code_; return error_code_;
} }

@ -1,5 +1,5 @@
#ifndef WF_MOCK_PROVIDER_CLIENT_HPP #ifndef WFP_MOCK_PROVIDER_CLIENT_HPP
#define WF_MOCK_PROVIDER_CLIENT_HPP #define WFP_MOCK_PROVIDER_CLIENT_HPP
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "webfuse_provider/client_config.h" #include "webfuse_provider/client_config.h"
@ -11,10 +11,10 @@ namespace webfuse_test
class ProviderClientException: public std::runtime_error class ProviderClientException: public std::runtime_error
{ {
public: public:
explicit ProviderClientException(wf_status error_code); explicit ProviderClientException(wfp_status error_code);
wf_status GetErrorCode(); wfp_status GetErrorCode();
private: private:
wf_status error_code_; wfp_status error_code_;
}; };
class IProviderClient class IProviderClient

@ -1,5 +1,5 @@
#ifndef WF_MOCK_REQUEST_HPP #ifndef WFP_MOCK_REQUEST_HPP
#define WF_MOCK_REQUEST_HPP #define WFP_MOCK_REQUEST_HPP
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <jansson.h> #include <jansson.h>

@ -3,29 +3,29 @@
extern "C" extern "C"
{ {
static wf_jsonrpc_test::ITimer * wf_jsonrpc_MockTimer = nullptr; static wfp_jsonrpc_test::ITimer * wfp_jsonrpc_MockTimer = nullptr;
WF_WRAP_FUNC0(wf_jsonrpc_MockTimer, wf_timer_manager *, wf_timer_manager_create); WFP_WRAP_FUNC0(wfp_jsonrpc_MockTimer, wfp_timer_manager *, wfp_timer_manager_create);
WF_WRAP_FUNC1(wf_jsonrpc_MockTimer, void, wf_timer_manager_dispose, wf_timer_manager *); WFP_WRAP_FUNC1(wfp_jsonrpc_MockTimer, void, wfp_timer_manager_dispose, wfp_timer_manager *);
WF_WRAP_FUNC1(wf_jsonrpc_MockTimer, void, wf_timer_manager_check, wf_timer_manager *); WFP_WRAP_FUNC1(wfp_jsonrpc_MockTimer, void, wfp_timer_manager_check, wfp_timer_manager *);
WF_WRAP_FUNC3(wf_jsonrpc_MockTimer, wf_timer *, wf_timer_create, wf_timer_manager *, wf_timer_on_timer_fn *, void *); WFP_WRAP_FUNC3(wfp_jsonrpc_MockTimer, wfp_timer *, wfp_timer_create, wfp_timer_manager *, wfp_timer_on_timer_fn *, void *);
WF_WRAP_FUNC1(wf_jsonrpc_MockTimer, void, wf_timer_dispose, wf_timer *); WFP_WRAP_FUNC1(wfp_jsonrpc_MockTimer, void, wfp_timer_dispose, wfp_timer *);
WF_WRAP_FUNC2(wf_jsonrpc_MockTimer, void, wf_timer_start, wf_timer *, int); WFP_WRAP_FUNC2(wfp_jsonrpc_MockTimer, void, wfp_timer_start, wfp_timer *, int);
WF_WRAP_FUNC1(wf_jsonrpc_MockTimer, void, wf_timer_cancel, wf_timer *); WFP_WRAP_FUNC1(wfp_jsonrpc_MockTimer, void, wfp_timer_cancel, wfp_timer *);
} }
namespace wf_jsonrpc_test namespace wfp_jsonrpc_test
{ {
MockTimer::MockTimer() MockTimer::MockTimer()
{ {
wf_jsonrpc_MockTimer = this; wfp_jsonrpc_MockTimer = this;
} }
MockTimer::~MockTimer() MockTimer::~MockTimer()
{ {
wf_jsonrpc_MockTimer = nullptr; wfp_jsonrpc_MockTimer = nullptr;
} }
} }

@ -1,27 +1,27 @@
#ifndef WF_JSONRPC_MOCK_TIMERMANAGER_HPP #ifndef WFP_JSONRPC_MOCK_TIMERMANAGER_HPP
#define WF_JSONRPC_MOCK_TIMERMANAGER_HPP #define WFP_JSONRPC_MOCK_TIMERMANAGER_HPP
#include "webfuse_provider/impl/timer/timer.h" #include "webfuse_provider/impl/timer/timer.h"
#include "webfuse_provider/impl/timer/manager.h" #include "webfuse_provider/impl/timer/manager.h"
#include <gmock/gmock.h> #include <gmock/gmock.h>
namespace wf_jsonrpc_test namespace wfp_jsonrpc_test
{ {
class ITimer class ITimer
{ {
public: public:
virtual ~ITimer() = default; virtual ~ITimer() = default;
virtual wf_timer_manager * wf_timer_manager_create() = 0; virtual wfp_timer_manager * wfp_timer_manager_create() = 0;
virtual void wf_timer_manager_dispose(wf_timer_manager * manager) = 0; virtual void wfp_timer_manager_dispose(wfp_timer_manager * manager) = 0;
virtual void wf_timer_manager_check(wf_timer_manager * manager) = 0; virtual void wfp_timer_manager_check(wfp_timer_manager * manager) = 0;
virtual wf_timer * wf_timer_create( virtual wfp_timer * wfp_timer_create(
wf_timer_manager * manager, wfp_timer_manager * manager,
wf_timer_on_timer_fn * on_timer, wfp_timer_on_timer_fn * on_timer,
void * user_data) = 0; void * user_data) = 0;
virtual void wf_timer_dispose(wf_timer * timer) = 0; virtual void wfp_timer_dispose(wfp_timer * timer) = 0;
virtual void wf_timer_start(wf_timer * timer, int timeout_ms) = 0; virtual void wfp_timer_start(wfp_timer * timer, int timeout_ms) = 0;
virtual void wf_timer_cancel(wf_timer * timer) = 0; virtual void wfp_timer_cancel(wfp_timer * timer) = 0;
}; };
class MockTimer: public ITimer class MockTimer: public ITimer
@ -29,16 +29,16 @@ class MockTimer: public ITimer
public: public:
MockTimer(); MockTimer();
~MockTimer() override; ~MockTimer() override;
MOCK_METHOD0(wf_timer_manager_create, wf_timer_manager * ()); MOCK_METHOD0(wfp_timer_manager_create, wfp_timer_manager * ());
MOCK_METHOD1(wf_timer_manager_dispose, void(wf_timer_manager * manager)); MOCK_METHOD1(wfp_timer_manager_dispose, void(wfp_timer_manager * manager));
MOCK_METHOD1(wf_timer_manager_check, void (wf_timer_manager * manager)); MOCK_METHOD1(wfp_timer_manager_check, void (wfp_timer_manager * manager));
MOCK_METHOD3(wf_timer_create, wf_timer *( MOCK_METHOD3(wfp_timer_create, wfp_timer *(
wf_timer_manager * manager, wfp_timer_manager * manager,
wf_timer_on_timer_fn * on_timer, wfp_timer_on_timer_fn * on_timer,
void * user_data)); void * user_data));
MOCK_METHOD1(wf_timer_dispose, void (wf_timer * timer)); MOCK_METHOD1(wfp_timer_dispose, void (wfp_timer * timer));
MOCK_METHOD2(wf_timer_start, void (wf_timer * timer, int timeout_ms)); MOCK_METHOD2(wfp_timer_start, void (wfp_timer * timer, int timeout_ms));
MOCK_METHOD1(wf_timer_cancel, void (wf_timer * timer)); MOCK_METHOD1(wfp_timer_cancel, void (wfp_timer * timer));
}; };

@ -2,10 +2,10 @@
extern "C" extern "C"
{ {
using wf_jsonrpc_test::MockTimerCallback; using wfp_jsonrpc_test::MockTimerCallback;
static void wf_jsonrpc_test_MockTimerCallback_on_timer( static void wfp_jsonrpc_test_MockTimerCallback_on_timer(
wf_timer * timer, wfp_timer * timer,
void * user_data) void * user_data)
{ {
auto * self = reinterpret_cast<MockTimerCallback*>(user_data); auto * self = reinterpret_cast<MockTimerCallback*>(user_data);
@ -14,7 +14,7 @@ static void wf_jsonrpc_test_MockTimerCallback_on_timer(
} }
namespace wf_jsonrpc_test namespace wfp_jsonrpc_test
{ {
MockTimerCallback::MockTimerCallback() MockTimerCallback::MockTimerCallback()
@ -27,9 +27,9 @@ MockTimerCallback::~MockTimerCallback()
} }
wf_timer_on_timer_fn * MockTimerCallback::on_timer_fn() wfp_timer_on_timer_fn * MockTimerCallback::on_timer_fn()
{ {
return &wf_jsonrpc_test_MockTimerCallback_on_timer; return &wfp_jsonrpc_test_MockTimerCallback_on_timer;
} }
void * MockTimerCallback::user_data() void * MockTimerCallback::user_data()

@ -1,20 +1,20 @@
#ifndef WF_JSONRPC_MOCK_TIMERCALLBACK_HPP #ifndef WFP_JSONRPC_MOCK_TIMERCALLBACK_HPP
#define WF_JSONRPC_MOCK_TIMERCALLBACK_HPP #define WFP_JSONRPC_MOCK_TIMERCALLBACK_HPP
#include "webfuse_provider/impl/timer/on_timer_fn.h" #include "webfuse_provider/impl/timer/on_timer_fn.h"
#include <gmock/gmock.h> #include <gmock/gmock.h>
namespace wf_jsonrpc_test namespace wfp_jsonrpc_test
{ {
class MockTimerCallback class MockTimerCallback
{ {
public: public:
MockTimerCallback(); MockTimerCallback();
virtual ~MockTimerCallback(); virtual ~MockTimerCallback();
wf_timer_on_timer_fn * on_timer_fn(); wfp_timer_on_timer_fn * on_timer_fn();
void * user_data(); void * user_data();
MOCK_METHOD2(on_timer, void (wf_timer * timer, void * user_data)); MOCK_METHOD2(on_timer, void (wfp_timer * timer, void * user_data));
}; };

@ -1,112 +1,112 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "webfuse_provider/impl/jsonrpc/request.h" #include "webfuse_provider/impl/jsonrpc/request.h"
TEST(wf_jsonrpc_is_request, request_with_object_params) TEST(wfp_jsonrpc_is_request, request_with_object_params)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "method", json_string("method")); json_object_set_new(request, "method", json_string("method"));
json_object_set_new(request, "params", json_object()); json_object_set_new(request, "params", json_object());
json_object_set_new(request, "id", json_integer(42)); json_object_set_new(request, "id", json_integer(42));
ASSERT_TRUE(wf_jsonrpc_is_request(request)); ASSERT_TRUE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_is_request, request_with_array_params) TEST(wfp_jsonrpc_is_request, request_with_array_params)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "method", json_string("method")); json_object_set_new(request, "method", json_string("method"));
json_object_set_new(request, "params", json_array()); json_object_set_new(request, "params", json_array());
json_object_set_new(request, "id", json_integer(42)); json_object_set_new(request, "id", json_integer(42));
ASSERT_TRUE(wf_jsonrpc_is_request(request)); ASSERT_TRUE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_is_request, null_request) TEST(wfp_jsonrpc_is_request, null_request)
{ {
ASSERT_FALSE(wf_jsonrpc_is_request(nullptr)); ASSERT_FALSE(wfp_jsonrpc_is_request(nullptr));
} }
TEST(wf_jsonrpc_is_request, invalid_request) TEST(wfp_jsonrpc_is_request, invalid_request)
{ {
json_t * request = json_array(); json_t * request = json_array();
json_array_append_new(request, json_string("method")); json_array_append_new(request, json_string("method"));
json_array_append_new(request, json_object()); json_array_append_new(request, json_object());
json_array_append_new(request, json_integer(42)); json_array_append_new(request, json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_request(request)); ASSERT_FALSE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_is_request, invalid_request_without_id) TEST(wfp_jsonrpc_is_request, invalid_request_without_id)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "method", json_string("method")); json_object_set_new(request, "method", json_string("method"));
json_object_set_new(request, "params", json_object()); json_object_set_new(request, "params", json_object());
ASSERT_FALSE(wf_jsonrpc_is_request(request)); ASSERT_FALSE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_is_request, invalid_request_due_to_invalid_id) TEST(wfp_jsonrpc_is_request, invalid_request_due_to_invalid_id)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "method", json_string("method")); json_object_set_new(request, "method", json_string("method"));
json_object_set_new(request, "params", json_object()); json_object_set_new(request, "params", json_object());
json_object_set_new(request, "id", json_string("42")); json_object_set_new(request, "id", json_string("42"));
ASSERT_FALSE(wf_jsonrpc_is_request(request)); ASSERT_FALSE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_is_request, invalid_request_without_method) TEST(wfp_jsonrpc_is_request, invalid_request_without_method)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "params", json_object()); json_object_set_new(request, "params", json_object());
json_object_set_new(request, "id", json_integer(42)); json_object_set_new(request, "id", json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_request(request)); ASSERT_FALSE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_is_request, invalid_request_due_to_invalid_method) TEST(wfp_jsonrpc_is_request, invalid_request_due_to_invalid_method)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "method", json_integer(42)); json_object_set_new(request, "method", json_integer(42));
json_object_set_new(request, "params", json_object()); json_object_set_new(request, "params", json_object());
json_object_set_new(request, "id", json_integer(42)); json_object_set_new(request, "id", json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_request(request)); ASSERT_FALSE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_is_request, invalid_request_without_params) TEST(wfp_jsonrpc_is_request, invalid_request_without_params)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "method", json_string("method")); json_object_set_new(request, "method", json_string("method"));
json_object_set_new(request, "id", json_integer(42)); json_object_set_new(request, "id", json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_request(request)); ASSERT_FALSE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_is_request, invalid_request_due_to_invalid_params) TEST(wfp_jsonrpc_is_request, invalid_request_due_to_invalid_params)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "methdo", json_string("method")); json_object_set_new(request, "methdo", json_string("method"));
json_object_set_new(request, "params", json_string("params")); json_object_set_new(request, "params", json_string("params"));
json_object_set_new(request, "id", json_integer(42)); json_object_set_new(request, "id", json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_request(request)); ASSERT_FALSE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }

@ -1,94 +1,94 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "webfuse_provider/impl/jsonrpc/response.h" #include "webfuse_provider/impl/jsonrpc/response.h"
TEST(wf_jsonrpc_is_response, valid_result) TEST(wfp_jsonrpc_is_response, valid_result)
{ {
json_t * message = json_object(); json_t * message = json_object();
json_object_set_new(message, "result", json_object()); json_object_set_new(message, "result", json_object());
json_object_set_new(message, "id", json_integer(42)); json_object_set_new(message, "id", json_integer(42));
ASSERT_TRUE(wf_jsonrpc_is_response(message)); ASSERT_TRUE(wfp_jsonrpc_is_response(message));
json_decref(message); json_decref(message);
} }
TEST(wf_jsonrpc_is_response, valid_result_string) TEST(wfp_jsonrpc_is_response, valid_result_string)
{ {
json_t * message = json_object(); json_t * message = json_object();
json_object_set_new(message, "result", json_string("also valid")); json_object_set_new(message, "result", json_string("also valid"));
json_object_set_new(message, "id", json_integer(42)); json_object_set_new(message, "id", json_integer(42));
ASSERT_TRUE(wf_jsonrpc_is_response(message)); ASSERT_TRUE(wfp_jsonrpc_is_response(message));
json_decref(message); json_decref(message);
} }
TEST(wf_jsonrpc_is_response, valid_error) TEST(wfp_jsonrpc_is_response, valid_error)
{ {
json_t * message = json_object(); json_t * message = json_object();
json_object_set_new(message, "error", json_object()); json_object_set_new(message, "error", json_object());
json_object_set_new(message, "id", json_integer(42)); json_object_set_new(message, "id", json_integer(42));
ASSERT_TRUE(wf_jsonrpc_is_response(message)); ASSERT_TRUE(wfp_jsonrpc_is_response(message));
json_decref(message); json_decref(message);
} }
TEST(wf_jsonrpc_is_response, invalid_null) TEST(wfp_jsonrpc_is_response, invalid_null)
{ {
ASSERT_FALSE(wf_jsonrpc_is_response(nullptr)); ASSERT_FALSE(wfp_jsonrpc_is_response(nullptr));
} }
TEST(wf_jsonrpc_is_response, invalid_message) TEST(wfp_jsonrpc_is_response, invalid_message)
{ {
json_t * message = json_array(); json_t * message = json_array();
json_array_append_new(message, json_object()); json_array_append_new(message, json_object());
json_array_append_new(message, json_integer(42)); json_array_append_new(message, json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_response(message)); ASSERT_FALSE(wfp_jsonrpc_is_response(message));
json_decref(message); json_decref(message);
} }
TEST(wf_jsonrpc_is_response, invalid_missing_id) TEST(wfp_jsonrpc_is_response, invalid_missing_id)
{ {
json_t * message = json_object(); json_t * message = json_object();
json_object_set_new(message, "result", json_object()); json_object_set_new(message, "result", json_object());
ASSERT_FALSE(wf_jsonrpc_is_response(message)); ASSERT_FALSE(wfp_jsonrpc_is_response(message));
json_decref(message); json_decref(message);
} }
TEST(wf_jsonrpc_is_response, invalid_id_wrong_type) TEST(wfp_jsonrpc_is_response, invalid_id_wrong_type)
{ {
json_t * message = json_object(); json_t * message = json_object();
json_object_set_new(message, "result", json_object()); json_object_set_new(message, "result", json_object());
json_object_set_new(message, "id", json_string("42")); json_object_set_new(message, "id", json_string("42"));
ASSERT_FALSE(wf_jsonrpc_is_response(message)); ASSERT_FALSE(wfp_jsonrpc_is_response(message));
json_decref(message); json_decref(message);
} }
TEST(wf_jsonrpc_is_response, invalid_missing_result_and_error) TEST(wfp_jsonrpc_is_response, invalid_missing_result_and_error)
{ {
json_t * message = json_object(); json_t * message = json_object();
json_object_set_new(message, "id", json_integer(42)); json_object_set_new(message, "id", json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_response(message)); ASSERT_FALSE(wfp_jsonrpc_is_response(message));
json_decref(message); json_decref(message);
} }
TEST(wf_jsonrpc_is_response, invalid_error_wrong_type) TEST(wfp_jsonrpc_is_response, invalid_error_wrong_type)
{ {
json_t * message = json_object(); json_t * message = json_object();
json_object_set_new(message, "error", json_array()); json_object_set_new(message, "error", json_array());
json_object_set_new(message, "id", json_integer(42)); json_object_set_new(message, "id", json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_response(message)); ASSERT_FALSE(wfp_jsonrpc_is_response(message));
json_decref(message); json_decref(message);
} }

@ -9,20 +9,20 @@
#include <chrono> #include <chrono>
using namespace std::chrono_literals; using namespace std::chrono_literals;
using wf_jsonrpc_test::MockTimer; using wfp_jsonrpc_test::MockTimer;
using testing::Return; using testing::Return;
using testing::_; using testing::_;
using testing::DoAll; using testing::DoAll;
using testing::SaveArg; using testing::SaveArg;
#define WF_DEFAULT_TIMEOUT (10 * 1000) #define WFP_DEFAULT_TIMEOUT (10 * 1000)
namespace namespace
{ {
int jsonrpc_get_status(json_t * error) int jsonrpc_get_status(json_t * error)
{ {
json_t * code = json_object_get(error, "code"); json_t * code = json_object_get(error, "code");
return (json_is_integer(code)) ? json_integer_value(code) : WF_BAD_FORMAT; return (json_is_integer(code)) ? json_integer_value(code) : WFP_BAD_FORMAT;
} }
struct SendContext struct SendContext
@ -99,31 +99,31 @@ namespace
} }
} }
TEST(wf_jsonrpc_proxy, init) TEST(wfp_jsonrpc_proxy, init)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext context; SendContext context;
void * user_data = reinterpret_cast<void*>(&context); void * user_data = reinterpret_cast<void*>(&context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, user_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, user_data);
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
ASSERT_FALSE(context.is_called); ASSERT_FALSE(context.is_called);
} }
TEST(wf_jsonrpc_proxy, invoke) TEST(wfp_jsonrpc_proxy, invoke)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
FinishedContext finished_context; FinishedContext finished_context;
void * finished_data = reinterpret_cast<void*>(&finished_context); void * finished_data = reinterpret_cast<void*>(&finished_context);
wf_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42); wfp_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
ASSERT_TRUE(send_context.is_called); ASSERT_TRUE(send_context.is_called);
ASSERT_TRUE(json_is_object(send_context.response)); ASSERT_TRUE(json_is_object(send_context.response));
@ -145,24 +145,24 @@ TEST(wf_jsonrpc_proxy, invoke)
ASSERT_FALSE(finished_context.is_called); ASSERT_FALSE(finished_context.is_called);
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
ASSERT_TRUE(finished_context.is_called); ASSERT_TRUE(finished_context.is_called);
ASSERT_FALSE(nullptr == finished_context.error); ASSERT_FALSE(nullptr == finished_context.error);
} }
TEST(wf_jsonrpc_proxy, invoke_calls_finish_if_send_fails) TEST(wfp_jsonrpc_proxy, invoke_calls_finish_if_send_fails)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context(false); SendContext send_context(false);
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
FinishedContext finished_context; FinishedContext finished_context;
void * finished_data = reinterpret_cast<void*>(&finished_context); void * finished_data = reinterpret_cast<void*>(&finished_context);
wf_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42); wfp_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
ASSERT_TRUE(send_context.is_called); ASSERT_TRUE(send_context.is_called);
ASSERT_TRUE(json_is_object(send_context.response)); ASSERT_TRUE(json_is_object(send_context.response));
@ -170,25 +170,25 @@ TEST(wf_jsonrpc_proxy, invoke_calls_finish_if_send_fails)
ASSERT_TRUE(finished_context.is_called); ASSERT_TRUE(finished_context.is_called);
ASSERT_FALSE(nullptr == finished_context.error); ASSERT_FALSE(nullptr == finished_context.error);
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }
TEST(wf_jsonrpc_proxy, invoke_fails_if_another_request_is_pending) TEST(wfp_jsonrpc_proxy, invoke_fails_if_another_request_is_pending)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
FinishedContext finished_context; FinishedContext finished_context;
void * finished_data = reinterpret_cast<void*>(&finished_context); void * finished_data = reinterpret_cast<void*>(&finished_context);
wf_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42); wfp_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
FinishedContext finished_context2; FinishedContext finished_context2;
void * finished_data2 = reinterpret_cast<void*>(&finished_context2); void * finished_data2 = reinterpret_cast<void*>(&finished_context2);
wf_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data2, "foo", ""); wfp_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data2, "foo", "");
ASSERT_TRUE(send_context.is_called); ASSERT_TRUE(send_context.is_called);
ASSERT_TRUE(json_is_object(send_context.response)); ASSERT_TRUE(json_is_object(send_context.response));
@ -196,44 +196,44 @@ TEST(wf_jsonrpc_proxy, invoke_fails_if_another_request_is_pending)
ASSERT_FALSE(finished_context.is_called); ASSERT_FALSE(finished_context.is_called);
ASSERT_TRUE(finished_context2.is_called); ASSERT_TRUE(finished_context2.is_called);
ASSERT_EQ(WF_BAD_BUSY, jsonrpc_get_status(finished_context2.error)); ASSERT_EQ(WFP_BAD_BUSY, jsonrpc_get_status(finished_context2.error));
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }
TEST(wf_jsonrpc_proxy, invoke_fails_if_request_is_invalid) TEST(wfp_jsonrpc_proxy, invoke_fails_if_request_is_invalid)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
FinishedContext finished_context; FinishedContext finished_context;
void * finished_data = reinterpret_cast<void*>(&finished_context); void * finished_data = reinterpret_cast<void*>(&finished_context);
wf_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "?", "error"); wfp_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "?", "error");
ASSERT_FALSE(send_context.is_called); ASSERT_FALSE(send_context.is_called);
ASSERT_TRUE(finished_context.is_called); ASSERT_TRUE(finished_context.is_called);
ASSERT_EQ(WF_BAD, jsonrpc_get_status(finished_context.error)); ASSERT_EQ(WFP_BAD, jsonrpc_get_status(finished_context.error));
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }
TEST(wf_jsonrpc_proxy, on_result) TEST(wfp_jsonrpc_proxy, on_result)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
FinishedContext finished_context; FinishedContext finished_context;
void * finished_data = reinterpret_cast<void*>(&finished_context); void * finished_data = reinterpret_cast<void*>(&finished_context);
wf_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42); wfp_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
ASSERT_TRUE(send_context.is_called); ASSERT_TRUE(send_context.is_called);
ASSERT_TRUE(json_is_object(send_context.response)); ASSERT_TRUE(json_is_object(send_context.response));
@ -245,7 +245,7 @@ TEST(wf_jsonrpc_proxy, on_result)
json_object_set_new(response, "result", json_string("okay")); json_object_set_new(response, "result", json_string("okay"));
json_object_set(response, "id", id); json_object_set(response, "id", id);
wf_jsonrpc_proxy_onresult(proxy, response); wfp_jsonrpc_proxy_onresult(proxy, response);
json_decref(response); json_decref(response);
ASSERT_TRUE(finished_context.is_called); ASSERT_TRUE(finished_context.is_called);
@ -253,21 +253,21 @@ TEST(wf_jsonrpc_proxy, on_result)
ASSERT_TRUE(json_is_string(finished_context.result)); ASSERT_TRUE(json_is_string(finished_context.result));
ASSERT_STREQ("okay", json_string_value(finished_context.result)); ASSERT_STREQ("okay", json_string_value(finished_context.result));
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }
TEST(wf_jsonrpc_proxy, on_result_reject_response_with_unknown_id) TEST(wfp_jsonrpc_proxy, on_result_reject_response_with_unknown_id)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
FinishedContext finished_context; FinishedContext finished_context;
void * finished_data = reinterpret_cast<void*>(&finished_context); void * finished_data = reinterpret_cast<void*>(&finished_context);
wf_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42); wfp_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
ASSERT_TRUE(send_context.is_called); ASSERT_TRUE(send_context.is_called);
ASSERT_TRUE(json_is_object(send_context.response)); ASSERT_TRUE(json_is_object(send_context.response));
@ -279,75 +279,75 @@ TEST(wf_jsonrpc_proxy, on_result_reject_response_with_unknown_id)
json_object_set_new(response, "result", json_string("okay")); json_object_set_new(response, "result", json_string("okay"));
json_object_set_new(response, "id", json_integer(1 + json_integer_value(id))); json_object_set_new(response, "id", json_integer(1 + json_integer_value(id)));
wf_jsonrpc_proxy_onresult(proxy, response); wfp_jsonrpc_proxy_onresult(proxy, response);
json_decref(response); json_decref(response);
ASSERT_FALSE(finished_context.is_called); ASSERT_FALSE(finished_context.is_called);
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }
TEST(wf_jsonrpc_proxy, timeout) TEST(wfp_jsonrpc_proxy, timeout)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, 0, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, 0, &jsonrpc_send, send_data);
FinishedContext finished_context; FinishedContext finished_context;
void * finished_data = reinterpret_cast<void*>(&finished_context); void * finished_data = reinterpret_cast<void*>(&finished_context);
wf_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42); wfp_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
ASSERT_TRUE(send_context.is_called); ASSERT_TRUE(send_context.is_called);
ASSERT_TRUE(json_is_object(send_context.response)); ASSERT_TRUE(json_is_object(send_context.response));
std::this_thread::sleep_for(10ms); std::this_thread::sleep_for(10ms);
wf_timer_manager_check(timer_manager); wfp_timer_manager_check(timer_manager);
ASSERT_TRUE(finished_context.is_called); ASSERT_TRUE(finished_context.is_called);
ASSERT_EQ(WF_BAD_TIMEOUT, jsonrpc_get_status(finished_context.error)); ASSERT_EQ(WFP_BAD_TIMEOUT, jsonrpc_get_status(finished_context.error));
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }
TEST(wf_jsonrpc_proxy, cleanup_pending_request) TEST(wfp_jsonrpc_proxy, cleanup_pending_request)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, 10, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, 10, &jsonrpc_send, send_data);
FinishedContext finished_context; FinishedContext finished_context;
void * finished_data = reinterpret_cast<void*>(&finished_context); void * finished_data = reinterpret_cast<void*>(&finished_context);
wf_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42); wfp_jsonrpc_proxy_invoke(proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
ASSERT_TRUE(send_context.is_called); ASSERT_TRUE(send_context.is_called);
ASSERT_TRUE(json_is_object(send_context.response)); ASSERT_TRUE(json_is_object(send_context.response));
ASSERT_FALSE(finished_context.is_called); ASSERT_FALSE(finished_context.is_called);
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
ASSERT_TRUE(finished_context.is_called); ASSERT_TRUE(finished_context.is_called);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }
TEST(wf_jsonrpc_proxy, notify) TEST(wfp_jsonrpc_proxy, notify)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
wf_jsonrpc_proxy_notify(proxy, "foo", "si", "bar", 42); wfp_jsonrpc_proxy_notify(proxy, "foo", "si", "bar", 42);
ASSERT_TRUE(send_context.is_called); ASSERT_TRUE(send_context.is_called);
ASSERT_TRUE(json_is_object(send_context.response)); ASSERT_TRUE(json_is_object(send_context.response));
@ -367,64 +367,64 @@ TEST(wf_jsonrpc_proxy, notify)
json_t * id = json_object_get(send_context.response, "id"); json_t * id = json_object_get(send_context.response, "id");
ASSERT_EQ(nullptr, id); ASSERT_EQ(nullptr, id);
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }
TEST(wf_jsonrpc_proxy, notify_dont_send_invalid_request) TEST(wfp_jsonrpc_proxy, notify_dont_send_invalid_request)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
wf_jsonrpc_proxy_notify(proxy, "foo", "?"); wfp_jsonrpc_proxy_notify(proxy, "foo", "?");
ASSERT_FALSE(send_context.is_called); ASSERT_FALSE(send_context.is_called);
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }
TEST(wf_jsonrpc_proxy, swallow_timeout_if_no_request_pending) TEST(wfp_jsonrpc_proxy, swallow_timeout_if_no_request_pending)
{ {
MockTimer timer_api; MockTimer timer_api;
wf_timer_on_timer_fn * on_timer = nullptr; wfp_timer_on_timer_fn * on_timer = nullptr;
void * timer_context = nullptr; void * timer_context = nullptr;
EXPECT_CALL(timer_api, wf_timer_create(_, _, _)) EXPECT_CALL(timer_api, wfp_timer_create(_, _, _))
.Times(1) .Times(1)
.WillOnce(DoAll(SaveArg<1>(&on_timer), SaveArg<2>(&timer_context), Return(nullptr))); .WillOnce(DoAll(SaveArg<1>(&on_timer), SaveArg<2>(&timer_context), Return(nullptr)));
EXPECT_CALL(timer_api, wf_timer_dispose(_)).Times(1); EXPECT_CALL(timer_api, wfp_timer_dispose(_)).Times(1);
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(nullptr, 1, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(nullptr, 1, &jsonrpc_send, send_data);
on_timer(nullptr, timer_context); on_timer(nullptr, timer_context);
ASSERT_FALSE(send_context.is_called); ASSERT_FALSE(send_context.is_called);
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
} }
TEST(wf_jsonrpc_proxy, on_result_swallow_if_no_request_pending) TEST(wfp_jsonrpc_proxy, on_result_swallow_if_no_request_pending)
{ {
struct wf_timer_manager * timer_manager = wf_timer_manager_create(); struct wfp_timer_manager * timer_manager = wfp_timer_manager_create();
SendContext send_context; SendContext send_context;
void * send_data = reinterpret_cast<void*>(&send_context); void * send_data = reinterpret_cast<void*>(&send_context);
struct wf_jsonrpc_proxy * proxy = wf_jsonrpc_proxy_create(timer_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data); struct wfp_jsonrpc_proxy * proxy = wfp_jsonrpc_proxy_create(timer_manager, WFP_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
json_t * response = json_object(); json_t * response = json_object();
json_object_set_new(response, "result", json_string("okay")); json_object_set_new(response, "result", json_string("okay"));
json_object_set_new(response, "id", json_integer(42)); json_object_set_new(response, "id", json_integer(42));
wf_jsonrpc_proxy_onresult(proxy, response); wfp_jsonrpc_proxy_onresult(proxy, response);
json_decref(response); json_decref(response);
wf_jsonrpc_proxy_dispose(proxy); wfp_jsonrpc_proxy_dispose(proxy);
wf_timer_manager_dispose(timer_manager); wfp_timer_manager_dispose(timer_manager);
} }

@ -23,29 +23,29 @@ bool jsonrpc_send(
} }
TEST(wf_jsonrpc_request, create_dispose) TEST(wfp_jsonrpc_request, create_dispose)
{ {
Context context{nullptr}; Context context{nullptr};
void * user_data = reinterpret_cast<void*>(&context); void * user_data = reinterpret_cast<void*>(&context);
struct wf_jsonrpc_request * request = struct wfp_jsonrpc_request * request =
wf_jsonrpc_request_create(42, &jsonrpc_send, user_data); wfp_jsonrpc_request_create(42, &jsonrpc_send, user_data);
ASSERT_NE(nullptr, request); ASSERT_NE(nullptr, request);
ASSERT_EQ(user_data, wf_jsonrpc_request_get_userdata(request)); ASSERT_EQ(user_data, wfp_jsonrpc_request_get_userdata(request));
wf_jsonrpc_request_dispose(request); wfp_jsonrpc_request_dispose(request);
} }
TEST(wf_jsonrpc_request, respond) TEST(wfp_jsonrpc_request, respond)
{ {
Context context{nullptr}; Context context{nullptr};
void * user_data = reinterpret_cast<void*>(&context); void * user_data = reinterpret_cast<void*>(&context);
struct wf_jsonrpc_request * request = struct wfp_jsonrpc_request * request =
wf_jsonrpc_request_create(42, &jsonrpc_send, user_data); wfp_jsonrpc_request_create(42, &jsonrpc_send, user_data);
wf_jsonrpc_respond(request, json_string("okay")); wfp_jsonrpc_respond(request, json_string("okay"));
ASSERT_NE(nullptr, context.response); ASSERT_NE(nullptr, context.response);
@ -66,15 +66,15 @@ TEST(wf_jsonrpc_request, respond)
json_decref(response); json_decref(response);
} }
TEST(wf_jsonrpc_request, respond_error) TEST(wfp_jsonrpc_request, respond_error)
{ {
Context context{nullptr}; Context context{nullptr};
void * user_data = reinterpret_cast<void*>(&context); void * user_data = reinterpret_cast<void*>(&context);
struct wf_jsonrpc_request * request = struct wfp_jsonrpc_request * request =
wf_jsonrpc_request_create(42, &jsonrpc_send, user_data); wfp_jsonrpc_request_create(42, &jsonrpc_send, user_data);
wf_jsonrpc_respond_error(request, WF_BAD, "Bad"); wfp_jsonrpc_respond_error(request, WFP_BAD, "Bad");
ASSERT_NE(nullptr, context.response); ASSERT_NE(nullptr, context.response);
@ -93,7 +93,7 @@ TEST(wf_jsonrpc_request, respond_error)
json_t * err_code = json_object_get(err, "code"); json_t * err_code = json_object_get(err, "code");
ASSERT_TRUE(json_is_integer(err_code)); ASSERT_TRUE(json_is_integer(err_code));
ASSERT_EQ(WF_BAD, json_integer_value(err_code)); ASSERT_EQ(WFP_BAD, json_integer_value(err_code));
json_t * err_message = json_object_get(err, "message"); json_t * err_message = json_object_get(err, "message");
ASSERT_TRUE(json_is_string(err_message)); ASSERT_TRUE(json_is_string(err_message));
@ -102,37 +102,37 @@ TEST(wf_jsonrpc_request, respond_error)
json_decref(response); json_decref(response);
} }
TEST(wf_jsonrpc_request, is_request_object_params) TEST(wfp_jsonrpc_request, is_request_object_params)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "method", json_string("some_method")); json_object_set_new(request, "method", json_string("some_method"));
json_object_set_new(request, "params", json_object()); json_object_set_new(request, "params", json_object());
json_object_set_new(request, "id", json_integer(42)); json_object_set_new(request, "id", json_integer(42));
ASSERT_TRUE(wf_jsonrpc_is_request(request)); ASSERT_TRUE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_request, is_request_fail_missing_params) TEST(wfp_jsonrpc_request, is_request_fail_missing_params)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "method", json_string("some_method")); json_object_set_new(request, "method", json_string("some_method"));
json_object_set_new(request, "id", json_integer(42)); json_object_set_new(request, "id", json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_request(request)); ASSERT_FALSE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }
TEST(wf_jsonrpc_request, is_request_fail_params_wrong_type) TEST(wfp_jsonrpc_request, is_request_fail_params_wrong_type)
{ {
json_t * request = json_object(); json_t * request = json_object();
json_object_set_new(request, "method", json_string("some_method")); json_object_set_new(request, "method", json_string("some_method"));
json_object_set_new(request, "params", json_string("invalid_params")); json_object_set_new(request, "params", json_string("invalid_params"));
json_object_set_new(request, "id", json_integer(42)); json_object_set_new(request, "id", json_integer(42));
ASSERT_FALSE(wf_jsonrpc_is_request(request)); ASSERT_FALSE(wfp_jsonrpc_is_request(request));
json_decref(request); json_decref(request);
} }

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

Loading…
Cancel
Save