File: fatal.c

package info (click to toggle)
shhmsg 1.4.2-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch, trixie
  • size: 208 kB
  • ctags: 133
  • sloc: ansic: 319; makefile: 301; sh: 20
file content (52 lines) | stat: -rw-r--r-- 1,629 bytes parent folder | download | duplicates (5)
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
/* $Id: fatal.c,v 1.6 2002/03/02 19:37:36 sverrehu Exp $ */
/*------------------------------------------------------------------------
 |  FILE            fatal.c
 |  MODULE OF       shhmsg - library for displaying messages.
 |
 |  DESCRIPTION     Function for displaying an error message and
 |                  abort the program.
 |
 |  WRITTEN BY      Sverre H. Huseby <shh@thathost.com>
 +----------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

#include "internal.h"
#include "shhmsg.h"

/*-----------------------------------------------------------------------+
|  PUBLIC FUNCTIONS                                                      |
+-----------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 |
 |  NAME          msgFatal
 |
 |  FUNCTION      Show given message and abort the program.
 |
 |  SYNOPSIS      #include "shhmsg.h"
 |                void msgFatal(const char *format, ...);
 |
 |  INPUT         format, ...
 |                        Arguments used as with printf().
 |
 |  RETURNS       Never returns. The program is aborted.
 |
 |  DESCRIPTION   Prints the name of this program followed by ": " and
 |                the given message on the _msgErrorStream, then aborts
 |                the program.
 */
void
msgFatal(const char *format, ...)
{
    va_list ap;

    fflush(stdout);
    fprintf(GET_ERROR_STREAM, "%s: ", msgGetName());
    va_start(ap, format);
    vfprintf(GET_ERROR_STREAM, format, ap);
    va_end(ap);
    exit(99);
}