doc
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 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 
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 #include "vio/csync_vio_method.h"
00044 #include "csync_macros.h"
00045 
00046 /**
00047  * How deep to scan directories.
00048  */
00049 #define MAX_DEPTH 50
00050 
00051 /**
00052  * Maximum time difference between two replicas in seconds
00053  */
00054 #define MAX_TIME_DIFFERENCE 10
00055 
00056 /**
00057  * Maximum size of a buffer for transfer
00058  */
00059 #ifndef MAX_XFER_BUF_SIZE
00060 #define MAX_XFER_BUF_SIZE (16 * 1024)
00061 #endif
00062 
00063 #define CSYNC_STATUS_INIT 1 << 0
00064 #define CSYNC_STATUS_UPDATE 1 << 1
00065 #define CSYNC_STATUS_RECONCILE 1 << 2
00066 #define CSYNC_STATUS_PROPAGATE 1 << 3
00067 
00068 #define CSYNC_STATUS_DONE (CSYNC_STATUS_INIT | \
00069                            CSYNC_STATUS_UPDATE | \
00070                            CSYNC_STATUS_RECONCILE | \
00071                            CSYNC_STATUS_PROPAGATE)
00072 
00073 enum csync_replica_e {
00074   LOCAL_REPLICA,
00075   REMOTE_REPLCIA
00076 };
00077 
00078 /**
00079  * @brief csync public structure
00080  */
00081 struct csync_s {
00082   csync_auth_callback auth_callback;
00083   void *userdata;
00084   c_strlist_t *excludes;
00085 
00086   struct {
00087     char *file;
00088     sqlite3 *db;
00089     int exists;
00090     int disabled;
00091   } statedb;
00092 
00093   struct {
00094     char *uri;
00095     c_rbtree_t *tree;
00096     c_list_t *list;
00097     enum csync_replica_e type;
00098   } local;
00099 
00100   struct {
00101     char *uri;
00102     c_rbtree_t *tree;
00103     c_list_t *list;
00104     enum csync_replica_e type;
00105   } remote;
00106 
00107   struct {
00108     void *handle;
00109     csync_vio_method_t *method;
00110     csync_vio_method_finish_fn finish_fn;
00111     csync_vio_capabilities_t capabilities;
00112   } module;
00113 
00114   struct {
00115     int max_depth;
00116     int max_time_difference;
00117     int sync_symbolic_links;
00118     int unix_extensions;
00119     char *config_dir;
00120     bool with_conflict_copys;
00121     bool local_only_mode;
00122     bool remote_push_atomar;
00123   } options;
00124 
00125   struct {
00126     uid_t uid;
00127     uid_t euid;
00128   } pwd;
00129 
00130   /* replica we are currently walking */
00131   enum csync_replica_e current;
00132 
00133   /* replica we want to work on */
00134   enum csync_replica_e replica;
00135 
00136   /* error code of the last operation */
00137   enum csync_error_codes_e error_code;
00138 
00139   int status;
00140 };
00141 
00142 enum csync_ftw_type_e {
00143   CSYNC_FTW_TYPE_FILE,
00144   CSYNC_FTW_TYPE_SLINK,
00145   CSYNC_FTW_TYPE_DIR
00146 };
00147 
00148 #ifdef _MSC_VER
00149 #pragma pack(1)
00150 #endif
00151 struct csync_file_stat_s {
00152   uint64_t phash;   /* u64 */
00153   time_t modtime;   /* u64 */
00154   off_t size;       /* u64 */
00155   size_t pathlen;   /* u64 */
00156   uint64_t inode;   /* u64 */
00157   uid_t uid;        /* u32 */
00158   gid_t gid;        /* u32 */
00159   mode_t mode;      /* u32 */
00160   int nlink;        /* u32 */
00161   int type;         /* u32 */
00162   char *destpath;   /* for renames */
00163   enum csync_instructions_e instruction; /* u32 */
00164   char path[1]; /* u8 */
00165 }
00166 #if !defined(__SUNPRO_C) && !defined(_MSC_VER)
00167 __attribute__ ((packed))
00168 #endif
00169 #ifdef _MSC_VER
00170 #pragma pack()
00171 #endif
00172 ;
00173 
00174 typedef struct csync_file_stat_s csync_file_stat_t;
00175 
00176 /*
00177  * context for the treewalk function
00178  */
00179 struct _csync_treewalk_context_s
00180 {
00181     csync_treewalk_visit_func *user_visitor;
00182     int instruction_filter;
00183     void *userdata;
00184 };
00185 typedef struct _csync_treewalk_context_s _csync_treewalk_context;
00186 
00187 /**
00188  * }@
00189  */
00190 #endif /* _CSYNC_PRIVATE_H */
00191 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */