[gcr] gck: Add an accessor for GckAttribute raw value data



commit 44b5f6a0a5e9567ea8321084a93fc19f8669dd6a
Author: Stef Walter <stefw gnome org>
Date:   Sun Mar 2 13:41:07 2014 +0100

    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).

 docs/reference/gck/gck-sections.txt |    3 ++-
 gck/Gck-1.metadata                  |    5 +++++
 gck/gck-attributes.c                |   30 ++++++++++++++++++++++++++++++
 gck/gck.h                           |    3 +++
 gck/gck.symbols                     |    3 ++-
 5 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/gck/gck-sections.txt b/docs/reference/gck/gck-sections.txt
index 3d30245..c4d934e 100644
--- a/docs/reference/gck/gck-sections.txt
+++ b/docs/reference/gck/gck-sections.txt
@@ -15,6 +15,7 @@ gck_attribute_get_boolean
 gck_attribute_get_ulong
 gck_attribute_get_string
 gck_attribute_get_date
+gck_attribute_get_data
 gck_attribute_dump
 gck_attribute_equal
 gck_attribute_hash
@@ -479,4 +480,4 @@ gck_error_get_type
 <SUBSECTION Private>
 GCK_URI_BAD_PREFIX
 CKR_GCK_MODULE_PROBLEM
-</SECTION>
\ No newline at end of file
+</SECTION>
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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]