csync_vio_method.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #ifndef _CSYNC_VIO_METHOD_H
00024 #define _CSYNC_VIO_METHOD_H
00025 
00026 #include <sys/time.h>
00027 
00028 #include "csync.h"
00029 #include "vio/csync_vio_file_stat.h"
00030 #include "vio/csync_vio_handle.h"
00031 
00032 #define VIO_METHOD_HAS_FUNC(method,func) \
00033   ((((char *)&((method)->func)) - ((char *)(method)) < (method)->method_table_size) \
00034   && method->func != NULL)
00035 
00036 typedef struct csync_vio_method_s csync_vio_method_t;
00037 
00038 typedef csync_vio_method_t *(*csync_vio_method_init_fn)(const char *method_name,
00039     const char *config_args, csync_auth_callback cb, void *userdata);
00040 typedef void (*csync_vio_method_finish_fn)(csync_vio_method_t *method);
00041 
00042 typedef csync_vio_method_handle_t *(*csync_method_open_fn)(const char *durl, int flags, mode_t mode);
00043 typedef csync_vio_method_handle_t *(*csync_method_creat_fn)(const char *durl, mode_t mode);
00044 typedef int (*csync_method_close_fn)(csync_vio_method_handle_t *fhandle);
00045 typedef ssize_t (*csync_method_read_fn)(csync_vio_method_handle_t *fhandle, void *buf, size_t count);
00046 typedef ssize_t (*csync_method_write_fn)(csync_vio_method_handle_t *fhandle, const void *buf, size_t count);
00047 typedef off_t (*csync_method_lseek_fn)(csync_vio_method_handle_t *fhandle, off_t offset, int whence);
00048 
00049 typedef csync_vio_method_handle_t *(*csync_method_opendir_fn)(const char *name);
00050 typedef int (*csync_method_closedir_fn)(csync_vio_method_handle_t *dhandle);
00051 typedef csync_vio_file_stat_t *(*csync_method_readdir_fn)(csync_vio_method_handle_t *dhandle);
00052 
00053 typedef int (*csync_method_mkdir_fn)(const char *uri, mode_t mode);
00054 typedef int (*csync_method_rmdir_fn)(const char *uri);
00055 
00056 typedef int (*csync_method_stat_fn)(const char *uri, csync_vio_file_stat_t *buf);
00057 typedef int (*csync_method_rename_fn)(const char *olduri, const char *newuri);
00058 typedef int (*csync_method_unlink_fn)(const char *uri);
00059 
00060 typedef int (*csync_method_chmod_fn)(const char *uri, mode_t mode);
00061 typedef int (*csync_method_chown_fn)(const char *uri, uid_t owner, gid_t group);
00062 
00063 typedef int (*csync_method_utimes_fn)(const char *uri, const struct timeval times[2]);
00064 
00065 struct csync_vio_method_s {
00066         size_t method_table_size;           
00067         csync_method_open_fn open;
00068         csync_method_creat_fn creat;
00069         csync_method_close_fn close;
00070         csync_method_read_fn read;
00071         csync_method_write_fn write;
00072         csync_method_lseek_fn lseek;
00073         csync_method_opendir_fn opendir;
00074         csync_method_closedir_fn closedir;
00075         csync_method_readdir_fn readdir;
00076         csync_method_mkdir_fn mkdir;
00077         csync_method_rmdir_fn rmdir;
00078         csync_method_stat_fn stat;
00079         csync_method_rename_fn rename;
00080         csync_method_unlink_fn unlink;
00081         csync_method_chmod_fn chmod;
00082         csync_method_chown_fn chown;
00083         csync_method_utimes_fn utimes;
00084 };
00085 
00086 #endif