diff options
author | Stef Walter <stefw@gnome.org> | 2014-03-02 13:41:07 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2014-03-03 08:17:55 +0100 |
commit | 44b5f6a0a5e9567ea8321084a93fc19f8669dd6a (patch) | |
tree | a755c98471f802b4448a8abb95e3f32010ac08b1 /gck/gck-attributes.c | |
parent | c6591124a582b0021d1795031ac2cff2aaeb71ab (diff) | |
download | gcr-44b5f6a0a5e9567ea8321084a93fc19f8669dd6a.tar.gz |
gck: Add an accessor for GckAttribute raw value data
vapigen is completely broken when it comes to having arrays as
fields in a compact class (ie: struct).
Diffstat (limited to 'gck/gck-attributes.c')
-rw-r--r-- | gck/gck-attributes.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gck/gck-attributes.c b/gck/gck-attributes.c index 066564e..d08f879 100644 --- a/gck/gck-attributes.c +++ b/gck/gck-attributes.c @@ -1523,6 +1523,36 @@ gck_attribute_get_date (const GckAttribute *attr, } /** + * gck_attribute_get_data: + * @attr: an attribute + * @length: the length of the returned data + * + * Get the raw value in the attribute. + * + * This is useful from scripting languages. C callers will generally + * access the #GckAttribute struct directly. + * + * This function will %NULL if the attribute contains empty or invalid + * data. The returned data must not be modified and is only valid + * as long as this @attribute. + * + * Returns: (transfer none) (array length=length): the value data or %NULL + */ +const guchar * +gck_attribute_get_data (const GckAttribute *attr, + gsize *length) +{ + g_return_val_if_fail (attr != NULL, NULL); + + if (attr->length == G_MAXULONG) { + *length = 0; + return NULL; + } + *length = attr->length; + return attr->value; +} + +/** * gck_attribute_init: (skip) * @attr: an uninitialized attribute * @attr_type: the PKCS\#11 attribute type to set on the attribute |