diff options
-rw-r--r-- | AUTHORS | 12 | ||||
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/cr-declaration.c | 48 | ||||
-rw-r--r-- | src/cr-declaration.h | 3 |
4 files changed, 63 insertions, 8 deletions
@@ -1,7 +1,13 @@ -Dodji Seketeli <dodji@seketeli.org> -################################### +Dodji Seketeli <dodji@gnome.org> +----------------------------------- Initial Author, main maintainer and main architect. -Gael Chamoulaud <strider@freespiders.org> +Gael Chamoulaud <strider@gnome.org> ########################################## Programmer. + +Rob BUIS <rwlbuis@xs4all.nl> +---------------------------- +Sent several patches. + + @@ -1,5 +1,13 @@ 2004-02-14 Dodji Seketeli <dodji@gnome.org> + * src/cr-declaration.[ch]: applied a patch from + Rob BUIS<rwlbuis@xs4all.nl> that does a bunch of cleanup and + fixes. It also adds the new cr_declaration_list_to_string() api + entry point. + * AUTHORS: updated this + +2004-02-14 Dodji Seketeli <dodji@gnome.org> + * src/cr-declaration.[ch]: (cr_declaration_nr_props), (cr_declaration_get_from_list), diff --git a/src/cr-declaration.c b/src/cr-declaration.c index 925e758..d1b99d0 100644 --- a/src/cr-declaration.c +++ b/src/cr-declaration.c @@ -603,17 +603,55 @@ cr_declaration_to_string (CRDeclaration *a_this, } /** + *Serializes the declaration list into a string + *@param a_this the current instance of #CRDeclaration. + *@param a_indent the number of indentation white char + *to put before the actual serialisation. + */ +guchar * +cr_declaration_list_to_string (CRDeclaration *a_this, + gulong a_indent) +{ + CRDeclaration *cur = NULL ; + GString *stringue = NULL ; + guchar *str = NULL, *result = NULL ; + + g_return_val_if_fail (a_this, NULL) ; + + stringue = g_string_new (NULL) ; + + for (cur = a_this ; cur ; cur = cur->next) + { + str = cr_declaration_to_string (cur, a_indent) ; + if (str) + { + g_string_append_printf (stringue, "%s;", str) ; + g_free (str) ; + } + else + break; + } + if (stringue && stringue->str) + { + result = stringue->str ; + g_string_free (stringue, FALSE) ; + } + + return result ; +} + +/** *Return the number of properties in the declaration; *@param a_this the current instance of #CRDeclaration. *@return number of properties in the declaration list. */ -int +gint cr_declaration_nr_props (CRDeclaration *a_this) { CRDeclaration *cur = NULL ; int nr = 0; - g_return_if_fail (a_this) ; + g_return_val_if_fail (a_this, -1) ; for (cur = a_this ; cur ; cur = cur->next) nr ++; @@ -633,7 +671,7 @@ cr_declaration_get_from_list (CRDeclaration *a_this, int itemnr) CRDeclaration *cur = NULL ; int nr = 0; - g_return_if_fail (a_this) ; + g_return_val_if_fail (a_this, NULL) ; for (cur = a_this ; cur ; cur = cur->next) if (nr++ == itemnr) @@ -652,8 +690,8 @@ cr_declaration_get_by_prop_name (CRDeclaration *a_this, const guchar *a_prop) { CRDeclaration *cur = NULL ; - g_return_if_fail (a_this) ; - g_return_if_fail (a_prop) ; + g_return_val_if_fail (a_this, NULL) ; + g_return_val_if_fail (a_prop, NULL) ; for (cur = a_this ; cur ; cur = cur->next) if (!strcmp (cur->property->str, a_prop)) diff --git a/src/cr-declaration.h b/src/cr-declaration.h index a423495..c065dac 100644 --- a/src/cr-declaration.h +++ b/src/cr-declaration.h @@ -112,6 +112,9 @@ cr_declaration_get_by_prop_name (CRDeclaration *a_this, const guchar *a_str) ; guchar * cr_declaration_to_string (CRDeclaration *a_this, gulong a_indent) ; +guchar * +cr_declaration_list_to_string (CRDeclaration *a_this, + gulong a_indent) ; void cr_declaration_ref (CRDeclaration *a_this) ; |