doc
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 
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 */
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 {
65 
66  int64_t start;
67  int64_t size;
68 
69  Hbf_State state;
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 
83 
86  int block_cnt;
87  int fd;
89  char *url;
90  int start_id;
91 
93  char *error_string;
94 
95  int64_t stat_size;
96  time_t modtime;
97  int64_t block_size;
98  int64_t threshold;
99 
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 
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