CJOSE 0.6.2.3
Loading...
Searching...
No Matches
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
59
66typedef struct
67{
70
72 const char *message;
73
76 const char *function;
77
79 const char *file;
80
82 unsigned long line;
83
84} cjose_err;
85
93
102#define CJOSE_ERROR(err, errcode) \
103 GCC_BEGIN_IGNORED_WARNING_ADDRESS \
104 if ((err) != NULL && (errcode) != CJOSE_ERR_NONE) \
105 { \
106 (err)->code = (errcode); \
107 (err)->message = cjose_err_message((errcode)); \
108 (err)->function = __func__; \
109 (err)->file = __FILE__; \
110 (err)->line = __LINE__; \
111 } \
112 GCC_END_IGNORED_WARNING_ADDRESS
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif /* CJOSE_ERROR_H */
cjose_errcode
Definition error.h:42
@ CJOSE_ERR_INVALID_STATE
Definition error.h:50
@ CJOSE_ERR_CRYPTO
Definition error.h:56
@ CJOSE_ERR_INVALID_ARG
Definition error.h:47
@ CJOSE_ERR_NONE
Definition error.h:44
@ CJOSE_ERR_NO_MEMORY
Definition error.h:53
const char * cjose_err_message(cjose_errcode code)
Definition error.h:67
const char * file
Definition error.h:79
const char * function
Definition error.h:76
cjose_errcode code
Definition error.h:69
const char * message
Definition error.h:72
unsigned long line
Definition error.h:82