error.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*====================================================================*
  2. *
  3. * error.h - error function definitions and declarations;
  4. *
  5. * this file is an alterantive to GNU header file of the same
  6. * name; in addition to standard GNU error function declarations,
  7. * some additional functions are declared;
  8. *
  9. * Motley Tools by Charles Maier;
  10. * Copyright 2001-2006 by Charles Maier Associates;
  11. * Licensed under the Internet Software Consortium License;
  12. *
  13. *--------------------------------------------------------------------*/
  14. #ifndef ERROR_HEADER
  15. #define ERROR_HEADER
  16. /*====================================================================*
  17. * system header files;
  18. *--------------------------------------------------------------------*/
  19. #include <errno.h>
  20. /*====================================================================*
  21. * custom header files;
  22. *--------------------------------------------------------------------*/
  23. #include "../tools/types.h"
  24. /*====================================================================*
  25. *
  26. *--------------------------------------------------------------------*/
  27. #if defined (WIN32)
  28. #define __func__ __FUNCTION__
  29. #endif
  30. /*====================================================================*
  31. * define error codes for systems that do not support POSIX codes;
  32. *--------------------------------------------------------------------*/
  33. #ifndef ECANCELED
  34. #define ECANCELED 0
  35. #endif
  36. #ifndef ENOTSUP
  37. #define ENOTSUP EPERM
  38. #endif
  39. #ifndef EBADMSG
  40. #define EBADMSG 0
  41. #endif
  42. #ifndef EPROTONOSUPPORT
  43. #define EPROTONOSUPPORT 124
  44. #endif
  45. #ifndef ENODATA
  46. #define ENODATA 0
  47. #endif
  48. #ifndef EOVERFLOW
  49. #define EOVERFLOW 0
  50. #endif
  51. /*====================================================================*
  52. * define common error message strings;
  53. *--------------------------------------------------------------------*/
  54. #define ERROR_NOTROOT "This program needs root privileges"
  55. #define ERROR_TOOMANY "Too many command line arguments"
  56. #define CANT_START_TIMER "function %s can't start timer", __func__
  57. #define CANT_RESET_TIMER "function %s can't reset timer", __func__
  58. /*====================================================================*
  59. *
  60. *--------------------------------------------------------------------*/
  61. #define TRACE error (0, 0, "%s (%d)", __FILE__, __LINE__);
  62. /*====================================================================*
  63. * declare GNU error() and error_at_line() functions;
  64. *--------------------------------------------------------------------*/
  65. #ifdef __GNUC__
  66. __attribute__ ((format (printf, 3, 4)))
  67. #endif
  68. signed error (signed status, errno_t number, char const * format, ...);
  69. #ifdef __GNUC__
  70. __attribute__ ((format (printf, 3, 4)))
  71. #endif
  72. signed debug (signed status, char const * string, char const * format, ...);
  73. signed extra (signed status, errno_t number, int argc, char const * argv []);
  74. /*====================================================================*
  75. * end definitions and declarations;
  76. *--------------------------------------------------------------------*/
  77. #endif