00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __FAXPP__PARSER_H
00018 #define __FAXPP__PARSER_H
00019
00020 #include <stdio.h>
00021
00022 #include "error.h"
00023 #include "transcode.h"
00024 #include "event.h"
00025
00081
00082 typedef struct FAXPP_ParserEnv_s FAXPP_Parser;
00083
00085 typedef enum {
00088 NO_CHECKS_PARSE_MODE,
00091 WELL_FORMED_PARSE_MODE
00092 } FAXPP_ParseMode;
00093
00095 typedef enum {
00096 EXTERNAL_PARSED_ENTITY = 0,
00097 EXTERNAL_SUBSET_ENTITY = 1,
00098 EXTERNAL_IN_MARKUP_ENTITY = 2
00099 } FAXPP_EntityType;
00100
00112 typedef unsigned int (*FAXPP_ReadCallback)(void *userData, void *buffer, unsigned int length);
00113
00131 typedef FAXPP_Error (*FAXPP_ExternalEntityCallback)(void *userData, FAXPP_Parser *parser, FAXPP_EntityType type,
00132 const FAXPP_Text *base_uri, const FAXPP_Text *system_id, const FAXPP_Text *public_id);
00133
00144 FAXPP_Parser *FAXPP_create_parser(FAXPP_ParseMode mode, FAXPP_Transcoder encode);
00145
00153 void FAXPP_free_parser(FAXPP_Parser *parser);
00154
00171 void FAXPP_set_null_terminate(FAXPP_Parser *parser, unsigned int boolean);
00172
00193 void FAXPP_set_normalize_attrs(FAXPP_Parser *parser, unsigned int boolean);
00194
00205 void FAXPP_set_encode(FAXPP_Parser *parser, FAXPP_Transcoder encode);
00206
00215 FAXPP_DecodeFunction FAXPP_get_decode(const FAXPP_Parser *parser);
00216
00232 void FAXPP_set_decode(FAXPP_Parser *parser, FAXPP_DecodeFunction decode);
00233
00246 const FAXPP_Text *FAXPP_get_base_uri(const FAXPP_Parser *parser);
00247
00265 FAXPP_Error FAXPP_set_base_uri(FAXPP_Parser *parser, const FAXPP_Text *base_uri);
00266
00282 FAXPP_Error FAXPP_set_base_uri_str(FAXPP_Parser *parser, const char *base_uri);
00283
00294 void FAXPP_set_external_entity_callback(FAXPP_Parser *parser, FAXPP_ExternalEntityCallback callback, void *userData);
00295
00316 FAXPP_Error FAXPP_init_parse(FAXPP_Parser *parser, void *buffer, unsigned int length, unsigned int done);
00317
00335 FAXPP_Error FAXPP_init_parse_file(FAXPP_Parser *parser, FILE *file);
00336
00352 FAXPP_Error FAXPP_init_parse_callback(FAXPP_Parser *parser, FAXPP_ReadCallback callback, void *userData);
00353
00378 FAXPP_Error FAXPP_parse_external_entity(FAXPP_Parser *parser, FAXPP_EntityType type, void *buffer, unsigned int length, unsigned int done);
00379
00401 FAXPP_Error FAXPP_parse_external_entity_file(FAXPP_Parser *parser, FAXPP_EntityType type, FILE *file);
00402
00422 FAXPP_Error FAXPP_parse_external_entity_callback(FAXPP_Parser *parser, FAXPP_EntityType type, FAXPP_ReadCallback callback, void *userData);
00423
00441 FAXPP_Error FAXPP_release_buffer(FAXPP_Parser *parser, void **buffer_position);
00442
00458 FAXPP_Error FAXPP_continue_parse(FAXPP_Parser *parser, void *buffer,
00459 unsigned int length, unsigned int done);
00460
00471 FAXPP_Error FAXPP_next_event(FAXPP_Parser *parser);
00472
00481 const FAXPP_Event *FAXPP_get_current_event(const FAXPP_Parser *parser);
00482
00499 FAXPP_Error FAXPP_lookup_namespace_uri(const FAXPP_Parser *parser, const FAXPP_Text *prefix, FAXPP_Text *uri);
00500
00509 unsigned int FAXPP_get_nesting_level(const FAXPP_Parser *parser);
00510
00519 unsigned int FAXPP_get_error_line(const FAXPP_Parser *parser);
00520
00529 unsigned int FAXPP_get_error_column(const FAXPP_Parser *parser);
00530
00531 #endif