57 lines
1.7 KiB
C
Raw Normal View History

2026-01-06 14:23:31 +01:00
/* retoor <retoor@molodetz.nl> */
#ifndef FUSEDAV_WEBDAV_H
#define FUSEDAV_WEBDAV_H
#include <curl/curl.h>
#include <pthread.h>
#include <stdint.h>
#include <sys/stat.h>
#include "cache.h"
#include "config.h"
typedef struct {
char *webdav_url;
char *username;
char *password;
CURL *curl_handle;
cache_t *metadata_cache;
cache_t *dir_cache;
int cache_ttl_ms;
int request_timeout_sec;
int debug;
pthread_mutex_t lock;
} webdav_context_t;
typedef struct {
char *path;
char *etag;
off_t file_size;
time_t last_modified;
uint8_t *write_buffer;
size_t write_buffer_pos;
size_t write_buffer_size;
int dirty;
} file_handle_t;
int webdav_init(webdav_context_t *ctx, const config_t *cfg);
void webdav_cleanup(webdav_context_t *ctx);
int webdav_get_stat(webdav_context_t *ctx, const char *path, struct stat *st);
int webdav_list_directory(webdav_context_t *ctx, const char *path, dir_listing_t *listing);
ssize_t webdav_read_file(webdav_context_t *ctx, const char *path,
off_t offset, size_t size, uint8_t *buffer);
ssize_t webdav_write_file(webdav_context_t *ctx, const char *path,
off_t offset, size_t size, const uint8_t *buffer);
int webdav_create_file(webdav_context_t *ctx, const char *path);
int webdav_mkdir(webdav_context_t *ctx, const char *path);
int webdav_delete(webdav_context_t *ctx, const char *path);
int webdav_rename(webdav_context_t *ctx, const char *old_path, const char *new_path);
int webdav_truncate(webdav_context_t *ctx, const char *path, off_t size);
file_handle_t *file_handle_create(const char *path);
void file_handle_destroy(file_handle_t *fh);
int file_handle_flush(webdav_context_t *ctx, file_handle_t *fh);
#endif