• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the License); you may
5  *  not use this file except in compliance with the License.
6  *
7  *  http://www.apache.org/licenses/LICENSE-2.0
8  */
9 
10 
11 
12 #ifndef GMSSL_ERROR_H
13 #define GMSSL_ERROR_H
14 
15 
16 #include <stdio.h>
17 #include <stdarg.h>
18 #include <string.h>
19 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 
26 #define GMSSL_FMT_BIN	1
27 #define GMSSL_FMT_HEX	2
28 #define GMSSL_FMT_DER	4
29 #define GMSSL_FMT_PEM	8
30 
31 
32 
33 #define DEBUG 1
34 
35 #define error_print() \
36 	do { if (DEBUG) fprintf(stderr, "%s:%d:%s():\n",__FILE__, __LINE__, __func__); } while (0)
37 
38 #define error_print_msg(fmt, ...) \
39 	do { if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0)
40 
41 #define error_puts(str) \
42             do { if (DEBUG) fprintf(stderr, "%s: %d: %s: %s", __FILE__, __LINE__, __func__, str); } while (0)
43 
44 
45 void print_der(const uint8_t *in, size_t inlen);
46 void print_bytes(const uint8_t *in, size_t inlen);
47 void print_nodes(const uint32_t *in, size_t inlen);
48 
49 #define FMT_CARRAY 0x80
50 
51 
52 int format_print(FILE *fp, int format, int indent, const char *str, ...);
53 int format_bytes(FILE *fp, int format, int indent, const char *str, const uint8_t *data, size_t datalen);
54 int format_string(FILE *fp, int format, int indent, const char *str, const uint8_t *data, size_t datalen);
55 
56 
57 
58 //int tls_trace(int format, int indent, const char *str, ...);
59 
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 #endif
65