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 DB_H
30 #define DB_H
31
32 #include <inttypes.h>
33 #include <libidav/webdav.h>
34 #include <cx/hash_map.h>
35 #include <cx/linked_list.h>
36 #include <cx/buffer.h>
37 #include <time.h>
38
39 #include <libxml/xmlreader.h>
40
41 #include "finfo.h"
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 #define DB_STORE_MODE 1
48 #define DB_STORE_OWNER 2
49
50 typedef struct LocalResource LocalResource;
51 typedef struct FilePart FilePart;
52 typedef struct SyncDatabase SyncDatabase;
53
54 struct LocalResource {
55 char *name;
56 char *path;
57 char *etag;
58 char *hash;
59 time_t last_modified;
60 mode_t mode;
61 uid_t uid;
62 gid_t gid;
63 off_t size;
64 DavBool isdirectory;
65 DavBool skipped;
66 CxBuffer *cached_tags;
67 XAttributes *xattr;
68 char *tags_hash;
69 char *xattr_hash;
70 char *remote_tags_hash;
71
72 char *local_path;
73
74 char *link_target;
75 char *link_target_db;
76
77 FilePart *parts;
78 size_t numparts;
79
80 int64_t blocksize;
81
82 DavBool tags_updated;
83 DavBool finfo_updated;
84 DavBool xattr_updated;
85 DavBool metadata_updated;
86 DavBool link_updated;
87
88 DavBool keep;
89 DavBool restore;
90
91 DavBool versioncontrol;
92
93 DavBool isnew;
94 LocalResource *origin;
95 char *conflict_source;
96
97 char *prev_hash;
98 };
99
100 struct FilePart {
101 uint64_t block;
102 char *hash;
103 char *etag;
104 };
105
106 struct SyncDatabase {
107 CxMap *resources;
108 CxMap *conflict;
109 };
110
111 SyncDatabase* load_db(
char *name);
112 int store_db(SyncDatabase *db,
char *name,
uint32_t settings);
113 void destroy_db(SyncDatabase *db);
114
115 void local_resource_free(LocalResource *res);
116
117 void local_resource_copy_parts(LocalResource *from, LocalResource *to);
118
119 LocalResource* local_resource_copy(LocalResource *src,
const char *new_path);
120
121 void filepart_free(FilePart *part);
122
123 CxMap* create_hash_index(SyncDatabase *db);
124
125 LocalResource* process_resource(xmlTextReaderPtr reader);
126 LocalResource* process_conflict(xmlTextReaderPtr reader);
127
128
129 #ifdef __cplusplus
130 }
131 #endif
132
133 #endif
134
135