doc
|
00001 /** 00002 * http big file functions 00003 * 00004 * Copyright (c) 2012 by Klaas Freitag <freitag@owncloud.com> 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * vim: ts=2 sw=2 et cindent 00021 **/ 00022 00023 #ifndef _HBF_SEND_H 00024 #define _HBF_SEND_H 00025 00026 #include "config.h" 00027 #ifdef NEON_WITH_LFS /* Switch on LFS in libneon. Never remove the NE_LFS! */ 00028 #define NE_LFS 00029 #endif 00030 00031 #include <neon/ne_session.h> 00032 00033 #ifdef __cplusplus 00034 extern "C" { 00035 #endif 00036 00037 enum hbf_state_e { 00038 HBF_SUCCESS, 00039 HBF_NOT_TRANSFERED, /* never tried to transfer */ 00040 HBF_TRANSFER, /* transfer currently running */ 00041 HBF_TRANSFER_FAILED, /* transfer tried but failed */ 00042 HBF_TRANSFER_SUCCESS, /* block transfer succeeded. */ 00043 HBF_SPLITLIST_FAIL, /* the file could not be split */ 00044 HBF_SESSION_FAIL, 00045 HBF_FILESTAT_FAIL, 00046 HBF_PARAM_FAIL, 00047 HBF_AUTH_FAIL, 00048 HBF_PROXY_AUTH_FAIL, 00049 HBF_CONNECT_FAIL, 00050 HBF_TIMEOUT_FAIL, 00051 HBF_MEMORY_FAIL, 00052 HBF_STAT_FAIL, 00053 HBF_SOURCE_FILE_CHANGE, 00054 HBF_USER_ABORTED, 00055 HBF_TRANSFER_NOT_ACKED, 00056 HBF_FAIL 00057 }; 00058 00059 typedef enum hbf_state_e Hbf_State; 00060 00061 typedef struct hbf_block_s hbf_block_t; 00062 00063 struct hbf_block_s { 00064 int seq_number; 00065 00066 int64_t start; 00067 int64_t size; 00068 00069 Hbf_State state; 00070 int http_result_code; 00071 char *http_error_msg; 00072 char *etag; 00073 00074 int tries; 00075 }; 00076 00077 /* Callback for to check on abort */ 00078 typedef int (*hbf_abort_callback) (); 00079 typedef void (*hbf_log_callback) (const char *, const char *); 00080 00081 00082 typedef struct hbf_transfer_s hbf_transfer_t; 00083 00084 struct hbf_transfer_s { 00085 hbf_block_t **block_arr; 00086 int block_cnt; 00087 int fd; 00088 int transfer_id; 00089 char *url; 00090 int start_id; 00091 00092 int status_code; 00093 char *error_string; 00094 00095 int64_t stat_size; 00096 time_t modtime; 00097 int64_t block_size; 00098 int64_t threshold; 00099 00100 hbf_abort_callback abort_cb; 00101 hbf_log_callback log_cb; 00102 00103 #ifndef NDEBUG 00104 int64_t calc_size; 00105 #endif 00106 }; 00107 00108 hbf_transfer_t *hbf_init_transfer( const char *dest_uri ); 00109 00110 Hbf_State hbf_transfer( ne_session *session, hbf_transfer_t *transfer, const char *verb ); 00111 00112 Hbf_State hbf_splitlist( hbf_transfer_t *transfer, int fd ); 00113 00114 void hbf_free_transfer( hbf_transfer_t *transfer ); 00115 00116 const char *hbf_error_string(hbf_transfer_t* transfer, Hbf_State state); 00117 00118 void hbf_set_abort_callback( hbf_transfer_t *transfer, hbf_abort_callback cb); 00119 void hbf_set_log_callback( hbf_transfer_t *transfer, hbf_log_callback cb); 00120 00121 /* returns an http (error) code of the transmission. If the transmission 00122 * succeeded, the code is 200. If it failed, its the error code of the 00123 * first part transmission that failed. 00124 */ 00125 int hbf_fail_http_code( hbf_transfer_t *transfer ); 00126 00127 #ifdef __cplusplus 00128 } 00129 #endif 00130 00131 00132 #endif