ssl_tls: fix format warning in ssl_parse_certificate() on x86_64
[tropicssl.git] / include / tropicssl / debug.h
blob6864b8c37f680dcbd20a7441550b409935670fba
1 /**
2 * \file debug.h
4 * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
6 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
8 * All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of PolarSSL or XySSL nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef SSL_DEBUG_H
36 #define SSL_DEBUG_H
38 #include "tropicssl/config.h"
39 #include "tropicssl/ssl.h"
41 #if defined(TROPICSSL_DEBUG_MSG)
43 #define SSL_DEBUG_MSG( level, args ) \
44 debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args );
46 #define SSL_DEBUG_RET( level, text, ret ) \
47 debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret );
49 #define SSL_DEBUG_BUF( level, text, buf, len ) \
50 debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len );
52 #define SSL_DEBUG_MPI( level, text, X ) \
53 debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X );
55 #define SSL_DEBUG_CRT( level, text, crt ) \
56 debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt );
58 #else
60 #define SSL_DEBUG_MSG( level, args ) do { } while( 0 )
61 #define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
62 #define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
63 #define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
64 #define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
66 #endif
68 #ifdef __GNUC__
69 #define __tropicssl_debug_fmt_format__ __attribute__((format(printf, 1, 2)))
70 #else /* __GNUC__ */
71 #define __tropicssl_debug_fmt_format__
72 #endif /* __GNUC__ */
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
78 char *debug_fmt(const char *format, ...) __tropicssl_debug_fmt_format__;
80 void debug_print_msg(const ssl_context * ssl, int level,
81 const char *file, int line, const char *text);
83 void debug_print_ret(const ssl_context * ssl, int level,
84 const char *file, int line,
85 const char *text, int ret);
87 void debug_print_buf(const ssl_context * ssl, int level,
88 const char *file, int line, const char *text,
89 unsigned char *buf, int len);
91 void debug_print_mpi(const ssl_context * ssl, int level,
92 const char *file, int line,
93 const char *text, const mpi * X);
95 void debug_print_crt(const ssl_context * ssl, int level,
96 const char *file, int line,
97 const char *text, const x509_cert * crt);
99 #ifdef __cplusplus
101 #endif
102 #endif /* debug.h */