summaryrefslogtreecommitdiff
path: root/common/attrs.c
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-03-18 20:59:57 +0100
committerStef Walter <stefw@gnome.org>2013-03-18 21:54:48 +0100
commit128239732a5b7e184d5d9c505402630ee9215080 (patch)
tree8432e2758971c4eecf56881cfe55803831985079 /common/attrs.c
parent1ad9f98b11f3f0d411bf9517f1dc8985ea3dbe2a (diff)
downloadp11-kit-128239732a5b7e184d5d9c505402630ee9215080.tar.gz
attrs: Change p11_attrs_to_string() to allow static templates
Allow passing the number of attributes to print, which lets us use this directly on templates passed in by callers of the PKCS#11 API.
Diffstat (limited to 'common/attrs.c')
-rw-r--r--common/attrs.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/common/attrs.c b/common/attrs.c
index a438264..5539789 100644
--- a/common/attrs.c
+++ b/common/attrs.c
@@ -813,12 +813,14 @@ format_attribute (p11_buffer *buffer,
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)
@@ -832,12 +834,13 @@ format_attributes (p11_buffer *buffer,
}
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);
}