mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
refactor: replaced jansson by own json parser implementation
This commit is contained in:
@@ -1,26 +1,27 @@
|
||||
#include "webfuse_provider/impl/operation/close.h"
|
||||
#include <limits.h>
|
||||
#include "webfuse_provider/impl/util/util.h"
|
||||
#include "webfuse_provider/impl/json/node.h"
|
||||
|
||||
void wfp_impl_close(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int WFP_UNUSED_PARAM(id))
|
||||
{
|
||||
size_t const param_count = json_array_size(params);
|
||||
size_t const param_count = wfp_impl_json_array_size(params);
|
||||
if (4 == param_count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 1);
|
||||
json_t * handle_holder = json_array_get(params, 2);
|
||||
json_t * flags_holder = json_array_get(params, 3);
|
||||
struct wfp_json const * inode_holder = wfp_impl_json_array_get(params, 1);
|
||||
struct wfp_json const * handle_holder = wfp_impl_json_array_get(params, 2);
|
||||
struct wfp_json const * flags_holder = wfp_impl_json_array_get(params, 3);
|
||||
|
||||
if (json_is_integer(inode_holder) &&
|
||||
json_is_integer(handle_holder) &&
|
||||
json_is_integer(flags_holder))
|
||||
if (wfp_impl_json_is_int(inode_holder) &&
|
||||
wfp_impl_json_is_int(handle_holder) &&
|
||||
wfp_impl_json_is_int(flags_holder))
|
||||
{
|
||||
ino_t inode = (ino_t) json_integer_value(inode_holder);
|
||||
uint32_t handle = (uint32_t) (json_integer_value(handle_holder) & UINT32_MAX);
|
||||
int flags = json_integer_value(flags_holder);
|
||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
||||
uint32_t handle = (uint32_t) (wfp_impl_json_get_int(handle_holder) & UINT32_MAX);
|
||||
int flags = wfp_impl_json_get_int(flags_holder);
|
||||
|
||||
context->provider->close(inode, handle, flags, context->user_data);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ extern "C"
|
||||
|
||||
extern void wfp_impl_close(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id);
|
||||
|
||||
extern void wfp_impl_close_default(
|
||||
|
||||
@@ -6,21 +6,22 @@
|
||||
#include "webfuse_provider/impl/request.h"
|
||||
#include "webfuse_provider/impl/message_writer.h"
|
||||
#include "webfuse_provider/impl/util/util.h"
|
||||
#include "webfuse_provider/impl/json/node.h"
|
||||
|
||||
|
||||
void wfp_impl_getattr(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id)
|
||||
{
|
||||
size_t const count = json_array_size(params);
|
||||
size_t const count = wfp_impl_json_array_size(params);
|
||||
if (2 == count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 1);
|
||||
struct wfp_json const * inode_holder = wfp_impl_json_array_get(params, 1);
|
||||
|
||||
if (json_is_integer(inode_holder))
|
||||
if (wfp_impl_json_is_int(inode_holder))
|
||||
{
|
||||
ino_t inode = (ino_t) json_integer_value(inode_holder);
|
||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||
|
||||
context->provider->getattr(request, inode, context->user_data);
|
||||
|
||||
@@ -14,7 +14,7 @@ extern void wfp_impl_respond_getattr(
|
||||
|
||||
extern void wfp_impl_getattr(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id);
|
||||
|
||||
extern void wfp_impl_getattr_default(
|
||||
|
||||
@@ -6,23 +6,24 @@
|
||||
#include "webfuse_provider/impl/request.h"
|
||||
#include "webfuse_provider/impl/message_writer.h"
|
||||
#include "webfuse_provider/impl/util/util.h"
|
||||
#include "webfuse_provider/impl/json/node.h"
|
||||
|
||||
void wfp_impl_lookup(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id)
|
||||
{
|
||||
size_t const count = json_array_size(params);
|
||||
size_t const count = wfp_impl_json_array_size(params);
|
||||
if (3 == count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 1);
|
||||
json_t * name_holder = json_array_get(params, 2);
|
||||
struct wfp_json const * inode_holder = wfp_impl_json_array_get(params, 1);
|
||||
struct wfp_json const * name_holder = wfp_impl_json_array_get(params, 2);
|
||||
|
||||
if (json_is_integer(inode_holder) &&
|
||||
json_is_string(name_holder))
|
||||
if (wfp_impl_json_is_int(inode_holder) &&
|
||||
wfp_impl_json_is_string(name_holder))
|
||||
{
|
||||
ino_t inode = json_integer_value(inode_holder);
|
||||
char const * name = json_string_value(name_holder);
|
||||
ino_t inode = wfp_impl_json_get_int(inode_holder);
|
||||
char const * name = wfp_impl_json_get_string(name_holder);
|
||||
|
||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||
context->provider->lookup(request, inode, name, context->user_data);
|
||||
|
||||
@@ -14,7 +14,7 @@ extern void wfp_impl_respond_lookup(
|
||||
|
||||
extern void wfp_impl_lookup(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id);
|
||||
|
||||
extern void wfp_impl_lookup_default(
|
||||
|
||||
@@ -3,23 +3,24 @@
|
||||
#include "webfuse_provider/impl/request.h"
|
||||
#include "webfuse_provider/impl/message_writer.h"
|
||||
#include "webfuse_provider/impl/util/util.h"
|
||||
#include "webfuse_provider/impl/json/node.h"
|
||||
|
||||
void wfp_impl_open(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id)
|
||||
{
|
||||
size_t const count = json_array_size(params);
|
||||
size_t const count = wfp_impl_json_array_size(params);
|
||||
if (3 == count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 1);
|
||||
json_t * flags_holder = json_array_get(params, 2);
|
||||
struct wfp_json const * inode_holder = wfp_impl_json_array_get(params, 1);
|
||||
struct wfp_json const * flags_holder = wfp_impl_json_array_get(params, 2);
|
||||
|
||||
if (json_is_integer(inode_holder) &&
|
||||
json_is_integer(flags_holder))
|
||||
if (wfp_impl_json_is_int(inode_holder) &&
|
||||
wfp_impl_json_is_int(flags_holder))
|
||||
{
|
||||
ino_t inode = (ino_t) json_integer_value(inode_holder);
|
||||
int flags = (ino_t) json_integer_value(flags_holder);
|
||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
||||
int flags = (ino_t) wfp_impl_json_get_int(flags_holder);
|
||||
|
||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ extern void wfp_impl_respond_open(
|
||||
|
||||
extern void wfp_impl_open(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id);
|
||||
|
||||
extern void wfp_impl_open_default(
|
||||
|
||||
@@ -6,29 +6,30 @@
|
||||
#include "webfuse_provider/impl/request.h"
|
||||
#include "webfuse_provider/impl/message_writer.h"
|
||||
#include "webfuse_provider/impl/util/util.h"
|
||||
#include "webfuse_provider/impl/json/node.h"
|
||||
|
||||
void wfp_impl_read(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id)
|
||||
{
|
||||
size_t const count = json_array_size(params);
|
||||
size_t const count = wfp_impl_json_array_size(params);
|
||||
if (5 == count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 1);
|
||||
json_t * handle_holder = json_array_get(params, 2);
|
||||
json_t * offset_holder = json_array_get(params, 3);
|
||||
json_t * length_holder = json_array_get(params, 4);
|
||||
struct wfp_json const * inode_holder = wfp_impl_json_array_get(params, 1);
|
||||
struct wfp_json const * handle_holder = wfp_impl_json_array_get(params, 2);
|
||||
struct wfp_json const * offset_holder = wfp_impl_json_array_get(params, 3);
|
||||
struct wfp_json const * length_holder = wfp_impl_json_array_get(params, 4);
|
||||
|
||||
if (json_is_integer(inode_holder) &&
|
||||
json_is_integer(handle_holder) &&
|
||||
json_is_integer(offset_holder) &&
|
||||
json_is_integer(length_holder))
|
||||
if (wfp_impl_json_is_int(inode_holder) &&
|
||||
wfp_impl_json_is_int(handle_holder) &&
|
||||
wfp_impl_json_is_int(offset_holder) &&
|
||||
wfp_impl_json_is_int(length_holder))
|
||||
{
|
||||
ino_t inode = (ino_t) json_integer_value(inode_holder);
|
||||
int handle = json_integer_value(handle_holder);
|
||||
size_t offset = json_integer_value(offset_holder);
|
||||
size_t length = json_integer_value(length_holder);
|
||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
||||
int handle = wfp_impl_json_get_int(handle_holder);
|
||||
size_t offset = wfp_impl_json_get_int(offset_holder);
|
||||
size_t length = wfp_impl_json_get_int(length_holder);
|
||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||
|
||||
context->provider->read(request, inode, handle, offset, length, context->user_data);
|
||||
|
||||
@@ -15,7 +15,7 @@ extern void wfp_impl_respond_read(
|
||||
|
||||
extern void wfp_impl_read(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id);
|
||||
|
||||
extern void wfp_impl_read_default(
|
||||
|
||||
@@ -4,20 +4,21 @@
|
||||
#include "webfuse_provider/impl/request.h"
|
||||
#include "webfuse_provider/impl/message_writer.h"
|
||||
#include "webfuse_provider/impl/util/util.h"
|
||||
#include "webfuse_provider/impl/json/node.h"
|
||||
|
||||
void wfp_impl_readdir(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id)
|
||||
{
|
||||
size_t const count = json_array_size(params);
|
||||
size_t const count = wfp_impl_json_array_size(params);
|
||||
if (2 == count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 1);
|
||||
struct wfp_json const * inode_holder = wfp_impl_json_array_get(params, 1);
|
||||
|
||||
if (json_is_integer(inode_holder))
|
||||
if (wfp_impl_json_is_int(inode_holder))
|
||||
{
|
||||
ino_t inode = (ino_t) json_integer_value(inode_holder);
|
||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||
|
||||
context->provider->readdir(request, inode, context->user_data);
|
||||
|
||||
@@ -14,7 +14,7 @@ extern void wfp_impl_respond_readdir(
|
||||
|
||||
extern void wfp_impl_readdir(
|
||||
struct wfp_impl_invokation_context * context,
|
||||
json_t * params,
|
||||
struct wfp_json const * params,
|
||||
int id);
|
||||
|
||||
extern void wfp_impl_readdir_default(
|
||||
|
||||
Reference in New Issue
Block a user