home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 110 / EnigmaAmiga110CD.iso / indispensabili / utility / apdf / xpdf-0.80 / xpdf / error.cc < prev    next >
C/C++ Source or Header  |  1999-04-10  |  942b  |  46 lines

  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 to send error (and other) messages to.
  24. FILE *errFile;
  25.  
  26. void errorInit() {
  27.   if (!errorsToTTY || !(errFile = fopen("/dev/tty", "w")))
  28.     errFile = stderr;
  29. }
  30.  
  31. void CDECL error(int pos, char *msg, ...) {
  32.   va_list args;
  33.  
  34.   if (printCommands)
  35.     fflush(stdout);
  36.   if (pos >= 0)
  37.     fprintf(errFile, "Error (%d): ", pos);
  38.   else
  39.     fprintf(errFile, "Error: ");
  40.   va_start(args, msg);
  41.   vfprintf(errFile, msg, args);
  42.   va_end(args);
  43.   fprintf(errFile, "\n");
  44.   fflush(errFile);
  45. }
  46.