home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ERR_EXIT.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  585b  |  34 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  ERR_EXIT.C - A generic fatal error-handler by Dave Schaumann
  5. */
  6.  
  7. #include <stdarg.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "errors.h"
  11.  
  12. void ErrExit(char *fmt, ...)
  13. {
  14.       va_list ap;
  15.  
  16.       va_start(ap, fmt) ;
  17.       vfprintf(stderr, fmt, ap);
  18.       fputc('\n', stderr);
  19.       exit(EXIT_FAILURE);
  20. }
  21.  
  22. #ifdef TEST
  23.  
  24. main()
  25. {
  26.       int x = 1, y = -1;
  27.  
  28.       if (x != y)
  29.             ErrExit("Found x = %d, y = %d; Expected them to be equal!", x, y);
  30.       return EXIT_SUCCESS;
  31. }
  32.  
  33. #endif /* TEST */
  34.