[gnome-keyring/dbus-api] [gp11] Return added attr from gp11_attributes_add_*



commit ddee2e798da8fee11f6df9bdbf59e95f30eeb1f3
Author: Stef Walter <stef memberwebs com>
Date:   Sat Sep 26 01:54:08 2009 +0000

    [gp11] Return added attr from gp11_attributes_add_*
    
    Return the added GP11Attribute struct from the
    gp11_attributes_add_xxx() set of functions.

 gp11/gp11-attributes.c |   74 +++++++++++++++++++++++++++++++----------------
 gp11/gp11.h            |   16 +++++-----
 2 files changed, 57 insertions(+), 33 deletions(-)
---
diff --git a/gp11/gp11-attributes.c b/gp11/gp11-attributes.c
index 57793ea..5917902 100644
--- a/gp11/gp11-attributes.c
+++ b/gp11/gp11-attributes.c
@@ -955,16 +955,19 @@ attributes_push (GP11Attributes *attrs)
  * Add the specified attribute to the array. 
  * 
  * The value stored in the attribute will be copied.
+ *
+ * Return value: The attribute that was added.
  **/
-void
+GP11Attribute*
 gp11_attributes_add (GP11Attributes *attrs, GP11Attribute *attr)
 {
 	GP11Attribute *added;
-	g_return_if_fail (attrs && attrs->array);
-	g_return_if_fail (!attrs->locked);
-	g_return_if_fail (attr);
+	g_return_val_if_fail (attrs && attrs->array, NULL);
+	g_return_val_if_fail (!attrs->locked, NULL);
+	g_return_val_if_fail (attr, NULL);
 	added = attributes_push (attrs);
 	attribute_init_copy (added, attr, attrs->allocator);
+	return added;
 }
 
 /**
@@ -977,16 +980,19 @@ gp11_attributes_add (GP11Attributes *attrs, GP11Attribute *attr)
  * Add an attribute with the specified type and value to the array. 
  * 
  * The value stored in the attribute will be copied.
+ *
+ * Return value: The attribute that was added.
  **/
-void 
+GP11Attribute*
 gp11_attributes_add_data (GP11Attributes *attrs, gulong attr_type,
                           gconstpointer value, gsize length)
 {
 	GP11Attribute *added;
-	g_return_if_fail (attrs);
-	g_return_if_fail (!attrs->locked);
+	g_return_val_if_fail (attrs, NULL);
+	g_return_val_if_fail (!attrs->locked, NULL);
 	added = attributes_push (attrs);
 	attribute_init (added, attr_type, value, length, attrs->allocator);
+	return added;
 }
 
 /**
@@ -995,15 +1001,18 @@ gp11_attributes_add_data (GP11Attributes *attrs, gulong attr_type,
  * @attr_type: The type of attribute to add.
  * 
  * Add an attribute with the specified type and an 'invalid' value to the array. 
+ *
+ * Return value: The attribute that was added.
  **/
-void
+GP11Attribute*
 gp11_attributes_add_invalid (GP11Attributes *attrs, gulong attr_type)
 {
 	GP11Attribute *added;
-	g_return_if_fail (attrs);
-	g_return_if_fail (!attrs->locked);
+	g_return_val_if_fail (attrs, NULL);
+	g_return_val_if_fail (!attrs->locked, NULL);
 	added = attributes_push (attrs);
 	gp11_attribute_init_invalid (added, attr_type);	
+	return added;
 }
 
 /**
@@ -1012,15 +1021,18 @@ gp11_attributes_add_invalid (GP11Attributes *attrs, gulong attr_type)
  * @attr_type: The type of attribute to add.
  * 
  * Add an attribute with the specified type, with empty data.
+ *
+ * Return value: The attribute that was added.
  **/
-void
+GP11Attribute*
 gp11_attributes_add_empty (GP11Attributes *attrs, gulong attr_type)
 {
 	GP11Attribute *added;
-	g_return_if_fail (attrs);
-	g_return_if_fail (!attrs->locked);
+	g_return_val_if_fail (attrs, NULL);
+	g_return_val_if_fail (!attrs->locked, NULL);
 	added = attributes_push (attrs);
 	gp11_attribute_init_empty (added, attr_type);		
+	return added;
 }
 
 /**
@@ -1032,15 +1044,18 @@ gp11_attributes_add_empty (GP11Attributes *attrs, gulong attr_type)
  * Add an attribute with the specified type and value to the array. 
  * 
  * The value will be stored as a CK_BBOOL PKCS#11 style attribute.
+ *
+ * Return value: The attribute that was added.
  **/
-void
+GP11Attribute*
 gp11_attributes_add_boolean (GP11Attributes *attrs, gulong attr_type, gboolean value)
 {
 	GP11Attribute *added;
-	g_return_if_fail (attrs);
-	g_return_if_fail (!attrs->locked);
+	g_return_val_if_fail (attrs, NULL);
+	g_return_val_if_fail (!attrs->locked, NULL);
 	added = attributes_push (attrs);
 	attribute_init_boolean (added, attr_type, value, attrs->allocator);
+	return added;
 }
 
 /**
@@ -1052,15 +1067,18 @@ gp11_attributes_add_boolean (GP11Attributes *attrs, gulong attr_type, gboolean v
  * Add an attribute with the specified type and value to the array. 
  * 
  * The value will be copied into the attribute.
+ *
+ * Return value: The attribute that was added.
  **/
-void
+GP11Attribute*
 gp11_attributes_add_string (GP11Attributes *attrs, gulong attr_type, const gchar *value)
 {
 	GP11Attribute *added;
-	g_return_if_fail (attrs);
-	g_return_if_fail (!attrs->locked);
+	g_return_val_if_fail (attrs, NULL);
+	g_return_val_if_fail (!attrs->locked, NULL);
 	added = attributes_push (attrs);
 	attribute_init_string (added, attr_type, value, attrs->allocator);
+	return added;
 }
 
 /**
@@ -1072,15 +1090,18 @@ gp11_attributes_add_string (GP11Attributes *attrs, gulong attr_type, const gchar
  * Add an attribute with the specified type and value to the array. 
  * 
  * The value will be stored as a CK_DATE PKCS#11 style attribute.
+ *
+ * Return value: The attribute that was added.
  **/
-void
+GP11Attribute*
 gp11_attributes_add_date (GP11Attributes *attrs, gulong attr_type, const GDate *value)
 {
 	GP11Attribute *added;
-	g_return_if_fail (attrs);
-	g_return_if_fail (!attrs->locked);
+	g_return_val_if_fail (attrs, NULL);
+	g_return_val_if_fail (!attrs->locked, NULL);
 	added = attributes_push (attrs);
 	attribute_init_date (added, attr_type, value, attrs->allocator);
+	return added;
 }
 
 /**
@@ -1092,15 +1113,18 @@ gp11_attributes_add_date (GP11Attributes *attrs, gulong attr_type, const GDate *
  * Add an attribute with the specified type and value to the array. 
  * 
  * The value will be stored as a CK_ULONG PKCS#11 style attribute.
+ *
+ * Return value: The attribute that was added.
  **/
-void
+GP11Attribute*
 gp11_attributes_add_ulong (GP11Attributes *attrs, gulong attr_type, gulong value)
 {
 	GP11Attribute *added;
-	g_return_if_fail (attrs);
-	g_return_if_fail (!attrs->locked);
+	g_return_val_if_fail (attrs, NULL);
+	g_return_val_if_fail (!attrs->locked, NULL);
 	added = attributes_push (attrs);
 	attribute_init_ulong (added, attr_type, value, attrs->allocator);
+	return added;
 }
 
 /**
diff --git a/gp11/gp11.h b/gp11/gp11.h
index 5d4ab4a..3cd9f37 100644
--- a/gp11/gp11.h
+++ b/gp11/gp11.h
@@ -177,33 +177,33 @@ GP11Attributes*     gp11_attributes_new_valist              (GP11Allocator alloc
 GP11Attribute*      gp11_attributes_at                      (GP11Attributes *attrs,
                                                              guint index);
 
-void                gp11_attributes_add                     (GP11Attributes *attrs,
+GP11Attribute*      gp11_attributes_add                     (GP11Attributes *attrs,
                                                              GP11Attribute *attr);
 
-void                gp11_attributes_add_data                (GP11Attributes *attrs,
+GP11Attribute*      gp11_attributes_add_data                (GP11Attributes *attrs,
                                                              gulong attr_type,
                                                              gconstpointer value,
                                                              gsize length);
 
-void                gp11_attributes_add_invalid             (GP11Attributes *attrs,
+GP11Attribute*      gp11_attributes_add_invalid             (GP11Attributes *attrs,
                                                              gulong attr_type);
 
-void                gp11_attributes_add_empty               (GP11Attributes *attrs,
+GP11Attribute*      gp11_attributes_add_empty               (GP11Attributes *attrs,
                                                              gulong attr_type);
 
-void                gp11_attributes_add_boolean             (GP11Attributes *attrs,
+GP11Attribute*      gp11_attributes_add_boolean             (GP11Attributes *attrs,
                                                              gulong attr_type,
                                                              gboolean value);
 
-void                gp11_attributes_add_string              (GP11Attributes *attrs,
+GP11Attribute*      gp11_attributes_add_string              (GP11Attributes *attrs,
                                                              gulong attr_type,
                                                              const gchar *string);
 
-void                gp11_attributes_add_date                (GP11Attributes *attrs,
+GP11Attribute*      gp11_attributes_add_date                (GP11Attributes *attrs,
                                                              gulong attr_type,
                                                              const GDate *date);
 
-void                gp11_attributes_add_ulong               (GP11Attributes *attrs,
+GP11Attribute*      gp11_attributes_add_ulong               (GP11Attributes *attrs,
                                                              gulong attr_type,
                                                              gulong value);
 



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