mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[bittorrent] cast
This commit is contained in:
parent
7d3cff0655
commit
1d862ec801
@ -331,7 +331,7 @@ struct bittorrent_fetcher {
|
||||
static void
|
||||
bittorrent_fetch_callback(struct download *download, void *data)
|
||||
{
|
||||
struct bittorrent_fetcher *fetcher = data;
|
||||
struct bittorrent_fetcher *fetcher = (struct bittorrent_fetcher *)data;
|
||||
struct fragment *fragment;
|
||||
struct bittorrent_const_string response;
|
||||
struct cache_entry *cached = download->cached;
|
||||
@ -426,7 +426,7 @@ init_bittorrent_fetch(struct bittorrent_fetcher **fetcher_ref,
|
||||
static void
|
||||
end_bittorrent_fetch(void *fetcher_data)
|
||||
{
|
||||
struct bittorrent_fetcher *fetcher = fetcher_data;
|
||||
struct bittorrent_fetcher *fetcher = (struct bittorrent_fetcher *)fetcher_data;
|
||||
|
||||
assert(fetcher && !fetcher->callback);
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
static void
|
||||
set_bittorrent_connection_timer(struct connection *conn)
|
||||
{
|
||||
struct bittorrent_connection *bittorrent = conn->info;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
milliseconds_T interval = sec_to_ms(get_opt_int("protocol.bittorrent.choke_interval", NULL));
|
||||
|
||||
install_timer(&bittorrent->timer, interval,
|
||||
@ -94,7 +94,7 @@ sort_bittorrent_peer_connections(struct bittorrent_connection *bittorrent)
|
||||
void
|
||||
update_bittorrent_connection_state(struct connection *conn)
|
||||
{
|
||||
struct bittorrent_connection *bittorrent = conn->info;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
struct bittorrent_peer_connection *peer, *next_peer;
|
||||
int peer_conns, max_peer_conns;
|
||||
int min_uploads = get_opt_int("protocol.bittorrent.min_uploads", NULL);
|
||||
@ -194,7 +194,7 @@ update_bittorrent_connection_state(struct connection *conn)
|
||||
static void
|
||||
update_bittorrent_connection_upload(void *data)
|
||||
{
|
||||
struct bittorrent_connection *bittorrent = data;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)data;
|
||||
|
||||
update_progress(&bittorrent->upload_progress,
|
||||
bittorrent->uploaded,
|
||||
@ -247,7 +247,7 @@ update_bittorrent_connection_stats(struct bittorrent_connection *bittorrent,
|
||||
static void
|
||||
done_bittorrent_connection(struct connection *conn)
|
||||
{
|
||||
struct bittorrent_connection *bittorrent = conn->info;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
struct bittorrent_peer_connection *peer, *next;
|
||||
|
||||
assert(bittorrent);
|
||||
@ -327,8 +327,8 @@ static void
|
||||
bittorrent_metainfo_callback(void *data, struct connection_state state,
|
||||
struct bittorrent_const_string *response)
|
||||
{
|
||||
struct connection *conn = data;
|
||||
struct bittorrent_connection *bittorrent = conn->info;
|
||||
struct connection *conn = (struct connection *)data;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
|
||||
bittorrent->fetch = NULL;
|
||||
|
||||
|
@ -203,7 +203,7 @@ set_bittorrent_files_for_deletion(struct download *download)
|
||||
if (!download->conn || !download->conn->info)
|
||||
return;
|
||||
|
||||
bittorrent = download->conn->info;
|
||||
bittorrent = (struct bittorrent_connection *)download->conn->info;
|
||||
bittorrent->cache->delete_files = 1;
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ set_bittorrent_notify_on_completion(struct download *download, struct terminal *
|
||||
if (!download->conn || !download->conn->info)
|
||||
return;
|
||||
|
||||
bittorrent = download->conn->info;
|
||||
bittorrent = (struct bittorrent_connection *)download->conn->info;
|
||||
bittorrent->cache->notify_complete = 1;
|
||||
bittorrent->term = term;
|
||||
}
|
||||
@ -240,7 +240,7 @@ notify_bittorrent_download_complete(struct bittorrent_connection *bittorrent)
|
||||
widget_handler_status_T
|
||||
dlg_show_bittorrent_info(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
{
|
||||
struct file_download *file_download = dlg_data->dlg->udata;
|
||||
struct file_download *file_download = (struct file_download *)dlg_data->dlg->udata;
|
||||
struct download *download = &file_download->download;
|
||||
struct string msg;
|
||||
|
||||
@ -251,7 +251,7 @@ dlg_show_bittorrent_info(struct dialog_data *dlg_data, struct widget_data *widge
|
||||
struct bittorrent_connection *bittorrent;
|
||||
enum msgbox_flags flags = MSGBOX_FREE_TEXT;
|
||||
|
||||
bittorrent = download->conn->info;
|
||||
bittorrent = (struct bittorrent_connection *)download->conn->info;
|
||||
|
||||
add_bittorrent_meta_to_string(&msg, &bittorrent->meta, term, 1);
|
||||
|
||||
@ -302,7 +302,7 @@ get_bittorrent_message(struct download *download, struct terminal *term,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bittorrent = download->conn->info;
|
||||
bittorrent = (struct bittorrent_connection *)download->conn->info;
|
||||
|
||||
add_to_string(&string, msg);
|
||||
mem_free(msg);
|
||||
@ -464,7 +464,7 @@ draw_bittorrent_piece_progress(struct download *download, struct terminal *term,
|
||||
if (!download->conn || !download->conn->info)
|
||||
return;
|
||||
|
||||
bittorrent = download->conn->info;
|
||||
bittorrent = (struct bittorrent_connection *)download->conn->info;
|
||||
|
||||
/* Draw the progress meter part "[### ]" */
|
||||
if (!text && width > 2) {
|
||||
@ -570,7 +570,7 @@ draw_bittorrent_piece_progress(struct download *download, struct terminal *term,
|
||||
void
|
||||
bittorrent_message_dialog(struct session *ses, void *data)
|
||||
{
|
||||
struct bittorrent_message *message = data;
|
||||
struct bittorrent_message *message = (struct bittorrent_message *)data;
|
||||
struct string string;
|
||||
char *uristring;
|
||||
|
||||
@ -617,7 +617,7 @@ bittorrent_message_dialog(struct session *ses, void *data)
|
||||
static void
|
||||
abort_bittorrent_download_query(struct dialog_data *dlg_data)
|
||||
{
|
||||
struct bittorrent_download_info *info = dlg_data->dlg->udata;
|
||||
struct bittorrent_download_info *info = (struct bittorrent_download_info *)dlg_data->dlg->udata;
|
||||
|
||||
done_bittorrent_download_info(info);
|
||||
}
|
||||
@ -630,8 +630,8 @@ abort_bittorrent_download_query(struct dialog_data *dlg_data)
|
||||
static widget_handler_status_T
|
||||
bittorrent_download(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
{
|
||||
struct type_query *type_query = dlg_data->dlg->udata2;
|
||||
struct bittorrent_download_info *info = dlg_data->dlg->udata;
|
||||
struct type_query *type_query = (struct type_query *)dlg_data->dlg->udata2;
|
||||
struct bittorrent_download_info *info = (struct bittorrent_download_info *)dlg_data->dlg->udata;
|
||||
struct file_download *file_download;
|
||||
struct session *ses = type_query->ses;
|
||||
struct string redirect;
|
||||
@ -687,7 +687,7 @@ bittorrent_download(struct dialog_data *dlg_data, struct widget_data *widget_dat
|
||||
static widget_handler_status_T
|
||||
tp_show_header(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
{
|
||||
struct type_query *type_query = widget_data->widget->data;
|
||||
struct type_query *type_query = (struct type_query *)widget_data->widget->data;
|
||||
|
||||
cached_header_dialog(type_query->ses, type_query->cached);
|
||||
|
||||
@ -703,7 +703,7 @@ bittorrent_query_callback(void *data, struct connection_state state,
|
||||
struct bittorrent_const_string *response)
|
||||
{
|
||||
/* [gettext_accelerator_context(.bittorrent_query_callback)] */
|
||||
struct type_query *type_query = data;
|
||||
struct type_query *type_query = (struct type_query *)data;
|
||||
struct string filename;
|
||||
char *text;
|
||||
struct dialog *dlg;
|
||||
|
@ -145,7 +145,7 @@ set_bittorrent_peer_connection_timeout(struct bittorrent_peer_connection *peer)
|
||||
static void
|
||||
set_bittorrent_socket_state(struct socket *socket, struct connection_state state)
|
||||
{
|
||||
struct bittorrent_peer_connection *peer = socket->conn;
|
||||
struct bittorrent_peer_connection *peer = (struct bittorrent_peer_connection *)socket->conn;
|
||||
|
||||
if (is_in_state(state, S_TRANS) && peer->bittorrent)
|
||||
set_connection_state(peer->bittorrent->conn,
|
||||
@ -158,7 +158,7 @@ static void
|
||||
set_bittorrent_socket_timeout(struct socket *socket, struct connection_state state)
|
||||
{
|
||||
assert(is_in_state(state, 0));
|
||||
set_bittorrent_peer_connection_timeout(socket->conn);
|
||||
set_bittorrent_peer_connection_timeout((struct bittorrent_peer_connection *)socket->conn);
|
||||
}
|
||||
|
||||
/* Called when a non-fatal error condition has appeared, i.e. the condition is
|
||||
@ -166,7 +166,7 @@ set_bittorrent_socket_timeout(struct socket *socket, struct connection_state sta
|
||||
static void
|
||||
retry_bittorrent_socket(struct socket *socket, struct connection_state state)
|
||||
{
|
||||
struct bittorrent_peer_connection *peer = socket->conn;
|
||||
struct bittorrent_peer_connection *peer = (struct bittorrent_peer_connection *)socket->conn;
|
||||
|
||||
check_bittorrent_peer_blacklisting(peer, state);
|
||||
|
||||
@ -183,7 +183,7 @@ retry_bittorrent_socket(struct socket *socket, struct connection_state state)
|
||||
static void
|
||||
done_bittorrent_socket(struct socket *socket, struct connection_state state)
|
||||
{
|
||||
struct bittorrent_peer_connection *peer = socket->conn;
|
||||
struct bittorrent_peer_connection *peer = (struct bittorrent_peer_connection *)socket->conn;
|
||||
|
||||
check_bittorrent_peer_blacklisting(peer, state);
|
||||
|
||||
@ -368,7 +368,7 @@ accept_bittorrent_peer_connection(void *____)
|
||||
struct connection_state
|
||||
init_bittorrent_listening_socket(struct connection *conn)
|
||||
{
|
||||
struct bittorrent_connection *bittorrent = conn->info;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
struct sockaddr_in addr, addr2;
|
||||
uint16_t port, max_port;
|
||||
socklen_t len;
|
||||
@ -439,7 +439,7 @@ init_bittorrent_listening_socket(struct connection *conn)
|
||||
void
|
||||
done_bittorrent_listening_socket(struct connection *conn)
|
||||
{
|
||||
struct bittorrent_connection *connection, *bittorrent = conn->info;
|
||||
struct bittorrent_connection *connection, *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
|
||||
/* The bittorrent connection might not even have been added if the
|
||||
* request for the metainfo file failed so carefully look it up. */
|
||||
|
@ -224,7 +224,7 @@ sent_bittorrent_peer_message(struct socket *socket)
|
||||
{
|
||||
assert(!socket->write_buffer);
|
||||
/* Check if there are pending messages or requests. */
|
||||
update_bittorrent_peer_connection_state(socket->conn);
|
||||
update_bittorrent_peer_connection_state((struct bittorrent_peer_connection *)socket->conn);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -624,7 +624,7 @@ read_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
||||
static void
|
||||
read_bittorrent_peer_data(struct socket *socket, struct read_buffer *buffer)
|
||||
{
|
||||
struct bittorrent_peer_connection *peer = socket->conn;
|
||||
struct bittorrent_peer_connection *peer = (struct bittorrent_peer_connection *)socket->conn;
|
||||
|
||||
if (!peer->remote.handshake) {
|
||||
enum bittorrent_handshake_state state;
|
||||
@ -701,7 +701,7 @@ read_bittorrent_peer_data(struct socket *socket, struct read_buffer *buffer)
|
||||
static void
|
||||
sent_bittorrent_peer_handshake(struct socket *socket)
|
||||
{
|
||||
struct bittorrent_peer_connection *peer = socket->conn;
|
||||
struct bittorrent_peer_connection *peer = (struct bittorrent_peer_connection *)socket->conn;
|
||||
struct read_buffer *buffer = peer->socket->read_buffer;
|
||||
|
||||
assert(buffer);
|
||||
@ -723,7 +723,7 @@ sent_bittorrent_peer_handshake(struct socket *socket)
|
||||
void
|
||||
send_bittorrent_peer_handshake(struct socket *socket)
|
||||
{
|
||||
struct bittorrent_peer_connection *peer = socket->conn;
|
||||
struct bittorrent_peer_connection *peer = (struct bittorrent_peer_connection *)socket->conn;
|
||||
struct bittorrent_connection *bittorrent = peer->bittorrent;
|
||||
struct bittorrent_meta *meta = &bittorrent->meta;
|
||||
char reserved[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
@ -901,7 +901,7 @@ check_bittorrent_peer_handshake(struct bittorrent_peer_connection *peer,
|
||||
static enum bittorrent_handshake_state
|
||||
do_read_bittorrent_peer_handshake(struct socket *socket, struct read_buffer *buffer)
|
||||
{
|
||||
struct bittorrent_peer_connection *peer = socket->conn;
|
||||
struct bittorrent_peer_connection *peer = (struct bittorrent_peer_connection *)socket->conn;
|
||||
enum bittorrent_handshake_state state;
|
||||
|
||||
state = check_bittorrent_peer_handshake(peer, buffer);
|
||||
|
@ -1191,7 +1191,7 @@ start_bittorrent_resume(struct bittorrent_connection *bittorrent,
|
||||
|
||||
if (!init_string(&info)) return;
|
||||
|
||||
add_bytes_to_string(&info, (void *) &meta->length, sizeof(meta->length));
|
||||
add_bytes_to_string(&info, (const char *)&meta->length, sizeof(meta->length));
|
||||
add_bytes_to_string(&info, meta->source, meta->length);
|
||||
|
||||
cache->resume_fd = start_thread(bittorrent_resume_writer, info.source,
|
||||
|
@ -41,7 +41,7 @@ static void do_send_bittorrent_tracker_request(struct connection *conn);
|
||||
static void
|
||||
set_bittorrent_tracker_interval(struct connection *conn)
|
||||
{
|
||||
struct bittorrent_connection *bittorrent = conn->info;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
int interval = get_opt_int("protocol.bittorrent.tracker.interval",
|
||||
NULL);
|
||||
|
||||
@ -69,8 +69,8 @@ static void
|
||||
bittorrent_tracker_callback(void *data, struct connection_state state,
|
||||
struct bittorrent_const_string *response)
|
||||
{
|
||||
struct connection *conn = data;
|
||||
struct bittorrent_connection *bittorrent = conn ? conn->info : NULL;
|
||||
struct connection *conn = (struct connection *)data;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)(conn ? conn->info : NULL);
|
||||
|
||||
/* We just did event=stopped and don't have any connection attached. */
|
||||
if (!bittorrent) return;
|
||||
@ -147,7 +147,7 @@ check_bittorrent_stopped_request(void *____)
|
||||
static void
|
||||
do_send_bittorrent_tracker_request(struct connection *conn)
|
||||
{
|
||||
struct bittorrent_connection *bittorrent = conn->info;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
int stopped = (bittorrent->tracker.event == BITTORRENT_EVENT_STOPPED);
|
||||
char *ip, *key;
|
||||
struct string request;
|
||||
@ -282,7 +282,7 @@ do_send_bittorrent_tracker_request(struct connection *conn)
|
||||
void
|
||||
send_bittorrent_tracker_request(struct connection *conn)
|
||||
{
|
||||
struct bittorrent_connection *bittorrent = conn->info;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
|
||||
/* Kill the timer when we are not sending a periodic request to make
|
||||
* sure that there are only one tracker request at any time. */
|
||||
@ -294,7 +294,7 @@ send_bittorrent_tracker_request(struct connection *conn)
|
||||
void
|
||||
done_bittorrent_tracker_connection(struct connection *conn)
|
||||
{
|
||||
struct bittorrent_connection *bittorrent = conn->info;
|
||||
struct bittorrent_connection *bittorrent = (struct bittorrent_connection *)conn->info;
|
||||
|
||||
kill_timer(&bittorrent->tracker.timer);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user