CJOSE 0.6.1
error.h
Go to the documentation of this file.
1
11#ifndef CJOSE_ERROR_H
12#define CJOSE_ERROR_H
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
26#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
27#define GCC_END_IGNORED_WARNING _Pragma("GCC diagnostic pop")
28
29#define GCC_BEGIN_IGNORED_WARNING_ADDRESS \
30 _Pragma("GCC diagnostic push"); \
31 _Pragma("GCC diagnostic ignored \"-Waddress\"")
32#define GCC_END_IGNORED_WARNING_ADDRESS GCC_END_IGNORED_WARNING
33#else
34#define GCC_BEGIN_IGNORED_WARNING_ADDRESS
35#define GCC_END_IGNORED_WARNING_ADDRESS
36#endif /* defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC_MINOR__ > 5) */
37
41typedef enum {
44
47
50
53
56
58
65typedef struct
66{
69
71 const char *message;
72
75 const char *function;
76
78 const char *file;
79
81 unsigned long line;
82
83} cjose_err;
84
92
101#define CJOSE_ERROR(err, errcode) \
102 GCC_BEGIN_IGNORED_WARNING_ADDRESS \
103 if ((err) != NULL && (errcode) != CJOSE_ERR_NONE) \
104 { \
105 (err)->code = (errcode); \
106 (err)->message = cjose_err_message((errcode)); \
107 (err)->function = __func__; \
108 (err)->file = __FILE__; \
109 (err)->line = __LINE__; \
110 } \
111 GCC_END_IGNORED_WARNING_ADDRESS
112
113#ifdef __cplusplus
114}
115#endif
116
117#endif /* CJOSE_ERROR_H */
cjose_errcode
Definition: error.h:41
@ CJOSE_ERR_INVALID_STATE
Definition: error.h:49
@ CJOSE_ERR_CRYPTO
Definition: error.h:55
@ CJOSE_ERR_INVALID_ARG
Definition: error.h:46
@ CJOSE_ERR_NONE
Definition: error.h:43
@ CJOSE_ERR_NO_MEMORY
Definition: error.h:52
const char * cjose_err_message(cjose_errcode code)
Definition: error.h:66
const char * file
Definition: error.h:78
cjose_errcode code
Definition: error.h:68
const char * message
Definition: error.h:71
unsigned long line
Definition: error.h:81