csync_vio_method.h

Go to the documentation of this file.
00001 /*
00002  * libcsync -- a library to sync a directory with another
00003  *
00004  * Copyright (c) 2008      by Andreas Schneider <mail@cynapses.org>
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  *
00020  * vim: ft=c.doxygen ts=2 sw=2 et cindent
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   (method != NULL && method->func != NULL \
00034    && ((size_t)(((char *)&((method)->func)) - ((char *)(method))) < (method)->method_table_size))
00035 
00036 typedef struct csync_vio_method_s csync_vio_method_t;
00037 
00038 /* module capabilities definition.
00039  * remember to set useful defaults in csync_vio.c if you add something here. */
00040 struct csync_vio_capabilities_s {
00041  bool atomar_copy_support; /* set to true if the backend provides atomar copy */
00042  bool do_post_copy_stat;   /* true if csync should check the copy afterwards  */
00043  bool time_sync_required;  /* true if local and remote need to be time synced */
00044  int  unix_extensions;     /* -1: do csync detection, 0: no unix extensions,
00045                                1: extensions available */
00046  bool use_send_file_to_propagate; /* if set, the module rather copies files using send_file than read and write */
00047 };
00048 
00049 typedef struct csync_vio_capabilities_s csync_vio_capabilities_t;
00050 
00051 typedef csync_vio_method_t *(*csync_vio_method_init_fn)(const char *method_name,
00052     const char *config_args, csync_auth_callback cb, void *userdata);
00053 typedef void (*csync_vio_method_finish_fn)(csync_vio_method_t *method);
00054 
00055 typedef csync_vio_capabilities_t *(*csync_method_get_capabilities_fn)(void);
00056 typedef const char* (*csync_method_get_file_id_fn)(const char* path);
00057 typedef csync_vio_method_handle_t *(*csync_method_open_fn)(const char *durl, int flags, mode_t mode);
00058 typedef csync_vio_method_handle_t *(*csync_method_creat_fn)(const char *durl, mode_t mode);
00059 typedef int (*csync_method_close_fn)(csync_vio_method_handle_t *fhandle);
00060 typedef ssize_t (*csync_method_read_fn)(csync_vio_method_handle_t *fhandle, void *buf, size_t count);
00061 typedef ssize_t (*csync_method_write_fn)(csync_vio_method_handle_t *fhandle, const void *buf, size_t count);
00062 typedef int (*csync_method_sendfile_fn)(csync_vio_method_handle_t *src, csync_vio_method_handle_t *dst);
00063 typedef int64_t (*csync_method_lseek_fn)(csync_vio_method_handle_t *fhandle, int64_t offset, int whence);
00064 
00065 typedef csync_vio_method_handle_t *(*csync_method_opendir_fn)(const char *name);
00066 typedef int (*csync_method_closedir_fn)(csync_vio_method_handle_t *dhandle);
00067 typedef csync_vio_file_stat_t *(*csync_method_readdir_fn)(csync_vio_method_handle_t *dhandle);
00068 
00069 typedef int (*csync_method_mkdir_fn)(const char *uri, mode_t mode);
00070 typedef int (*csync_method_rmdir_fn)(const char *uri);
00071 
00072 typedef int (*csync_method_stat_fn)(const char *uri, csync_vio_file_stat_t *buf);
00073 typedef int (*csync_method_rename_fn)(const char *olduri, const char *newuri);
00074 typedef int (*csync_method_unlink_fn)(const char *uri);
00075 
00076 typedef int (*csync_method_chmod_fn)(const char *uri, mode_t mode);
00077 typedef int (*csync_method_chown_fn)(const char *uri, uid_t owner, gid_t group);
00078 
00079 typedef int (*csync_method_utimes_fn)(const char *uri, const struct timeval times[2]);
00080 
00081 typedef int (*csync_method_set_property_fn)(const char *key, void *data);
00082 
00083 typedef char* (*csync_method_get_error_string_fn)();
00084 typedef void (*csync_method_commit_fn)();
00085 
00086 struct csync_vio_method_s {
00087         size_t method_table_size;           /* Used for versioning */
00088         csync_method_get_capabilities_fn get_capabilities;
00089         csync_method_get_file_id_fn get_file_id;
00090         csync_method_open_fn open;
00091         csync_method_creat_fn creat;
00092         csync_method_close_fn close;
00093         csync_method_read_fn read;
00094         csync_method_write_fn write;
00095         csync_method_lseek_fn lseek;
00096         csync_method_opendir_fn opendir;
00097         csync_method_closedir_fn closedir;
00098         csync_method_readdir_fn readdir;
00099         csync_method_mkdir_fn mkdir;
00100         csync_method_rmdir_fn rmdir;
00101         csync_method_stat_fn stat;
00102         csync_method_rename_fn rename;
00103         csync_method_unlink_fn unlink;
00104         csync_method_chmod_fn chmod;
00105         csync_method_chown_fn chown;
00106         csync_method_utimes_fn utimes;
00107         csync_method_sendfile_fn sendfile;
00108         csync_method_set_property_fn set_property;
00109         csync_method_get_error_string_fn get_error_string;
00110         csync_method_commit_fn commit;
00111 };
00112 
00113 #endif /* _CSYNC_VIO_H */

Generated on Mon Oct 21 19:24:18 2013 for doc by  doxygen 1.5.6