|
1 /* |
|
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
3 * |
|
4 * Copyright 2018 Olaf Wintermann. All rights reserved. |
|
5 * |
|
6 * Redistribution and use in source and binary forms, with or without |
|
7 * modification, are permitted provided that the following conditions are met: |
|
8 * |
|
9 * 1. Redistributions of source code must retain the above copyright |
|
10 * notice, this list of conditions and the following disclaimer. |
|
11 * |
|
12 * 2. Redistributions in binary form must reproduce the above copyright |
|
13 * notice, this list of conditions and the following disclaimer in the |
|
14 * documentation and/or other materials provided with the distribution. |
|
15 * |
|
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
26 * POSSIBILITY OF SUCH DAMAGE. |
|
27 */ |
|
28 |
|
29 #ifndef METHODS_H |
|
30 #define METHODS_H |
|
31 |
|
32 #include "webdav.h" |
|
33 #include "resource.h" |
|
34 |
|
35 #include <cx/list.h> |
|
36 |
|
37 #ifdef __cplusplus |
|
38 extern "C" { |
|
39 #endif |
|
40 |
|
41 typedef struct PropfindParser PropfindParser; |
|
42 typedef struct ResponseTag ResponseTag; |
|
43 typedef struct LockDiscovery LockDiscovery; |
|
44 |
|
45 struct PropfindParser { |
|
46 xmlDoc *document; |
|
47 xmlNode *current; |
|
48 }; |
|
49 |
|
50 struct ResponseTag { |
|
51 const char *href; |
|
52 int iscollection; |
|
53 CxList *properties; |
|
54 const char *crypto_name; |
|
55 const char *crypto_key; |
|
56 }; |
|
57 |
|
58 struct LockDiscovery { |
|
59 char *timeout; |
|
60 char *locktoken; |
|
61 }; |
|
62 |
|
63 int dav_buffer_seek(CxBuffer *b, curl_off_t offset, int origin); |
|
64 |
|
65 CURLcode do_propfind_request( |
|
66 DavSession *sn, |
|
67 CxBuffer *request, |
|
68 CxBuffer *response); |
|
69 |
|
70 CURLcode do_proppatch_request( |
|
71 DavSession *sn, |
|
72 char *lock, |
|
73 CxBuffer *request, |
|
74 CxBuffer *response); |
|
75 |
|
76 CURLcode do_put_request( |
|
77 DavSession *sn, |
|
78 char *lock, |
|
79 DavBool create, |
|
80 void *data, |
|
81 dav_read_func read_func, |
|
82 dav_seek_func seek_func, |
|
83 size_t length); |
|
84 |
|
85 CxBuffer* create_allprop_propfind_request(void); |
|
86 CxBuffer* create_cryptoprop_propfind_request(void); |
|
87 CxBuffer* create_propfind_request(DavSession *sn, CxList *properties, char *rootelm, DavBool nocrypt); |
|
88 CxBuffer* create_basic_propfind_request(void); |
|
89 |
|
90 PropfindParser* create_propfind_parser(CxBuffer *response, char *url); |
|
91 void destroy_propfind_parser(PropfindParser *parser); |
|
92 int get_propfind_response(PropfindParser *parser, ResponseTag *result); |
|
93 void cleanup_response(ResponseTag *result); |
|
94 |
|
95 int hrefeq(DavSession *sn, const char *href1, const char *href2); |
|
96 DavResource* response2resource(DavSession *sn, ResponseTag *response, char *parent_path); |
|
97 void add_properties(DavResource *res, ResponseTag *response); |
|
98 |
|
99 DavResource* parse_propfind_response(DavSession *sn, DavResource *root, CxBuffer *response); |
|
100 int parse_response_tag(DavResource *resource, xmlNode *node); |
|
101 void set_davprops(DavResource *res); |
|
102 |
|
103 /* |
|
104 * parses the content of a resourcetype element |
|
105 * returns 1 if the resourcetype is a collection, 0 otherwise |
|
106 */ |
|
107 int parse_resource_type(xmlNode *node); |
|
108 |
|
109 CxBuffer* create_proppatch_request(DavResourceData *data); |
|
110 CxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, const char *name, const char *hash); |
|
111 |
|
112 CURLcode do_delete_request(DavSession *sn, char *lock, CxBuffer *response); |
|
113 |
|
114 CURLcode do_mkcol_request(DavSession *sn, char *lock); |
|
115 |
|
116 CURLcode do_head_request(DavSession *sn); |
|
117 |
|
118 CURLcode do_copy_move_request(DavSession *sn, char *dest, char *lock, DavBool copy, DavBool override); |
|
119 |
|
120 CxBuffer* create_lock_request(void); |
|
121 int parse_lock_response(DavSession *sn, CxBuffer *response, LockDiscovery *lock); |
|
122 CURLcode do_lock_request(DavSession *sn, CxBuffer *request, CxBuffer *response, time_t timeout); |
|
123 CURLcode do_unlock_request(DavSession *sn, char *locktoken); |
|
124 |
|
125 CURLcode do_simple_request(DavSession *sn, char *method, char *locktoken); |
|
126 |
|
127 CURLcode do_report_request(DavSession *sn, CxBuffer *request, CxBuffer *response); |
|
128 |
|
129 #ifdef __cplusplus |
|
130 } |
|
131 #endif |
|
132 |
|
133 #endif /* METHODS_H */ |
|
134 |