1 /*-------------- Telecommunications & Signal Processing Lab ---------------
2 McGill University
3
4 Routine:
5 void UThalt (const char Errmsg[], ...)
6
7 Purpose:
8 Print an error message, stop with error status set
9
10 Description:
11 This routine prints an error message to stderr (standard error) and then
12 terminates execution with exit status set to EXIT_FAILURE. An example of the
13 use of this routine is as follows.
14 UThalt ("%s: Invalid option", PROGRAM);
15
16 Parameters:
17 -> const char Errmsg[]
18 Character string to be printed. This string can contain optional
19 formatting codes. The arguments corresponding to the formatting codes
20 appear at the end of the argument list. The input string should not
21 normally have a terminating newline character, since this routine
22 supplies a newline.
23 -> <args...>
24 Arguments corresponding to the formatting codes. The format string and
25 the variable number of arguments is passed on to the system routine
26 vprintf.
27
28 Author / revision:
29 P. Kabal Copyright (C) 2003
30 $Revision: 1.22 $ $Date: 2003/05/09 03:20:37 $
31
32 -------------------------------------------------------------------------*/
33
34 #include <stdarg.h>
35 #include <stdlib.h> /* EXIT_FAILURE */
36
37 #include <libtsp.h>
38
39
40 void
UThalt(const char Errmsg[],...)41 UThalt (const char Errmsg[], ...)
42
43 {
44 va_list ap;
45
46 va_start (ap, Errmsg);
47
48 /* Print the error message */
49 vfprintf (stderr, Errmsg, ap);
50 fprintf (stderr, "\n");
51
52 va_end (ap);
53
54 exit (EXIT_FAILURE);
55 }
56