debug.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * This file is part of the Nice GLib ICE library.
  3. *
  4. * (C) 2008-2009 Collabora Ltd.
  5. * Contact: Youness Alaoui
  6. * (C) 2007 Nokia Corporation. All rights reserved.
  7. *
  8. * The contents of this file are subject to the Mozilla Public License Version
  9. * 1.1 (the "License"); you may not use this file except in compliance with
  10. * the License. You may obtain a copy of the License at
  11. * http://www.mozilla.org/MPL/
  12. *
  13. * Software distributed under the License is distributed on an "AS IS" basis,
  14. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  15. * for the specific language governing rights and limitations under the
  16. * License.
  17. *
  18. * The Original Code is the Nice GLib ICE library.
  19. *
  20. * The Initial Developers of the Original Code are Collabora Ltd and Nokia
  21. * Corporation. All Rights Reserved.
  22. *
  23. * Contributors:
  24. * Youness Alaoui, Collabora Ltd.
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of the
  27. * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
  28. * case the provisions of LGPL are applicable instead of those above. If you
  29. * wish to allow use of your version of this file only under the terms of the
  30. * LGPL and not to allow others to use your version of this file under the
  31. * MPL, indicate your decision by deleting the provisions above and replace
  32. * them with the notice and other provisions required by the LGPL. If you do
  33. * not delete the provisions above, a recipient may use your version of this
  34. * file under either the MPL or the LGPL.
  35. */
  36. #ifndef STUN_DEBUG_H
  37. #define STUN_DEBUG_H
  38. #include <stddef.h>
  39. #include <stdarg.h>
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /**
  44. * stun_debug_enable:
  45. *
  46. * Enable debug messages to stderr
  47. */
  48. void stun_debug_enable (void);
  49. /**
  50. * stun_debug_disable:
  51. *
  52. * Disable debug messages to stderr
  53. */
  54. void stun_debug_disable (void);
  55. /**
  56. * StunDebugHandler:
  57. * @format: printf()-style debug message format string
  58. * @ap: Parameters to substitute into message placeholders
  59. *
  60. * Callback for a debug message from the STUN code.
  61. */
  62. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4))
  63. typedef void (*StunDebugHandler) (const char *format, va_list ap)
  64. __attribute__((__format__ (__printf__, 1, 0)));
  65. #else
  66. typedef void (*StunDebugHandler) (const char *format, va_list ap);
  67. #endif
  68. /**
  69. * stun_set_debug_handler:
  70. * @handler: (nullable): Handler for STUN debug messages, or %NULL to use the
  71. * default
  72. *
  73. * Set a callback function to be invoked for each debug message from the STUN
  74. * code. The callback will only be invoked if STUN debugging is enabled using
  75. * stun_debug_enable().
  76. *
  77. * The default callback prints the formatted debug message to stderr.
  78. */
  79. void stun_set_debug_handler (StunDebugHandler handler);
  80. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4))
  81. void stun_debug (const char *fmt, ...)
  82. __attribute__((__format__ (__printf__, 1, 2)));
  83. #else
  84. void stun_debug (const char *fmt, ...);
  85. #endif
  86. void stun_debug_bytes (const char *prefix, const void *data, size_t len);
  87. # ifdef __cplusplus
  88. }
  89. # endif
  90. #endif /* STUN_DEBUG_H */