mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
fixes missing files
This commit is contained in:
parent
d205d2f127
commit
76713554ee
88
include/wsfs/provider/client_config.h
Normal file
88
include/wsfs/provider/client_config.h
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef WSFS_PROVIDER_CLIENT_CONFIG_H
|
||||
#define WSFS_PROVIDER_CLIENT_CONFIG_H
|
||||
|
||||
#include <wsfs/provider/api.h>
|
||||
|
||||
#include <wsfs/provider/operation/lookup.h>
|
||||
#include <wsfs/provider/operation/getattr.h>
|
||||
#include <wsfs/provider/operation/readdir.h>
|
||||
#include <wsfs/provider/operation/open.h>
|
||||
#include <wsfs/provider/operation/close.h>
|
||||
#include <wsfs/provider/operation/read.h>
|
||||
|
||||
struct wsfsp_client_config;
|
||||
|
||||
typedef void wsfsp_connected_fn(
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_disconnected_fn(
|
||||
void * user_data);
|
||||
|
||||
typedef void wsfsp_ontimer_fn(
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern WSFSP_API struct wsfsp_client_config * wsfsp_client_config_create(void);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_dispose(
|
||||
struct wsfsp_client_config * config);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_userdata(
|
||||
struct wsfsp_client_config * config,
|
||||
void * user_data);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_keypath(
|
||||
struct wsfsp_client_config * config,
|
||||
char const * key_path);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_certpath(
|
||||
struct wsfsp_client_config * config,
|
||||
char const * cert_path);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onconnected(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_connected_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_ondisconnected(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_disconnected_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_ontimer(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_ontimer_fn * handler);
|
||||
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onlookup(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_lookup_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_ongetattr(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_getattr_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onreaddir(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_readdir_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onopen(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_open_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onclose(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_close_fn * handler);
|
||||
|
||||
extern WSFSP_API void wsfsp_client_config_set_onread(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_read_fn * handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
17
include/wsfs/status.h
Normal file
17
include/wsfs/status.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef WSFS_STATUS_H
|
||||
#define WSFS_STATUS_H
|
||||
|
||||
#define WSFS_GOOD 0
|
||||
#define WSFS_BAD 1
|
||||
|
||||
#define WSFS_BAD_NOTIMPLEMENTED 2
|
||||
#define WSFS_BAD_TIMEOUT 3
|
||||
#define WSFS_BAD_BUSY 4
|
||||
#define WSFS_BAD_FORMAT 5
|
||||
|
||||
#define WSFS_BAD_NOENTRY 101
|
||||
#define WSFS_BAD_NOACCESS 102
|
||||
|
||||
typedef int wsfs_status;
|
||||
|
||||
#endif
|
112
lib/wsfs/provider/client_config.c
Normal file
112
lib/wsfs/provider/client_config.c
Normal file
@ -0,0 +1,112 @@
|
||||
#include "wsfs/provider/client_config_intern.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct wsfsp_client_config * wsfsp_client_config_create(void)
|
||||
{
|
||||
struct wsfsp_client_config * config = malloc(sizeof(struct wsfsp_client_config));
|
||||
if (NULL != config)
|
||||
{
|
||||
wsfsp_provider_init(&config->provider);
|
||||
config->user_data = NULL;
|
||||
config->key_path = NULL;
|
||||
config->cert_path = NULL;
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_dispose(
|
||||
struct wsfsp_client_config * config)
|
||||
{
|
||||
free(config->key_path);
|
||||
free(config->cert_path);
|
||||
free(config);
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_userdata(
|
||||
struct wsfsp_client_config * config,
|
||||
void * user_data)
|
||||
{
|
||||
config->user_data = user_data;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_keypath(
|
||||
struct wsfsp_client_config * config,
|
||||
char const * key_path)
|
||||
{
|
||||
free(config->key_path);
|
||||
config->key_path = strdup(key_path);
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_certpath(
|
||||
struct wsfsp_client_config * config,
|
||||
char const * cert_path)
|
||||
{
|
||||
free(config->cert_path);
|
||||
config->cert_path = strdup(cert_path);
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onconnected(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_connected_fn * handler)
|
||||
{
|
||||
config->provider.connected = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_ondisconnected(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_disconnected_fn * handler)
|
||||
{
|
||||
config->provider.disconnected = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_ontimer(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_ontimer_fn * handler)
|
||||
{
|
||||
config->provider.ontimer = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onlookup(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_lookup_fn * handler)
|
||||
{
|
||||
config->provider.lookup = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_ongetattr(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_getattr_fn * handler)
|
||||
{
|
||||
config->provider.getattr = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onreaddir(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_readdir_fn * handler)
|
||||
{
|
||||
config->provider.readdir = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onopen(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_open_fn * handler)
|
||||
{
|
||||
config->provider.open = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onclose(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_close_fn * handler)
|
||||
{
|
||||
config->provider.close = handler;
|
||||
}
|
||||
|
||||
void wsfsp_client_config_set_onread(
|
||||
struct wsfsp_client_config * config,
|
||||
wsfsp_read_fn * handler)
|
||||
{
|
||||
config->provider.read = handler;
|
||||
}
|
24
lib/wsfs/provider/client_config_intern.h
Normal file
24
lib/wsfs/provider/client_config_intern.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef WSFS_PROVIDER_CLIENT_CONFIG_INTERN_H
|
||||
#define WSFS_PROVIDER_CLIENT_CONFIG_INTERN_H
|
||||
|
||||
#include "wsfs/provider/client_config.h"
|
||||
#include "wsfs/provider/provider.h"
|
||||
|
||||
struct wsfsp_client_config
|
||||
{
|
||||
struct wsfsp_provider provider;
|
||||
void * user_data;
|
||||
char * key_path;
|
||||
char * cert_path;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
65
lib/wsfs/provider/provider.h
Normal file
65
lib/wsfs/provider/provider.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef WSFS_PROVIDER_PROVIDER_H
|
||||
#define WSFS_PROVIDER_PROVIDER_H
|
||||
|
||||
#include "wsfs/provider/client_config.h"
|
||||
#include "wsfs/provider/request.h"
|
||||
#include <wsfs/provider/operation/lookup.h>
|
||||
#include <wsfs/provider/operation/getattr.h>
|
||||
#include <wsfs/provider/operation/readdir.h>
|
||||
#include <wsfs/provider/operation/open.h>
|
||||
#include <wsfs/provider/operation/close.h>
|
||||
#include <wsfs/provider/operation/read.h>
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
struct wsfsp_provider
|
||||
{
|
||||
wsfsp_connected_fn * connected;
|
||||
wsfsp_disconnected_fn * disconnected;
|
||||
wsfsp_ontimer_fn * ontimer;
|
||||
wsfsp_lookup_fn * lookup;
|
||||
wsfsp_getattr_fn * getattr;
|
||||
wsfsp_readdir_fn * readdir;
|
||||
wsfsp_open_fn * open;
|
||||
wsfsp_close_fn * close;
|
||||
wsfsp_read_fn * read;
|
||||
};
|
||||
|
||||
struct wsfsp_invokation_context
|
||||
{
|
||||
struct wsfsp_provider * provider;
|
||||
void * user_data;
|
||||
struct wsfsp_request * request;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_provider_init(
|
||||
struct wsfsp_provider * provider);
|
||||
|
||||
extern void wsfsp_provider_init_from_prototype(
|
||||
struct wsfsp_provider * provider,
|
||||
struct wsfsp_provider const * prototype);
|
||||
|
||||
|
||||
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
|
||||
|
||||
#endif
|
34
lib/wsfs/status.c
Normal file
34
lib/wsfs/status.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include "wsfs/status_intern.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
int wsfs_status_to_rc(wsfs_status status)
|
||||
{
|
||||
switch(status)
|
||||
{
|
||||
case WSFS_GOOD: return 0;
|
||||
case WSFS_BAD_NOTIMPLEMENTED: return -ENOSYS;
|
||||
case WSFS_BAD_TIMEOUT: return -ETIMEDOUT;
|
||||
case WSFS_BAD_BUSY: return -ENOENT;
|
||||
case WSFS_BAD_FORMAT: return -ENOENT;
|
||||
case WSFS_BAD_NOENTRY: return -ENOENT;
|
||||
case WSFS_BAD_NOACCESS: return -EACCES;
|
||||
default: return -ENOENT;
|
||||
}
|
||||
}
|
||||
|
||||
char const * wsfs_status_tostring(wsfs_status status)
|
||||
{
|
||||
switch(status)
|
||||
{
|
||||
case WSFS_GOOD: return "Good";
|
||||
case WSFS_BAD: return "Bad";
|
||||
case WSFS_BAD_NOTIMPLEMENTED: return "Bad (not implelemted)";
|
||||
case WSFS_BAD_TIMEOUT: return "Bad (timeout)";
|
||||
case WSFS_BAD_BUSY: return "Bad (busy)";
|
||||
case WSFS_BAD_FORMAT: return "Bad (format)";
|
||||
case WSFS_BAD_NOENTRY: return "Bad (no entry)";
|
||||
case WSFS_BAD_NOACCESS: return "Bad (no access)";
|
||||
default: return "Bad (unknown)";
|
||||
}
|
||||
}
|
19
lib/wsfs/status_intern.h
Normal file
19
lib/wsfs/status_intern.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef WSFS_STATUS_INTERN_H
|
||||
#define WSFS_STATUS_INTERN_H
|
||||
|
||||
#include "wsfs/status.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int wsfs_status_to_rc(wsfs_status status);
|
||||
|
||||
extern char const * wsfs_status_tostring(wsfs_status status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user