dapdebug.c 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*********************************************************************
  2. * Copyright 1993, UCAR/Unidata
  3. * See netcdf/COPYRIGHT file for copying and redistribution conditions.
  4. * $Header: /upc/share/CVS/netcdf-3/libncdap3/dapdebug.c,v 1.9 2009/09/23 22:26:00 dmh Exp $
  5. *********************************************************************/
  6. #include "config.h"
  7. #include <stdarg.h>
  8. #include <stdio.h>
  9. #include "nclog.h"
  10. #include "oc.h"
  11. #include "dapdebug.h"
  12. int ncdap3debug = 0;
  13. #ifdef CATCHERROR
  14. /* Place breakpoint here to catch errors close to where they occur*/
  15. int
  16. dapbreakpoint(int err) {return err;}
  17. int
  18. dapthrow(int err)
  19. {
  20. if(err == 0) return err;
  21. return dapbreakpoint(err);
  22. }
  23. #endif
  24. int
  25. dappanic(const char* fmt, ...)
  26. {
  27. va_list args;
  28. if(fmt != NULL) {
  29. va_start(args, fmt);
  30. vfprintf(stderr, fmt, args);
  31. fprintf(stderr, "\n" );
  32. va_end( args );
  33. } else {
  34. fprintf(stderr, "panic" );
  35. }
  36. fprintf(stderr, "\n" );
  37. fflush(stderr);
  38. return 0;
  39. }