From d326f24d169154673717129098ff4554a673f178 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Fri, 7 May 2004 01:13:29 -0400 Subject: snapshot of project "lynx", label v2-8-6dev_3 --- src/LYexit.c | 77 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 40 deletions(-) (limited to 'src/LYexit.c') diff --git a/src/LYexit.c b/src/LYexit.c index 1e49ba9c..1b904393 100644 --- a/src/LYexit.c +++ b/src/LYexit.c @@ -14,77 +14,75 @@ #include /* - * Flag for outofmem macro. - FM + * Flag for outofmem macro. - FM */ BOOL LYOutOfMemory = FALSE; - /* - * Stack of functions to call upon exit. + * Stack of functions to call upon exit. */ static void (*callstack[ATEXITSIZE]) (void); static int topOfStack = 0; /* - * Purpose: Registers termination function. - * Arguments: function The function to register. - * Return Value: int 0 registered + * Purpose: Registers termination function. + * Arguments: function The function to register. + * Return Value: int 0 registered * !0 no more space to register - * Remarks/Portability/Dependencies/Restrictions: - * Revision History: + * Remarks/Portability/Dependencies/Restrictions: + * Revision History: * 06-15-94 created Lynx 2-3-1 Garrett Arch Blythe */ int LYatexit(void (*function) (void)) { /* - * Check for available space. + * Check for available space. */ if (topOfStack == ATEXITSIZE) { CTRACE((tfp, "(LY)atexit: Too many functions, ignoring one!\n")); - return(-1); + return (-1); } /* - * Register the function. + * Register the function. */ callstack[topOfStack] = function; topOfStack++; - return(0); + return (0); } /* - * Purpose: Call the functions registered with LYatexit - * Arguments: void - * Return Value: void - * Remarks/Portability/Dependencies/Restrictions: - * Revision History: + * Purpose: Call the functions registered with LYatexit + * Arguments: void + * Return Value: void + * Remarks/Portability/Dependencies/Restrictions: + * Revision History: * 06-15-94 created Lynx 2-3-1 Garrett Arch Blythe */ -static void LYCompleteExit (void) +static void LYCompleteExit(void) { /* - * Just loop through registered functions. - * This is reentrant if more exits occur in the registered functions. + * Just loop through registered functions. This is reentrant if more exits + * occur in the registered functions. */ while (--topOfStack >= 0) { - callstack[topOfStack](); + callstack[topOfStack] (); } } /* - * Purpose: Terminates program, reports memory not freed. - * Arguments: status Exit code. - * Return Value: void - * Remarks/Portability/Dependencies/Restrictions: + * Purpose: Terminates program, reports memory not freed. + * Arguments: status Exit code. + * Return Value: void + * Remarks/Portability/Dependencies/Restrictions: * Function calls stdlib.h exit - * Revision History: + * Revision History: * 06-15-94 created Lynx 2-3-1 Garrett Arch Blythe */ -void LYexit ( - int status) +void LYexit(int status) { -#ifndef VMS /* On VMS, the VMSexit() handler does these. - FM */ +#ifndef VMS /* On VMS, the VMSexit() handler does these. - FM */ #ifdef _WINDOWS extern CRITICAL_SECTION critSec_DNS; /* 1998/09/03 (Thu) 22:01:56 */ extern CRITICAL_SECTION critSec_READ; /* 1998/09/03 (Thu) 22:01:56 */ @@ -96,13 +94,13 @@ void LYexit ( #endif if (LYOutOfMemory == TRUE) { /* - * Ignore further interrupts. - FM + * Ignore further interrupts. - FM */ #ifndef NOSIGHUP (void) signal(SIGHUP, SIG_IGN); #endif /* NOSIGHUP */ - (void) signal (SIGTERM, SIG_IGN); - (void) signal (SIGINT, SIG_IGN); + (void) signal(SIGTERM, SIG_IGN); + (void) signal(SIGINT, SIG_IGN); #ifndef __linux__ #ifndef DOSPATH (void) signal(SIGBUS, SIG_IGN); @@ -112,13 +110,13 @@ void LYexit ( (void) signal(SIGILL, SIG_IGN); /* - * Flush all messages. - FM + * Flush all messages. - FM */ fflush(stderr); fflush(stdout); /* - * Deal with curses, if on, and clean up. - FM + * Deal with curses, if on, and clean up. - FM */ if (LYCursesON) { LYSleepAlert(); @@ -143,7 +141,7 @@ void LYexit ( #endif /* !VMS && SYSLOG_REQUESTED_URLS */ /* - * Do functions registered with LYatexit. - GAB + * Do functions registered with LYatexit. - GAB */ LYCompleteExit(); @@ -155,8 +153,8 @@ void LYexit ( #undef exit #endif /* exit */ - cleanup_files(); /* if someone starts with LYNXfoo: page */ -#ifndef VMS /* On VMS, the VMSexit() handler does these. - FM */ + cleanup_files(); /* if someone starts with LYNXfoo: page */ +#ifndef VMS /* On VMS, the VMSexit() handler does these. - FM */ fflush(stderr); if (LYOutOfMemory == TRUE) { LYOutOfMemory = FALSE; @@ -169,9 +167,8 @@ void LYexit ( exit(status); } -void outofmem ( - const char * fname, - const char * func) +void outofmem(const char *fname, + const char *func) { fprintf(stderr, "\n\n\n%s %s: %s\n", fname, func, MEMORY_EXHAUSTED_ABORTING); LYOutOfMemory = TRUE; -- cgit 1.4.1-2-gfad0