Wed, 20 Mar 2019 10:23:39 +0100
implements list-versions for deltav syncdirs
361
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2018 Olaf Wintermann. All rights reserved. |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #ifndef TAGS_H |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #define TAGS_H |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #include <ucx/string.h> |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include <ucx/buffer.h> |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | #include <ucx/list.h> |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #include <libidav/webdav.h> |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | #ifdef __cplusplus |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | extern "C" { |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | #endif |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | |
400
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
42 | |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
43 | /* OFF must be zero, other constants are arbitrary */ |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
44 | #define DAV_SYNC_TAGFILTER_OFF 0 |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
45 | #define DAV_SYNC_TAGFILTER_AND 1 |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
46 | #define DAV_SYNC_TAGFILTER_OR 2 |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
47 | #define DAV_SYNC_TAGFILTER_ONE 3 |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
48 | #define DAV_SYNC_TAGFILTER_NONE 4 |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
49 | |
414
ea50585ec9d9
adds tagfilter scope
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
400
diff
changeset
|
50 | #define DAV_SYNC_TAGFILTER_SCOPE_RESOURCE 1 |
ea50585ec9d9
adds tagfilter scope
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
400
diff
changeset
|
51 | #define DAV_SYNC_TAGFILTER_SCOPE_COLLECTION 2 |
ea50585ec9d9
adds tagfilter scope
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
400
diff
changeset
|
52 | |
361
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | typedef struct DavTag { |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | char *name; |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | char *color; |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | } DavTag; |
363
e9ed8e130ccf
adds support for macos file tags
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
57 | |
400
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
58 | /** |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
59 | * filter ::= operator? , (tag_list | ("(" , filter , ")")+) |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
60 | * tag_list ::= tag , ("," tag)* |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
61 | * operator ::= "&" | "|" | "1" | "0" |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
62 | */ |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
63 | typedef struct SyncTagFilter SyncTagFilter; |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
64 | |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
65 | struct SyncTagFilter { |
414
ea50585ec9d9
adds tagfilter scope
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
400
diff
changeset
|
66 | int scope; |
400
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
67 | int mode; |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
68 | UcxList* tags; |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
69 | size_t subfilter_count; |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
70 | SyncTagFilter** subfilters; |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
71 | }; |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
72 | |
390
26998dc980f9
adds tag filter evaluation functions
Mike Becker <universe@uap-core.de>
parents:
363
diff
changeset
|
73 | void free_dav_tag(DavTag* tag); |
26998dc980f9
adds tag filter evaluation functions
Mike Becker <universe@uap-core.de>
parents:
363
diff
changeset
|
74 | |
524
d53fd1006485
store hash of remote xattr and tags in sync db
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
75 | void free_taglist(UcxList *list); |
d53fd1006485
store hash of remote xattr and tags in sync db
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
76 | |
390
26998dc980f9
adds tag filter evaluation functions
Mike Becker <universe@uap-core.de>
parents:
363
diff
changeset
|
77 | int compare_tagname(DavTag* left, DavTag* right, void* ignorecase); |
26998dc980f9
adds tag filter evaluation functions
Mike Becker <universe@uap-core.de>
parents:
363
diff
changeset
|
78 | |
361
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | UcxList* parse_text_taglist(const char *buf, size_t length); |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | UcxBuffer* create_text_taglist(UcxList *tags); |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | UcxList* parse_csv_taglist(const char *buf, size_t length); |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | UcxBuffer* create_csv_taglist(UcxList *tags); |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | UcxList* parse_dav_xml_taglist(DavXmlNode *taglistnode); |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | DavXmlNode* create_xml_taglist(UcxList *tags); |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | |
363
e9ed8e130ccf
adds support for macos file tags
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
88 | UcxList* parse_macos_taglist(const char *buf, size_t length); |
e9ed8e130ccf
adds support for macos file tags
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
89 | UcxBuffer* create_macos_taglist(UcxList *tags); |
361
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | |
525
26a1d5b9d9d2
improves metadata support in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
524
diff
changeset
|
91 | char* create_tags_hash(UcxList *tags); |
26a1d5b9d9d2
improves metadata support in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
524
diff
changeset
|
92 | |
26a1d5b9d9d2
improves metadata support in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
524
diff
changeset
|
93 | UcxList* merge_tags(UcxList *tags1, UcxList *tags2); |
26a1d5b9d9d2
improves metadata support in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
524
diff
changeset
|
94 | |
26a1d5b9d9d2
improves metadata support in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
524
diff
changeset
|
95 | /* |
26a1d5b9d9d2
improves metadata support in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
524
diff
changeset
|
96 | * Adds tag colors from the colored list to taglist if tags have the same name |
26a1d5b9d9d2
improves metadata support in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
524
diff
changeset
|
97 | */ |
26a1d5b9d9d2
improves metadata support in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
524
diff
changeset
|
98 | void add_tag_colors(UcxList *taglist, UcxList *colored); |
400
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
99 | |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
100 | /* ----------- ----------- tag filter ---------------------- */ |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
101 | |
414
ea50585ec9d9
adds tagfilter scope
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
400
diff
changeset
|
102 | SyncTagFilter* parse_tagfilter_string(const char* filterstring, int scope); |
400
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
103 | void free_tagfilter(SyncTagFilter* filter); |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
104 | |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
105 | int matches_tagfilter(UcxList *dav_tags, SyncTagFilter *tagfilter); |
90c6bfa94fa2
moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
390
diff
changeset
|
106 | |
361
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | #ifdef __cplusplus |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | } |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | #endif |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | #endif /* TAGS_H */ |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 |