dav/main.h

Fri, 07 Dec 2018 11:17:29 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 07 Dec 2018 11:17:29 +0100
changeset 499
efd8f489d415
parent 498
37af2eac3e6a
child 500
0fe1514667e6
permissions
-rw-r--r--

fix: don't detect end of tar file as broken content

1
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
364
3769ba002fd1 updates copyright date
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 355
diff changeset
4 * Copyright 2018 Olaf Wintermann. All rights reserved.
1
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1bcaac272cdf added existing source code
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
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #ifndef MAIN_H
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #define MAIN_H
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
355
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
32 #include <time.h>
1
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include <curl/curl.h>
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
34 #include "optparser.h"
33
0bbbb0341606 some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
35 #include <libidav/webdav.h>
1
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36
334
5f80c5d0e87f adds tar import/export
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
37 #include "tar.h"
190
a76e43d89f55 dav-sync can create and delete empty directories now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
38 #include "version.h"
188
753c8fcde12f added version info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
39
1
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #ifdef __cplusplus
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 extern "C" {
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #endif
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
333
000cdd124115 refactores cmd_get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
44 typedef struct {
000cdd124115 refactores cmd_get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
45 DavResource *res;
000cdd124115 refactores cmd_get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
46 char *path;
000cdd124115 refactores cmd_get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
47 } GetResource;
334
5f80c5d0e87f adds tar import/export
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
48
355
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
49 typedef struct {
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
50 FILE *out;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
51 int isstdout;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
52 int64_t total;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
53 int64_t cur;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
54 int64_t last_res_cur;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
55 int64_t last_res_total;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
56 DavResource *last_resource;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
57 time_t ts;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
58 } Progress;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
59
334
5f80c5d0e87f adds tar import/export
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
60 typedef int(*getfunc)(Repository *, GetResource *, CmdArgs *, void *);
333
000cdd124115 refactores cmd_get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
61
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
62 void print_usage(char *cmd);
212
01e80c7cfe96 added noinput option to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 209
diff changeset
63 int request_auth(Repository *repo, DavSession *sn, CmdArgs *args);
4
ae5a98f0545c added put method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1
diff changeset
64
355
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
65 int update_progress(DavResource *res, int64_t total, int64_t now, Progress *p);
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
66 void download_progress(DavResource *res, int64_t total, int64_t now, void *data);
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
67
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
68 int cmd_list(CmdArgs *args);
270
0edfb4c0e7f8 fixes dav list -R output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
69 void ls_print_list_elm(DavResource *res, char *parent, CmdArgs *args);
0edfb4c0e7f8 fixes dav list -R output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
70 void ls_print_elm(DavResource *res, char *parent, CmdArgs *args);
14
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
71
376
222997d48ae1 moving tar option from get/put to new export/import commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 364
diff changeset
72 int cmd_get(CmdArgs *args, DavBool export);
334
5f80c5d0e87f adds tar import/export
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
73 int get_resource(Repository *repo, GetResource *res, CmdArgs *a, void *unused);
5f80c5d0e87f adds tar import/export
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
74 int resource2tar(Repository *repo, GetResource *res, CmdArgs *a, TarOutputStream *tar);
18
651989681053 recursive list and get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
75
376
222997d48ae1 moving tar option from get/put to new export/import commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 364
diff changeset
76 int cmd_put(CmdArgs *args, DavBool import);
241
da7ace67deab improved dav put output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
77 int put_entry(Repository *repo, CmdArgs *a, DavSession *sn, char *path, char *file, DavBool root);
334
5f80c5d0e87f adds tar import/export
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
78 int put_tar(Repository *repo, CmdArgs *a, DavSession *sn, char *tarfile, char *path);
178
e137883e620f using content-length header in dav put
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 147
diff changeset
79 int put_file(Repository *repo, CmdArgs *a, DavSession *sn, char *path, char *name, FILE *in, off_t len);
28
4e46c65711ef added recursive put
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 18
diff changeset
80
15
182af08b4813 added remove command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
81 int cmd_remove(CmdArgs *args);
16
5dbef9e07376 added mkdir command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 15
diff changeset
82 int cmd_mkdir(CmdArgs *args);
1
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
181
a8f8cdbf85df implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 178
diff changeset
84 int cmd_move(CmdArgs *args, int cp);
498
37af2eac3e6a adds rename command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
85 int cmd_rename(CmdArgs *args);
181
a8f8cdbf85df implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 178
diff changeset
86
29
938957a4eea7 added date command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
87 int cmd_date(CmdArgs *args);
938957a4eea7 added date command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
88
62
3b813c57c106 added property-set and property-get command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
89 int cmd_get_property(CmdArgs *args);
84
7fca3788261d added info command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
90 int cmd_set_property(CmdArgs *args);
304
a4d3ff32d49c adds dav remove-property command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
91 int cmd_remove_property(CmdArgs *args);
62
3b813c57c106 added property-set and property-get command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
92
209
d24761f1e07c added lock and unlock commands to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
93 int cmd_lock(CmdArgs *args);
d24761f1e07c added lock and unlock commands to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
94 int cmd_unlock(CmdArgs *args);
d24761f1e07c added lock and unlock commands to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
95
84
7fca3788261d added info command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
96 int cmd_info(CmdArgs *args);
7fca3788261d added info command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
97
475
52e4171d42ce adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
98 int cmd_checkout(CmdArgs *args);
52e4171d42ce adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
99 int cmd_checkin(CmdArgs *args);
52e4171d42ce adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
100 int cmd_uncheckout(CmdArgs *args);
52e4171d42ce adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
101 int cmd_versioncontrol(CmdArgs *args);
52e4171d42ce adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
102 int cmd_list_versions(CmdArgs *args);
52e4171d42ce adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
103
476
b4e3453e2b49 adds -V option to get, get-property and info commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 475
diff changeset
104 DavResource* find_version(DavResource *res, char *version);
b4e3453e2b49 adds -V option to get, get-property and info commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 475
diff changeset
105
62
3b813c57c106 added property-set and property-get command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
106 char* stdin2str();
338
c7f3fe4abdb2 dav get-property supports xml property output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 334
diff changeset
107 char* xml2str(DavXmlNode *node);
c7f3fe4abdb2 dav get-property supports xml property output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 334
diff changeset
108 void printxmldoc(FILE *out, char *root, char *rootns, DavXmlNode *content);
33
0bbbb0341606 some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
109
195
4b7823a58199 fixed add-repository function name
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
110 int cmd_add_repository(CmdArgs *args);
398
26fdeed98cd7 adds remove-repository command
Mike Becker <universe@uap-core.de>
parents: 376
diff changeset
111 int cmd_remove_repository(CmdArgs *args);
119
451607eeff05 added initial code for config commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
112
419
0b48f935f8a6 adds repository-url command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 398
diff changeset
113 int cmd_repository_url(CmdArgs *args);
0b48f935f8a6 adds repository-url command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 398
diff changeset
114
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 432
diff changeset
115 int cmd_add_user(CmdArgs *args);
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 432
diff changeset
116
432
a213ecaf3f4a adjusts completion index, if options are specified
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 431
diff changeset
117 int shell_completion(CmdArgs *args, int index);
431
1e8592657a01 adds semi-functional bash completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
118
1e8592657a01 adds semi-functional bash completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
119 int url_completion(char *url);
1e8592657a01 adds semi-functional bash completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
120
1
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 #ifdef __cplusplus
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 }
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 #endif
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 #endif /* MAIN_H */
1bcaac272cdf added existing source code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126

mercurial