예제 #1
0
/**
 * cr_om_parser_simply_parse_paths_to_cascade:
 *@a_author_path: the path to the author stylesheet
 *@a_user_path: the path to the user stylesheet
 *@a_ua_path: the path to the User Agent stylesheet
 *@a_encoding: the encoding of the sheets.
 *@a_result: out parameter. The resulting cascade if the parsing
 *was okay
 *
 *Parses three sheets located by their paths and build a cascade
 *
 *Returns CR_OK upon successful completion, an error code otherwise
 */
enum CRStatus
cr_om_parser_simply_parse_paths_to_cascade (const guchar * a_author_path,
                                            const guchar * a_user_path,
                                            const guchar * a_ua_path,
                                            enum CREncoding a_encoding,
                                            CRCascade ** a_result)
{
        enum CRStatus status = CR_OK;
        CROMParser *parser = NULL;

        parser = cr_om_parser_new (NULL);
        if (!parser) {
                cr_utils_trace_info ("could not allocated om parser");
                cr_utils_trace_info ("System may be out of memory");
                return CR_ERROR;
        }
        status = cr_om_parser_parse_paths_to_cascade (parser,
                                                      a_author_path,
                                                      a_user_path,
                                                      a_ua_path,
                                                      a_encoding, a_result);
        if (parser) {
                cr_om_parser_destroy (parser);
                parser = NULL;
        }
        return status;
}
예제 #2
0
/**
 * cr_om_parser_simply_parse_buf:
 *@a_buf: the css2 in memory buffer.
 *@a_len: the length of the in memory buffer.
 *@a_enc: the encoding of the in memory buffer.
 *@a_result: out parameter. The resulting css2 style sheet.
 *
 *The simpler way to parse an in memory css2 buffer.
 *
 *Returns CR_OK upon successfull completion, an error code otherwise.
 */
enum CRStatus
cr_om_parser_simply_parse_buf (const guchar * a_buf,
                               gulong a_len,
                               enum CREncoding a_enc,
                               CRStyleSheet ** a_result)
{
        CROMParser *parser = NULL;
        enum CRStatus status = CR_OK;

        parser = cr_om_parser_new (NULL);
        if (!parser) {
                cr_utils_trace_info ("Could not create om parser");
                cr_utils_trace_info ("System possibly out of memory");
                return CR_ERROR;
        }

        status = cr_om_parser_parse_buf (parser, a_buf, a_len,
                                         a_enc, a_result);

        if (parser) {
                cr_om_parser_destroy (parser);
                parser = NULL;
        }

        return status;
}
예제 #3
0
/**
 * cr_cascade_new:
 *@a_author_sheet: the author origin style sheet.  May be NULL.
 *@a_user_sheet: the user origin style sheet.  May be NULL.
 *@a_ua_sheet: the user agent origin style sheet.  May be NULL.
 *
 *Constructor of the #CRCascade class.
 *Note that all three parameters of this
 *method are ref counted and their refcount is increased.
 *Their refcount will be decreased at the destruction of
 *the instance of #CRCascade.
 *So the caller should not call their destructor. The caller
 *should call their ref/unref method instead if it wants
 *
 *Returns the newly built instance of CRCascade or NULL if
 *an error arose during constrution.
 */
CRCascade *
cr_cascade_new (CRStyleSheet * a_author_sheet,
                CRStyleSheet * a_user_sheet, CRStyleSheet * a_ua_sheet)
{
        CRCascade *result = NULL;

        result = g_try_malloc (sizeof (CRCascade));
        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }
        memset (result, 0, sizeof (CRCascade));

        PRIVATE (result) = g_try_malloc (sizeof (CRCascadePriv));
        if (!PRIVATE (result)) {
                g_free(result);
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }
        memset (PRIVATE (result), 0, sizeof (CRCascadePriv));

        if (a_author_sheet) {
                cr_cascade_set_sheet (result, a_author_sheet, ORIGIN_AUTHOR);
        }
        if (a_user_sheet) {
                cr_cascade_set_sheet (result, a_user_sheet, ORIGIN_USER);
        }
        if (a_ua_sheet) {
                cr_cascade_set_sheet (result, a_ua_sheet, ORIGIN_UA);
        }

        return result;
}
예제 #4
0
static void
end_selector (CRDocHandler * a_this, CRSelector * a_selector_list)
{
        enum CRStatus status = CR_OK;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = NULL;

        (void) a_selector_list;

        g_return_if_fail (a_this);

	ctxtptr = &ctxt;
        status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr);

        g_return_if_fail (status == CR_OK && ctxt);

        g_return_if_fail (ctxt->cur_stmt && ctxt->stylesheet);

        if (ctxt->cur_stmt) {
                CRStatement *stmts = NULL;

                if (ctxt->cur_media_stmt) {
                        CRAtMediaRule *media_rule = NULL;

                        media_rule = ctxt->cur_media_stmt->kind.media_rule;

                        stmts = cr_statement_append
                                (media_rule->rulesets, ctxt->cur_stmt);

                        if (!stmts) {
                                cr_utils_trace_info
                                        ("Could not append a new statement");
                                cr_statement_destroy (media_rule->rulesets);
                                ctxt->cur_media_stmt->
                                        kind.media_rule->rulesets = NULL;
                                return;
                        }
                        media_rule->rulesets = stmts;
                        ctxt->cur_stmt = NULL;
                } else {
                        stmts = cr_statement_append
                                (ctxt->stylesheet->statements,
                                 ctxt->cur_stmt);
                        if (!stmts) {
                                cr_utils_trace_info
                                        ("Could not append a new statement");
                                cr_statement_destroy (ctxt->cur_stmt);
                                ctxt->cur_stmt = NULL;
                                return;
                        }
                        ctxt->stylesheet->statements = stmts;
                        ctxt->cur_stmt = NULL;
                }

        }

        a_selector_list = NULL; /*keep compiler happy */
}
예제 #5
0
파일: cr-rgb.c 프로젝트: MacIrssi/MILibs
/**
 * cr_rgb_set_from_term:
 *@a_this: the instance of #CRRgb to set
 *@a_value: the terminal from which to set
 *
 *Set the rgb from a terminal symbol
 *
 * Returns CR_OK upon successful completion, an error code otherwise.
 */
enum CRStatus
cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value)
{
        enum CRStatus status = CR_OK ;
        g_return_val_if_fail (a_this && a_value,
                              CR_BAD_PARAM_ERROR) ;

	switch(a_value->type) {
	case TERM_RGB:
                if (a_value->content.rgb) {
                        cr_rgb_set_from_rgb
                                (a_this, a_value->content.rgb) ;
                }
		break ;
	case TERM_IDENT:
                if (a_value->content.str
                    && a_value->content.str->stryng
                    && a_value->content.str->stryng->str) {
			if (!strncmp ("inherit",
                                      a_value->content.str->stryng->str,
                                      sizeof ("inherit")-1)) {
				a_this->inherit = TRUE;
                                a_this->is_transparent = FALSE ;
			} else  {
                        	status = cr_rgb_set_from_name
                                        (a_this,
                                         a_value->content.str->stryng->str) ;
			}
                } else {
                        cr_utils_trace_info 
                                ("a_value has NULL string value") ;
                }
		break ;
	case TERM_HASH:
                if (a_value->content.str
                    && a_value->content.str->stryng
                    && a_value->content.str->stryng->str) {
                        status = cr_rgb_set_from_hex_str
                                (a_this, 
                                 a_value->content.str->stryng->str) ;
                } else {
                        cr_utils_trace_info
                                ("a_value has NULL string value") ;
                }
                break ;
	default:
                status =  CR_UNKNOWN_TYPE_ERROR ;
	}
        return status ;
}
예제 #6
0
/**
 * cr_declaration_new:
 * @a_statement: the statement this declaration belongs to. can be NULL.
 *@a_property: the property string of the declaration
 *@a_value: the value expression of the declaration.
 *Constructor of #CRDeclaration.
 *
 *Returns the newly built instance of #CRDeclaration, or NULL in
 *case of error.
 */
CRDeclaration *
cr_declaration_new (CRStatement * a_statement,
                    CRString * a_property, CRTerm * a_value)
{
        CRDeclaration *result = NULL;

        g_return_val_if_fail (a_property, NULL);

        if (a_statement)
                g_return_val_if_fail (a_statement
                                      && ((a_statement->type == RULESET_STMT)
                                          || (a_statement->type
                                              == AT_FONT_FACE_RULE_STMT)
                                          || (a_statement->type
                                              == AT_PAGE_RULE_STMT)), NULL);

        result = g_try_malloc (sizeof (CRDeclaration));
        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }
        memset (result, 0, sizeof (CRDeclaration));
        result->property = a_property;
        result->value = a_value;

        if (a_value) {
                cr_term_ref (a_value);
        }
        result->parent_statement = a_statement;
        return result;
}
예제 #7
0
/**
 * cr_om_parser_new:
 *@a_input: the input stream.
 *
 *Constructor of the CROMParser.
 *Returns the newly built instance of #CROMParser.
 */
CROMParser *
cr_om_parser_new (CRInput * a_input)
{
        CROMParser *result = NULL;
        enum CRStatus status = CR_OK;

        result = g_try_malloc (sizeof (CROMParser));

        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }

        memset (result, 0, sizeof (CROMParser));
        PRIVATE (result) = g_try_malloc (sizeof (CROMParserPriv));

        if (!PRIVATE (result)) {
                cr_utils_trace_info ("Out of memory");
                goto error;
        }

        memset (PRIVATE (result), 0, sizeof (CROMParserPriv));

        PRIVATE (result)->parser = cr_parser_new_from_input (a_input);

        if (!PRIVATE (result)->parser) {
                cr_utils_trace_info ("parsing instanciation failed");
                goto error;
        }

        status = cr_om_parser_init_default_sac_handler (result);

        if (status != CR_OK) {
                goto error;
        }

        return result;

      error:

        if (result) {
                cr_om_parser_destroy (result);
        }

        return NULL;
}
예제 #8
0
/**
 * cr_font_weight_get_bolder:
 * @a_weight: the #CRFontWeight to consider.
 *
 * Returns a font weight bolder than @a_weight
 */
enum CRFontWeight
cr_font_weight_get_bolder (enum CRFontWeight a_weight)
{
        if (a_weight == FONT_WEIGHT_INHERIT) {
                cr_utils_trace_info ("can't return a bolder weight for FONT_WEIGHT_INHERIT") ;
                return a_weight;
        } else if (a_weight >= FONT_WEIGHT_900) {
                return FONT_WEIGHT_900 ;
        } else if (a_weight < FONT_WEIGHT_NORMAL) {
                return FONT_WEIGHT_NORMAL ;
        } else if (a_weight == FONT_WEIGHT_BOLDER
                   || a_weight == FONT_WEIGHT_LIGHTER) {
                cr_utils_trace_info ("FONT_WEIGHT_BOLDER or FONT_WEIGHT_LIGHTER should not appear here") ;
                return FONT_WEIGHT_NORMAL ;
        } else {
                return a_weight << 1 ;
        }
}
예제 #9
0
/**
 * cr_font_size_get_larger_predefined_font_size:
 * @a_font_size: the font size to consider.
 * @a_larger_size: out parameter. the font size considered larger than
 * @a_font_size.
 *
 */
void 
cr_font_size_get_larger_predefined_font_size 
			(enum CRPredefinedAbsoluteFontSize a_font_size,
		         enum CRPredefinedAbsoluteFontSize *a_larger_size)
{
        enum CRPredefinedAbsoluteFontSize result = FONT_SIZE_MEDIUM ;
        
        g_return_if_fail (a_larger_size) ;
        g_return_if_fail (a_font_size >= FONT_SIZE_XX_SMALL 
                          && a_font_size < NB_PREDEFINED_ABSOLUTE_FONT_SIZES) ;

        switch (a_font_size) {
        case FONT_SIZE_XX_SMALL:
                result =  FONT_SIZE_X_SMALL ;
                break ;
        case FONT_SIZE_X_SMALL:
                result =  FONT_SIZE_SMALL ;
                break ;
        case FONT_SIZE_SMALL:
                result =  FONT_SIZE_MEDIUM;
                break ;
        case FONT_SIZE_MEDIUM:
                result =  FONT_SIZE_LARGE;
                break ;
        case FONT_SIZE_LARGE:
                result =  FONT_SIZE_X_LARGE;
                break ;
        case FONT_SIZE_X_LARGE:
                result =  FONT_SIZE_XX_LARGE ;
                break ;
        case FONT_SIZE_XX_LARGE:
                result =  FONT_SIZE_XX_LARGE;
                break ;
	case FONT_SIZE_INHERIT:
                cr_utils_trace_info ("can't return a bigger size for FONT_SIZE_INHERIT") ;                
                result =  FONT_SIZE_MEDIUM ;
                break ;
        default:
                cr_utils_trace_info ("Unknown FONT_SIZE") ;
                result = FONT_SIZE_MEDIUM ;
                break ;
        }
        *a_larger_size = result ;
}
예제 #10
0
/**
 *Default allocator of CRPropList
 *@return the newly allocated CRPropList or NULL
 *if an error arises.
 */
static CRPropList *
cr_prop_list_allocate (void)
{
        CRPropList *result = NULL;

        result = g_try_malloc (sizeof (CRPropList));
        if (!result) {
                cr_utils_trace_info ("could not allocate CRPropList");
                return NULL;
        }
        memset (result, 0, sizeof (CRPropList));
        PRIVATE (result) = g_try_malloc (sizeof (CRPropListPriv));
        if (!result) {
                cr_utils_trace_info ("could not allocate CRPropListPriv");
                g_free (result);
                return NULL;
        }
        memset (PRIVATE (result), 0, sizeof (CRPropListPriv));
        return result;
}
예제 #11
0
파일: cr-term.c 프로젝트: vabz7867/inkscape
/**
 *Instanciate a #CRTerm.
 *@return the newly build instance
 *of #CRTerm.
 */
CRTerm *
cr_term_new (void)
{
    CRTerm *result = (CRTerm *)g_try_malloc (sizeof (CRTerm));
    if (!result) {
        cr_utils_trace_info ("Out of memory");
        return NULL;
    }
    memset (result, 0, sizeof (CRTerm));
    return result;
}
예제 #12
0
파일: cr-fonts.c 프로젝트: Spin0za/inkscape
CRFontSize *
cr_font_size_new (void)
{
        CRFontSize *result = (CRFontSize *)g_try_malloc (sizeof (CRFontSize));
        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }
        memset (result, 0, sizeof (CRFontSize));

        return result;
}
예제 #13
0
/**
 *Creates a new instance of #CRSelector.
 *@param a_simple_sel the initial simple selector list
 *of the current instance of #CRSelector.
 *@return 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));
        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }
        memset (result, 0, sizeof (CRSelector));
        result->simple_sel = a_simple_sel;
        return result;
}
예제 #14
0
static ParsingContext *
new_parsing_context (void)
{
        ParsingContext *result = 
		    (ParsingContext *)g_try_malloc (sizeof (ParsingContext));
        if (!result) {
                cr_utils_trace_info ("Out of Memory");
                return NULL;
        }
        memset (result, 0, sizeof (ParsingContext));
        return result;
}
예제 #15
0
/**
 *Instanciates a new parsing location.
 *@return the newly instanciated #CRParsingLocation.
 *Must be freed by cr_parsing_location_destroy()
 */
CRParsingLocation * 
cr_parsing_location_new (void)
{
	CRParsingLocation *result = 
	    (CRParsingLocation *)g_try_malloc (sizeof (CRParsingLocation)) ;
	if (!result) {
		cr_utils_trace_info ("Out of memory error") ;
		return NULL ;
	}
	cr_parsing_location_init (result) ;
	return result ;
}
예제 #16
0
/**
 *Instanciate a string and initialise it to
 *a_string.
 *@param a_string the initial string
 *@return the newly instanciated string.
 */
CRString  *
cr_string_new_from_string (const gchar * a_string)
{
	CRString *result = cr_string_new () ;
	if (!result) {
		cr_utils_trace_info ("Out of memory") ;
		return NULL ;
	}
	if (a_string)
		g_string_append (result->stryng, a_string) ;
	return result ;
}
예제 #17
0
/**
 *Instanciates a #CRString
 *@return the newly instanciated #CRString
 *Must be freed with cr_string_destroy().
 */
CRString *
cr_string_new (void)
{
	CRString *result = (CRString *)g_try_malloc (sizeof (CRString)) ;
	if (!result) {
		cr_utils_trace_info ("Out of memory") ;
		return NULL ;
	}
	memset (result, 0, sizeof (CRString)) ;
        result->stryng = g_string_new (NULL) ;
	return result ;
}
예제 #18
0
파일: cr-input.c 프로젝트: MacIrssi/MILibs
static CRInput *
cr_input_new_real (void)
{
        CRInput *result = NULL;

        result = g_try_malloc (sizeof (CRInput));
        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }
        memset (result, 0, sizeof (CRInput));

        PRIVATE (result) = g_try_malloc (sizeof (CRInputPriv));
        if (!PRIVATE (result)) {
                cr_utils_trace_info ("Out of memory");
                g_free (result);
                return NULL;
        }
        memset (PRIVATE (result), 0, sizeof (CRInputPriv));
        PRIVATE (result)->free_in_buf = TRUE;
        return result;
}
예제 #19
0
파일: cr-token.c 프로젝트: Spin0za/inkscape
/**
 *Default constructor of
 *the #CRToken class.
 *@return the newly built instance of #CRToken.
 */
CRToken *
cr_token_new (void)
{
        CRToken *result = (CRToken *)g_try_malloc (sizeof (CRToken));

        if (result == NULL) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }

        memset (result, 0, sizeof (CRToken));

        return result;
}
예제 #20
0
파일: cr-num.c 프로젝트: Spin0za/inkscape
/**
 *The default constructor of
 *#CRNum.
 *@return the newly built instance of
 *#CRNum.
 */
CRNum *
cr_num_new (void)
{
        CRNum *result = (CRNum *)g_try_malloc (sizeof (CRNum));

        if (result == NULL) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }

        memset (result, 0, sizeof (CRNum));

        return result;
}
예제 #21
0
/**
 * cr_simple_sel_new:
 *
 *The constructor of #CRSimpleSel.
 *
 *Returns the new instance of #CRSimpleSel.
 */
CRSimpleSel *
cr_simple_sel_new (void)
{
        CRSimpleSel *result = NULL;

        result = g_try_malloc (sizeof (CRSimpleSel));
        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }
        memset (result, 0, sizeof (CRSimpleSel));

        return result;
}
예제 #22
0
/**
 * cr_font_size_adjust_new:
 *
 * Returns a newly built instance of #CRFontSizeAdjust
 */
CRFontSizeAdjust *
cr_font_size_adjust_new (void)
{
        CRFontSizeAdjust *result = NULL;

        result = g_try_malloc (sizeof (CRFontSizeAdjust));
        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }
        memset (result, 0, sizeof (CRFontSizeAdjust));

        return result;
}
예제 #23
0
CRString *
cr_string_dup (CRString *a_this)
{
	g_return_val_if_fail (a_this, NULL) ;

	CRString *result = cr_string_new_from_gstring (a_this->stryng) ;
	if (!result) {
		cr_utils_trace_info ("Out of memory") ;
		return NULL ;
	}
	cr_parsing_location_copy (&result->location,
                                  &a_this->location) ;
        return result ;
}
예제 #24
0
파일: cr-fonts.c 프로젝트: Spin0za/inkscape
enum CRFontWeight
cr_font_weight_get_bolder (enum CRFontWeight a_weight)
{
        if (a_weight >= NB_FONT_WEIGHTS) {
                return FONT_WEIGHT_900 ;
        } else if (a_weight < FONT_WEIGHT_NORMAL) {
                return FONT_WEIGHT_NORMAL ;
        } else if (a_weight == FONT_WEIGHT_BOLDER
                   || a_weight == FONT_WEIGHT_BOLDER) {
                cr_utils_trace_info ("FONT_WEIGHT_BOLDER or FONT_WEIGHT_LIGHTER should not appear here") ;
                return FONT_WEIGHT_NORMAL ;
        } else {
                return (enum CRFontWeight)(a_weight << 1) ;
        }
}
예제 #25
0
/**
 * cr_om_parser_simply_parse_file:
 *@a_file_path: the css2 local file path.
 *@a_enc: the file encoding.
 *@a_result: out parameter. The returned css stylesheet.
 *Must be freed by the caller using cr_stylesheet_destroy.
 *
 *The simpler method to parse a css2 file.
 *
 *Returns CR_OK upon successfull completion, an error code otherwise.
 *Note that this method uses cr_om_parser_parse_file() so both methods
 *have the same return values.
 */
enum CRStatus
cr_om_parser_simply_parse_file (const guchar * a_file_path,
                                enum CREncoding a_enc,
                                CRStyleSheet ** a_result)
{
        CROMParser *parser = NULL;
        enum CRStatus status = CR_OK;

        parser = cr_om_parser_new (NULL);
        if (!parser) {
                cr_utils_trace_info ("Could not allocate om parser");
                cr_utils_trace_info ("System may be out of memory");
                return CR_ERROR;
        }

        status = cr_om_parser_parse_file (parser, a_file_path,
                                          a_enc, a_result);
        if (parser) {
                cr_om_parser_destroy (parser);
                parser = NULL;
        }

        return status;
}
예제 #26
0
/**
 *Instanciates a #CRString from an instance of GString.
 *@param a_string the input string that will be copied into
 *the newly instanciated #CRString
 *@return the newly instanciated #CRString.
 */
CRString *
cr_string_new_from_gstring (GString *a_string)
{
	CRString *result = cr_string_new () ;
	if (!result) {
		cr_utils_trace_info ("Out of memory") ;
		return NULL ;
	}
	if (a_string) {
		result->stryng = g_string_new_len
			(a_string->str, a_string->len) ;
	} else {
		result->stryng = g_string_new (NULL) ;
	}
	return result ;
}
예제 #27
0
파일: cr-rgb.c 프로젝트: MacIrssi/MILibs
/**
 * cr_rgb_new:
 *
 *The default constructor of #CRRgb.
 *
 *Returns the newly built instance of #CRRgb
 */
CRRgb *
cr_rgb_new (void)
{
        CRRgb *result = NULL;

        result = g_try_malloc (sizeof (CRRgb));

        if (result == NULL) {
                cr_utils_trace_info ("No more memory");
                return NULL;
        }

        memset (result, 0, sizeof (CRRgb));

        return result;
}
예제 #28
0
파일: cr-fonts.c 프로젝트: Spin0za/inkscape
CRFontFamily *
cr_font_family_new (enum CRFontFamilyType a_type, guchar * a_name)
{
        CRFontFamily *result = (CRFontFamily *)g_try_malloc (sizeof (CRFontFamily));

        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }

        memset (result, 0, sizeof (CRFontFamily));
        result->type = a_type;

        cr_font_family_set_name (result, a_name);

        return result;
}
예제 #29
0
/**
 *Constructor of the #CRStyleSheet class.
 *@param the initial list of css statements.
 *@return the newly built css2 stylesheet, or NULL in case of error.
 */
CRStyleSheet *
cr_stylesheet_new (CRStatement * a_stmts)
{
        CRStyleSheet *result;

        result = (CRStyleSheet *) g_try_malloc (sizeof (CRStyleSheet));
        if (!result) {
                cr_utils_trace_info ("Out of memory");
                return NULL;
        }

        memset (result, 0, sizeof (CRStyleSheet));

        if (a_stmts)
                result->statements = a_stmts;

        return result;
}
예제 #30
0
/**
 *Instanciates a #CRString from an instance of GString.
 *@param a_string the input string that will be copied into
 *the newly instanciated #CRString
 *@return the newly instanciated #CRString.
 */
CRString *
cr_string_new_from_gstring (GString const *a_string)
{
	CRString *result = NULL ;

	result = cr_string_new () ;
	if (!result) {
		cr_utils_trace_info ("Out of memory") ;
		return NULL ;
	}
	if (a_string) {
		g_string_append_len (result->stryng,
				     a_string->str,
				     a_string->len);

	}
	return result ;
}