| 1 |
/* This is xdvipsk, an eXtended version of dvips(k) by Tomas Rokicki. |
| 2 |
|
| 3 |
Copyright (C) 2016 by VTeX Ltd (www.vtex.lt), |
| 4 |
the xdvipsk project team - Sigitas Tolusis and Arunas Povilaitis. |
| 5 |
|
| 6 |
Program original code copyright (C) 2007-2014 by Jin-Hwan Cho and |
| 7 |
Shunsaku Hirata, the dvipdfmx project team. |
| 8 |
|
| 9 |
This program is free software; you can redistribute it and/or modify |
| 10 |
it under the terms of the GNU General Public License as published by |
| 11 |
the Free Software Foundation; either version 2 of the License, or |
| 12 |
(at your option) any later version. |
| 13 |
|
| 14 |
This program is distributed in the hope that it will be useful, |
| 15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
GNU General Public License for more details. |
| 18 |
|
| 19 |
You should have received a copy of the GNU General Public License |
| 20 |
along with this program; if not, write to the Free Software |
| 21 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 22 |
*/ |
| 23 |
|
| 24 |
#include <config.h> |
| 25 |
|
| 26 |
#include <stdarg.h> |
| 27 |
#include <stdio.h> |
| 28 |
#include <stdlib.h> |
| 29 |
|
| 30 |
#include "xdvips.h" /* The copyright notice in that file is included too! */ |
| 31 |
#include "error.h" |
| 32 |
|
| 33 |
#include "protos.h" |
| 34 |
|
| 35 |
#define DPX_MESG 0 |
| 36 |
#define DPX_MESG_WARN 1 |
| 37 |
#define DPX_MESG_ERROR 2 |
| 38 |
|
| 39 |
static int _mesg_type = DPX_MESG; |
| 40 |
#define WANT_NEWLINE() (_mesg_type != DPX_MESG_WARN && _mesg_type != DPX_MESG_ERROR) |
| 41 |
|
| 42 |
static int really_quiet = 1; //Only warnings and errors |
| 43 |
|
| 44 |
void |
| 45 |
shut_up (int quietness) |
| 46 |
{ |
| 47 |
really_quiet = quietness; |
| 48 |
} |
| 49 |
|
| 50 |
void |
| 51 |
MESG (const char *fmt, ...) |
| 52 |
{ |
| 53 |
va_list argp; |
| 54 |
|
| 55 |
if (really_quiet < 1) { |
| 56 |
va_start(argp, fmt); |
| 57 |
vfprintf(stderr, fmt, argp); |
| 58 |
va_end(argp); |
| 59 |
_mesg_type = DPX_MESG; |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
void |
| 64 |
WARN (const char *fmt, ...) |
| 65 |
{ |
| 66 |
va_list argp; |
| 67 |
char str[1024], buf[1024]; |
| 68 |
|
| 69 |
if (really_quiet < 2) { |
| 70 |
va_start(argp, fmt); |
| 71 |
vsprintf(str, fmt, argp); |
| 72 |
va_end(argp); |
| 73 |
sprintf(buf, "Warning: %s", str); |
| 74 |
error(buf); |
| 75 |
|
| 76 |
_mesg_type = DPX_MESG_WARN; |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
void |
| 81 |
ERROR (const char *fmt, ...) |
| 82 |
{ |
| 83 |
va_list argp; |
| 84 |
char str[1024], buf[1024]; |
| 85 |
|
| 86 |
if (really_quiet < 3) { |
| 87 |
va_start(argp, fmt); |
| 88 |
vsprintf(str, fmt, argp); |
| 89 |
va_end(argp); |
| 90 |
sprintf(buf, "!%s", str); |
| 91 |
error(buf); |
| 92 |
} |
| 93 |
} |