comparison libcruft/misc/lo-error.cc @ 222:a592507b3bad

[project @ 1993-11-14 10:54:16 by jwe] Initial revision
author jwe
date Sun, 14 Nov 1993 10:54:16 +0000
parents
children 1a48a1b91489
comparison
equal deleted inserted replaced
221:e2110730e556 222:a592507b3bad
1 // error.cc -*- C++ -*-
2 /*
3
4 Copyright (C) 1992, 1993 John W. Eaton
5
6 This file is part of Octave.
7
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
11 later version.
12
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, write to the Free
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 */
23
24 #ifdef __GNUG__
25 #pragma implementation
26 #endif
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <stdarg.h>
31
32 #include "liboctave-error.h"
33
34 static
35 liboctave_error_handler default_liboctave_error_handler = liboctave_fatal;
36
37 static
38 liboctave_error_handler current_liboctave_error_handler = liboctave_fatal;
39
40 static void
41 verror (const char *name, const char *fmt, va_list args)
42 {
43 if (name != (char *) NULL)
44 fprintf (stderr, "%s: ", name);
45
46 vfprintf (stderr, fmt, args);
47 fprintf (stderr, "\n");
48 fflush (stderr);
49 }
50
51 void
52 set_liboctave_error_handler (liboctave_error_handler f)
53 {
54 if (f)
55 current_liboctave_error_handler = f;
56 else
57 current_liboctave_error_handler = default_liboctave_error_handler;
58 }
59
60 void
61 liboctave_fatal (const char *fmt, ...)
62 {
63 va_list args;
64 va_start (args, fmt);
65 verror ("fatal", fmt, args);
66 va_end (args);
67
68 exit (1);
69 }
70
71 /*
72 ;;; Local Variables: ***
73 ;;; mode: C++ ***
74 ;;; page-delimiter: "^/\\*" ***
75 ;;; End: ***
76 */