]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/Error.cc
added changelog entries for last changes
[evince.git] / pdf / xpdf / Error.cc
1 //========================================================================
2 //
3 // Error.cc
4 //
5 // Copyright 1996 Derek B. Noonburg
6 //
7 //========================================================================
8
9 #ifdef __GNUC__
10 #pragma implementation
11 #endif
12
13 #include <stdio.h>
14 #include <stddef.h>
15 #include <stdarg.h>
16 #include "gtypes.h"
17 #include "Params.h"
18 #include "Error.h"
19
20 // Send error messages to /dev/tty instead of stderr.
21 GBool errorsToTTY = gFalse;
22
23 FILE *errFile;
24 GBool errQuiet;
25
26 void errorInit() {
27   if (errQuiet) {
28     errFile = NULL;
29   } else {
30     if (!errorsToTTY || !(errFile = fopen("/dev/tty", "w")))
31       errFile = stderr;
32   }
33 }
34
35 void CDECL error(int pos, char *msg, ...) {
36   va_list args;
37
38   if (errQuiet) {
39     return;
40   }
41   if (printCommands) {
42     fflush(stdout);
43   }
44   if (pos >= 0) {
45     fprintf(errFile, "Error (%d): ", pos);
46   } else {
47     fprintf(errFile, "Error: ");
48   }
49   va_start(args, msg);
50   vfprintf(errFile, msg, args);
51   va_end(args);
52   fprintf(errFile, "\n");
53   fflush(errFile);
54 }