httpbf.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _HBF_SEND_H
00024 #define _HBF_SEND_H
00025
00026 #include "config.h"
00027 #ifdef NEON_WITH_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,
00040 HBF_TRANSFER,
00041 HBF_TRANSFER_FAILED,
00042 HBF_TRANSFER_SUCCESS,
00043 HBF_SPLITLIST_FAIL,
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
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
00122
00123
00124
00125 int hbf_fail_http_code( hbf_transfer_t *transfer );
00126
00127 #ifdef __cplusplus
00128 }
00129 #endif
00130
00131
00132 #endif