isc_abort.c 885 Bytes
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
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
/*
** isc_abort.c                                  Route to handle fatal errors
**
** Copyright (c) 1991 Peter Eriksson and Per Cederqvist of the
**                    Lysator Academic Computer Association.
**
** history:
** 910305 pen      moved into separate file
*/

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include "isc.h"
#include "intern.h"

/*
** External function declarations
*/
extern int fprintf(FILE *, char *, ...);
#if defined(__sun__) && !defined(__stdlib_h)
extern void abort(void);
#endif

static void (*isc_abortfn)(const char *msg) = (void (*)(const char *))NULL;

  
void
isc_setabortfn(void (*abortfn)(const char *msg))
{
  isc_abortfn = abortfn;
}


void
isc_abort(const char *message)
{
  if (isc_abortfn)
    (*isc_abortfn)(message);
  else
  {
    fprintf(stderr, "\n\r*** ISC SUBSYSTEM FATAL ERROR: %s\n\r", message);
    abort();
  }
}