/** *The test of the cr_input_read_byte() method. *Reads the each byte of a_file_uri using the *cr_input_read_byte() method. Each byte is send to *stdout. *@param a_file_uri the file to read. *@return CR_OK upon successfull completion of the *function, an error code otherwise. */ static enum CRStatus test_cr_parser_parse (guchar * a_file_uri) { enum CRStatus status = CR_OK; CRParser *parser = NULL; g_return_val_if_fail (a_file_uri, CR_BAD_PARAM_ERROR); gv_test_handler = cr_doc_handler_new (); init_test_sac_handler (gv_test_handler); parser = cr_parser_new (NULL); status = cr_parser_set_sac_handler (parser, gv_test_handler); if (status != CR_OK) { cr_parser_destroy (parser); g_return_val_if_fail (status == CR_OK, CR_ERROR); } status = cr_parser_parse_file (parser, a_file_uri, CR_ASCII); cr_parser_destroy (parser); gv_test_handler = NULL; return status; }
static enum CRStatus cr_om_parser_init_default_sac_handler (CROMParser * a_this) { CRDocHandler *sac_handler = NULL; gboolean free_hdlr_if_error = FALSE; enum CRStatus status = CR_OK; g_return_val_if_fail (a_this && PRIVATE (a_this) && PRIVATE (a_this)->parser, CR_BAD_PARAM_ERROR); status = cr_parser_get_sac_handler (PRIVATE (a_this)->parser, &sac_handler); g_return_val_if_fail (status == CR_OK, status); if (!sac_handler) { sac_handler = cr_doc_handler_new (); free_hdlr_if_error = TRUE; } /* *initialyze here the sac handler. */ sac_handler->start_document = start_document; sac_handler->end_document = end_document; sac_handler->start_selector = start_selector; sac_handler->end_selector = end_selector; sac_handler->property = property; sac_handler->start_font_face = start_font_face; sac_handler->end_font_face = end_font_face; sac_handler->error = error; sac_handler->unrecoverable_error = unrecoverable_error; sac_handler->charset = charset; sac_handler->start_page = start_page; sac_handler->end_page = end_page; sac_handler->start_media = start_media; sac_handler->end_media = end_media; sac_handler->import_style = import_style; status = cr_parser_set_sac_handler (PRIVATE (a_this)->parser, sac_handler); if (status == CR_OK) { return CR_OK; } if (sac_handler && free_hdlr_if_error == TRUE) { cr_doc_handler_destroy (sac_handler); sac_handler = NULL; } return status; }