1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifndef SCFG_H
30 #define SCFG_H
31
32 #include <cx/string.h>
33 #include <stdbool.h>
34 #include <libidav/webdav.h>
35
36 #ifdef _WIN32
37 #include "pcreposix.h"
38 #else
39 #include <regex.h>
40 #endif
41
42 #include "db.h"
43 #include "tags.h"
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #define SYNC_CMD_PULL 1
50 #define SYNC_CMD_PUSH 2
51 #define SYNC_CMD_ARCHIVE 4
52 #define SYNC_CMD_RESTORE 8
53
54 #define SYNC_SYMLINK_SYNC 1
55 #define SYNC_SYMLINK_IGNORE_EXTERN 2
56 #define SYNC_SYMLINK_IGNORE_INTERN 4
57
58 #define DEFAULT_TAG_XATTR "tags"
59 #define MACOS_TAG_XATTR "com.apple.metadata:_kMDItemUserTags"
60
61 #define VERSIONING_DEFAULT_PATH "/.dav-version-history"
62
63 #define SYNC_SYMLINK(dir) \
64 (((dir)->symlink &
SYNC_SYMLINK_SYNC) ==
SYNC_SYMLINK_SYNC)
65
66 #define SYNC_HASHING(dir) ((dir)->hashing)
67 #define SYNC_STORE_HASH(dir) ((dir)->store_hash)
68
69 typedef struct TagConfig TagConfig;
70 typedef struct Versioning Versioning;
71 typedef struct SplitConfig SplitConfig;
72 typedef struct Filter Filter;
73
74 enum PushStrategy {
75 PUSH_STRATEGY_METADATA =
0,
76 PUSH_STRATEGY_HASH
77 };
78 typedef enum PushStrategy PushStrategy;
79
80 struct Filter {
81 CxList *include;
82 CxList *exclude;
83 CxList *tags;
84 };
85
86 typedef struct SyncDirectory {
87 char *name;
88 char *path;
89 char *trash;
90 char *collection;
91 char *repository;
92 char *database;
93 char *logfile;
94 TagConfig *tagconfig;
95 Versioning *versioning;
96 Filter filter;
97 CxList *splitconfig;
98 uint32_t metadata;
99 int max_retry;
100 int allow_cmd;
101 uint32_t symlink;
102 time_t lock_timeout;
103 PushStrategy push_strategy;
104 bool backuppull;
105 bool lockpull;
106 bool lockpush;
107 bool hashing;
108 bool store_hash;
109 bool pull_skip_hashing;
110 uint32_t db_settings;
111 } SyncDirectory;
112
113 struct SplitConfig {
114
115
116
117 Filter *filter;
118
119
120
121
122 int64_t minsize;
123
124
125
126 size_t blocksize;
127 };
128
129
130 enum TagFormat {
131 TAG_FORMAT_TEXT =
0,
132 TAG_FORMAT_CSV,
133 TAG_FORMAT_XML,
134 TAG_FORMAT_MACOS,
135 TAG_FORMAT_UNKNOWN
136 };
137 typedef enum TagFormat TagFormat;
138
139 enum TagStore {
140 TAG_STORE_XATTR =
0,
141 TAG_STORE_UNKNOWN
142 };
143 typedef enum TagStore TagStore;
144
145 enum TagConflict {
146 TAG_NO_CONFLICT =
0,
147 TAG_KEEP_LOCAL,
148 TAG_KEEP_REMOTE,
149 TAG_MERGE
150 };
151 typedef enum TagConflict TagConflict;
152
153 struct TagConfig {
154 TagStore store;
155 TagFormat local_format;
156 TagFormat server_format;
157 char *xattr_name;
158 TagConflict conflict;
159 bool detect_changes;
160 };
161
162 enum VersioningType {
163 VERSIONING_SIMPLE =
0,
164 VERSIONING_DELTAV
165 };
166 typedef enum VersioningType VersioningType;
167
168 struct Versioning {
169 VersioningType type;
170 char *collection;
171 bool always;
172 };
173
174 int load_sync_config();
175
176 CxIterator scfg_directory_iterator();
177 SyncDirectory* scfg_get_dir(
const char *name);
178
179 int scfg_check_dir(SyncDirectory *dir);
180
181 char* scfg_create_path(
const char *cfg);
182
183 int add_directory(SyncDirectory *dir);
184
185 char* generate_db_name(
const char *basename);
186
187 void free_filter(Filter filter);
188
189 void free_sync_config();
190
191
192 #ifdef __cplusplus
193 }
194 #endif
195
196 #endif
197
198