doc
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
modules
csync_owncloud.h
Go to the documentation of this file.
1
/*
2
* libcsync -- a library to sync a directory with another
3
*
4
* Copyright (c) 2011 by Andreas Schneider <asn@cryptomilk.org>
5
* Copyright (c) 2012 by Klaas Freitag <freitag@owncloud.com>
6
*
7
* This program is free software = NULL, you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation = NULL, either version 2
10
* of the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY = NULL, without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program = NULL, if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
*/
21
#ifndef CSYNC_OWNCLOUD_H
22
#define CSYNC_OWNCLOUD_H
23
24
#include <errno.h>
25
#include <stdio.h>
26
#include <time.h>
27
#include <limits.h>
28
#include <stdlib.h>
29
30
#include <sys/types.h>
31
#include <sys/stat.h>
32
#include <fcntl.h>
33
34
#include "config.h"
35
#ifdef NEON_WITH_LFS
/* Switch on LFS in libneon. Never remove the NE_LFS! */
36
#define NE_LFS
37
#endif
38
39
#include <neon/ne_basic.h>
40
#include <neon/ne_socket.h>
41
#include <neon/ne_session.h>
42
#include <neon/ne_request.h>
43
#include <neon/ne_props.h>
44
#include <neon/ne_auth.h>
45
#include <neon/ne_dates.h>
46
#include <neon/ne_compress.h>
47
#include <neon/ne_redirect.h>
48
49
50
#include "
c_rbtree.h
"
51
52
#include "
c_lib.h
"
53
#include "
csync.h
"
54
#include "
csync_misc.h
"
55
#include "
csync_macros.h
"
56
#include "
c_private.h
"
57
#include "
httpbf.h
"
58
59
#include "
vio/csync_vio_module.h
"
60
#include "
vio/csync_vio_file_stat.h
"
61
#include "
vio/csync_vio.h
"
62
63
#include "
csync_log.h
"
64
65
66
#define DEBUG_WEBDAV(...) csync_log( dav_session.csync_ctx, 9, "oc_module", __VA_ARGS__);
67
68
enum
resource_type
{
69
resr_normal
= 0,
70
resr_collection
,
71
resr_reference
,
72
resr_error
73
};
74
75
#define DAV_STRTOL strtoll
76
77
/* Struct to store data for each resource found during an opendir operation.
78
* It represents a single file entry.
79
*/
80
81
typedef
struct
resource
{
82
char
*
uri
;
/* The complete uri */
83
char
*
name
;
/* The filename only */
84
85
enum
resource_type
type
;
86
int64_t
size
;
87
time_t
modtime
;
88
char
*
md5
;
89
90
struct
resource
*
next
;
91
}
resource
;
92
93
/* Struct to hold the context of a WebDAV PropFind operation to fetch
94
* a directory listing from the server.
95
*/
96
struct
listdir_context
{
97
struct
resource
*
list
;
/* The list of result resources */
98
struct
resource
*
currResource
;
/* A pointer to the current resource */
99
char
*
target
;
/* Request-URI of the PROPFIND */
100
unsigned
int
result_count
;
/* number of elements stored in list */
101
int
ref
;
/* reference count, only destroy when it reaches 0 */
102
};
103
104
105
/* Our cache, key is a char* */
106
extern
c_rbtree_t
*
propfind_recursive_cache
;
107
/* Values are propfind_recursive_element: */
108
struct
propfind_recursive_element
{
109
struct
resource
*
self
;
110
struct
resource
*
children
;
111
};
112
typedef
struct
propfind_recursive_element
propfind_recursive_element_t
;
113
void
clear_propfind_recursive_cache
(
void
);
114
struct
listdir_context
*
get_listdir_context_from_cache
(
const
char
*curi);
115
struct
listdir_context
*
fetch_resource_list_recursive
(
const
char
*uri,
const
char
*curi);
116
117
118
/*
119
* context to store info about a temp file for GET and PUT requests
120
* which store the data in a local file to save memory and secure the
121
* transmission.
122
*/
123
struct
transfer_context
{
124
ne_request *
req
;
/* the neon request */
125
int
fd
;
/* file descriptor of the file to read or write from */
126
const
char
*
method
;
/* the HTTP method, either PUT or GET */
127
ne_decompress *
decompress
;
/* the decompress context */
128
char
*
url
;
129
130
/* Used for limiting the bandwidth */
131
struct
timeval
last_time
;
132
ne_off_t
last_progress
;
133
int64_t
get_size
;
134
};
135
136
typedef
int (*
csync_owncloud_redirect_callback_t
)(
CSYNC
* ctx,
const
char
* uri);
137
138
/* Struct with the WebDAV session */
139
struct
dav_session_s
{
140
ne_session *
ctx
;
141
char
*
user
;
142
char
*
pwd
;
143
144
char
*
proxy_type
;
145
char
*
proxy_host
;
146
int
proxy_port
;
147
char
*
proxy_user
;
148
char
*
proxy_pwd
;
149
150
char
*
session_key
;
151
152
char
*
error_string
;
153
154
int
read_timeout
;
155
156
CSYNC
*
csync_ctx
;
157
158
csync_hbf_info_t
*
chunk_info
;
159
160
bool
no_recursive_propfind
;
161
int64_t
hbf_block_size
;
162
int64_t
hbf_threshold
;
163
164
/* If 0, it is disabled. If >0, in Byte/seconds. If < 0, in % of the available bandwidth*/
165
int
bandwidth_limit_upload
;
166
int
bandwidth_limit_download
;
167
168
csync_overall_progress_t
*
overall_progress_data
;
169
csync_owncloud_redirect_callback_t
redir_callback
;
170
};
171
extern
struct
dav_session_s
dav_session
;
172
173
/* The list of properties that is fetched in PropFind on a collection */
174
static
const
ne_propname
ls_props
[] = {
175
{
"DAV:"
,
"getlastmodified"
},
176
{
"DAV:"
,
"getcontentlength"
},
177
{
"DAV:"
,
"resourcetype"
},
178
{
"DAV:"
,
"getetag"
},
179
{ NULL, NULL }
180
};
181
182
void
set_errno_from_http_errcode
(
int
err );
183
void
set_error_message
(
const
char
*msg );
184
void
set_errno_from_neon_errcode
(
int
neon_code );
185
int
http_result_code_from_session
(
void
);
186
void
set_errno_from_session
(
void
);
187
188
time_t
oc_httpdate_parse
(
const
char
*date );
189
190
char
*
_cleanPath
(
const
char
* uri );
191
192
int
_stat_perms
(
int
type
);
193
csync_vio_file_stat_t
*
resourceToFileStat
(
struct
resource
*res );
194
195
void
oc_notify_progress
(
const
char
*file,
enum
csync_notify_type_e
kind, int64_t current_size, int64_t full_size);
196
197
#endif
/* CSYNC_OWNCLOUD_H */
Generated by
1.8.2