1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
/*
\funcref{error}{void error (\params, ...)}
{
{char} {*fmt} {format string}
}
{}
{}
{}
{error.c}
{
Prints an error message, defined by the format string and (optional)
following arguments, to {\em stderr}. If {\em stdout} is redirected,
the message is printed to {\em stdout} too. Then the global {\em int}
variable {\em error\_occurred} is incremented to reflect an error (a
cleanup function, attached by {\em atexit()},
may inspect this value and take appropriate action).
After this, the program is terminated with an exit value 1.
}
*/
#include "icrssdef.h"
int
error_occurred = 0;
#ifdef _PROTOTYPES
void error (char *fmt, ...)
#else
void error (fmt MARG)
char *fmt;
#endif
{
va_list
args;
fflush (stdout);
fflush (stderr);
va_start (args, fmt);
vfprintf (stderr, fmt, args);
fputc ('\n', stderr);
if (! isatty (fileno (stdout)))
{
va_start (args, fmt);
vprintf (fmt, args);
putchar ('\n');
}
error_occurred++;
exit (1);
}
|