debug.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * \file debug.h
  3. *
  4. * \brief Debug functions
  5. *
  6. * Copyright (C) 2006-2010, Brainspark B.V.
  7. *
  8. * This file is part of PolarSSL (http://www.polarssl.org)
  9. * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
  10. *
  11. * All rights reserved.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #ifndef SSL_DEBUG_H
  28. #define SSL_DEBUG_H
  29. #include "config.h"
  30. #include "polarssl/ssl.h"
  31. #if defined(POLARSSL_DEBUG_MSG) && defined(POLARSSL_DEBUG_C)
  32. #define __FILENAME__ (strrchr(__FILE__, 0x5c) +1)
  33. #define SSL_DEBUG_MSG( level, args ) \
  34. debug_print_msg( ssl, level, __FILENAME__, __LINE__, debug_fmt args );
  35. #define SSL_DEBUG_RET( level, text, ret ) \
  36. debug_print_ret( ssl, level, __FILENAME__, __LINE__, text, ret );
  37. #define SSL_DEBUG_BUF( level, text, buf, len ) \
  38. debug_print_buf( ssl, level, __FILENAME__, __LINE__, text, buf, len );
  39. #define SSL_DEBUG_MPI( level, text, X ) \
  40. debug_print_mpi( ssl, level, __FILENAME__, __LINE__, text, X );
  41. #define SSL_DEBUG_CRT( level, text, crt ) \
  42. debug_print_crt( ssl, level, __FILENAME__, __LINE__, text, crt );
  43. #else
  44. #define SSL_DEBUG_MSG( level, args ) do { } while( 0 )
  45. #define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
  46. #define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
  47. #define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
  48. #define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
  49. #endif
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. char *debug_fmt( const char *format, ... );
  54. void debug_print_msg( const ssl_context *ssl, int level,
  55. const char *file, int line, const char *text );
  56. void debug_print_ret( const ssl_context *ssl, int level,
  57. const char *file, int line,
  58. const char *text, int ret );
  59. void debug_print_buf( const ssl_context *ssl, int level,
  60. const char *file, int line, const char *text,
  61. unsigned char *buf, size_t len );
  62. void debug_print_mpi( const ssl_context *ssl, int level,
  63. const char *file, int line,
  64. const char *text, const mpi *X );
  65. void debug_print_crt( const ssl_context *ssl, int level,
  66. const char *file, int line,
  67. const char *text, const x509_cert *crt );
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif /* debug.h */