PRIVATE void terminate_letter ARGS1(int,sig GCC_UNUSED) { term_letter = TRUE; /* Reassert the AST */ signal(SIGINT, terminate_letter); #if USE_VMS_MAILER || defined(PDCURSES) /* * Refresh the screen to get rid of the "interrupt" message. */ if (!dump_output_immediately) { lynx_force_repaint(); LYrefresh(); } #endif /* VMS */ }
static void terminate_message(int sig GCC_UNUSED) { term_message = TRUE; /* * Reassert the AST. */ signal(SIGINT, terminate_message); #ifdef VMS /* * Refresh the screen to get rid of the "interrupt" message. */ lynx_force_repaint(); LYrefresh(); #endif /* VMS */ }
/* * Interrupt handler. Stop curses and exit gracefully. */ void cleanup_sig(int sig) { #ifdef IGNORE_CTRL_C if (sig == SIGINT) { /* * Need to rearm the signal. */ #ifdef DJGPP if (wathndlcbrk) { sig_handler_watt(sig); /* Use WATT-32 signal handler */ } #endif /* DJGPP */ signal(SIGINT, cleanup_sig); sigint = TRUE; #ifdef DJGPP _eth_release(); _eth_init(); #endif /* DJGPP */ return; } #endif /* IGNORE_CTRL_C */ #ifdef VMS if (!dump_output_immediately) { int c; /* * Reassert the AST. */ (void) signal(SIGINT, cleanup_sig); if (!LYCursesON) return; /* * Refresh screen to get rid of "cancel" message, then query. */ lynx_force_repaint(); LYrefresh(); /* * Ask if exit is intended. */ if (LYQuitDefaultYes == TRUE) { c = HTConfirmDefault(REALLY_EXIT, YES); } else { c = HTConfirmDefault(REALLY_EXIT, NO); } HadVMSInterrupt = TRUE; if (LYQuitDefaultYes == TRUE) { if (c == NO) { return; } } else if (c != YES) { return; } } #endif /* VMS */ /* * Ignore further interrupts. - mhc: 11/2/91 */ #ifndef NOSIGHUP (void) signal(SIGHUP, SIG_IGN); #endif /* NOSIGHUP */ #ifdef VMS /* * Use ttclose() from cleanup() for VMS if not dumping. */ if (dump_output_immediately) #else /* Unix: */ (void) signal(SIGINT, SIG_IGN); #endif /* VMS */ (void) signal(SIGTERM, SIG_IGN); if (traversal) dump_traversal_history(); #ifndef NOSIGHUP if (sig != SIGHUP) { #endif /* NOSIGHUP */ if (!dump_output_immediately) { /* * cleanup() also calls cleanup_files(). */ cleanup(); } if (sig != 0) { SetOutputMode(O_TEXT); printf("\n\n%s %d\n\n", gettext("Exiting via interrupt:"), sig); fflush(stdout); } #ifndef NOSIGHUP } else { cleanup_files(); } #endif /* NOSIGHUP */ if (sig != 0) { exit_immediately(EXIT_SUCCESS); } else { reset_signals(); } }
void HTFWriter_free( HTStream *me ) { int len; char *path = 0; char *addr = 0; int status; BOOLEAN use_zread = 0; BOOLEAN found = 0; if ( me->fp ) fflush( &me->fp ); if ( me->end_command ) { LYCloseTempFP( &me->fp ); if ( me->input_format == HTAtom_for( "www/compressed" ) ) { if ( me->anchor->FileCache ) { BOOLEAN skip_loadfile = me->viewer_command != 0; HTSACopy( &path, &me->anchor->FileCache ); len = strlen( path ); if ( len > 3 && ( strcasecomp( &path[ len + -2 ], "gz" ) == 0 || strcasecomp( &path[ len + -2 ], "zz" ) == 0 ) ) { if ( skip_loadfile == 0 ) use_zread = 1; else { path[ len + -3 ] = 0; remove( path ); } } else if ( len > 4 && strcasecomp( &path[ len + -3 ], "bz2" ) == 0 ) { path[ len + -4 ] = 0; remove( path ); } else if ( len > 2 && strcasecomp( &path[ len + -1 ], "Z" ) == 0 ) { path[ len + -2 ] = 0; remove( path ); } if ( use_zread == 0 ) { if ( dump_output_immediately == 0 ) { mustshow = 1; HTProgress( &me->end_command ); } if ( me->end_command && me->end_command[0] ) LYSystem( &me->end_command ); found = LYCanReadFile( &me->anchor->FileCache ); } if ( found ) { if ( dump_output_immediately == 0 ) { lynx_force_repaint( ); LYrefresh( ); } HTAlert( gettext( "Error uncompressing temporary file!" ) ); LYRemoveTemp( &me->anchor->FileCache ); if ( me->anchor->FileCache ) { free( &me->anchor->FileCache ); me->anchor->FileCache = 0; } } else { LYLocalFileToURL( &addr, path ); if ( use_zread == 0 ) { LYRenamedTemp( &me->anchor->FileCache, path ); HTSACopy( &me->anchor->FileCache, path ); HTSACopy( &me->anchor->content_encoding, "binary" ); } if ( path ) { free( path ); path = 0; } if ( skip_loadfile == 0 ) { if ( HTAnchor_getUCLYhndl( &me->anchor, 1 ) < 0 ) HTAnchor_copyUCInfoStage( &me->anchor, 1, 0, 2 ); HTAnchor_copyUCInfoStage( &me->anchor, 1, 0, -1 ); } if ( dump_output_immediately == 0 ) { LYstore_message2( gettext( "Using %s" ), addr ); } if ( skip_loadfile ) { if ( me->end_command ) { free( &me->end_command ); *(int*)&me->end_command = 0; } HTAddParam( &me->end_command, &me->viewer_command, 1, &me->anchor->FileCache ); HTEndParam( &me->end_command, &me->viewer_command, 1 ); if ( dump_output_immediately == 0 ) { HTProgress( &me->end_command ); stop_curses( ); } LYSystem( &me->end_command ); if ( me->remove_command && me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } if ( dump_output_immediately == 0 ) start_curses( ); } else { status = HTLoadFile( addr, &me->anchor, &me->output_format, &me->sink ); } if ( dump_output_immediately && me->output_format == HTAtom_for( "www/present" ) ) { if ( addr ) { free( addr ); addr = 0; } remove( &me->anchor->FileCache ); if ( me->anchor->FileCache ) { free( &me->anchor->FileCache ); me->anchor->FileCache = 0; } if ( me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } if ( me->end_command ) { free( &me->end_command ); *(int*)&me->end_command = 0; } if ( me->viewer_command ) { free( &me->viewer_command ); *(int*)&me->viewer_command = 0; } if ( me == 0 ) { return; } free( me ); me = 0; return; } } if ( addr ) { free( addr ); addr = 0; } } if ( me->remove_command && me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } } else { if ( strcmp( &me->end_command, "SaveToFile" ) ) { if ( dump_output_immediately == 0 ) { mustshow = 1; HTProgress( &me->end_command ); stop_curses( ); } LYSystem( &me->end_command ); if ( me->remove_command && me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } if ( dump_output_immediately == 0 ) start_curses( ); } else { if ( me->remove_command && me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } if ( dump_output_immediately == 0 ) start_curses( ); } } if ( me->end_command ) { free( &me->end_command ); *(int*)&me->end_command = 0; } } if ( me->viewer_command ) { free( &me->viewer_command ); *(int*)&me->viewer_command = 0; } if ( dump_output_immediately ) { if ( me->anchor->FileCache ) remove( &me->anchor->FileCache ); if ( me ) { free( me ); me = 0; } if ( persistent_cookies ) LYStoreCookies( LYCookieSaveFile ); exit_immediately( 0 ); } if ( me == 0 ) { return; } free( me ); me = 0; return; }