static void
format_attributes (p11_buffer *buffer,
- const CK_ATTRIBUTE *attrs)
+ const CK_ATTRIBUTE *attrs,
+ int count)
{
CK_BBOOL first = CK_TRUE;
- int count, i;
+ int i;
- count = p11_attrs_count (attrs);
+ if (count < 0)
+ count = p11_attrs_count (attrs);
buffer_append_printf (buffer, "(%d) [", count);
for (i = 0; i < count; i++) {
if (first)
}
char *
-p11_attrs_to_string (const CK_ATTRIBUTE *attrs)
+p11_attrs_to_string (const CK_ATTRIBUTE *attrs,
+ int count)
{
p11_buffer buffer;
if (!p11_buffer_init_null (&buffer, 128))
return_val_if_reached (NULL);
- format_attributes (&buffer, attrs);
+ format_attributes (&buffer, attrs, count);
return p11_buffer_steal (&buffer, NULL);
}
const CK_ATTRIBUTE *match,
CK_ULONG count);
-char * p11_attrs_to_string (const CK_ATTRIBUTE *attrs);
+char * p11_attrs_to_string (const CK_ATTRIBUTE *attrs,
+ int count);
char * p11_attr_to_string (const CK_ATTRIBUTE *attr);
CuAssertStrEquals (tc, "{ CKA_LABEL = (3) \"yay\" }", string);
free (string);
- string = p11_attrs_to_string (attrs);
+ string = p11_attrs_to_string (attrs, -1);
CuAssertStrEquals (tc, "(2) [ { CKA_LABEL = (3) \"yay\" }, { CKA_VALUE = (5) NOT-PRINTED } ]", string);
free (string);
+
+ string = p11_attrs_to_string (attrs, 1);
+ CuAssertStrEquals (tc, "(1) [ { CKA_LABEL = (3) \"yay\" } ]", string);
+ free (string);
}
static void
else
name = strdup ("unknown");
- string = p11_attrs_to_string (attrs);
+ string = p11_attrs_to_string (attrs, -1);
printf ("\"%s\" = %s\n", name, string);
free (string);