summaryrefslogtreecommitdiff
path: root/src/check.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/check.c')
-rw-r--r--src/check.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/check.c b/src/check.c
index 7e45f5f..01b19fb 100644
--- a/src/check.c
+++ b/src/check.c
@@ -56,6 +56,36 @@ p11t_check_ulong(const char *message, CK_ULONG have, CK_ULONG want)
}
int
+p11t_check_bool(const char *message, CK_BBOOL value)
+{
+ if(value != CK_FALSE && value != CK_TRUE)
+ {
+ p11t_msg_print("%s: expected CK_TRUE or CK_FALSE but got 0x%02x",
+ message, (int)value);
+ return 0;
+ }
+
+ return 1;
+}
+
+int
+p11t_check_string(const char *message, CK_UTF8CHAR_PTR value, CK_ULONG length)
+{
+ CK_ULONG i;
+
+ for(i = 0; i < length; ++i)
+ {
+ if(!value[i])
+ {
+ p11t_msg_print("%s: is null terminated", message);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+int
p11t_check_mask(const char *message, CK_ULONG flags, CK_ULONG mask)
{
if((flags & ~mask) != 0)