]> diplodocus.org Git - nmh/blob - sbr/done.c
sendsbr.c: Move interface to own file.
[nmh] / sbr / done.c
1 /* done.c -- terminate the program
2 *
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
6 */
7
8 #include "h/mh.h"
9 #include "error.h"
10
11 static void (*altexit)(int) NORETURN = exit;
12
13 /* set_done changes the path of done() from exit(3), or back to exit(3).
14 * Anything else will work, but a standard-error warning will report the
15 * old non-exit() value has been trampled. */
16 void
17 set_done(void (*new)(int) NORETURN)
18 {
19 generic_pointer gpo, gpn;
20
21 if (altexit != exit && new != exit) {
22 gpo.f = (void (*)(void))altexit;
23 gpn.f = (void (*)(void))new;
24 inform("altexit trampled: %p %p", gpo.v, gpn.v);
25 }
26 altexit = new;
27 }
28
29 void NORETURN
30 done(int status)
31 {
32 (*altexit)(status);
33 }