Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.4KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008-2020 Jonathan Moore Liles (as "Non-Session-Manager") */
  3. /* Copyright (C) 2020- Nils Hilbricht */
  4. /* */
  5. /* This file is part of New-Session-Manager */
  6. /* */
  7. /* New-Session-Manager is free software: you can redistribute it and/or modify */
  8. /* it under the terms of the GNU General Public License as published by */
  9. /* the Free Software Foundation, either version 3 of the License, or */
  10. /* (at your option) any later version. */
  11. /* */
  12. /* New-Session-Manager is distributed in the hope that it will be useful, */
  13. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  14. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  15. /* GNU General Public License for more details. */
  16. /* */
  17. /* You should have received a copy of the GNU General Public License */
  18. /* along with New-Session-Manager. If not, see <https://www.gnu.org/licenses/>.*/
  19. /*******************************************************************************/
  20. /* debug.h
  21. *
  22. * 11/21/2003 - Jonathan Moore Liles
  23. *
  24. * Debuging support.
  25. *
  26. * Disable by defining the preprocessor variable NDEBUG prior to inclusion.
  27. *
  28. * The following macros sould be defined as string literals
  29. *
  30. * name value
  31. *
  32. * __MODULE__ Name of module. eg. "libfoo"
  33. *
  34. * __FILE__ Name of file. eg. "foo.c"
  35. *
  36. * __FUNCTION__ Name of enclosing function. eg. "bar"
  37. *
  38. * (inteter literal)
  39. * __LINE__ Number of enclosing line.
  40. *
  41. *
  42. * __FILE__, and __LINE__ are automatically defined by standard CPP
  43. * implementations. __FUNCTION__ is more or less unique to GNU, and isn't
  44. * strictly a preprocessor macro, but rather a reserved word in the compiler.
  45. * There is a sed script available with this toolset that is able to fake
  46. * __FUNCTION__ (among other things) with an extra preprocesessing step.
  47. *
  48. * __MODULE__ is nonstandard and should be defined the enclosing program(s).
  49. * Autoconf defines PACKAGE as the module name, and these routines will use its
  50. * value instead if __MODULE__ is undefined.
  51. *
  52. * The following routines are provided (as macros) and take the same arguments
  53. * as printf():
  54. *
  55. * MESSAGE( const char *format, ... )
  56. * WARNING( const char *format, ... )
  57. * FATAL( const char *format, ... )
  58. *
  59. * Calling MESSAGE or WARNING prints the message to stderr along with module,
  60. * file and line information, as well as appropriate emphasis. Calling
  61. * FATAL will do the same, and then call abort() to end the program. It is
  62. * unwise to supply any of these marcros with arguments that produce side
  63. * effects. As, doing so will most likely result in Heisenbugs; program
  64. * behavior that changes when debugging is disabled.
  65. *
  66. */
  67. #ifndef _DEBUG_H
  68. #define _DEBUG_H
  69. #ifndef __MODULE__
  70. #ifdef PACKAGE
  71. #define __MODULE__ PACKAGE
  72. #else
  73. #define __MODULE__ NULL
  74. #endif
  75. #endif
  76. #ifndef __GNUC__
  77. #define __FUNCTION__ NULL
  78. #endif
  79. extern bool quietMessages;
  80. typedef enum {
  81. W_MESSAGE = 0,
  82. W_WARNING,
  83. W_FATAL
  84. } warning_t;
  85. void
  86. warnf ( warning_t level,
  87. const char *module,
  88. const char *file,
  89. const char *function, int line, const char *fmt, ... );
  90. //We do not use NDEBUG anymore. Messages are a command line switch.
  91. //Warnings, asserts and errors are always important.
  92. // #define MESSAGE( fmt, args... ) warnf( W_MESSAGE, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args )
  93. #define MESSAGE( fmt, args... ) do { if ( ! (quietMessages) ) { warnf( W_MESSAGE, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ); } } while ( 0 )
  94. #define WARNING( fmt, args... ) warnf( W_WARNING, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args )
  95. #define FATAL( fmt, args... ) ( warnf( W_FATAL, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ), abort() )
  96. #define ASSERT( pred, fmt, args... ) do { if ( ! (pred) ) { warnf( W_FATAL, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ); abort(); } } while ( 0 )
  97. #endif