Imported Upstream version 3.3.5
[platform/upstream/gnutls.git] / tests / utils.h
1 /*
2  * Copyright (C) 2004-2012 Free Software Foundation, Inc.
3  *
4  * Author: Simon Josefsson
5  *
6  * This file is part of GnuTLS.
7  *
8  * GnuTLS is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * GnuTLS is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with GnuTLS; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #ifndef UTILS_H
24 #define UTILS_H
25
26 #include <string.h>
27 #include <stdarg.h>
28 #include <gnutls/gnutls.h>
29 #include <gnutls/pkcs11.h>
30
31 #ifndef __attribute__
32 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
33 #define __attribute__(Spec)     /* empty */
34 #endif
35 #endif
36
37 inline static int global_init(void)
38 {
39 #ifdef ENABLE_PKCS11
40         gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_MANUAL, NULL);
41 #endif
42         return gnutls_global_init();
43 }
44
45 extern int debug;
46 extern int error_count;
47 extern int break_on_error;
48
49 extern const char *pkcs3;
50
51 extern void fail(const char *format, ...)
52     __attribute__ ((format(printf, 1, 2)));
53 extern void success(const char *format, ...)
54     __attribute__ ((format(printf, 1, 2)));
55
56 extern void escapeprint(const char *str, size_t len);
57 extern void hexprint(const void *str, size_t len);
58 extern void binprint(const void *str, size_t len);
59
60 /* This must be implemented elsewhere. */
61 extern void doit(void);
62
63 #endif                          /* UTILS_H */