csync_private.h

Go to the documentation of this file.
00001 /*
00002  * libcsync -- a library to sync a directory with another
00003  *
00004  * Copyright (c) 2006-2012 by Andreas Schneider <asn@cryptomilk.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 
00021 /**
00022  * @file csync_private.h
00023  *
00024  * @brief Private interface of csync
00025  *
00026  * @defgroup csyncInternalAPI csync internal API
00027  *
00028  * @{
00029  */
00030 
00031 #ifndef _CSYNC_PRIVATE_H
00032 #define _CSYNC_PRIVATE_H
00033 
00034 #include <stdint.h>
00035 #include <stdbool.h>
00036 #include <sqlite3.h>
00037 
00038 #include "config.h"
00039 #include "c_lib.h"
00040 #include "c_private.h"
00041 #include "csync.h"
00042 
00043 #ifdef WITH_ICONV
00044 #include <iconv.h>
00045 #endif
00046 
00047 #include "vio/csync_vio_method.h"
00048 #include "csync_macros.h"
00049 
00050 /**
00051  * How deep to scan directories.
00052  */
00053 #define MAX_DEPTH 50
00054 
00055 /**
00056  * Maximum time difference between two replicas in seconds
00057  */
00058 #define MAX_TIME_DIFFERENCE 10
00059 
00060 /**
00061  * Maximum size of a buffer for transfer
00062  */
00063 #ifndef MAX_XFER_BUF_SIZE
00064 #define MAX_XFER_BUF_SIZE (16 * 1024)
00065 #endif
00066 
00067 #define CSYNC_STATUS_INIT 1 << 0
00068 #define CSYNC_STATUS_UPDATE 1 << 1
00069 #define CSYNC_STATUS_RECONCILE 1 << 2
00070 #define CSYNC_STATUS_PROPAGATE 1 << 3
00071 
00072 #define CSYNC_STATUS_DONE (CSYNC_STATUS_INIT | \
00073                            CSYNC_STATUS_UPDATE | \
00074                            CSYNC_STATUS_RECONCILE | \
00075                            CSYNC_STATUS_PROPAGATE)
00076 
00077 enum csync_replica_e {
00078   LOCAL_REPLICA,
00079   REMOTE_REPLICA
00080 };
00081 
00082 /**
00083  * @brief csync public structure
00084  */
00085 struct csync_s {
00086   struct {
00087       csync_auth_callback auth_function;
00088       csync_log_callback log_function;
00089       csync_progress_callback progresscb;
00090       void *userdata;
00091   } callbacks;
00092   c_strlist_t *excludes;
00093 
00094   struct {
00095     char *file;
00096     sqlite3 *db;
00097     int exists;
00098     int disabled;
00099   } statedb;
00100 
00101   struct {
00102     char *uri;
00103     c_rbtree_t *tree;
00104     c_list_t *list;
00105     c_list_t *id_list;
00106     enum csync_replica_e type;
00107   } local;
00108 
00109   struct {
00110     char *uri;
00111     c_rbtree_t *tree;
00112     c_list_t *list;
00113     c_list_t *id_list;
00114     enum csync_replica_e type;
00115     int  read_from_db;
00116   } remote;
00117 
00118   struct {
00119     void *handle;
00120     csync_vio_method_t *method;
00121     csync_vio_method_finish_fn finish_fn;
00122     csync_vio_capabilities_t capabilities;
00123   } module;
00124 
00125   struct {
00126     int max_depth;
00127     int max_time_difference;
00128     int sync_symbolic_links;
00129     int unix_extensions;
00130     char *config_dir;
00131     bool with_conflict_copys;
00132     bool local_only_mode;
00133     bool remote_push_atomar;
00134     int log_verbosity;
00135     int timeout;
00136 #ifdef WITH_ICONV
00137     iconv_t iconv_cd;
00138 #endif
00139   } options;
00140 
00141   struct {
00142     uid_t uid;
00143     uid_t euid;
00144   } pwd;
00145 
00146   /* replica we are currently walking */
00147   enum csync_replica_e current;
00148 
00149   /* replica we want to work on */
00150   enum csync_replica_e replica;
00151 
00152   /* error code of the last operation */
00153   enum csync_error_codes_e error_code;
00154   char *error_string;
00155   
00156   int status;
00157 };
00158 
00159 
00160 #ifdef _MSC_VER
00161 #pragma pack(1)
00162 #endif
00163 struct csync_file_stat_s {
00164   uint64_t phash;   /* u64 */
00165   time_t modtime;   /* u64 */
00166   off_t size;       /* u64 */
00167   size_t pathlen;   /* u64 */
00168   uint64_t inode;   /* u64 */
00169   uid_t uid;        /* u32 */
00170   gid_t gid;        /* u32 */
00171   mode_t mode;      /* u32 */
00172   int nlink;        /* u32 */
00173   int type;         /* u32 */
00174 
00175   char *destpath;   /* for renames */
00176   const char *md5;
00177 
00178   enum csync_instructions_e instruction; /* u32 */
00179   char path[1]; /* u8 */
00180 }
00181 #if !defined(__SUNPRO_C) && !defined(_MSC_VER)
00182 __attribute__ ((packed))
00183 #endif
00184 #ifdef _MSC_VER
00185 #pragma pack()
00186 #endif
00187 ;
00188 
00189 typedef struct csync_file_stat_s csync_file_stat_t;
00190 
00191 /*
00192  * context for the treewalk function
00193  */
00194 struct _csync_treewalk_context_s
00195 {
00196     csync_treewalk_visit_func *user_visitor;
00197     int instruction_filter;
00198     void *userdata;
00199 };
00200 typedef struct _csync_treewalk_context_s _csync_treewalk_context;
00201 
00202 /**
00203  * }@
00204  */
00205 #endif /* _CSYNC_PRIVATE_H */
00206 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */

Generated on Mon Aug 18 13:53:10 2014 for doc by  doxygen 1.5.6