996
|
1 /* -*- mode: C; coding: utf-8; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
|
|
2 *
|
|
3 * cfunge - A standard-conforming Befunge93/98/109 interpreter in C.
|
|
4 * Copyright (C) 2008-2009 Arvid Norlander <anmaster AT tele2 DOT se>
|
|
5 *
|
|
6 * This program is free software: you can redistribute it and/or modify
|
|
7 * it under the terms of the GNU General Public License as published by
|
|
8 * the Free Software Foundation, either version 3 of the License, or
|
|
9 * (at the proxy's option) any later version. Arvid Norlander is a
|
|
10 * proxy who can decide which future versions of the GNU General Public
|
|
11 * License can be used.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20 */
|
|
21 #include "global.h"
|
|
22 #include "diagnostic.h"
|
|
23
|
|
24 #include <stdlib.h> /* abort, exit */
|
|
25 #include <stdio.h>
|
|
26
|
|
27 FUNGE_ATTR_FAST
|
|
28 void diag_fatal(const char* message)
|
|
29 {
|
|
30 fprintf(stderr, "FATAL: %s\n", message);
|
|
31 exit(1);
|
|
32 }
|
|
33
|
|
34 FUNGE_ATTR_FAST
|
|
35 void diag_error(const char* message)
|
|
36 {
|
|
37 if (FUNGE_UNLIKELY(setting_enable_errors))
|
|
38 fprintf(stderr, "ERROR: %s\n", message);
|
|
39 }
|
|
40
|
|
41 FUNGE_ATTR_FAST
|
|
42 void diag_warn(const char* message)
|
|
43 {
|
|
44 if (FUNGE_UNLIKELY(setting_enable_warnings))
|
|
45 fprintf(stderr, "WARN: %s\n", message);
|
|
46 }
|
|
47
|
|
48
|
|
49 FUNGE_ATTR_FAST
|
|
50 void diag_fatal_format(const char* format, ...)
|
|
51 {
|
|
52 va_list ap;
|
|
53 fputs("FATAL: ", stderr);
|
|
54 va_start(ap, format);
|
|
55 vfprintf(stderr, format, ap);
|
|
56 va_end(ap);
|
|
57 fputc('\n', stderr);
|
|
58 exit(1);
|
|
59 }
|
|
60
|
|
61 FUNGE_ATTR_FAST
|
|
62 void diag_error_format(const char* format, ...)
|
|
63 {
|
|
64 if (FUNGE_UNLIKELY(setting_enable_errors)) {
|
|
65 va_list ap;
|
|
66 fputs("ERROR: ", stderr);
|
|
67 va_start(ap, format);
|
|
68 vfprintf(stderr, format, ap);
|
|
69 va_end(ap);
|
|
70 fputc('\n', stderr);
|
|
71 }
|
|
72 }
|
|
73
|
|
74 FUNGE_ATTR_FAST
|
|
75 void diag_warn_format(const char* format, ...)
|
|
76 {
|
|
77 if (FUNGE_UNLIKELY(setting_enable_warnings)) {
|
|
78 va_list ap;
|
|
79 fputs("WARN: ", stderr);
|
|
80 va_start(ap, format);
|
|
81 vfprintf(stderr, format, ap);
|
|
82 va_end(ap);
|
|
83 fputc('\n', stderr);
|
|
84 }
|
|
85 }
|