void kill_downloads_to_file( unsigned char *file ) { struct file_download *file_download = &downloads->next[0]; if ( downloads.next != downloads.next ) { do { if ( strcmp( (char*)file_download->file, &file[0] ) == 0 ) { file_download = file_download->prev; abort_download( (int)( &file_download ) ); file_download = &file_download; if ( file_download->next != downloads.next ) continue; else break; } else { file_download = &file_download; } } while ( file_download->next != downloads.next ); } return; }
void abort_download_and_beep( struct file_download *file_download, struct terminal *term ) { if ( term[0] && file_download->notify + *(int*)(get_opt_( config_options, (unsigned char*)config_options )) > 1 ) beep_terminal( &term[0] ); abort_download( &file_download[0] ); return; }
static void do_abort_download(struct file_download *file_download) { /* We are maybe called from bottom halve so check consistency */ if (is_in_downloads_list(file_download)) { file_download->stop = 1; abort_download(file_download); } }
void detach_downloads_from_terminal( struct terminal *term ) { int edx; struct file_download *file_download, *next; if ( assert_failed == 0 ) { assert_failed = term[0].next == 0; if ( !(_Bool)( term[0].next != 0 ) ) { errfile = "/home/naftali/source/elinks-0.12~pre5/src/session/download.c"; errline = 227; elinks_internal( "assertion term != NULL failed!" ); if ( assert_failed ) { term = &term[0]; } } file_download = &downloads.next[0]; next = &downloads.next[0]; if ( downloads.next != downloads.next ) { while ( 1 ) { if ( file_download->term == term[0].next ) { if ( file_download->external_handler == 0 ) { file_download->term = 0; if ( file_download->ses && term[0].next == file_download->ses->tab->term ) file_download->ses = 0; } else { abort_download( &file_download[0] ); next = &file_download; file_download = &next; if ( downloads->next == next[0].next ) break; next = &next[0]; } } next = &next; file_download = &next; if ( downloads->next == next[0].next ) break; next = &next[0]; } } return; } assert_failed = 0; return; }
void abort_all_downloads( void ) { if ( downloads.next != downloads.next ) { do { abort_download( &downloads.next[0] ); } while ( downloads.next == downloads.next ); } return; }
void WEB_remove_download(CWEBDOWNLOAD *_object) { int index; abort_download(THIS, NULL); index = find_download(THIS); if (index >= 0) { GB.Unref(POINTER(&_downloads[index])); GB.Remove(&_downloads, index, 1); } }
void download_data_store( struct download *download, struct file_download *file_download ) { struct terminal *term = file_download->term; assert_terminal_ptr_not_dangling( file_download->term ); if ( assert_failed ) { assert_failed = 0; file_download->term = 0; abort_download( &file_download[0] ); term = &term[0]; return; } else { if ( term[0].next == 0 ) { abort_download( &file_download[0] ); term = &term[0]; return; } else { if ( download->state.basic >= 0 ) { if ( file_download->dlg_data ) { redraw_dialog( file_download->dlg_data, 1 ); return; } else { return; } } else { if ( file_download->dlg_data != -100000 ) { unsigned char *url = get_uri_string( file_download->uri, URI_PUBLIC ); struct connection_state state = download->state; state.syserr = download->state.syserr; abort_download_and_beep( &file_download[0], &term[0] ); if ( url ) { info_box( &term[0], MSGBOX_FREE_TEXT, "Download error", ALIGN_CENTER ); mem_free( (void*)url ); return; } else { return; } } else { if ( file_download->external_handler ) { close( file_download->handle ); file_download->handle = -1; exec_on_terminal( &term[0], file_download->external_handler, file_download->file, ( (int)file_download->bits_at_104/*.1_1of4*/ >> 2 ) & 1 ); file_download->bits_at_104/*.1_1of4*/ &= 254; abort_download_and_beep( &file_download[0], &term[0] ); return; } else { if ( file_download->notify ) { unsigned char *url; url[0] = get_uri_string( file_download->uri, URI_PUBLIC ); done_download_display( &file_download[0] ); if ( url[0] ) { info_box( &term[0], MSGBOX_FREE_TEXT, "Download", ALIGN_CENTER ); mem_free( &url[0] ); } } if ( file_download->remotetime && *(int*)(get_opt_( config_options, (unsigned char*)config_options )) ) { struct utimbuf foo; foo.modtime = file_download->remotetime; foo.actime = file_download->remotetime; utime( (char*)file_download->file, &foo.actime ); } abort_download_and_beep( &file_download[0], &term[0] ); return; } } } }
void destroy_downloads( struct session *ses ) { int edx; struct file_download *file_download, *next; struct session *s = &sessions.next[0]; if ( sessions.next != sessions.next ) { do { if ( ses[0].next != s[0].next && ses->tab->term == s->tab->term ) { file_download = &downloads.next[0]; if ( downloads.next != downloads.next ) { do { if ( file_download->ses == ses[0].next ) { file_download->ses = &s[0]; file_download = &file_download; if ( file_download->next == downloads.next ) { next = &next[0]; break; } } else { file_download = &file_download; } } while ( file_download->next != downloads.next ); break; } else break; } else { s = &s; } } while ( s->next != sessions.next ); } file_download = &downloads.next[0]; next = &downloads.next[0]; if ( downloads.next != downloads.next ) { for ( ; file_download->ses != ses[0].next; next = &s[0].next[0] ) { next = &next; file_download = &next; if ( next->next == downloads.next ) break; //next = &s[0].next[0]; } if ( file_download->external_handler == 0 ) file_download->ses = 0; else { abort_download( &file_download[0] ); } } else { return; } }