1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-09-30 00:30:45 +00:00
falk-werner_webfuse-provider/include/webfuse/provider/operation/read.h

77 lines
2.0 KiB
C
Raw Normal View History

2020-02-17 20:53:42 +00:00
////////////////////////////////////////////////////////////////////////////////
/// \file provider/operation/read.h
/// \brief Read contents of a file.
////////////////////////////////////////////////////////////////////////////////
2019-03-26 22:04:53 +00:00
#ifndef WFP_OPERATION_READ_H
#define WFP_OPERATION_READ_H
2019-02-24 17:03:22 +00:00
#ifndef __cplusplus
#include <stddef.h>
#include <inttypes.h>
#else
#include <cstddef>
#include <cinttypes>
using std::size_t;
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
2019-03-26 22:04:53 +00:00
#include "webfuse/provider/api.h"
2019-02-24 17:03:22 +00:00
#ifdef __cplusplus
extern "C"
{
#endif
2019-03-26 22:04:53 +00:00
struct wfp_request;
2019-02-24 17:03:22 +00:00
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Requests content of a file.
///
/// On success, up to \arg length bytes should be returned via \ref
/// wfp_respond_read.
///
/// \note After this function is called, exactly one response must be sent,
/// either via \ref wfp_respond_read or via \ref wfp_respond_error.
///
/// \param request pointer to request
/// \param inode inode of the file to read
/// \param handle handle of the file to read (returned by open)
/// \param offset offset within the file where to start reading
/// \param length amount of bytes to read
/// \param user_data used defined context
///
/// \see wfp_respond_read
/// \see wfp_respond_error
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
typedef void wfp_read_fn(
struct wfp_request * request,
2019-02-24 17:03:22 +00:00
ino_t inode,
uint32_t handle,
size_t offset,
size_t length,
void * user_data);
2020-02-17 20:53:42 +00:00
//------------------------------------------------------------------------------
/// \brief Respond to read.
///
/// \note The user is responsible to manage lifetime of \arg data.
///
/// \param request pointer to request
/// \param data data read from file
/// \param length amount of bytes read
//------------------------------------------------------------------------------
2019-03-26 22:04:53 +00:00
extern WFP_API void wfp_respond_read(
struct wfp_request * request,
2019-02-24 17:03:22 +00:00
char const * data,
size_t length);
#ifdef __cplusplus
}
#endif
#endif