Initial revision
[swftools.git] / pdf2swf / 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 FILE *errFile;
21 GBool errQuiet;
22
23 void errorInit() {
24   if (errQuiet) {
25     errFile = NULL;
26   } else {
27     errFile = stderr;
28   }
29 }
30
31 void CDECL error(int pos, char *msg, ...) {
32   va_list args;
33
34   if (errQuiet) {
35     return;
36   }
37   if (printCommands) {
38     fflush(stdout);
39   }
40   if (pos >= 0) {
41     fprintf(errFile, "Error (%d): ", pos);
42   } else {
43     fprintf(errFile, "Error: ");
44   }
45   va_start(args, msg);
46   vfprintf(errFile, msg, args);
47   va_end(args);
48   fprintf(errFile, "\n");
49   fflush(errFile);
50 }