static void charset (CRDocHandler * a_this, CRString * a_charset, CRParsingLocation *a_location) { enum CRStatus status = CR_OK; CRStatement *stmt = NULL, *stmt2 = NULL; CRString *charset = NULL; ParsingContext *ctxt = NULL; ParsingContext **ctxtptr = NULL; 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->stylesheet); charset = cr_string_dup (a_charset) ; stmt = cr_statement_new_at_charset_rule (ctxt->stylesheet, charset); g_return_if_fail (stmt); stmt2 = cr_statement_append (ctxt->stylesheet->statements, stmt); if (!stmt2) { if (stmt) { cr_statement_destroy (stmt); stmt = NULL; } if (charset) { cr_string_destroy (charset); } return; } ctxt->stylesheet->statements = stmt2; stmt2 = NULL; }
static void import_style (CRDocHandler * a_this, GList * a_media_list, CRString * a_uri, CRString * a_uri_default_ns, CRParsingLocation *a_location) { enum CRStatus status = CR_OK; CRString *uri = NULL; CRStatement *stmt = NULL, *stmt2 = NULL; ParsingContext *ctxt = NULL; ParsingContext **ctxtptr = NULL; GList *media_list = NULL ; 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->stylesheet); uri = cr_string_dup (a_uri) ; if (a_media_list) media_list = cr_utils_dup_glist_of_cr_string (a_media_list) ; stmt = cr_statement_new_at_import_rule (ctxt->stylesheet, uri, media_list, NULL); if (!stmt) goto error; if (ctxt->cur_stmt) { stmt2 = cr_statement_append (ctxt->cur_stmt, stmt); if (!stmt2) goto error; ctxt->cur_stmt = stmt2; stmt2 = NULL; stmt = NULL; } else { stmt2 = cr_statement_append (ctxt->stylesheet->statements, stmt); if (!stmt2) goto error; ctxt->stylesheet->statements = stmt2; stmt2 = NULL; stmt = NULL; } return; error: if (uri) { cr_string_destroy (uri); } if (stmt) { cr_statement_destroy (stmt); stmt = NULL; } a_uri_default_ns = NULL; /*keep compiler happy */ }
static void start_page (CRDocHandler * a_this, CRString * a_page, CRString * a_pseudo, CRParsingLocation *a_location) { enum CRStatus status = CR_OK; ParsingContext *ctxt = NULL; ParsingContext **ctxtptr = NULL; (void) a_location; 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 == NULL); ctxt->cur_stmt = cr_statement_new_at_page_rule (ctxt->stylesheet, NULL, NULL, NULL); if (a_page) { ctxt->cur_stmt->kind.page_rule->name = cr_string_dup (a_page) ; if (!ctxt->cur_stmt->kind.page_rule->name) { goto error; } } if (a_pseudo) { ctxt->cur_stmt->kind.page_rule->pseudo = cr_string_dup (a_pseudo) ; if (!ctxt->cur_stmt->kind.page_rule->pseudo) { goto error; } } return; error: if (ctxt->cur_stmt) { cr_statement_destroy (ctxt->cur_stmt); ctxt->cur_stmt = NULL; } }
static void property (CRDocHandler * a_this, CRString * a_name, CRTerm * a_expression, gboolean a_important) { enum CRStatus status = CR_OK; ParsingContext *ctxt = NULL; ParsingContext **ctxtptr = NULL; CRDeclaration *decl = NULL, *decl2 = NULL; CRString *str = NULL; 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); /* *make sure a current ruleset statement has been allocated *already. */ g_return_if_fail (ctxt->cur_stmt && (ctxt->cur_stmt->type == RULESET_STMT || ctxt->cur_stmt->type == AT_FONT_FACE_RULE_STMT || ctxt->cur_stmt->type == AT_PAGE_RULE_STMT)); if (a_name) { str = cr_string_dup (a_name); g_return_if_fail (str); } /*instanciates a new declaration */ decl = cr_declaration_new (ctxt->cur_stmt, str, a_expression); g_return_if_fail (decl); str = NULL; decl->important = a_important; /* *add the new declaration to the current statement *being build. */ switch (ctxt->cur_stmt->type) { case RULESET_STMT: decl2 = cr_declaration_append (ctxt->cur_stmt->kind.ruleset->decl_list, decl); if (!decl2) { cr_declaration_destroy (decl); cr_utils_trace_info ("Could not append decl to ruleset"); goto error; } ctxt->cur_stmt->kind.ruleset->decl_list = decl2; decl = NULL; decl2 = NULL; break; case AT_FONT_FACE_RULE_STMT: decl2 = cr_declaration_append (ctxt->cur_stmt->kind.font_face_rule->decl_list, decl); if (!decl2) { cr_declaration_destroy (decl); cr_utils_trace_info ("Could not append decl to ruleset"); goto error; } ctxt->cur_stmt->kind.font_face_rule->decl_list = decl2; decl = NULL; decl2 = NULL; break; case AT_PAGE_RULE_STMT: decl2 = cr_declaration_append (ctxt->cur_stmt->kind.page_rule->decl_list, decl); if (!decl2) { cr_declaration_destroy (decl); cr_utils_trace_info ("Could not append decl to ruleset"); goto error; } ctxt->cur_stmt->kind.page_rule->decl_list = decl2; decl = NULL; decl2 = NULL; break; default: goto error; break; } return; error: if (str) { g_free (str); str = NULL; } if (decl) { cr_declaration_destroy (decl); decl = NULL; } }