GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
cruft
misc
lo-error.c
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 1996-2013 John W. Eaton
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 3 of the License, or (at your
10
option) any 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, see
19
<http://www.gnu.org/licenses/>.
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
33
/* Having this file in this directory is a kluge to avoid unresolved
34
symbol errors when creating shared versions of libcruft. */
35
36
/* Pointer to the current error handling function. */
37
liboctave_error_handler
current_liboctave_error_handler
38
=
liboctave_fatal
;
39
40
/* Pointer to the current error_with_id handling function. */
41
liboctave_error_with_id_handler
current_liboctave_error_with_id_handler
42
=
liboctave_fatal_with_id
;
43
44
/* Pointer to the current warning handler. */
45
liboctave_warning_handler
current_liboctave_warning_handler
46
=
liboctave_warning
;
47
48
/* Pointer to the current warning_with_id handler. */
49
liboctave_warning_with_id_handler
current_liboctave_warning_with_id_handler
50
=
liboctave_warning_with_id
;
51
52
static
void
53
verror
(
const
char
*name,
const
char
*fmt, va_list args)
54
{
55
if
(name)
56
fprintf (stderr,
"%s: "
, name);
57
58
vfprintf (stderr, fmt, args);
59
fprintf (stderr,
"\n"
);
60
fflush (stderr);
61
}
62
63
void
64
set_liboctave_error_handler
(
liboctave_error_handler
f
)
65
{
66
if
(f)
67
current_liboctave_error_handler
=
f
;
68
else
69
current_liboctave_error_handler
=
liboctave_fatal
;
70
}
71
72
void
73
set_liboctave_error_with_id_handler
(
liboctave_error_with_id_handler
f
)
74
{
75
if
(f)
76
current_liboctave_error_with_id_handler
=
f
;
77
else
78
current_liboctave_error_with_id_handler
=
liboctave_fatal_with_id
;
79
}
80
81
void
82
set_liboctave_warning_handler
(
liboctave_warning_handler
f
)
83
{
84
if
(f)
85
current_liboctave_warning_handler
=
f
;
86
else
87
current_liboctave_warning_handler
=
liboctave_warning
;
88
}
89
90
void
91
set_liboctave_warning_with_id_handler
(
liboctave_warning_with_id_handler
f
)
92
{
93
if
(f)
94
current_liboctave_warning_with_id_handler
=
f
;
95
else
96
current_liboctave_warning_with_id_handler
=
liboctave_warning_with_id
;
97
}
98
99
void
100
liboctave_fatal
(
const
char
*fmt, ...)
101
{
102
va_list args;
103
va_start (args, fmt);
104
verror
(
"fatal"
, fmt, args);
105
va_end (args);
106
107
exit (1);
108
}
109
110
void
111
liboctave_fatal_with_id
(
const
char
*
id
,
const
char
*fmt, ...)
112
{
113
va_list args;
114
(
void
)
id
;
/*unused*/
115
va_start (args, fmt);
116
verror
(
"fatal"
, fmt, args);
117
va_end (args);
118
119
exit (1);
120
}
121
122
void
123
liboctave_warning
(
const
char
*fmt, ...)
124
{
125
va_list args;
126
va_start (args, fmt);
127
verror
(
"warning"
, fmt, args);
128
va_end (args);
129
}
130
131
void
132
liboctave_warning_with_id
(
const
char
*
id
,
const
char
*fmt, ...)
133
{
134
va_list args;
135
(
void
)
id
;
/*unused*/
136
va_start (args, fmt);
137
verror
(
"warning"
, fmt, args);
138
va_end (args);
139
}
Generated on Mon Dec 30 2013 03:04:46 for GNU Octave by
1.8.1.2