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

refactor: moved default implementation of operations to their modules

This commit is contained in:
Falk Werner 2019-02-24 19:16:29 +01:00
parent bc0dc2889d
commit 3bc041877a
18 changed files with 164 additions and 169 deletions

View File

@ -99,10 +99,9 @@ install(FILES "${PROJECT_BINARY_DIR}/libwsfs.pc" DESTINATION lib${LIB_SUFFIX}/pk
#libwsfs-provider
set(WSFS_PROVIDER_SOURCES
lib/wsfsp/url.c
lib/wsfsp/client.c
lib/wsfsp/client_protocol.c
lib/wsfsp/provider_default.c
lib/wsfsp/url.c
lib/wsfsp/provider.c
lib/wsfsp/operation/error.c
lib/wsfsp/operation/lookup.c

View File

@ -6,8 +6,15 @@
#include <libwebsockets.h>
#include <jansson.h>
#include "wsfsp/provider_default.h"
#include "wsfsp/provider_intern.h"
#include "wsfsp/operation/lookup_intern.h"
#include "wsfsp/operation/getattr_intern.h"
#include "wsfsp/operation/readdir_intern.h"
#include "wsfsp/operation/open_intern.h"
#include "wsfsp/operation/close_intern.h"
#include "wsfsp/operation/read_intern.h"
#include "wsfs/util.h"
static void wsfsp_client_protocol_respond(

View File

@ -26,4 +26,18 @@ void wsfsp_close(
}
}
}
void wsfsp_close_default(
ino_t inode,
uint32_t handle,
int flags,
void * user_data)
{
(void) inode;
(void) handle;
(void) flags;
(void) user_data;
// empty
}

View File

@ -14,6 +14,12 @@ extern void wsfsp_close(
json_t * params,
int id);
extern void wsfsp_close_default(
ino_t inode,
uint32_t handle,
int flags,
void * user_data);
#ifdef __cplusplus
}
#endif

View File

@ -1,6 +1,9 @@
#include "wsfsp/operation/getattr_intern.h"
#include <stdio.h>
#include "wsfsp/operation/error.h"
void wsfsp_getattr(
struct wsfsp_invokation_context * context,
json_t * params,
@ -13,6 +16,17 @@ void wsfsp_getattr(
puts("getattr");
}
void wsfsp_getattr_default(
struct wsfsp_request * request,
ino_t inode,
void * user_data)
{
(void) inode;
(void) user_data;
wsfsp_respond_error(request, -1);
}
void wsfsp_respond_getattr(
struct wsfsp_request * request,
struct stat const * stat)

View File

@ -14,6 +14,11 @@ extern void wsfsp_getattr(
json_t * params,
int id);
extern void wsfsp_getattr_default(
struct wsfsp_request * request,
ino_t inode,
void * user_data);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,6 @@
#include "wsfsp/operation/lookup_intern.h"
#include <stdio.h>
#include "wsfsp/operation/error.h"
void wsfsp_lookup(
struct wsfsp_invokation_context * context,
@ -22,3 +23,16 @@ void wsfsp_respond_lookup(
}
void wsfsp_lookup_default(
struct wsfsp_request * request,
ino_t parent,
char const * name,
void * user_data)
{
(void) parent;
(void) name;
(void) user_data;
wsfsp_respond_error(request, -1);
}

View File

@ -14,6 +14,12 @@ extern void wsfsp_lookup(
json_t * params,
int id);
extern void wsfsp_lookup_default(
struct wsfsp_request * request,
ino_t parent,
char const * name,
void * user_data);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,6 @@
#include "wsfsp/operation/open_intern.h"
#include <stdio.h>
#include "wsfsp/operation/error.h"
void wsfsp_open(
struct wsfsp_invokation_context * context,
@ -13,6 +14,19 @@ void wsfsp_open(
puts("open");
}
void wsfsp_open_default(
struct wsfsp_request * request,
ino_t inode,
int flags,
void * user_data)
{
(void) inode;
(void) flags;
(void) user_data;
wsfsp_respond_error(request, -1);
}
void wsfsp_respond_open(
struct wsfsp_request * request,
uint32_t handle)

View File

@ -14,6 +14,12 @@ extern void wsfsp_open(
json_t * params,
int id);
extern void wsfsp_open_default(
struct wsfsp_request * request,
ino_t inode,
int flags,
void * user_data);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,6 @@
#include "wsfsp/operation/read_intern.h"
#include <stdio.h>
#include "wsfsp/operation/error.h"
void wsfsp_read(
struct wsfsp_invokation_context * context,
@ -13,6 +14,23 @@ void wsfsp_read(
puts("read");
}
void wsfsp_read_default(
struct wsfsp_request * request,
ino_t inode,
uint32_t handle,
size_t offset,
size_t length,
void * user_data)
{
(void) inode;
(void) handle;
(void) offset;
(void) length;
(void) user_data;
wsfsp_respond_error(request, -1);
}
void wsfsp_respond_read(
struct wsfsp_request * request,
char const * data,

View File

@ -14,6 +14,14 @@ extern void wsfsp_read(
json_t * params,
int id);
extern void wsfsp_read_default(
struct wsfsp_request * request,
ino_t inode,
uint32_t handle,
size_t offset,
size_t length,
void * user_data);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,6 @@
#include "wsfsp/operation/readdir_intern.h"
#include <stdio.h>
#include "wsfsp/operation/error.h"
void wsfsp_readdir(
struct wsfsp_invokation_context * context,
@ -13,6 +14,17 @@ void wsfsp_readdir(
puts("readdir");
}
void wsfsp_readdir_default(
struct wsfsp_request * request,
ino_t directory,
void * user_data)
{
(void) directory;
(void) user_data;
wsfsp_respond_error(request, -1);
}
void wsfsp_respond_readdir(
struct wsfsp_request * request,
struct wsfsp_dirbuffer * dirbuffer)

View File

@ -14,6 +14,11 @@ extern void wsfsp_readdir(
json_t * params,
int id);
extern void wsfsp_readdir_default(
struct wsfsp_request * request,
ino_t directory,
void * user_data);
#ifdef __cplusplus
}
#endif

View File

@ -71,4 +71,28 @@ void wsfsp_provider_invoke(
wsfsp_provider_invoke_method(context, method, params, id);
}
}
void wsfsp_connected_default(
void * user_data)
{
(void) user_data;
// empty
}
void wsfsp_disconnected_default(
void * user_data)
{
(void) user_data;
// empty
}
void wsfsp_ontimer_default(
void * user_data)
{
(void) user_data;
// empty
}

View File

@ -1,105 +0,0 @@
#include "wsfsp/provider_default.h"
#include "wsfsp/operation/error.h"
void wsfsp_lookup_default(
struct wsfsp_request * request,
ino_t parent,
char const * name,
void * user_data)
{
(void) parent;
(void) name;
(void) user_data;
wsfsp_respond_error(request, -1);
}
void wsfsp_getattr_default(
struct wsfsp_request * request,
ino_t inode,
void * user_data)
{
(void) inode;
(void) user_data;
wsfsp_respond_error(request, -1);
}
void wsfsp_readdir_default(
struct wsfsp_request * request,
ino_t directory,
void * user_data)
{
(void) directory;
(void) user_data;
wsfsp_respond_error(request, -1);
}
void wsfsp_open_default(
struct wsfsp_request * request,
ino_t inode,
int flags,
void * user_data)
{
(void) inode;
(void) flags;
(void) user_data;
wsfsp_respond_error(request, -1);
}
void wsfsp_close_default(
ino_t inode,
uint32_t handle,
int flags,
void * user_data)
{
(void) inode;
(void) handle;
(void) flags;
(void) user_data;
// empty
}
void wsfsp_read_default(
struct wsfsp_request * request,
ino_t inode,
uint32_t handle,
size_t offset,
size_t length,
void * user_data)
{
(void) inode;
(void) handle;
(void) offset;
(void) length;
(void) user_data;
wsfsp_respond_error(request, -1);
}
void wsfsp_connected_default(
void * user_data)
{
(void) user_data;
// empty
}
void wsfsp_disconnected_default(
void * user_data)
{
(void) user_data;
// empty
}
void wsfsp_ontimer_default(
void * user_data)
{
(void) user_data;
// empty
}

View File

@ -1,61 +0,0 @@
#ifndef WSFSP_PROVIDER_DEFAULT_H
#define WSFSP_PROVIDER_DEFAULT_H
#include "wsfsp/provider.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern void wsfsp_lookup_default(
struct wsfsp_request * request,
ino_t parent,
char const * name,
void * user_data);
extern void wsfsp_getattr_default(
struct wsfsp_request * request,
ino_t inode,
void * user_data);
extern void wsfsp_readdir_default(
struct wsfsp_request * request,
ino_t directory,
void * user_data);
extern void wsfsp_open_default(
struct wsfsp_request * request,
ino_t inode,
int flags,
void * user_data);
extern void wsfsp_close_default(
ino_t inode,
uint32_t handle,
int flags,
void * user_data);
extern void wsfsp_read_default(
struct wsfsp_request * request,
ino_t inode,
uint32_t handle,
size_t offset,
size_t length,
void * user_data);
extern void wsfsp_connected_default(
void * user_data);
extern void wsfsp_disconnected_default(
void * user_data);
extern void wsfsp_ontimer_default(
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -20,6 +20,15 @@ extern void wsfsp_provider_invoke(
struct wsfsp_invokation_context * context,
json_t * request);
extern void wsfsp_connected_default(
void * user_data);
extern void wsfsp_disconnected_default(
void * user_data);
extern void wsfsp_ontimer_default(
void * user_data);
#ifdef __cplusplus
}
#endif