mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
1c9d1c8420
* moves implementation to impl subdirectory * adds prefix _impl to implementation symbols * removes double compilation for shared and static libraries * fixes include guards * fixes usage of extern "C"
55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
#include "wsfs/provider/impl/request.h"
|
|
|
|
#include <stdlib.h>
|
|
#include "wsfs/provider/impl/operation/error.h"
|
|
|
|
struct wsfsp_request * wsfsp_impl_request_create(
|
|
struct wsfsp_request * prototype,
|
|
int id)
|
|
{
|
|
struct wsfsp_request * request = malloc(sizeof(struct wsfsp_request));
|
|
if (NULL != request)
|
|
{
|
|
request->respond = prototype->respond;
|
|
request->user_data = prototype->user_data;
|
|
request->id = id;
|
|
}
|
|
|
|
return request;
|
|
}
|
|
|
|
void wsfsp_impl_request_dispose(
|
|
struct wsfsp_request * request)
|
|
{
|
|
free(request);
|
|
}
|
|
|
|
extern void wsfsp_impl_respond(
|
|
struct wsfsp_request * request,
|
|
json_t * result)
|
|
{
|
|
json_t * response = json_object();
|
|
json_object_set_new(response, "result", result);
|
|
json_object_set_new(response, "id", json_integer(request->id));
|
|
|
|
request->respond(response, request->user_data);
|
|
|
|
json_decref(response);
|
|
wsfsp_impl_request_dispose(request);
|
|
}
|
|
|
|
void wsfsp_impl_respond_error(
|
|
struct wsfsp_request * request,
|
|
wsfs_status status)
|
|
{
|
|
json_t * response = json_object();
|
|
json_t * error = json_object();
|
|
json_object_set_new(error, "code", json_integer(status));
|
|
json_object_set_new(response, "error", error);
|
|
json_object_set_new(response, "id", json_integer(request->id));
|
|
|
|
request->respond(response, request->user_data);
|
|
|
|
json_decref(response);
|
|
wsfsp_impl_request_dispose(request);
|
|
} |