diff options
Diffstat (limited to 'src/p11-tests.h')
-rw-r--r-- | src/p11-tests.h | 73 |
1 files changed, 57 insertions, 16 deletions
diff --git a/src/p11-tests.h b/src/p11-tests.h index 9be69da..525e964 100644 --- a/src/p11-tests.h +++ b/src/p11-tests.h @@ -28,10 +28,10 @@ const char* p11t_msg_rv(CK_RV rv); const char* p11t_msg_lasterr(void); void p11t_msg_va(const char *message, va_list va); +void p11t_msg_code(const char* code, const char *message, va_list va); void p11t_msg_print(const char *message, ...); void p11t_msg_fatal(const char *message, ...); -void p11t_msg_exit(int code, const char *message, ...); -void p11t_msg_prefix(const char *prefix); +const char* p11t_msg_prefix(const char *prefix); #define p11t_msg_here() \ (__func__ "() at " __FILE__ ":" __LINE__) @@ -40,26 +40,67 @@ void p11t_msg_prefix(const char *prefix); * check.c */ +enum +{ + STOP = 0, + CONTINUE = 1 +}; + +#define P11T_SECTION(check) \ + p11t_msg_prefix(check) + + +#define _P11T_BEGIN do { +#define _P11T_END } while(0) + +#define P11T_CHECK_FAIL(what) \ + _P11T_BEGIN p11t_check_fail("%s", (what)); return STOP; _P11T_END + int p11t_check_fail(const char *message, ...); +int p11t_check_warn(const char *message, ...); +int p11t_check_info(const char *message, ...); + +#define P11T_CHECK_RV(what, have, want) \ + _P11T_BEGIN if(!_p11t_check_rv((what), (have), (want))) return STOP; _P11T_END + +int _p11t_check_rv(const char *what, CK_RV have, CK_RV want); + +#define P11T_CHECK_PADDED(what, padded) \ + _P11T_BEGIN if(!_p11t_check_padded((what), (padded), sizeof(padded))) return STOP; _P11T_END + +int _p11t_check_padded(const char *what, const CK_UTF8CHAR_PTR padded, CK_ULONG length); + +#define P11T_CHECK_ULONG(what, have, want) \ + _P11T_BEGIN if(!_p11t_check_ulong((what), (have), (want))) return STOP; _P11T_END + +int _p11t_check_ulong(const char *what, CK_ULONG have, CK_ULONG want); + +#define P11T_CHECK_MASK(what, have, want) \ + _P11T_BEGIN if(!_p11t_check_mask((what), (have), (want))) return STOP; _P11T_END + +int _p11t_check_mask(const char *what, CK_ULONG flags, CK_ULONG mask); -int p11t_check_returns(const char *message, CK_RV have, CK_RV want); +#define P11T_CHECK_FLAG(what, have, want) \ + _P11T_BEGIN if(!_p11t_check_flag((what), (have), (want))) return STOP; _P11T_END -#define p11t_check_padded(msg, padded) \ - (p11t_check_padded_len((msg), (padded), sizeof(padded))) +int _p11t_check_flag(const char *what, CK_ULONG flags, CK_ULONG flag); -int p11t_check_padded_len(const char *message, const CK_UTF8CHAR_PTR padded, CK_ULONG length); +#define P11T_CHECK_NFLAG(what, have, want) \ + _P11T_BEGIN if(!_p11t_check_nflag((what), (have), (want))) return STOP; _P11T_END -int p11t_check_ulong(const char *message, CK_ULONG have, CK_ULONG want); +int _p11t_check_nflag(const char *what, CK_ULONG flags, CK_ULONG nflag); -int p11t_check_mask(const char *message, CK_ULONG flags, CK_ULONG mask); +#define P11T_CHECK_BOOL(what, value) \ + _P11T_BEGIN if(!_p11t_check_bool((what), (value))) return STOP; _P11T_END -int p11t_check_flag(const char *message, CK_ULONG flags, CK_ULONG flag); +int _p11t_check_bool(const char *what, CK_BBOOL value); -int p11t_check_nflag(const char *message, CK_ULONG flags, CK_ULONG nflag); +#define P11T_CHECK_STRING(what, value, length) \ + _P11T_BEGIN if(!_p11t_check_string((what), (value), (length))) return STOP; _P11T_END -int p11t_check_bool(const char *message, CK_BBOOL value); +int _p11t_check_string(const char *what, CK_UTF8CHAR_PTR value, CK_ULONG length); -int p11t_check_string(const char *message, CK_UTF8CHAR_PTR value, CK_ULONG length); +#define P11T_CHECK_NOTE(what) /* ------------------------------------------------------------------- * config.c @@ -86,11 +127,11 @@ extern CK_FUNCTION_LIST_PTR p11t_module_funcs; void p11t_module_config(const char *name, const char *value); -void p11t_module_load(const char *filename); -void p11t_module_unload(void); +int p11t_module_load(const char *filename); +int p11t_module_unload(void); -void p11t_module_initialize(void); -void p11t_module_finalize(void); +int p11t_module_initialize(void); +int p11t_module_finalize(void); /* ------------------------------------------------------------------- * object.c |