Debian Codegraph @

texk/dvipdfm-x/error.c

raw
1 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
2
3 Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
4 the dvipdfmx project team.
5
6 Copyright (C) 1998, 1999 by Mark A. Wicks <[email protected]>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
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, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <stdarg.h>
28 #include <stdio.h>
29
30 #include "dvipdfmx.h"
31 #include "error.h"
32
33 #define DPX_MESG 0
34 #define DPX_MESG_WARN 1
35 #define DPX_MESG_ERROR 2
36
37 static int _mesg_type = DPX_MESG;
38 #define WANT_NEWLINE() (_mesg_type != DPX_MESG_WARN && _mesg_type != DPX_MESG_ERROR)
39
40 static int really_quiet = 0;
41
42 void
43 shut_up (int quietness)
44 {
45 really_quiet = quietness;
46 }
47
48 void
49 MESG (const char *fmt, ...)
50 {
51 va_list argp;
52
53 if (really_quiet < 1) {
54 va_start(argp, fmt);
55 vfprintf(stderr, fmt, argp);
56 va_end(argp);
57 _mesg_type = DPX_MESG;
58 }
59 }
60
61 void
62 WARN (const char *fmt, ...)
63 {
64 va_list argp;
65
66 if (really_quiet < 2) {
67 if (WANT_NEWLINE())
68 fprintf(stderr, "\n");
69 fprintf(stderr, "%s:warning: ", my_name);
70 va_start(argp, fmt);
71 vfprintf(stderr, fmt, argp);
72 va_end(argp);
73 fprintf(stderr, "\n");
74
75 _mesg_type = DPX_MESG_WARN;
76 }
77 }
78
79 void
80 ERROR (const char *fmt, ...)
81 {
82 va_list argp;
83
84 if (really_quiet < 3) {
85 if (WANT_NEWLINE())
86 fprintf(stderr, "\n");
87 fprintf(stderr, "%s:fatal: ", my_name);
88 va_start(argp, fmt);
89 vfprintf(stderr, fmt, argp);
90 va_end(argp);
91 fprintf(stderr, "\n");
92 }
93 error_cleanup();
94 exit( 1 );
95 }