2551
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2551
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include <stdarg.h> |
|
28 #include <stdio.h> |
|
29 #include <stdlib.h> |
|
30 |
|
31 #include "lo-error.h" |
|
32 |
2597
|
33 /* Having this file in this directory is a kluge to avoid unresolved |
|
34 symbol errors when creating shared versions of libcruft. */ |
2551
|
35 |
2597
|
36 /* Pointer to the current error handling function. */ |
2551
|
37 liboctave_error_handler current_liboctave_error_handler = liboctave_fatal; |
|
38 |
|
39 static void |
|
40 verror (const char *name, const char *fmt, va_list args) |
|
41 { |
|
42 if (name) |
|
43 fprintf (stderr, "%s: ", name); |
|
44 |
|
45 vfprintf (stderr, fmt, args); |
|
46 fprintf (stderr, "\n"); |
|
47 fflush (stderr); |
|
48 } |
|
49 |
|
50 void |
|
51 set_liboctave_error_handler (liboctave_error_handler f) |
|
52 { |
|
53 if (f) |
|
54 current_liboctave_error_handler = f; |
|
55 else |
|
56 current_liboctave_error_handler = liboctave_fatal; |
|
57 } |
|
58 |
|
59 void |
|
60 liboctave_fatal (const char *fmt, ...) |
|
61 { |
|
62 va_list args; |
|
63 va_start (args, fmt); |
|
64 verror ("fatal", fmt, args); |
|
65 va_end (args); |
|
66 |
|
67 exit (1); |
|
68 } |
|
69 |
|
70 /* |
|
71 ;;; Local Variables: *** |
|
72 ;;; mode: C *** |
|
73 ;;; page-delimiter: "^/\\*" *** |
|
74 ;;; End: *** |
|
75 */ |