Logo Search packages:      
Sourcecode: inkscape version File versions

CRStatement* cr_statement_font_face_rule_parse_from_buf ( const guchar *  a_buf,
enum CREncoding  a_encoding 
)

Parses a buffer that contains an "@font-face" rule and builds an instance of CRStatement of type AT_FONT_FACE_RULE_STMT out of it.

Parameters:
a_buf the buffer to parse.
a_encoding the character encoding of a_buf.
Returns:
the newly built instance of CRStatement in case of successufull parsing, NULL otherwise.

Definition at line 1648 of file cr-statement.c.

References cr_doc_handler_get_result(), cr_doc_handler_new(), cr_doc_handler_unref(), cr_parser_destroy(), cr_parser_new_from_buf(), cr_parser_parse_font_face(), cr_parser_set_sac_handler(), and cr_parser_try_to_skip_spaces_and_comments().

Referenced by cr_statement_parse_from_buf().

{
        CRStatement *result = NULL;
        CRStatement **resultptr = NULL;
        CRDocHandler *sac_handler = NULL;
        enum CRStatus status = CR_OK;

        CRParser *parser = (CRParser *)cr_parser_new_from_buf (
                                             (guchar*)a_buf,
                                                             strlen ((char *)a_buf),
                                         a_encoding, FALSE);
        if (!parser)
                goto cleanup;

        sac_handler = cr_doc_handler_new ();
        if (!sac_handler)
                goto cleanup;

        /*
         *set sac callbacks here
         */
        sac_handler->start_font_face = parse_font_face_start_font_face_cb;
        sac_handler->property = parse_font_face_property_cb;
        sac_handler->end_font_face = parse_font_face_end_font_face_cb;
        sac_handler->unrecoverable_error =
                parse_font_face_unrecoverable_error_cb;

        status = cr_parser_set_sac_handler (parser, sac_handler);
        if (status != CR_OK)
                goto cleanup;

        /*
         *cleanup spaces of comment that may be there before the real
         *"@font-face" thing.
         */
        status = cr_parser_try_to_skip_spaces_and_comments (parser);
        if (status != CR_OK)
                goto cleanup;

        status = cr_parser_parse_font_face (parser);
        if (status != CR_OK)
                goto cleanup;

      resultptr = &result;
        status = cr_doc_handler_get_result (sac_handler,
                                            (gpointer *) resultptr);
        if (status != CR_OK || !result)
                goto cleanup;

      cleanup:
        if (parser) {
                cr_parser_destroy (parser);
                parser = NULL;
                sac_handler = NULL ;
        }
        if (sac_handler) {
                cr_doc_handler_unref (sac_handler);
                sac_handler = NULL;
        }
        return result;
}


Generated by  Doxygen 1.6.0   Back to index