summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-06-09 16:54:49 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-06-09 16:54:49 +0000
commit80a930cc3775f1f12d1cd04e8836f49c97b60a6c (patch)
tree121ea4f44ec3ca5cd3f1fb7f314bfb4077c5c6ed
parent4c130d779aff0d043c17c1087180af64d5288cf4 (diff)
downloadlasso-80a930cc3775f1f12d1cd04e8836f49c97b60a6c.tar.gz
lasso-80a930cc3775f1f12d1cd04e8836f49c97b60a6c.tar.xz
lasso-80a930cc3775f1f12d1cd04e8836f49c97b60a6c.zip
Utils: add function to extract/create node in lists
* lasso_extract_gtype_from_list_or_new will help for method with create or extend nodes in lists.
-rw-r--r--lasso/saml-2.0/Makefile.am6
-rw-r--r--lasso/saml-2.0/saml2_assertion_addons.c0
-rw-r--r--lasso/saml-2.0/saml2_assertion_addons.h0
-rw-r--r--lasso/saml-2.0/saml2_conditions_addons.c0
-rw-r--r--lasso/saml-2.0/saml2_conditions_addons.h0
-rw-r--r--lasso/saml-2.0/samlp2_authn_request_addons.c0
-rw-r--r--lasso/saml-2.0/samlp2_authn_request_addons.h0
-rw-r--r--lasso/utils.c29
-rw-r--r--lasso/utils.h4
9 files changed, 38 insertions, 1 deletions
diff --git a/lasso/saml-2.0/Makefile.am b/lasso/saml-2.0/Makefile.am
index 8a12d51e..6b600744 100644
--- a/lasso/saml-2.0/Makefile.am
+++ b/lasso/saml-2.0/Makefile.am
@@ -19,6 +19,9 @@ liblasso_saml_20_la_SOURCES = \
logout.c \
name_id_management.c \
server.c \
+ saml2_conditions_addons.c \
+ saml2_assertion_addons.c \
+ samlp2_authn_request_addons.c \
saml2_helper.c
liblassoinclude_HEADERS = \
@@ -27,6 +30,9 @@ liblassoinclude_HEADERS = \
profile.h \
name_id_management.h \
provider.h \
+ saml2_conditions_addons.h \
+ saml2_assertion_addons.h \
+ samlp2_authn_request_addons.h \
saml2_helper.h
lasso_private_h_sources = \
diff --git a/lasso/saml-2.0/saml2_assertion_addons.c b/lasso/saml-2.0/saml2_assertion_addons.c
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lasso/saml-2.0/saml2_assertion_addons.c
diff --git a/lasso/saml-2.0/saml2_assertion_addons.h b/lasso/saml-2.0/saml2_assertion_addons.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lasso/saml-2.0/saml2_assertion_addons.h
diff --git a/lasso/saml-2.0/saml2_conditions_addons.c b/lasso/saml-2.0/saml2_conditions_addons.c
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lasso/saml-2.0/saml2_conditions_addons.c
diff --git a/lasso/saml-2.0/saml2_conditions_addons.h b/lasso/saml-2.0/saml2_conditions_addons.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lasso/saml-2.0/saml2_conditions_addons.h
diff --git a/lasso/saml-2.0/samlp2_authn_request_addons.c b/lasso/saml-2.0/samlp2_authn_request_addons.c
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lasso/saml-2.0/samlp2_authn_request_addons.c
diff --git a/lasso/saml-2.0/samlp2_authn_request_addons.h b/lasso/saml-2.0/samlp2_authn_request_addons.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lasso/saml-2.0/samlp2_authn_request_addons.h
diff --git a/lasso/utils.c b/lasso/utils.c
index 7a97be31..78e37bc9 100644
--- a/lasso/utils.c
+++ b/lasso/utils.c
@@ -127,10 +127,37 @@ lasso_extract_gtype_from_list(GType type, GList *list)
{
GList *needle;
-
needle = g_list_find_custom(list, (gconstpointer)type, (GCompareFunc)lasso_gobject_is_of_type);
if (needle) {
return needle->data;
}
return NULL;
}
+
+/**
+ * lasso_extract_gtype_from_list_or_new:
+ * @type: a #GType
+ * @list: a pointer to a #GList pointer variable
+ * @create: whether to look up an object whose #GType is type, or to just create it.
+ *
+ * If create is TRUE, add a new object of type @type to @list and return it.
+ * Otherwise try to look up an object of type @type, and if none is found add a new one and return
+ * it.
+ *
+ * Return value: a #GObject of type @type.
+ */
+GObject *
+lasso_extract_gtype_from_list_or_new(GType type, GList **list, gboolean create)
+{
+ GObject *result = NULL;
+ g_assert (list);
+
+ if (! create) {
+ result = lasso_extract_gtype_from_list(type, *list);
+ }
+ if (result == NULL) {
+ result = g_object_new(type, NULL);
+ lasso_list_add_new_gobject(*list, result);
+ }
+ return result;
+}
diff --git a/lasso/utils.h b/lasso/utils.h
index 577a3ab5..515625c7 100644
--- a/lasso/utils.h
+++ b/lasso/utils.h
@@ -599,9 +599,13 @@ lasso_is_empty_string(const char *str) {
/* Get a printable extract for error messages */
char* lasso_safe_prefix_string(const char *str, gsize length);
+
int lasso_gobject_is_of_type(GObject *a, GType b);
+
GObject *lasso_extract_gtype_from_list(GType type, GList *list);
+GObject * lasso_extract_gtype_from_list_or_new(GType type, GList **list, gboolean create);
+
/* Get first node of this type in a list */
/* ex: lasso_extract_node (LassoNode, LASSO_TYPE_NODE, list) */
#define lasso_extract_gobject_from_list(type, gobjecttype, list) \