debug.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* debug.c - Debug interface.
  2. Copyright (C) 2006, 2008 g10 Code GmbH
  3. This file is part of Scute.
  4. Scute is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. Scute is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Scute; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. In addition, as a special exception, g10 Code GmbH gives permission
  16. to link this library: with the Mozilla Foundation's code for
  17. Mozilla (or with modified versions of it that use the same license
  18. as the "Mozilla" code), and distribute the linked executables. You
  19. must obey the GNU General Public License in all respects for all of
  20. the code used other than "Mozilla". If you modify this file, you
  21. may extend this exception to your version of the file, but you are
  22. not obligated to do so. If you do not wish to do so, delete this
  23. exception statement from your version. */
  24. #ifndef DEBUG_H
  25. #define DEBUG_H 1
  26. #include <stdio.h>
  27. #define DEBUG_PREFIX "scute: "
  28. #define DBG_CRIT 0
  29. #define DBG_INFO (1 << 0)
  30. #define DBG_ASSUAN (1 << 1)
  31. extern FILE *_scute_debug_stream;
  32. extern unsigned int _scute_debug_flags;
  33. #define DEBUG(flag, format, ...) \
  34. do \
  35. { \
  36. if (_scute_debug_flags & (flag) || flag == DBG_CRIT) \
  37. fprintf (_scute_debug_stream, \
  38. DEBUG_PREFIX "%s: " format "\n", __func__, ##__VA_ARGS__); \
  39. } \
  40. while (0)
  41. void _scute_debug_init (void);
  42. #endif /* !DEBUG_H */