Logo Search packages:      
Sourcecode: inkscape version File versions

CRStatement* cr_statement_at_media_rule_parse_from_buf ( const guchar *  a_buf,
enum CREncoding  a_enc 
)

Parses a buffer that contains an "@media" declaration and builds an css statement.

Parameters:
a_buf the input to parse.
a_enc the encoding of the buffer.
Returns:
the statement, or NULL if the buffer could not be successfully parsed.

Definition at line 1164 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_media(), cr_parser_set_sac_handler(), cr_parser_try_to_skip_spaces_and_comments(), and cr_utils_trace_info.

Referenced by cr_statement_parse_from_buf().

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

        parser = cr_parser_new_from_buf ((guchar*)a_buf,
                                             strlen ((char *)a_buf), 
                                         a_enc, FALSE);
        if (!parser) {
                cr_utils_trace_info ("Instanciation of the parser failed");
                goto cleanup;
        }

        sac_handler = cr_doc_handler_new ();
        if (!sac_handler) {
                cr_utils_trace_info
                        ("Instanciation of the sac handler failed");
                goto cleanup;
        }

        sac_handler->start_media = parse_at_media_start_media_cb;
        sac_handler->start_selector = parse_at_media_start_selector_cb;
        sac_handler->property = parse_at_media_property_cb;
        sac_handler->end_selector = parse_at_media_end_selector_cb;
        sac_handler->end_media = parse_at_media_end_media_cb;
        sac_handler->unrecoverable_error =
                parse_at_media_unrecoverable_error_cb;

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

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

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

      resultptr = &result;
        status = cr_doc_handler_get_result (sac_handler,
                                            (gpointer *) resultptr);
        if (status != CR_OK)
                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