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 #include "csync_misc.h"
43 
44 #ifdef WITH_ICONV
45 #include <iconv.h>
46 #endif
47 
48 #include "vio/csync_vio_method.h"
49 #include "csync_macros.h"
50 
51 /**
52  * How deep to scan directories.
53  */
54 #define MAX_DEPTH 50
55 
56 /**
57  * Maximum time difference between two replicas in seconds
58  */
59 #define MAX_TIME_DIFFERENCE 10
60 
61 /**
62  * Maximum size of a buffer for transfer
63  */
64 #ifndef MAX_XFER_BUF_SIZE
65 #define MAX_XFER_BUF_SIZE (16 * 1024)
66 #endif
67 
68 #define CSYNC_STATUS_INIT 1 << 0
69 #define CSYNC_STATUS_UPDATE 1 << 1
70 #define CSYNC_STATUS_RECONCILE 1 << 2
71 #define CSYNC_STATUS_PROPAGATE 1 << 3
72 
73 #define CSYNC_STATUS_DONE (CSYNC_STATUS_INIT | \
74  CSYNC_STATUS_UPDATE | \
75  CSYNC_STATUS_RECONCILE | \
76  CSYNC_STATUS_PROPAGATE)
77 
81 };
82 
84 
85 /**
86  * @brief csync public structure
87  */
88 struct csync_s {
89  struct {
93  void *userdata;
94  } callbacks;
96 
97  struct {
98  char *file;
99  sqlite3 *db;
100  int exists;
101  int disabled;
102  } statedb;
103 
104  struct {
105  char *uri;
110  } local;
111 
112  struct {
113  char *uri;
119  } remote;
120 
121  struct {
122  void *handle;
126  } module;
127 
128  struct {
133  char *config_dir;
138  int timeout;
139 #ifdef WITH_ICONV
140  iconv_t iconv_cd;
141 #endif
142  } options;
143 
144  struct {
145  uid_t uid;
146  uid_t euid;
147  } pwd;
148 
150 
152 
153  /* replica we are currently walking */
155 
156  /* replica we want to work on */
158 
159  /* Used in the update phase so changes in the sub directories can be notified to
160  parent directories */
162 
163  /* error code of the last operation */
166 
167  int status;
168  volatile int abort;
169  void *rename_info;
170 };
171 
172 
173 #ifdef _MSC_VER
174 #pragma pack(1)
175 #endif
177  uint64_t phash; /* u64 */
178  time_t modtime; /* u64 */
179  int64_t size; /* u64 */
180  size_t pathlen; /* u64 */
181  uint64_t inode; /* u64 */
182  uid_t uid; /* u32 */
183  gid_t gid; /* u32 */
184  mode_t mode; /* u32 */
185  int nlink; /* u32 */
186  int type; /* u32 */
187  int child_modified;/*bool*/
188  int should_update_md5; /*bool */
189 
190  char *destpath; /* for renames */
191  const char *md5;
192  const char *error_string;
193 
195  char path[1]; /* u8 */
196 }
197 #if !defined(__SUNPRO_C) && !defined(_MSC_VER)
198 __attribute__ ((packed))
199 #endif
200 #ifdef _MSC_VER
201 #pragma pack()
202 #endif
203 ;
207 /*
208  * context for the treewalk function
209  */
211 {
214  void *userdata;
215 };
218 /**
219  * }@
220  */
221 #endif /* _CSYNC_PRIVATE_H */
222 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */