doc
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
httpbf
src
httpbf.h
Go to the documentation of this file.
1
/**
2
* http big file functions
3
*
4
* Copyright (c) 2012 by Klaas Freitag <freitag@owncloud.com>
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
*
20
* vim: ts=2 sw=2 et cindent
21
**/
22
23
#ifndef _HBF_SEND_H
24
#define _HBF_SEND_H
25
26
#include "config.h"
27
#ifdef NEON_WITH_LFS
/* Switch on LFS in libneon. Never remove the NE_LFS! */
28
#define NE_LFS
29
#endif
30
31
#include <neon/ne_session.h>
32
33
#ifdef __cplusplus
34
extern
"C"
{
35
#endif
36
37
enum
hbf_state_e
{
38
HBF_SUCCESS
,
39
HBF_NOT_TRANSFERED
,
/* never tried to transfer */
40
HBF_TRANSFER
,
/* transfer currently running */
41
HBF_TRANSFER_FAILED
,
/* transfer tried but failed */
42
HBF_TRANSFER_SUCCESS
,
/* block transfer succeeded. */
43
HBF_SPLITLIST_FAIL
,
/* the file could not be split */
44
HBF_SESSION_FAIL
,
45
HBF_FILESTAT_FAIL
,
46
HBF_PARAM_FAIL
,
47
HBF_AUTH_FAIL
,
48
HBF_PROXY_AUTH_FAIL
,
49
HBF_CONNECT_FAIL
,
50
HBF_TIMEOUT_FAIL
,
51
HBF_MEMORY_FAIL
,
52
HBF_STAT_FAIL
,
53
HBF_SOURCE_FILE_CHANGE
,
54
HBF_USER_ABORTED
,
55
HBF_TRANSFER_NOT_ACKED
,
56
HBF_FAIL
57
};
58
59
typedef
enum
hbf_state_e
Hbf_State
;
60
61
typedef
struct
hbf_block_s
hbf_block_t
;
62
63
struct
hbf_block_s
{
64
int
seq_number
;
65
66
int64_t
start
;
67
int64_t
size
;
68
69
Hbf_State
state
;
70
int
http_result_code
;
71
char
*
http_error_msg
;
72
char
*
etag
;
73
74
int
tries
;
75
};
76
77
/* Callback for to check on abort */
78
typedef
int (*
hbf_abort_callback
) ();
79
typedef
void (*
hbf_log_callback
) (
const
char
*,
const
char
*);
80
81
82
typedef
struct
hbf_transfer_s
hbf_transfer_t
;
83
84
struct
hbf_transfer_s
{
85
hbf_block_t
**
block_arr
;
86
int
block_cnt
;
87
int
fd
;
88
int
transfer_id
;
89
char
*
url
;
90
int
start_id
;
91
92
int
status_code
;
93
char
*
error_string
;
94
95
int64_t
stat_size
;
96
time_t
modtime
;
97
int64_t
block_size
;
98
int64_t
threshold
;
99
100
hbf_abort_callback
abort_cb
;
101
hbf_log_callback
log_cb
;
102
103
#ifndef NDEBUG
104
int64_t
calc_size
;
105
#endif
106
};
107
108
hbf_transfer_t
*
hbf_init_transfer
(
const
char
*dest_uri );
109
110
Hbf_State
hbf_transfer
( ne_session *session,
hbf_transfer_t
*transfer,
const
char
*verb );
111
112
Hbf_State
hbf_splitlist
(
hbf_transfer_t
*transfer,
int
fd );
113
114
void
hbf_free_transfer
(
hbf_transfer_t
*transfer );
115
116
const
char
*
hbf_error_string
(
hbf_transfer_t
* transfer, Hbf_State state);
117
118
void
hbf_set_abort_callback
(
hbf_transfer_t
*transfer,
hbf_abort_callback
cb);
119
void
hbf_set_log_callback
(
hbf_transfer_t
*transfer,
hbf_log_callback
cb);
120
121
/* returns an http (error) code of the transmission. If the transmission
122
* succeeded, the code is 200. If it failed, its the error code of the
123
* first part transmission that failed.
124
*/
125
int
hbf_fail_http_code
(
hbf_transfer_t
*transfer );
126
127
#ifdef __cplusplus
128
}
129
#endif
130
131
132
#endif
Generated by
1.8.2