error.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/types.h>
  4. #include <unistd.h>
  5. #include <time.h>
  6. #include <stdarg.h>
  7. #include <rpc/types.h>
  8. #include <rpc/xdr.h>
  9. #include <grass/gis.h>
  10. #include "G3d_intern.h"
  11. /*---------------------------------------------------------------------------*/
  12. /*!
  13. * \brief
  14. *
  15. * This function ignores the error.
  16. *
  17. * \param
  18. * \return void
  19. */
  20. void G3d_skipError(const char *msg)
  21. {
  22. }
  23. /*!
  24. * \brief
  25. *
  26. * This function prints the
  27. * error message <em>msg</em> to <em>stderr</em> and returns.
  28. *
  29. * \param
  30. * \return void
  31. */
  32. void G3d_printError(const char *msg)
  33. {
  34. fprintf(stderr, "ERROR: ");
  35. fprintf(stderr, msg);
  36. fprintf(stderr, "\n");
  37. }
  38. /*!
  39. * \brief
  40. *
  41. * This function prints the
  42. * error message <em>msg</em>, and terminates the program with an error status.
  43. *
  44. * \param
  45. * \return void
  46. */
  47. void G3d_fatalError(const char *msg, ...)
  48. {
  49. char buffer[2000]; /* No novels to the error logs, OK? */
  50. va_list ap;
  51. va_start(ap, msg);
  52. vsprintf(buffer, msg, ap);
  53. va_end(ap);
  54. G_fatal_error("%s", buffer);
  55. }
  56. void G3d_fatalError_noargs(const char *msg)
  57. {
  58. G_fatal_error("%s", msg);
  59. }
  60. void G3d_error(const char *msg, ...)
  61. {
  62. char buffer[2000]; /* No novels to the error logs, OK? */
  63. va_list ap;
  64. va_start(ap, msg);
  65. vsprintf(buffer, msg, ap);
  66. va_end(ap);
  67. (*g3d_error_fun) (buffer);
  68. }