summaryrefslogtreecommitdiff
path: root/gck
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2014-03-02 13:41:07 +0100
committerStef Walter <stefw@gnome.org>2014-03-03 08:17:55 +0100
commit44b5f6a0a5e9567ea8321084a93fc19f8669dd6a (patch)
treea755c98471f802b4448a8abb95e3f32010ac08b1 /gck
parentc6591124a582b0021d1795031ac2cff2aaeb71ab (diff)
downloadgcr-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')
-rw-r--r--gck/Gck-1.metadata5
-rw-r--r--gck/gck-attributes.c30
-rw-r--r--gck/gck.h3
-rw-r--r--gck/gck.symbols3
4 files changed, 40 insertions, 1 deletions
diff --git a/gck/Gck-1.metadata b/gck/Gck-1.metadata
index 793d585..2388578 100644
--- a/gck/Gck-1.metadata
+++ b/gck/Gck-1.metadata
@@ -2,3 +2,8 @@
// See https://live.gnome.org/Vala/UpstreamGuide for more information
mechanisms_check skip=false
+
+// Because vapigen is broken with regards to array fields
+Attribute
+ .length skip=true
+ .value skip=true \ No newline at end of file
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
diff --git a/gck/gck.h b/gck/gck.h
index 1af1e22..4576d1e 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -175,6 +175,9 @@ gchar* gck_attribute_get_string (const GckAttribute
void gck_attribute_get_date (const GckAttribute *attr,
GDate* value);
+const guchar * gck_attribute_get_data (const GckAttribute *attr,
+ gsize *length);
+
gboolean gck_attribute_equal (gconstpointer attr1,
gconstpointer attr2);
diff --git a/gck/gck.symbols b/gck/gck.symbols
index 1f095cd..d62d6ea 100644
--- a/gck/gck.symbols
+++ b/gck/gck.symbols
@@ -9,6 +9,7 @@ gck_attribute_equal
gck_attribute_free
gck_attribute_hash
gck_attribute_get_boolean
+gck_attribute_get_data
gck_attribute_get_date
gck_attribute_get_string
gck_attribute_get_type
@@ -303,4 +304,4 @@ gck_uri_get_error_quark
gck_uri_parse
gck_value_to_boolean
gck_value_to_ulong
-SECMEM_pool_data_v1_0 \ No newline at end of file
+SECMEM_pool_data_v1_0