home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume10
/
parseargs
/
syserr.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-02-16
|
2KB
|
128 lines
#include <useful.h>
#include <funclist.h>
VERSIONID("$Header: syserr.c,v 2.0 89/12/24 00:56:31 eric Exp $");
/*
** SYSERR -- indicate a system error
**
** Parameters:
** m -- the printf() message to print.
** a, b, c, d, e -- parameters to the message
**
** Returns:
** never
**
** Side Effects:
** Terminates the process if no acceptable recover takes place.
**
** Globals:
** SyserrFuncs -- a list of functions to call.
**
** Author:
** Eric Allman
** University of California, Berkeley
*/
#ifdef FUNCLISTSTUFF
FUNCLIST *SyserrFuncs = FUNCLISTNULL;
#endif
VOID
syserr(m, a, b, c, d, e)
char *m;
{
static BOOL exiting = FALSE;
/* print the error message */
_error_message(m, a, b, c, d, e);
/* if we recursively syserr during exit, drop out now! */
if (exiting)
_exit(1);
#ifdef FUNCLISTSTUFF
/* call any possible cleanup functions */
funclist_call(SyserrFuncs, ARBNULL);
#endif
/* try a clean exit */
exiting = TRUE;
exit(1);
/*NOTREACHED*/
}
/*
** USRERR -- print a user error
**
** Parameters:
** m -- the printf() message to print.
** a, b, c, d, e -- parameters to the message
**
** Returns:
** none.
**
** Side Effects:
** clears the global error number.
*/
#ifdef FUNCLISTSTUFF
FUNCLIST *UsrerrFuncs = FUNCLISTNULL;
#endif
VOID
usrerr(m, a, b, c, d, e)
char *m;
{
extern int errno;
/* print the error message */
_error_message(m, a, b, c, d, e);
#ifdef FUNCLISTSTUFF
/* allow cleanup actions */
funclist_call(UsrerrFuncs, ARBNULL);
#endif
/* give us a clean slate */
errno = 0;
}
/*
** _ERROR_MESSAGE -- generic message printing routine.
**
** Includes the program name with the message, as well as the
** various possible error codes.
**
** Parameters:
** m -- the printf() message to print.
** a, b, c, d, e -- parameters to the message
**
** Returns:
** none.
**
** Side Effects:
** none.
**
** Globals:
** ProgName -- the name of the program.
*/
STATIC VOID
_error_message(m, a, b, c, d, e)
char *m;
{
extern char *ProgName;
int saveerr;
extern int errno;
saveerr = errno;
if (ProgName != CHARNULL)
fprintf(stderr, "%s: ", ProgName);
fprintf(stderr, m, a, b, c, d, e);
fprintf(stderr, "\n");
if (saveerr != 0)
{
errno = saveerr;
perror("System error");
}
}