#ifndef _WEBDAVD_H_INCLUDE
#define _WEBDAVD_H_INCLUDE
#define DEBUG_ASSERT_PRODUCTION_CODE 0
#define WEBDAV_LOG_LEVEL LOG_ERR
#define DEBUG_ASSERT_COMPONENT_NAME_STRING "webdavfs"
#define DEBUG_ASSERT_MESSAGE(componentNameString, assertionString, exceptionLabelString, errorString, fileName, lineNumber, errorCode) \
webdav_debug_assert(componentNameString, assertionString, exceptionLabelString, errorString, fileName, lineNumber, errorCode)
#include <AssertMacros.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/syslog.h>
#include "../webdav_fs.kextproj/webdav_fs.kmodproj/webdav.h"
#include <errno.h>
#include <mach/boolean.h>
#include <unistd.h>
#include <CoreFoundation/CFURL.h>
#include <CoreFoundation/CoreFoundation.h>
#define WEBDAV_RLIMIT_NOFILE 1024
#define WEBDAV_MAX_OPEN_FILES 512
#define WEBDAV_DEFAULT_CACHE_MAX_SIZE 0x02000000
#define WEBDAV_ONE_GIGABYTE 0x40000000
#define WEBDAV_REQUEST_THREADS 5
#define PRIVATE_CERT_UI_COMMAND "/System/Library/Filesystems/webdav.fs/Support/webdav_cert_ui.app/Contents/MacOS/webdav_cert_ui"
#define PRIVATE_LOAD_COMMAND "/System/Library/Extensions/webdav_fs.kext/Contents/Resources/load_webdav"
#define PRIVATE_UNMOUNT_COMMAND "/sbin/umount"
#define PRIVATE_UNMOUNT_FLAGS "-f"
#define WEBDAV_PULSE_TIMEOUT "600"
#define APPLEDOUBLEHEADER_LENGTH 82
#define BODY_BUFFER_SIZE 0x10000
#define WEBDAV_ROOTPARENTFILEID 2
#define WEBDAV_ROOTFILEID 3
#define WEBDAV_DIR_SIZE 2048
#define WEBDAV_IOSIZE (4*1024)
#define WEBDAV_WRITESEQ_RSPBUF_LEN 4096
#define WEBDAV_WRITESEQ_REQUEST_TIMEOUT 30
#define WEBDAV_MANAGER_STARTUP_TIMEOUT 5
#define CFReleaseNull(obj) do { if(obj != NULL) { CFRelease(obj); obj = NULL; } } while (0)
struct seqwrite_mgr_req;
enum WriteMgrStatus {WR_MGR_VIRGIN=0, WR_MGR_RUNNING, WR_MGR_DONE};
struct stream_put_ctx {
CFReadStreamRef rdStreamRef;
CFWriteStreamRef wrStreamRef;
struct ReadStreamRec* readStreamRec;
CFReadStreamRef rspStreamRef;
int sockfd[2];
CFTypeRef theResponsePropertyRef;
off_t curr_offset;
pthread_mutex_t ctx_lock;
pthread_cond_t ctx_condvar;
CFRunLoopRef mgr_rl;
enum WriteMgrStatus mgr_status;
uint32_t canAcceptBytesEvents;
CFMessagePortRef mgrPort;
struct seqwrite_mgr_req *req_head, *req_tail;
bool finalStatusValid;
int finalStatus;
CFIndex totalRead;
UInt8 rspBuf[WEBDAV_WRITESEQ_RSPBUF_LEN];
bool writeStreamOpenEventReceived;
bool rspStreamOpenEventReceived;
uint32_t is_retry;
};
enum SeqWriteMgrReqType {SEQWRITE_CHUNK, SEQWRITE_CLOSE};
struct seqwrite_mgr_req
{
enum SeqWriteMgrReqType type;
struct seqwrite_mgr_req *prev, *next;
pthread_mutex_t req_lock;
pthread_cond_t req_condvar;
struct webdav_request_writeseq *req;
bool request_done;
uint32_t is_retry; int error;
CFIndex chunkLen, chunkWritten;
uint32_t refCount;
unsigned char *data;
};
extern void webdav_debug_assert(const char *componentNameString, const char *assertionString,
const char *exceptionLabelString, const char *errorString,
const char *fileName, long lineNumber, uint64_t errorCode);
extern void webdav_kill(int message);
extern unsigned int gtimeout_val;
extern char * gtimeout_string;
extern int gWebdavfsDebug;
extern uid_t gProcessUID;
extern int gSuppressAllUI;
extern int gSecureServerAuth;
extern char gWebdavCachePath[MAXPATHLEN + 1];
extern int gSecureConnection;
extern CFURLRef gBaseURL;
extern uint32_t gServerIdent;
#include "webdav_cache.h"
extern int filesystem_lookup(struct webdav_request_lookup *request_lookup,
struct webdav_reply_lookup *reply_lookup);
extern int filesystem_create(struct webdav_request_create *request_create,
struct webdav_reply_create *reply_create);
extern int filesystem_open(struct webdav_request_open *request_open,
struct webdav_reply_open *reply_open);
extern int filesystem_close(struct webdav_request_close *request_close);
extern int filesystem_getattr(struct webdav_request_getattr *request_getattr,
struct webdav_reply_getattr *reply_getattr);
extern int filesystem_read(struct webdav_request_read *request_read,
char **a_byte_addr, size_t *a_size);
extern int filesystem_fsync(struct webdav_request_fsync *request_fsync);
extern int filesystem_remove(struct webdav_request_remove *request_remove);
extern int filesystem_rename(struct webdav_request_rename *request_rename);
extern int filesystem_mkdir(struct webdav_request_mkdir *request_mkdir,
struct webdav_reply_mkdir *reply_mkdir);
extern int filesystem_rmdir(struct webdav_request_rmdir *request_rmdir);
extern int filesystem_write_seq(struct webdav_request_writeseq *request_sq_wr);
extern int filesystem_readdir(struct webdav_request_readdir *request_readdir);
extern int filesystem_statfs(struct webdav_request_statfs *request_statfs,
struct webdav_reply_statfs *reply_statfs);
extern int filesystem_invalidate_caches(struct webdav_request_invalcaches *request_invalcaches);
extern int filesystem_mount(int *a_mount_args);
extern int filesystem_lock(struct node_entry *node);
extern int filesystem_init(int typenum);
#endif