doc
csync_private.h
Go to the documentation of this file.
1 /*
2  * cynapses libc functions
3  *
4  * Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
5  * Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file csync_private.h
24  *
25  * @brief Private interface of csync
26  *
27  * @defgroup csyncInternalAPI csync internal API
28  *
29  * @{
30  */
31 
32 #ifndef _CSYNC_PRIVATE_H
33 #define _CSYNC_PRIVATE_H
34 
35 #include <stdint.h>
36 #include <stdbool.h>
37 #include <sqlite3.h>
38 
39 #include "config.h"
40 #include "c_lib.h"
41 #include "c_private.h"
42 #include "csync.h"
43 
44 #ifdef HAVE_ICONV_H
45 #include <iconv.h>
46 #endif
47 #ifdef HAVE_SYS_ICONV_H
48 #include <sys/iconv.h>
49 #endif
50 
51 #include "vio/csync_vio_method.h"
52 #include "csync_macros.h"
53 
54 /**
55  * How deep to scan directories.
56  */
57 #define MAX_DEPTH 50
58 
59 /**
60  * Maximum time difference between two replicas in seconds
61  */
62 #define MAX_TIME_DIFFERENCE 10
63 
64 /**
65  * Maximum size of a buffer for transfer
66  */
67 #ifndef MAX_XFER_BUF_SIZE
68 #define MAX_XFER_BUF_SIZE (16 * 1024)
69 #endif
70 
71 #define CSYNC_STATUS_INIT 1 << 0
72 #define CSYNC_STATUS_UPDATE 1 << 1
73 #define CSYNC_STATUS_RECONCILE 1 << 2
74 #define CSYNC_STATUS_PROPAGATE 1 << 3
75 
76 #define CSYNC_STATUS_DONE (CSYNC_STATUS_INIT | \
77  CSYNC_STATUS_UPDATE | \
78  CSYNC_STATUS_RECONCILE | \
79  CSYNC_STATUS_PROPAGATE)
80 
84 };
85 
86 /**
87  * @brief csync public structure
88  */
89 struct csync_s {
90  struct {
94  void *userdata;
95  } callbacks;
97 
98  struct {
99  char *file;
100  sqlite3 *db;
101  int exists;
102  int disabled;
103  } statedb;
104 
105  struct {
106  char *uri;
110  } local;
111 
112  struct {
113  char *uri;
117  } remote;
118 
119  struct {
120  void *handle;
124  } module;
125 
126  struct {
131  char *config_dir;
134 #if defined(HAVE_ICONV) && defined(WITH_ICONV)
135  iconv_t iconv_cd;
136 #endif
137  } options;
138 
139  struct {
140  uid_t uid;
141  uid_t euid;
142  } pwd;
143 
144  struct {
147  long long byte_sum;
148  long long byte_current;
149  } progress;
150 
151  /* replica we are currently walking */
153 
154  /* replica we want to work on */
156 
157  /* csync error code */
159 
161 
162  int status;
163 };
164 
169 };
170 
171 #ifdef _MSC_VER
172 #pragma pack(1)
173 #endif
175  uint64_t phash; /* u64 */
176  time_t modtime; /* u64 */
177  off_t size; /* u64 */
178  size_t pathlen; /* u64 */
179  ino_t inode; /* u64 */
180  uid_t uid; /* u32 */
181  gid_t gid; /* u32 */
182  mode_t mode; /* u32 */
183  int nlink; /* u32 */
184  int type; /* u32 */
186  char path[1]; /* u8 */
187 }
188 #if !defined(__SUNPRO_C) && !defined(_MSC_VER)
189 __attribute__ ((packed))
190 #endif
191 #ifdef _MSC_VER
192 #pragma pack()
193 #endif
194 ;
195 
197 
198 /*
199  * context for the treewalk function
200  */
202 {
205  void *userdata;
206 };
208 
209 /**
210  * }@
211  */
212 #endif /* _CSYNC_PRIVATE_H */
213 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
csync_instructions_e
Definition: csync.h:135
Used for each element in a doubly-linked list.
Definition: c_list.h:54
Application developer interface for csync.
csync_ftw_type_e
struct csync_s::@4 module
struct csync_s::@1 statedb
struct csync_s::@5 options
csync_treewalk_visit_func * user_visitor
enum csync_instructions_e instruction
char * config_dir
int(* csync_auth_callback)(const char *prompt, char *buf, size_t len, int echo, int verify, void *userdata)
Definition: csync.h:185
void * userdata
Definition: csync_private.h:94
csync_vio_method_t * method
enum csync_replica_e replica
struct csync_s::@2 local
int max_time_difference
int csync_treewalk_visit_func(TREE_WALK_FILE *, void *)
Definition: csync.h:493
bool with_conflict_copys
bool local_only_mode
c_list_t * list
c_rbtree_t * tree
csync_vio_method_finish_fn finish_fn
sqlite3 * db
enum csync_replica_e type
struct csync_s::@3 remote
Structure that represents a red-black tree.
Definition: c_rbtree.h:109
csync_overall_progress_callback overall_progress_cb
Definition: csync_private.h:92
Structure for a stringlist.
Definition: c_string.h:53
csync_vio_capabilities_t capabilities
csync public structure
Definition: csync_private.h:89
struct csync_s::@6 pwd
void(* csync_vio_method_finish_fn)(csync_vio_method_t *method)
csync_status_codes_e
Instruction enum.
Definition: csync.h:77
long long byte_current
char * error_string
c_list_t * list
c_strlist_t * excludes
Definition: csync_private.h:96
int sync_symbolic_links
csync_replica_e
Definition: csync_private.h:81
struct _csync_treewalk_context_s __attribute__
enum csync_status_codes_e status_code
csync_file_progress_callback file_progress_cb
Definition: csync_private.h:93
void(* csync_overall_progress_callback)(const char *file_name, int file_no, int file_cnt, long long o1, long long o2, void *userdata)
Callback definition for overall progress callback.
Definition: csync.h:596
struct csync_s::@0 callbacks
void(* csync_file_progress_callback)(const char *remote_url, enum csync_notify_type_e kind, long long o1, long long o2, void *userdata)
Callback definition for individual file progress callback.
Definition: csync.h:569
enum csync_replica_e current
struct csync_s::@7 progress
c_rbtree_t * tree
csync_auth_callback auth_function
Definition: csync_private.h:91
long long byte_sum