blob: 7aa3d7c86f5d8da352d38802c53ba1f9c35be2af [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file debug.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
4 * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
5 *
Paul Bakker785a9ee2009-01-25 14:15:10 +00006 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000021 */
22#ifndef SSL_DEBUG_H
23#define SSL_DEBUG_H
24
Paul Bakker8e831ed2009-01-03 21:24:11 +000025#include "polarssl/config.h"
26#include "polarssl/ssl.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000027
Paul Bakker40e46942009-01-03 21:51:57 +000028#if defined(POLARSSL_DEBUG_MSG)
Paul Bakker5121ce52009-01-03 21:22:43 +000029
30#define SSL_DEBUG_MSG( level, args ) \
31 debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args );
32
33#define SSL_DEBUG_RET( level, text, ret ) \
34 debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret );
35
36#define SSL_DEBUG_BUF( level, text, buf, len ) \
37 debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len );
38
39#define SSL_DEBUG_MPI( level, text, X ) \
40 debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X );
41
42#define SSL_DEBUG_CRT( level, text, crt ) \
43 debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt );
44
45#else
46
47#define SSL_DEBUG_MSG( level, args ) do { } while( 0 )
48#define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
49#define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
50#define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
51#define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
52
53#endif
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59char *debug_fmt( const char *format, ... );
60
61void debug_print_msg( ssl_context *ssl, int level,
62 char *file, int line, char *text );
63
64void debug_print_ret( ssl_context *ssl, int level,
65 char *file, int line, char *text, int ret );
66
67void debug_print_buf( ssl_context *ssl, int level,
68 char *file, int line, char *text,
69 unsigned char *buf, int len );
70
71void debug_print_mpi( ssl_context *ssl, int level,
72 char *file, int line, char *text, mpi *X );
73
74void debug_print_crt( ssl_context *ssl, int level,
75 char *file, int line, char *text, x509_cert *crt );
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif /* debug.h */