minor update to the fix.
[gnutls.git] / lib / gnutls_errors.h
blob095a08401f88dd458173e752f5dfea560d4aa2a4
1 /*
2 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, 2010
3 * Free Software Foundation, Inc.
5 * Author: Nikos Mavrogiannopoulos
7 * This file is part of GnuTLS.
9 * The GnuTLS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 * USA
26 #ifndef GNUTLS_ERRORS_H
27 #define GNUTLS_ERRORS_H
29 #include <gnutls_int.h>
30 #include <gnutls_global.h>
32 #define GNUTLS_E_INT_RET_0 -1251
34 #ifdef __FILE__
35 #ifdef __LINE__
36 #define gnutls_assert() _gnutls_debug_log( "ASSERT: %s:%d\n", __FILE__,__LINE__);
37 #else
38 #define gnutls_assert()
39 #endif
40 #else /* __FILE__ not defined */
41 #define gnutls_assert()
42 #endif
44 int _gnutls_asn2err (int asn_err);
45 void
46 _gnutls_log (int, const char *fmt, ...)
47 #ifdef __GNUC__
48 __attribute__ ((format (printf, 2, 3)));
49 #else
51 #endif
53 void _gnutls_mpi_log (const char *prefix, bigint_t a);
55 #ifdef C99_MACROS
56 #define LEVEL(l, ...) do { if (_gnutls_log_level >= l || _gnutls_log_level > 9) \
57 _gnutls_log( l, __VA_ARGS__); } while(0)
59 #define LEVEL_EQ(l, ...) do { if (_gnutls_log_level == l || _gnutls_log_level > 9) \
60 _gnutls_log( l, __VA_ARGS__); } while(0)
62 #define _gnutls_debug_log(...) LEVEL(2, __VA_ARGS__)
63 #define _gnutls_handshake_log(...) LEVEL(3, __VA_ARGS__)
64 #define _gnutls_io_log(...) LEVEL_EQ(5, __VA_ARGS__)
65 #define _gnutls_buffers_log(...) LEVEL_EQ(6, __VA_ARGS__)
66 #define _gnutls_hard_log(...) LEVEL(9, __VA_ARGS__)
67 #define _gnutls_record_log(...) LEVEL(4, __VA_ARGS__)
68 #define _gnutls_read_log(...) LEVEL_EQ(7, __VA_ARGS__)
69 #define _gnutls_write_log(...) LEVEL_EQ(7, __VA_ARGS__)
70 #define _gnutls_x509_log(...) LEVEL(1, __VA_ARGS__)
71 #else
72 #define _gnutls_debug_log _gnutls_null_log
73 #define _gnutls_handshake_log _gnutls_null_log
74 #define _gnutls_io_log _gnutls_null_log
75 #define _gnutls_buffers_log _gnutls_null_log
76 #define _gnutls_hard_log _gnutls_null_log
77 #define _gnutls_record_log _gnutls_null_log
78 #define _gnutls_read_log _gnutls_null_log
79 #define _gnutls_write_log _gnutls_null_log
80 #define _gnutls_x509_log _gnutls_null_log
82 void _gnutls_null_log (void *, ...);
84 #endif /* C99_MACROS */
86 /* GCC won't inline this by itself and results in a "fatal warning"
87 otherwise. Making this a macro has been tried, but it interacts
88 badly with the do..while in the expansion. Welcome to the dark
89 side. */
90 static inline
91 #ifdef __GNUC__
92 __attribute__ ((always_inline))
93 #endif
94 int gnutls_assert_val_int (int val, const char *file, int line)
96 _gnutls_debug_log ("ASSERT: %s:%d\n", file, line);
97 return val;
100 #define gnutls_assert_val(x) gnutls_assert_val_int(x, __FILE__, __LINE__)
102 #endif /* GNUTLS_ERRORS_H */