doc
csync_private.h
Go to the documentation of this file.
1 /*
2  * libcsync -- a library to sync a directory with another
3  *
4  * Copyright (c) 2006-2012 by Andreas Schneider <asn@cryptomilk.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 /**
22  * @file csync_private.h
23  *
24  * @brief Private interface of csync
25  *
26  * @defgroup csyncInternalAPI csync internal API
27  *
28  * @{
29  */
30 
31 #ifndef _CSYNC_PRIVATE_H
32 #define _CSYNC_PRIVATE_H
33 
34 #include <stdint.h>
35 #include <stdbool.h>
36 #include <sqlite3.h>
37 
38 #include "config.h"
39 #include "c_lib.h"
40 #include "c_private.h"
41 #include "csync.h"
42 
43 #ifdef WITH_ICONV
44 #include <iconv.h>
45 #endif
46 
47 #include "vio/csync_vio_method.h"
48 #include "csync_macros.h"
49 
50 /**
51  * How deep to scan directories.
52  */
53 #define MAX_DEPTH 50
54 
55 /**
56  * Maximum time difference between two replicas in seconds
57  */
58 #define MAX_TIME_DIFFERENCE 10
59 
60 /**
61  * Maximum size of a buffer for transfer
62  */
63 #ifndef MAX_XFER_BUF_SIZE
64 #define MAX_XFER_BUF_SIZE (16 * 1024)
65 #endif
66 
67 #define CSYNC_STATUS_INIT 1 << 0
68 #define CSYNC_STATUS_UPDATE 1 << 1
69 #define CSYNC_STATUS_RECONCILE 1 << 2
70 #define CSYNC_STATUS_PROPAGATE 1 << 3
71 
72 #define CSYNC_STATUS_DONE (CSYNC_STATUS_INIT | \
73  CSYNC_STATUS_UPDATE | \
74  CSYNC_STATUS_RECONCILE | \
75  CSYNC_STATUS_PROPAGATE)
76 
80 };
81 
82 /**
83  * @brief csync public structure
84  */
85 struct csync_s {
86  struct {
90  void *userdata;
91  } callbacks;
93 
94  struct {
95  char *file;
96  sqlite3 *db;
97  int exists;
98  int disabled;
99  } statedb;
100 
101  struct {
102  char *uri;
107  } local;
108 
109  struct {
110  char *uri;
116  } remote;
117 
118  struct {
119  void *handle;
123  } module;
124 
125  struct {
130  char *config_dir;
135  int timeout;
136 #ifdef WITH_ICONV
137  iconv_t iconv_cd;
138 #endif
139  } options;
140 
141  struct {
142  uid_t uid;
143  uid_t euid;
144  } pwd;
145 
146  /* replica we are currently walking */
148 
149  /* replica we want to work on */
151 
152  /* error code of the last operation */
155 
156  int status;
157 };
158 
159 
160 #ifdef _MSC_VER
161 #pragma pack(1)
162 #endif
164  uint64_t phash; /* u64 */
165  time_t modtime; /* u64 */
166  off_t size; /* u64 */
167  size_t pathlen; /* u64 */
168  uint64_t inode; /* u64 */
169  uid_t uid; /* u32 */
170  gid_t gid; /* u32 */
171  mode_t mode; /* u32 */
172  int nlink; /* u32 */
173  int type; /* u32 */
174 
175  char *destpath; /* for renames */
176  const char *md5;
177 
179  char path[1]; /* u8 */
180 }
181 #if !defined(__SUNPRO_C) && !defined(_MSC_VER)
182 __attribute__ ((packed))
183 #endif
184 #ifdef _MSC_VER
185 #pragma pack()
186 #endif
187 ;
191 /*
192  * context for the treewalk function
193  */
195 {
198  void *userdata;
199 };
201 
202 /**
203  * }@
204  */
205 #endif /* _CSYNC_PRIVATE_H */
206 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */