GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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. */
39 
40 /* Pointer to the current error_with_id handling function. */
43 
44 /* Pointer to the current warning handler. */
47 
48 /* Pointer to the current warning_with_id handler. */
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
65 {
66  if (f)
68  else
70 }
71 
72 void
74 {
75  if (f)
77  else
79 }
80 
81 void
83 {
84  if (f)
86  else
88 }
89 
90 void
92 {
93  if (f)
95  else
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 }