dav/scfg.h

Thu, 11 Oct 2018 19:29:45 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 11 Oct 2018 19:29:45 +0200
branch
v1.2
changeset 481
ff477f1f7765
parent 417
f340460a8b5d
child 490
d94c4fd35c21
permissions
-rw-r--r--

fixes redirects

46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
364
3769ba002fd1 updates copyright date
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 363
diff changeset
4 * Copyright 2018 Olaf Wintermann. All rights reserved.
46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0542668d0f26 added new sync tool
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
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #ifndef SCFG_H
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #define SCFG_H
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include <ucx/string.h>
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include <stdbool.h>
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include <libidav/webdav.h>
58
1708cba82ca3 added include / exclude patterns
Mike Becker <universe@uap-core.de>
parents: 56
diff changeset
35 #include <regex.h>
46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36
399
a985a587787f fixes header include order (dav-sync)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 368
diff changeset
37 #include "db.h"
400
90c6bfa94fa2 moves tag filter to tags.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 399
diff changeset
38 #include "tags.h"
399
a985a587787f fixes header include order (dav-sync)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 368
diff changeset
39
46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #ifdef __cplusplus
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 extern "C" {
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #endif
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
347
b6ff6be7aa91 adds config option to disable certain commands for specific syncdirs and fixes authmethod config parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 316
diff changeset
44 #define SYNC_CMD_PULL 1
b6ff6be7aa91 adds config option to disable certain commands for specific syncdirs and fixes authmethod config parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 316
diff changeset
45 #define SYNC_CMD_PUSH 2
b6ff6be7aa91 adds config option to disable certain commands for specific syncdirs and fixes authmethod config parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 316
diff changeset
46 #define SYNC_CMD_ARCHIVE 4
144
c2c02c9b3be4 dav-sync detects broken uploads
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
47
368
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
48 #define DEFAULT_TAG_XATTR "tags"
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
49 #define MACOS_TAG_XATTR "com.apple.metadata:_kMDItemUserTags"
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
50
361
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
51 typedef struct TagConfig TagConfig;
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
52
46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 typedef struct SyncDirectory {
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 char *name;
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 char *path;
65
d4077e8175f3 added optional trash for deleted files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 58
diff changeset
56 char *trash;
56
99f7816fcf01 added collection config for sync directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
57 char *collection;
46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 char *repository;
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 char *database;
361
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
60 TagConfig *tagconfig;
58
1708cba82ca3 added include / exclude patterns
Mike Becker <universe@uap-core.de>
parents: 56
diff changeset
61 UcxList *include;
1708cba82ca3 added include / exclude patterns
Mike Becker <universe@uap-core.de>
parents: 56
diff changeset
62 UcxList *exclude;
417
f340460a8b5d disables tagfilter for directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
63 UcxList *tagfilter;
144
c2c02c9b3be4 dav-sync detects broken uploads
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
64 int max_retry;
347
b6ff6be7aa91 adds config option to disable certain commands for specific syncdirs and fixes authmethod config parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 316
diff changeset
65 int allow_cmd;
316
9d0505d80044 adds dav-sync lock timeout config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 256
diff changeset
66 time_t lock_timeout;
145
82475dc12dd4 improved dav-sync data-loss prevention
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 144
diff changeset
67 bool backuppull;
221
e22c29b7ee2f using locks in dav-sync
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
68 bool lockpull;
e22c29b7ee2f using locks in dav-sync
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
69 bool lockpush;
46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 } SyncDirectory;
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71
361
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
72
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
73 enum TagFormat {
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
74 TAG_FORMAT_TEXT = 0,
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
75 TAG_FORMAT_CSV,
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
76 TAG_FORMAT_XML,
363
e9ed8e130ccf adds support for macos file tags
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 361
diff changeset
77 TAG_FORMAT_MACOS,
361
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
78 TAG_FORMAT_UNKNOWN
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
79 };
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
80 typedef enum TagFormat TagFormat;
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
81
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
82 enum TagStore {
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
83 TAG_STORE_XATTR = 0,
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
84 TAG_STORE_UNKNOWN
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
85 };
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
86 typedef enum TagStore TagStore;
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
87
368
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
88 enum TagConflict {
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
89 TAG_NO_CONFLICT = 0,
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
90 TAG_KEEP_LOCAL,
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
91 TAG_KEEP_REMOTE,
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
92 TAG_MERGE
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
93 };
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
94 typedef enum TagConflict TagConflict;
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
95
361
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
96 struct TagConfig {
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
97 TagStore store;
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
98 TagFormat local_format;
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
99 TagFormat server_format;
368
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
100 char *xattr_name;
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
101 TagConflict conflict;
11797f33bc24 adds more tag config options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 367
diff changeset
102 bool detect_changes;
361
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
103 };
b6f2462ee055 adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
104
46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 int load_sync_config();
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106
256
54433cb371df implements check-repositories command for dav-sync
Mike Becker <universe@uap-core.de>
parents: 244
diff changeset
107 UcxMapIterator scfg_directory_iterator();
46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 SyncDirectory* scfg_get_dir(char *name);
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109
233
d8042cede66c improved dav-sync error handling on startup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
110 int scfg_check_dir(SyncDirectory *dir);
d8042cede66c improved dav-sync error handling on startup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
111
226
acc997e0d0f9 added support for paths with environment variables in sync.xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
112 char* scfg_create_path(char *cfg);
acc997e0d0f9 added support for paths with environment variables in sync.xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
113
200
cc474cf2c2f5 added add-directory command to dav-sync
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
114 int add_directory(SyncDirectory *dir);
256
54433cb371df implements check-repositories command for dav-sync
Mike Becker <universe@uap-core.de>
parents: 244
diff changeset
115
200
cc474cf2c2f5 added add-directory command to dav-sync
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
116 char* generate_db_name(char *basename);
198
44054c452de1 added list-repositories and list-directories commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
117
224
4b55f05f4e00 added more cleanup code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
118 void free_sync_config();
4b55f05f4e00 added more cleanup code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
119
46
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 #ifdef __cplusplus
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 }
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 #endif
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 #endif /* SCFG_H */
0542668d0f26 added new sync tool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126

mercurial