GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
lo-error.c
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <stdarg.h>
31#include <stdio.h>
32#include <stdlib.h>
33
34#include "lo-error.h"
35
36/* Having this file in this directory is a kluge to avoid unresolved
37 symbol errors when creating shared versions of liboctave. */
38
39/* Pointer to the current error handling function. */
40OCTAVE_NORETURN liboctave_error_handler
42
43/* Pointer to the current error_with_id handling function. */
46
47/* Pointer to the current warning handler. */
50
51/* Pointer to the current warning_with_id handler. */
54
55static void
56verror (const char *name, const char *fmt, va_list args)
57{
58 if (name)
59 fprintf (stderr, "%s: ", name);
60
61 vfprintf (stderr, fmt, args);
62 fprintf (stderr, "\n");
63 fflush (stderr);
64}
65
66void
74
75void
84
85void
93
94void
102
103void
104liboctave_fatal (const char *fmt, ...)
105{
106 va_list args;
107 va_start (args, fmt);
108 verror ("fatal", fmt, args);
109 va_end (args);
110
111 exit (1);
112}
113
114void
115liboctave_fatal_with_id (const char *id, const char *fmt, ...)
116{
117 octave_unused_parameter (id);
118
119 va_list args;
120 va_start (args, fmt);
121 verror ("fatal", fmt, args);
122 va_end (args);
123
124 exit (1);
125}
126
127void
128liboctave_warning (const char *fmt, ...)
129{
130 va_list args;
131 va_start (args, fmt);
132 verror ("warning", fmt, args);
133 va_end (args);
134}
135
136void
137liboctave_warning_with_id (const char *id, const char *fmt, ...)
138{
139 octave_unused_parameter (id);
140
141 va_list args;
142 va_start (args, fmt);
143 verror ("warning", fmt, args);
144 va_end (args);
145}
void set_liboctave_error_handler(OCTAVE_NORETURN liboctave_error_handler f)
Definition lo-error.c:67
OCTAVE_NORETURN liboctave_error_with_id_handler current_liboctave_error_with_id_handler
Definition lo-error.c:45
void liboctave_warning(const char *fmt,...)
Definition lo-error.c:128
void liboctave_fatal(const char *fmt,...)
Definition lo-error.c:104
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
Definition lo-error.c:41
void set_liboctave_warning_handler(liboctave_warning_handler f)
Definition lo-error.c:86
void set_liboctave_error_with_id_handler(OCTAVE_NORETURN liboctave_error_with_id_handler f)
Definition lo-error.c:76
void set_liboctave_warning_with_id_handler(liboctave_warning_with_id_handler f)
Definition lo-error.c:95
void liboctave_fatal_with_id(const char *id, const char *fmt,...)
Definition lo-error.c:115
liboctave_warning_handler current_liboctave_warning_handler
Definition lo-error.c:49
liboctave_warning_with_id_handler current_liboctave_warning_with_id_handler
Definition lo-error.c:53
void liboctave_warning_with_id(const char *id, const char *fmt,...)
Definition lo-error.c:137
void(* liboctave_error_with_id_handler)(const char *, const char *,...)
Definition lo-error.h:49
void(* liboctave_error_handler)(const char *,...)
Definition lo-error.h:47
void(* liboctave_warning_with_id_handler)(const char *, const char *,...)
Definition lo-error.h:53
void(* liboctave_warning_handler)(const char *,...)
Definition lo-error.h:51
F77_RET_T const F77_DBLE const F77_DBLE * f