/** *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; }
/** * cr_om_parser_parse_buf: *@a_this: the current instance of #CROMParser. *@a_buf: the in memory buffer to parse. *@a_len: the length of the in memory buffer in number of bytes. *@a_enc: the encoding of the in memory buffer. *@a_result: out parameter the resulting style sheet * *Parses the content of an in memory buffer. * *Returns CR_OK upon successfull completion, an error code otherwise. */ enum CRStatus cr_om_parser_parse_buf (CROMParser * a_this, const guchar * a_buf, gulong a_len, enum CREncoding a_enc, CRStyleSheet ** a_result) { enum CRStatus status = CR_OK; g_return_val_if_fail (a_this && a_result, CR_BAD_PARAM_ERROR); if (!PRIVATE (a_this)->parser) { PRIVATE (a_this)->parser = cr_parser_new (NULL); } status = cr_parser_parse_buf (PRIVATE (a_this)->parser, a_buf, a_len, a_enc); if (status == CR_OK) { CRStyleSheet *result = NULL; CRStyleSheet **resultptr = NULL; CRDocHandler *sac_handler = NULL; cr_parser_get_sac_handler (PRIVATE (a_this)->parser, &sac_handler); g_return_val_if_fail (sac_handler, CR_ERROR); resultptr = &result; status = cr_doc_handler_get_result (sac_handler, (gpointer *) resultptr); g_return_val_if_fail (status == CR_OK, status); if (result) *a_result = result; } return status; }