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;
97 
98  struct {
99  char *file;
100  sqlite3 *db;
101  int exists;
102  int disabled;
104 
105  struct {
106  char *uri;
109  enum csync_replica_e type;
110  } local;
111 
112  struct {
113  char *uri;
116  enum csync_replica_e type;
118 
119  struct {
120  void *handle;
125 
126  struct {
131  char *config_dir;
134 #if defined(HAVE_ICONV) && defined(WITH_ICONV)
135  iconv_t iconv_cd;
136 #endif
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;
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 */
185  enum csync_instructions_e instruction; /* 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 
196 typedef struct csync_file_stat_s csync_file_stat_t;
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_s::@7::byte_current
long long byte_current
Definition: csync_private.h:148
csync_s::error_string
char * error_string
Definition: csync_private.h:160
csync_s::@5::with_conflict_copys
bool with_conflict_copys
Definition: csync_private.h:132
csync_s::@0::overall_progress_cb
csync_overall_progress_callback overall_progress_cb
Definition: csync_private.h:92
csync_vio_method_finish_fn
void(* csync_vio_method_finish_fn)(csync_vio_method_t *method)
Definition: csync_vio_method.h:46
c_lib.h
csync_s::@7::byte_sum
long long byte_sum
Definition: csync_private.h:147
csync_instructions_e
csync_instructions_e
Definition: csync.h:135
csync_s::local
struct csync_s::@2 local
csync_s::@4::method
csync_vio_method_t * method
Definition: csync_private.h:121
csync_s::@1::db
sqlite3 * db
Definition: csync_private.h:100
csync.h
Application developer interface for csync.
csync_s::@4::handle
void * handle
Definition: csync_private.h:120
csync_auth_callback
int(* csync_auth_callback)(const char *prompt, char *buf, size_t len, int echo, int verify, void *userdata)
Definition: csync.h:185
c_rbtree_s
Structure that represents a red-black tree.
Definition: c_rbtree.h:109
csync_s::@4::capabilities
csync_vio_capabilities_t capabilities
Definition: csync_private.h:123
csync_s::@0::auth_function
csync_auth_callback auth_function
Definition: csync_private.h:91
csync_s::@3::tree
c_rbtree_t * tree
Definition: csync_private.h:114
csync_treewalk_visit_func
int csync_treewalk_visit_func(TREE_WALK_FILE *, void *)
Definition: csync.h:493
csync_file_stat_s::instruction
enum csync_instructions_e instruction
Definition: csync_private.h:185
csync_ftw_type_e
csync_ftw_type_e
Definition: csync_private.h:165
csync_vio_capabilities_s
Definition: csync_vio_method.h:36
csync_file_stat_s::mode
mode_t mode
Definition: csync_private.h:182
csync_s::@6::uid
uid_t uid
Definition: csync_private.h:140
csync_macros.h
csync_s::@3::uri
char * uri
Definition: csync_private.h:113
csync_file_stat_s::type
int type
Definition: csync_private.h:184
csync_s::@4::finish_fn
csync_vio_method_finish_fn finish_fn
Definition: csync_private.h:122
csync_file_stat_s::pathlen
size_t pathlen
Definition: csync_private.h:178
csync_s::replica
enum csync_replica_e replica
Definition: csync_private.h:155
csync_file_stat_s
Definition: csync_private.h:174
csync_s::pwd
struct csync_s::@6 pwd
csync_s::@5::sync_symbolic_links
int sync_symbolic_links
Definition: csync_private.h:129
csync_s::@1::exists
int exists
Definition: csync_private.h:101
c_list_s
Definition: c_list.h:54
csync_file_stat_s::modtime
time_t modtime
Definition: csync_private.h:176
csync_s::module
struct csync_s::@4 module
csync_s::status
int status
Definition: csync_private.h:162
csync_s::options
struct csync_s::@5 options
csync_vio_method.h
csync_s::excludes
c_strlist_t * excludes
Definition: csync_private.h:96
_csync_treewalk_context_s::instruction_filter
int instruction_filter
Definition: csync_private.h:204
csync_s::@0::userdata
void * userdata
Definition: csync_private.h:94
csync_s::statedb
struct csync_s::@1 statedb
csync_s::current
enum csync_replica_e current
Definition: csync_private.h:152
csync_s::@6::euid
uid_t euid
Definition: csync_private.h:141
__attribute__
struct _csync_treewalk_context_s __attribute__
csync_s::remote
struct csync_s::@3 remote
csync_file_stat_s::inode
ino_t inode
Definition: csync_private.h:179
csync_s::type
enum csync_replica_e type
Definition: csync_private.h:109
csync_s::callbacks
struct csync_s::@0 callbacks
_csync_treewalk_context_s
Definition: csync_private.h:202
csync_s::@1::disabled
int disabled
Definition: csync_private.h:102
csync_status_codes_e
csync_status_codes_e
Instruction enum.
Definition: csync.h:77
csync_s::@5::unix_extensions
int unix_extensions
Definition: csync_private.h:130
LOCAL_REPLICA
@ LOCAL_REPLICA
Definition: csync_private.h:82
_csync_treewalk_context_s::user_visitor
csync_treewalk_visit_func * user_visitor
Definition: csync_private.h:203
csync_file_stat_s::gid
gid_t gid
Definition: csync_private.h:181
csync_s::list
c_list_t * list
Definition: csync_private.h:108
csync_s::@5::config_dir
char * config_dir
Definition: csync_private.h:131
c_strlist_s
Structure for a stringlist.
Definition: c_string.h:53
csync_s::status_code
enum csync_status_codes_e status_code
Definition: csync_private.h:158
csync_file_stat_s::size
off_t size
Definition: csync_private.h:177
csync_s
csync public structure
Definition: csync_private.h:89
csync_s::@5::max_time_difference
int max_time_difference
Definition: csync_private.h:128
CSYNC_FTW_TYPE_DIR
@ CSYNC_FTW_TYPE_DIR
Definition: csync_private.h:168
REMOTE_REPLICA
@ REMOTE_REPLICA
Definition: csync_private.h:83
CSYNC_FTW_TYPE_SLINK
@ CSYNC_FTW_TYPE_SLINK
Definition: csync_private.h:167
csync_replica_e
csync_replica_e
Definition: csync_private.h:81
csync_overall_progress_callback
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
csync_file_stat_s::phash
uint64_t phash
Definition: csync_private.h:175
csync_s::@7::current_file_no
int current_file_no
Definition: csync_private.h:146
c_private.h
csync_file_progress_callback
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
csync_s::@1::file
char * file
Definition: csync_private.h:99
csync_file_stat_s::path
char path[1]
Definition: csync_private.h:186
csync_s::@0::file_progress_cb
csync_file_progress_callback file_progress_cb
Definition: csync_private.h:93
csync_s::@5::local_only_mode
bool local_only_mode
Definition: csync_private.h:133
csync_vio_method_s
Definition: csync_vio_method.h:86
csync_s::@7::file_count
int file_count
Definition: csync_private.h:145
csync_file_stat_s::uid
uid_t uid
Definition: csync_private.h:180
_csync_treewalk_context_s::userdata
void * userdata
Definition: csync_private.h:205
csync_s::@5::max_depth
int max_depth
Definition: csync_private.h:127
CSYNC_FTW_TYPE_FILE
@ CSYNC_FTW_TYPE_FILE
Definition: csync_private.h:166
csync_s::@2::tree
c_rbtree_t * tree
Definition: csync_private.h:107
csync_s::progress
struct csync_s::@7 progress
csync_s::@2::uri
char * uri
Definition: csync_private.h:106
csync_file_stat_s::nlink
int nlink
Definition: csync_private.h:183