diff options
Diffstat (limited to 'src/cr-selector.c')
-rw-r--r-- | src/cr-selector.c | 87 |
1 files changed, 59 insertions, 28 deletions
diff --git a/src/cr-selector.c b/src/cr-selector.c index d85b3ef..a3603e3 100644 --- a/src/cr-selector.c +++ b/src/cr-selector.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ /* * This file is part of The Croco Library @@ -25,16 +25,22 @@ #include "cr-parser.h" /** - *Creates a new instance of #CRSelector. - *@param a_simple_sel the initial simple selector list + * cr_selector_new: + * + *@a_simple_sel: the initial simple selector list *of the current instance of #CRSelector. - *@return the newly built instance of #CRSelector, or + * + *Creates a new instance of #CRSelector. + * + *Returns the newly built instance of #CRSelector, or *NULL in case of failure. */ CRSelector * cr_selector_new (CRSimpleSel * a_simple_sel) { - CRSelector *result = (CRSelector *)g_try_malloc (sizeof (CRSelector)); + CRSelector *result = NULL; + + result = g_try_malloc (sizeof (CRSelector)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; @@ -51,8 +57,7 @@ cr_selector_parse_from_buf (const guchar * a_char_buf, enum CREncoding a_enc) g_return_val_if_fail (a_char_buf, NULL); - parser = cr_parser_new_from_buf ((guchar*)a_char_buf, - strlen ((char *)a_char_buf), + parser = cr_parser_new_from_buf ((guchar*)a_char_buf, strlen (a_char_buf), a_enc, FALSE); g_return_val_if_fail (parser, NULL); @@ -60,10 +65,14 @@ cr_selector_parse_from_buf (const guchar * a_char_buf, enum CREncoding a_enc) } /** + * cr_selector_append: + * + *@a_this: the current instance of #CRSelector. + *@a_new: the instance of #CRSelector to be appended. + * *Appends a new instance of #CRSelector to the current selector list. - *@param a_this the current instance of #CRSelector. - *@param a_new the instance of #CRSelector to be appended. - *@return the new list. + * + *Returns the new list. */ CRSelector * cr_selector_append (CRSelector * a_this, CRSelector * a_new) @@ -84,10 +93,14 @@ cr_selector_append (CRSelector * a_this, CRSelector * a_new) } /** + * cr_selector_prepend: + * + *@a_this: the current instance of #CRSelector list. + *@a_new: the instance of #CRSelector. + * *Prepends an element to the #CRSelector list. - *@param a_this the current instance of #CRSelector list. - *@param a_new the instance of #CRSelector. - *@return the new list. + * + *Returns the new list. */ CRSelector * cr_selector_prepend (CRSelector * a_this, CRSelector * a_new) @@ -103,10 +116,14 @@ cr_selector_prepend (CRSelector * a_this, CRSelector * a_new) } /** + * cr_selector_append_simple_sel: + * + *@a_this: the current instance of #CRSelector. + *@a_simple_sel: the simple selector to append. + * *append a simple selector to the current #CRSelector list. - *@param a_this the current instance of #CRSelector. - *@param a_simple_sel the simple selector to append. - *@return the new list or NULL in case of failure. + * + *Returns the new list or NULL in case of failure. */ CRSelector * cr_selector_append_simple_sel (CRSelector * a_this, @@ -121,15 +138,16 @@ cr_selector_append_simple_sel (CRSelector * a_this, } guchar * -cr_selector_to_string (CRSelector * a_this) +cr_selector_to_string (CRSelector const * a_this) { guchar *result = NULL; + GString *str_buf = NULL; - GString *str_buf = (GString *)g_string_new (NULL); + str_buf = g_string_new (NULL); g_return_val_if_fail (str_buf, NULL); if (a_this) { - CRSelector *cur = NULL; + CRSelector const *cur = NULL; for (cur = a_this; cur; cur = cur->next) { if (cur->simple_sel) { @@ -143,7 +161,7 @@ cr_selector_to_string (CRSelector * a_this) g_string_append (str_buf, ", "); - g_string_append (str_buf, (gchar *)tmp_str); + g_string_append (str_buf, tmp_str); g_free (tmp_str); tmp_str = NULL; @@ -153,7 +171,7 @@ cr_selector_to_string (CRSelector * a_this) } if (str_buf) { - result = (guchar *)str_buf->str; + result = str_buf->str; g_string_free (str_buf, FALSE); str_buf = NULL; } @@ -162,12 +180,15 @@ cr_selector_to_string (CRSelector * a_this) } /** + * cr_selector_dump: + * + *@a_this: the current instance of #CRSelector. + *@a_fp: the destination file. + * *Serializes the current instance of #CRSelector to a file. - *@param a_this the current instance of #CRSelector. - *@param a_fp the destination file. */ void -cr_selector_dump (CRSelector * a_this, FILE * a_fp) +cr_selector_dump (CRSelector const * a_this, FILE * a_fp) { guchar *tmp_buf = NULL; @@ -182,9 +203,12 @@ cr_selector_dump (CRSelector * a_this, FILE * a_fp) } /** + * cr_selector_ref: + * + *@a_this: the current instance of #CRSelector. + * *Increments the ref count of the current instance *of #CRSelector. - *@param a_this the current instance of #CRSelector. */ void cr_selector_ref (CRSelector * a_this) @@ -195,12 +219,16 @@ cr_selector_ref (CRSelector * a_this) } /** + * cr_selector_unref: + * + *@a_this: the current instance of #CRSelector. + * *Decrements the ref count of the current instance of *#CRSelector. *If the ref count reaches zero, the current instance of *#CRSelector is destroyed. - *@param a_this the current instance of #CRSelector. - *@return TRUE if this function destroyed the current instance + * + *Returns TRUE if this function destroyed the current instance *of #CRSelector, FALSE otherwise. */ gboolean @@ -221,8 +249,11 @@ cr_selector_unref (CRSelector * a_this) } /** + * cr_selector_destroy: + * + *@a_this: the current instance of #CRSelector. + * *Destroys the selector list. - *@param a_this the current instance of #CRSelector. */ void cr_selector_destroy (CRSelector * a_this) |