nghttp2_debug.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * nghttp2 - HTTP/2 C Library
  3. *
  4. * Copyright (c) 2016 Tatsuhiro Tsujikawa
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. */
  25. #include "nghttp2_debug.h"
  26. #include <stdio.h>
  27. #ifdef DEBUGBUILD
  28. static void nghttp2_default_debug_vfprintf_callback(const char *fmt,
  29. va_list args) {
  30. vfprintf(stderr, fmt, args);
  31. }
  32. static nghttp2_debug_vprintf_callback static_debug_vprintf_callback =
  33. nghttp2_default_debug_vfprintf_callback;
  34. void nghttp2_debug_vprintf(const char *format, ...) {
  35. if (static_debug_vprintf_callback) {
  36. va_list args;
  37. va_start(args, format);
  38. static_debug_vprintf_callback(format, args);
  39. va_end(args);
  40. }
  41. }
  42. void nghttp2_set_debug_vprintf_callback(
  43. nghttp2_debug_vprintf_callback debug_vprintf_callback) {
  44. static_debug_vprintf_callback = debug_vprintf_callback;
  45. }
  46. #else /* !DEBUGBUILD */
  47. void nghttp2_set_debug_vprintf_callback(
  48. nghttp2_debug_vprintf_callback debug_vprintf_callback) {
  49. (void)debug_vprintf_callback;
  50. }
  51. #endif /* !DEBUGBUILD */