1 /* -*- Mode: c; c-basic-offset: 2 -*- 2 * 3 * raptor.h - Redland Parser Toolkit for RDF (Raptor) interfaces and definition 4 * 5 * Copyright (C) 2000-2008, David Beckett http://www.dajobe.org/ 6 * Copyright (C) 2000-2005, University of Bristol, UK http://www.bristol.ac.uk/ 7 * 8 * This package is Free Software and part of Redland http://librdf.org/ 9 * 10 * It is licensed under the following three licenses as alternatives: 11 * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version 12 * 2. GNU General Public License (GPL) V2 or any newer version 13 * 3. Apache License, V2.0 or any newer version 14 * 15 * You may not use this file except in compliance with at least one of 16 * the above three licenses. 17 * 18 * See LICENSE.html or LICENSE.txt at the top of this package for the 19 * complete terms and further detail along with the license texts for 20 * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. 21 * 22 * 23 */ 24 25 26 27 #ifndef RAPTOR_H 28 #define RAPTOR_H 29 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #include <stdio.h> 36 37 /* Required for va_list in raptor_vsnprintf */ 38 #include <stdarg.h> 39 40 41 /** 42 * RAPTOR_API: 43 * 44 * Macro for wrapping API function call declarations. 45 * 46 */ 47 #ifndef RAPTOR_API 48 # ifdef WIN32 49 # ifdef __GNUC__ 50 # undef _declspec 51 # define _declspec(x) __declspec(x) 52 # endif 53 # ifdef RAPTOR_STATIC 54 # define RAPTOR_API 55 # else 56 # ifdef RAPTOR_INTERNAL 57 # define RAPTOR_API _declspec(dllexport) 58 # else 59 # define RAPTOR_API _declspec(dllimport) 60 # endif 61 # endif 62 # else 63 # define RAPTOR_API 64 # endif 65 #endif 66 67 /* Use gcc 3.1+ feature to allow marking of deprecated API calls. 68 * This gives a warning during compiling. 69 */ 70 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3 71 #ifdef __APPLE_CC__ 72 /* OSX gcc cpp-precomp is broken */ 73 #define RAPTOR_DEPRECATED 74 #else 75 #define RAPTOR_DEPRECATED __attribute__((deprecated)) 76 #endif 77 #else 78 #define RAPTOR_DEPRECATED 79 #endif 80 81 /** 82 * RAPTOR_V2_EXPERIMENTAL: 83 * 84 * Enable EXPERIMENTAL and UNSUPPORTED API v2 structs and functions 85 * 86 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 87 * 88 * The v2 structs and raptor*_v2() functions are NOT supported. 89 * 90 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 91 */ 92 #undef RAPTOR_V2_AVAILABLE 93 #ifdef RAPTOR_V2_EXPERIMENTAL 94 #define RAPTOR_V2_AVAILABLE 1 95 #endif 96 97 /* Allow to flag V1 functions as deprecated */ 98 #ifndef RAPTOR_V1 99 #define RAPTOR_V1 100 #endif 101 102 /** 103 * RAPTOR_PRINTF_FORMAT: 104 * @string_index: ignore me 105 * @first_to_check_index: ignore me 106 * 107 * Internal macro 108 */ 109 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) 110 #define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index) \ 111 __attribute__((__format__(__printf__, string_index, first_to_check_index))) 112 #else 113 #define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index) 114 #endif 115 116 /** 117 * raptor_uri: 118 * 119 * Raptor URI Class. 120 */ 121 typedef void* raptor_uri; 122 123 124 /* Public statics */ 125 RAPTOR_API 126 extern const char * const raptor_short_copyright_string; 127 RAPTOR_API 128 extern const char * const raptor_copyright_string; 129 RAPTOR_API 130 extern const char * const raptor_version_string; 131 RAPTOR_API 132 extern const unsigned int raptor_version_major; 133 RAPTOR_API 134 extern const unsigned int raptor_version_minor; 135 RAPTOR_API 136 extern const unsigned int raptor_version_release; 137 RAPTOR_API 138 extern const unsigned int raptor_version_decimal; 139 RAPTOR_API 140 extern const char * const raptor_license_string; 141 RAPTOR_API 142 extern const char * const raptor_home_url_string; 143 144 RAPTOR_API 145 extern const unsigned char * const raptor_xml_namespace_uri; 146 RAPTOR_API 147 extern const unsigned char * const raptor_rdf_namespace_uri; 148 RAPTOR_API 149 extern const unsigned char * const raptor_rdf_schema_namespace_uri; 150 RAPTOR_API 151 extern const unsigned char * const raptor_xmlschema_datatypes_namespace_uri; 152 RAPTOR_API 153 extern const unsigned char * const raptor_owl_namespace_uri; 154 155 /** 156 * raptor_rdf_namespace_uri_len: 157 * 158 * Length of #raptor_rdf_namespace_uri string 159 */ 160 RAPTOR_API 161 extern const unsigned int raptor_rdf_namespace_uri_len; 162 163 RAPTOR_API 164 extern const unsigned char * const raptor_xml_literal_datatype_uri_string; 165 166 /** 167 * raptor_xml_literal_datatype_uri_string_len: 168 * 169 * Length of #raptor_xml_literal_datatype_uri_string 170 */ 171 RAPTOR_API 172 extern const unsigned int raptor_xml_literal_datatype_uri_string_len; 173 174 175 /* Public structure */ 176 #ifndef RAPTOR_WORLD_DECLARED 177 #define RAPTOR_WORLD_DECLARED 1 178 /** 179 * raptor_world: 180 * 181 * Raptor world class. 182 */ 183 typedef struct raptor_world_s raptor_world; 184 #endif 185 /** 186 * raptor_parser: 187 * 188 * Raptor Parser class 189 */ 190 typedef struct raptor_parser_s raptor_parser; 191 /** 192 * raptor_serializer: 193 * 194 * Raptor Serializer class 195 */ 196 typedef struct raptor_serializer_s raptor_serializer; 197 198 /** 199 * raptor_www: 200 * 201 * Raptor WWW class 202 */ 203 typedef struct raptor_www_s raptor_www; 204 /** 205 * raptor_iostream: 206 * 207 * Raptor I/O Stream class 208 */ 209 typedef struct raptor_iostream_s raptor_iostream; 210 /** 211 * raptor_xml_element: 212 * 213 * Raptor XML Element class 214 */ 215 typedef struct raptor_xml_element_s raptor_xml_element; 216 /** 217 * raptor_xml_writer: 218 * 219 * Raptor XML Writer class 220 */ 221 typedef struct raptor_xml_writer_s raptor_xml_writer; 222 /** 223 * raptor_qname: 224 * 225 * Raptor XML qname class 226 */ 227 typedef struct raptor_qname_s raptor_qname; 228 /** 229 * raptor_namespace: 230 * 231 * Raptor XML Namespace class 232 */ 233 typedef struct raptor_namespace_s raptor_namespace; 234 /** 235 * raptor_namespace_stack: 236 * 237 * Raptor XML Namespace Stack class 238 */ 239 typedef struct raptor_namespace_stack_s raptor_namespace_stack; 240 241 /** 242 * raptor_ntriples_parser: 243 * 244 * @Deprecated: use #raptor_parser. 245 * 246 * old structure - use #raptor_parser instead. 247 */ 248 typedef raptor_parser raptor_ntriples_parser; 249 250 /** 251 * raptor_sax2: 252 * 253 * Raptor SAX2 class 254 */ 255 typedef struct raptor_sax2_s raptor_sax2; 256 257 258 /** 259 * raptor_identifier_type: 260 * @RAPTOR_IDENTIFIER_TYPE_RESOURCE: Resource URI (e.g. <literal>rdf:about</literal>) 261 * @RAPTOR_IDENTIFIER_TYPE_ANONYMOUS: <literal>_:foo</literal> N-Triples, or generated 262 * @RAPTOR_IDENTIFIER_TYPE_PREDICATE: predicate URI. WARNING: Will not be generated in in Raptor 1.4.9 or newer. Instead a #RAPTOR_IDENTIFIER_TYPE_RESOURCE will be returned. 263 * @RAPTOR_IDENTIFIER_TYPE_ORDINAL: <literal>rdf:li</literal>, <literal>rdf:_</literal><emphasis>n</emphasis>. No longer generated in any parser in Raptor 1.4.10+, instead a #RAPTOR_IDENTIFIER_TYPE_RESOURCE is returned. 264 * @RAPTOR_IDENTIFIER_TYPE_LITERAL: regular literal 265 * @RAPTOR_IDENTIFIER_TYPE_XML_LITERAL: <literal>rdf:parseType="Literal"</literal>. No longer generated by any parser in Raptor 1.4.8+, instead a #RAPTOR_IDENTIFIER_TYPE_LITERAL is returned with a datatype of <literal>rdf:XMLLiteral</literal>. 266 * @RAPTOR_IDENTIFIER_TYPE_UNKNOWN: Internal 267 * 268 * Type of identifier in a #raptor_statement 269 * 270 */ 271 typedef enum { 272 RAPTOR_IDENTIFIER_TYPE_UNKNOWN, 273 RAPTOR_IDENTIFIER_TYPE_RESOURCE, 274 RAPTOR_IDENTIFIER_TYPE_ANONYMOUS, 275 RAPTOR_IDENTIFIER_TYPE_PREDICATE, 276 RAPTOR_IDENTIFIER_TYPE_ORDINAL, 277 RAPTOR_IDENTIFIER_TYPE_LITERAL, 278 RAPTOR_IDENTIFIER_TYPE_XML_LITERAL 279 } raptor_identifier_type; 280 281 282 /** 283 * raptor_uri_source: 284 * @RAPTOR_URI_SOURCE_UNKNOWN: Internal 285 * @RAPTOR_URI_SOURCE_NOT_URI: Internal 286 * @RAPTOR_URI_SOURCE_ELEMENT: Internal 287 * @RAPTOR_URI_SOURCE_ATTRIBUTE: Internal 288 * @RAPTOR_URI_SOURCE_ID: Internal 289 * @RAPTOR_URI_SOURCE_URI: Internal 290 * @RAPTOR_URI_SOURCE_GENERATED: Internal 291 * @RAPTOR_URI_SOURCE_BLANK_ID: Internal 292 * 293 * Internal: Where a URI or identifier was derived from 294 * 295 * Likely to be deprecated in future releases. 296 */ 297 298 typedef enum { RAPTOR_URI_SOURCE_UNKNOWN, RAPTOR_URI_SOURCE_NOT_URI, RAPTOR_URI_SOURCE_ELEMENT, RAPTOR_URI_SOURCE_ATTRIBUTE, RAPTOR_URI_SOURCE_ID, RAPTOR_URI_SOURCE_URI, RAPTOR_URI_SOURCE_GENERATED, RAPTOR_URI_SOURCE_BLANK_ID } raptor_uri_source; 299 300 /** 301 * raptor_ntriples_term_type: 302 * @RAPTOR_NTRIPLES_TERM_TYPE_URI_REF: Internal 303 * @RAPTOR_NTRIPLES_TERM_TYPE_BLANK_NODE: Internal 304 * @RAPTOR_NTRIPLES_TERM_TYPE_LITERAL: I 305 * 306 * N-Triples term types 307 * 308 * Used for the deprecated function raptor_ntriples_term_as_string() only. 309 * 310 */ 311 typedef enum { RAPTOR_NTRIPLES_TERM_TYPE_URI_REF, RAPTOR_NTRIPLES_TERM_TYPE_BLANK_NODE, RAPTOR_NTRIPLES_TERM_TYPE_LITERAL } raptor_ntriples_term_type; 312 313 314 /** 315 * raptor_locator: 316 * @uri: URI of location (or NULL) 317 * @file: Filename of location (or NULL) 318 * @line: Line number of location (or <0 for no line) 319 * @column: Column number of location (or <0 for no column) 320 * @byte: Byte number of location (or <0 for no byte) 321 * 322 * Location information for an error, warning or information message. 323 */ 324 typedef struct { 325 raptor_uri *uri; 326 const char *file; 327 int line; 328 int column; 329 int byte; 330 } raptor_locator; 331 332 /** 333 * raptor_feature: 334 * @RAPTOR_FEATURE_SCANNING: If true (default false), the RDF/XML 335 * parser will look for embedded rdf:RDF elements inside the XML 336 * content, and not require that the XML start with an rdf:RDF root 337 * element. 338 * @RAPTOR_FEATURE_ASSUME_IS_RDF: If true (default false) then the 339 * RDF/XML parser will assume the content is RDF/XML, not require 340 * that rdf:RDF root element, and immediately interpret the content 341 * as RDF/XML. 342 * @RAPTOR_FEATURE_ALLOW_NON_NS_ATTRIBUTES: If true (default true) 343 * then the RDF/XML parser will allow non-XML namespaced attributes 344 * to be accepted as well as rdf: namespaced ones. For example, 345 * 'about' and 'ID' will be interpreted as if they were rdf:about 346 * and rdf:ID respectively. 347 * @RAPTOR_FEATURE_ALLOW_OTHER_PARSETYPES: If true (default true) 348 * then the RDF/XML parser will allow unknown parsetypes to be 349 * present and will pass them on to the user. Unimplemented at 350 * present. 351 * @RAPTOR_FEATURE_ALLOW_BAGID: If true (default true) then the 352 * RDF/XML parser will support the rdf:bagID attribute that was 353 * removed from the RDF/XML language when it was revised. This 354 * support may be removed in future. 355 * @RAPTOR_FEATURE_ALLOW_RDF_TYPE_RDF_LIST: If true (default false) 356 * then the RDF/XML parser will generate the idList rdf:type 357 * rdf:List triple in the handling of rdf:parseType="Collection". 358 * This triple was removed during the revising of RDF/XML after 359 * collections were initially added. 360 * @RAPTOR_FEATURE_NORMALIZE_LANGUAGE: If true (default true) then 361 * XML language values such as from xml:lang will be normalized to 362 * lowercase. 363 * @RAPTOR_FEATURE_NON_NFC_FATAL: If true (default false) then 364 * illegal Unicode Normal Form C in literals will give a fatal 365 * error, otherwise just a warning. 366 * @RAPTOR_FEATURE_WARN_OTHER_PARSETYPES: If true (default true) then 367 * the RDF/XML parser will warn about unknown rdf:parseType values. 368 * @RAPTOR_FEATURE_CHECK_RDF_ID: If true (default true) then the 369 * RDF/XML will check rdf:ID attribute values for duplicates and 370 * cause an error if any are found. 371 * @RAPTOR_FEATURE_RELATIVE_URIS: If true (default true) then 372 * relative URIs will be used wherever possible when serializing. 373 * @RAPTOR_FEATURE_START_URI: Set the start URI for serlalizing to use. 374 * @RAPTOR_FEATURE_WRITER_AUTO_INDENT: Automatically indent elements when 375 * seriailizing. 376 * @RAPTOR_FEATURE_WRITER_AUTO_EMPTY: Automatically detect and 377 * abbreviate empty elements when serializing. 378 * @RAPTOR_FEATURE_WRITER_INDENT_WIDTH: Integer number of spaces to use 379 * for each indent level when serializing with auto indent. 380 * @RAPTOR_FEATURE_WRITER_XML_VERSION: Integer XML version XML 1.0 (10) or XML 1.1 (11) 381 * @RAPTOR_FEATURE_WRITER_XML_DECLARATION: Write XML 1.0 or 1.1 declaration. 382 * @RAPTOR_FEATURE_NO_NET: Deny network requests. 383 * @RAPTOR_FEATURE_RESOURCE_BORDER: Border color of resource 384 * nodes for GraphViz DOT serializer. 385 * @RAPTOR_FEATURE_LITERAL_BORDER: Border color of literal nodes 386 * for GraphViz DOT serializer. 387 * @RAPTOR_FEATURE_BNODE_BORDER: Border color of blank nodes for 388 * GraphViz DOT serializer. 389 * @RAPTOR_FEATURE_RESOURCE_FILL: Fill color of resource nodes 390 * for GraphViz DOT serializer. 391 * @RAPTOR_FEATURE_LITERAL_FILL: Fill color of literal nodes for 392 * GraphViz DOT serializer. 393 * @RAPTOR_FEATURE_BNODE_FILL: Fill color of blank nodes for 394 * GraphViz DOT serializer. 395 * @RAPTOR_FEATURE_HTML_TAG_SOUP: Use a lax HTML parser if an XML parser 396 * fails when read HTML for GRDDL parser. 397 * @RAPTOR_FEATURE_MICROFORMATS: Look for microformats for GRDDL parser. 398 * @RAPTOR_FEATURE_HTML_LINK: Look for head <link> to type rdf/xml 399 * for GRDDL parser. 400 * @RAPTOR_FEATURE_WWW_TIMEOUT: Set timeout for internal WWW URI requests 401 * for GRDDL parser. 402 * @RAPTOR_FEATURE_WRITE_BASE_URI: Write @base directive for Turtle/N3. 403 * @RAPTOR_FEATURE_WWW_HTTP_CACHE_CONTROL: HTTP Cache-Control: header 404 * @RAPTOR_FEATURE_WWW_HTTP_USER_AGENT: HTTP User-Agent: header 405 * @RAPTOR_FEATURE_JSON_CALLBACK: JSON serializer callback function. 406 * @RAPTOR_FEATURE_JSON_EXTRA_DATA: JSON serializer extra top-level data 407 * @RAPTOR_FEATURE_RSS_TRIPLES: Atom/RSS serializer writes extra RDF triples it finds (none, rdf-xml, atom-triples) 408 * @RAPTOR_FEATURE_ATOM_ENTRY_URI: Atom entry URI. If given, generate an Atom Entry Document with the item having the given URI, otherwise generate an Atom Feed Document with any items found. 409 * @RAPTOR_FEATURE_PREFIX_ELEMENTS: Integer. If set, generate Atom/RSS1.0 documents with prefixed elements, otherwise unprefixed. 410 * @RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES: When reading XML, load external entities. 411 * @RAPTOR_FEATURE_LAST: Internal 412 * 413 * Raptor parser, serializer or XML writer features. 414 */ 415 typedef enum { 416 RAPTOR_FEATURE_SCANNING, 417 RAPTOR_FEATURE_ASSUME_IS_RDF, 418 RAPTOR_FEATURE_ALLOW_NON_NS_ATTRIBUTES, 419 RAPTOR_FEATURE_ALLOW_OTHER_PARSETYPES, 420 RAPTOR_FEATURE_ALLOW_BAGID, 421 RAPTOR_FEATURE_ALLOW_RDF_TYPE_RDF_LIST, 422 RAPTOR_FEATURE_NORMALIZE_LANGUAGE, 423 RAPTOR_FEATURE_NON_NFC_FATAL, 424 RAPTOR_FEATURE_WARN_OTHER_PARSETYPES, 425 RAPTOR_FEATURE_CHECK_RDF_ID, 426 RAPTOR_FEATURE_RELATIVE_URIS, 427 RAPTOR_FEATURE_START_URI, 428 RAPTOR_FEATURE_WRITER_AUTO_INDENT, 429 RAPTOR_FEATURE_WRITER_AUTO_EMPTY, 430 RAPTOR_FEATURE_WRITER_INDENT_WIDTH, 431 RAPTOR_FEATURE_WRITER_XML_VERSION, 432 RAPTOR_FEATURE_WRITER_XML_DECLARATION, 433 RAPTOR_FEATURE_NO_NET, 434 RAPTOR_FEATURE_RESOURCE_BORDER, 435 RAPTOR_FEATURE_LITERAL_BORDER, 436 RAPTOR_FEATURE_BNODE_BORDER, 437 RAPTOR_FEATURE_RESOURCE_FILL, 438 RAPTOR_FEATURE_LITERAL_FILL, 439 RAPTOR_FEATURE_BNODE_FILL, 440 RAPTOR_FEATURE_HTML_TAG_SOUP, 441 RAPTOR_FEATURE_MICROFORMATS, 442 RAPTOR_FEATURE_HTML_LINK, 443 RAPTOR_FEATURE_WWW_TIMEOUT, 444 RAPTOR_FEATURE_WRITE_BASE_URI, 445 RAPTOR_FEATURE_WWW_HTTP_CACHE_CONTROL, 446 RAPTOR_FEATURE_WWW_HTTP_USER_AGENT, 447 RAPTOR_FEATURE_JSON_CALLBACK, 448 RAPTOR_FEATURE_JSON_EXTRA_DATA, 449 RAPTOR_FEATURE_RSS_TRIPLES, 450 RAPTOR_FEATURE_ATOM_ENTRY_URI, 451 RAPTOR_FEATURE_PREFIX_ELEMENTS, 452 RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES, 453 RAPTOR_FEATURE_LAST = RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES 454 } raptor_feature; 455 456 457 /** 458 * raptor_genid_type: 459 * @RAPTOR_GENID_TYPE_BNODEID: Generated ID is for a blank node 460 * @RAPTOR_GENID_TYPE_BAGID: Generated ID is for rdf:bagID 461 * 462 * Intended type for a generated identifier asked for by the handler 463 * registered with raptor_set_generate_id_handler(). 464 */ 465 typedef enum { 466 RAPTOR_GENID_TYPE_BNODEID, 467 RAPTOR_GENID_TYPE_BAGID 468 } raptor_genid_type; 469 470 471 /** 472 * raptor_identifier: 473 * @type: Type of identifier 474 * @uri: URI of identifier for types %RAPTOR_IDENTIFIER_TYPE_RESOURCE and 475 * %RAPTOR_IDENTIFIER_TYPE_PREDICATE 476 * @uri_source: where the identifier (URI or blank node) came from 477 * @id: blank node identifier for type %RAPTOR_IDENTIFIER_TYPE_ANONYMOUS 478 * @ordinal: integer ordinal for type %RAPTOR_IDENTIFIER_TYPE_ORDINAL 479 * @is_malloced: internal 480 * @literal: literal string for types %RAPTOR_IDENTIFIER_TYPE_LITERAL and 481 * %RAPTOR_IDENTIFIER_TYPE_XML_LITERAL 482 * @literal_datatype: RDF literal datatype URI for types 483 * %RAPTOR_IDENTIFIER_TYPE_LITERAL and %RAPTOR_IDENTIFIER_TYPE_XML_LITERAL 484 * @literal_language: RDF literal language for type 485 * %RAPTOR_IDENTIFIER_TYPE_LITERAL 486 * @world: raptor_world object 487 * 488 * Raptor RDF term identifier. 489 */ 490 typedef struct { 491 raptor_identifier_type type; 492 raptor_uri *uri; 493 raptor_uri_source uri_source; 494 const unsigned char *id; 495 int ordinal; 496 int is_malloced; 497 const unsigned char *literal; 498 raptor_uri *literal_datatype; 499 const unsigned char *literal_language; 500 raptor_world *world; 501 } raptor_identifier; 502 503 504 /** 505 * raptor_statement: 506 * @subject: triple subject data 507 * @subject_type: triple subject type 508 * @predicate: triple predicate data 509 * @predicate_type: triple predicate type 510 * @object: triple object literal string 511 * @object_type: triple object type 512 * @object_literal_datatype: triple object literal datatype URI (or NULL) 513 * @object_literal_language: triple object literal language string (or NULL) 514 * 515 * An RDF triple 516 * 517 * See #raptor_identifier for a description of how the fields may be used. 518 * As returned by a parser statement_handler. 519 * 520 * See also #raptor_statement_v2. 521 */ 522 typedef struct { 523 const void *subject; 524 raptor_identifier_type subject_type; 525 const void *predicate; 526 raptor_identifier_type predicate_type; 527 const void *object; 528 raptor_identifier_type object_type; 529 raptor_uri *object_literal_datatype; 530 const unsigned char *object_literal_language; 531 } raptor_statement; 532 533 534 #ifdef RAPTOR_V2_AVAILABLE 535 /** 536 * raptor_statement_v2: 537 * @world: raptor_world object 538 * @s: #raptor_statement 539 * 540 * An RDF triple wrapper for raptor v2 statement API. 541 * 542 * See #raptor_statement. 543 */ 544 typedef struct { 545 raptor_world* world; 546 raptor_statement *s; 547 } raptor_statement_v2; 548 #endif 549 550 551 /** 552 * raptor_new_uri_func: 553 * @context: URI context data 554 * @uri_string: URI string 555 * 556 * Handler function for implementing raptor_new_uri(). 557 * 558 * Return value: new URI object or NULL on failure 559 */ 560 typedef raptor_uri* (*raptor_new_uri_func) (void *context, const unsigned char *uri_string); 561 562 /** 563 * raptor_new_uri_from_uri_local_name_func: 564 * @context: URI context data 565 * @uri: URI object 566 * @local_name: local name string 567 * 568 * Handler function for implementing raptor_new_uri_from_uri_local_name(). 569 * 570 * Return value: new URI object or NULL on failure 571 */ 572 typedef raptor_uri* (*raptor_new_uri_from_uri_local_name_func) (void *context, raptor_uri *uri, const unsigned char *local_name); 573 574 /** 575 * raptor_new_uri_relative_to_base_func: 576 * @context: URI context data 577 * @base_uri: base URI object 578 * @uri_string: relative URI string 579 * 580 * Handler function for implementing raptor_new_uri_relative_to_base(). 581 * 582 * Return value: new URI object or NULL on failure 583 */ 584 typedef raptor_uri* (*raptor_new_uri_relative_to_base_func) (void *context, raptor_uri *base_uri, const unsigned char *uri_string); 585 586 /** 587 * raptor_new_uri_for_rdf_concept_func: 588 * @context: URI context data 589 * @name: RDF term 590 * 591 * Handler function for implementing raptor_new_uri_for_rdf_concept(). 592 * 593 * Return value: new URI object or NULL on failure 594 */ 595 typedef raptor_uri* (*raptor_new_uri_for_rdf_concept_func) (void *context, const char *name); 596 597 /** 598 * raptor_free_uri_func: 599 * @context: URI context data 600 * @uri: URI object 601 * 602 * Handler function for implementing raptor_free_uri(). 603 */ 604 typedef void (*raptor_free_uri_func) (void *context, raptor_uri *uri); 605 606 /** 607 * raptor_uri_equals_func: 608 * @context: URI context data 609 * @uri1: URI object 1 610 * @uri2: URI object 2 611 * 612 * Handler function for implementing raptor_uri_equals(). 613 * 614 * Return value: non-0 if the URIs are equal 615 */ 616 typedef int (*raptor_uri_equals_func) (void *context, raptor_uri* uri1, raptor_uri* uri2); 617 618 /** 619 * raptor_uri_compare_func: 620 * @context: URI context data 621 * @uri1: URI object 1 622 * @uri2: URI object 2 623 * 624 * Handler function for implementing raptor_uri_equals(). 625 * 626 * Return value: -1 if uri1 < uri2, 0 if equal, 1 if uri1 > uri2 627 */ 628 typedef int (*raptor_uri_compare_func) (void *context, raptor_uri* uri1, raptor_uri* uri2); 629 630 /** 631 * raptor_uri_copy_func: 632 * @context: URI context data 633 * @uri: URI object 634 * 635 * Handler function for implementing raptor_uri_copy(). 636 * 637 * Return value: new URI object or NULL on failure 638 */ 639 typedef raptor_uri* (*raptor_uri_copy_func) (void *context, raptor_uri *uri); 640 641 /** 642 * raptor_uri_as_string_func: 643 * @context: URI context data 644 * @uri: URI object 645 * 646 * Handler function for implementing raptor_uri_as_string(). 647 * 648 * Return value: shared string representation of the URI 649 */ 650 typedef unsigned char* (*raptor_uri_as_string_func)(void *context, raptor_uri *uri); 651 652 /** 653 * raptor_uri_as_counted_string_func: 654 * @context: URI context data 655 * @uri: URI object 656 * @len_p: length 657 * 658 * Handler function for implementing raptor_uri_as_counted_string(). 659 * 660 * Return value: shared string representation of the URI 661 */ 662 typedef unsigned char* (*raptor_uri_as_counted_string_func)(void *context, raptor_uri *uri, size_t* len_p); 663 664 665 /** 666 * raptor_uri_handler: 667 * @new_uri: function for raptor_new_uri() 668 * @new_uri_from_uri_local_name: function for raptor_new_uri_from_uri_local_name() 669 * @new_uri_relative_to_base: function for raptor_new_uri_relative_to_base() 670 * @new_uri_for_rdf_concept: function for raptor_new_uri_for_rdf_concept() 671 * @free_uri: function for raptor_free_uri() 672 * @uri_equals: function for raptor_uri_equals() 673 * @uri_compare: function for raptor_uri_compare() 674 * @uri_copy: function for raptor_uri_copy() 675 * @uri_as_string: function for raptor_uri_as_string() 676 * @uri_as_counted_string: function for raptor_uri_as_counted_string() 677 * @initialised: API version - set to API version implemented: 1..2 678 * 679 * URI implementation handler structure. 680 */ 681 typedef struct { 682 /* constructors - URI Interface V1 */ 683 raptor_new_uri_func new_uri; 684 raptor_new_uri_from_uri_local_name_func new_uri_from_uri_local_name; 685 raptor_new_uri_relative_to_base_func new_uri_relative_to_base; 686 raptor_new_uri_for_rdf_concept_func new_uri_for_rdf_concept; 687 /* destructor - URI Interface V1 */ 688 raptor_free_uri_func free_uri; 689 /* methods - URI Interface V1 */ 690 raptor_uri_equals_func uri_equals; 691 raptor_uri_copy_func uri_copy; /* well, copy constructor */ 692 raptor_uri_as_string_func uri_as_string; 693 raptor_uri_as_counted_string_func uri_as_counted_string; 694 int initialised; 695 /* methods - URI Interface V2 */ 696 raptor_uri_compare_func uri_compare; 697 } raptor_uri_handler; 698 699 700 /** 701 * raptor_simple_message_handler: 702 * @user_data: user data 703 * @message: message to report 704 * @...: arguments for message 705 * 706 * Simple message handler function. 707 * 708 * Used by multiple functions including raptor_xml_escape_string(), 709 * raptor_iostream_write_xml_escaped_string(), raptor_new_qname(), 710 * raptor_qname_string_to_uri(), raptor_new_namespaces(), 711 * raptor_namespaces_init(), raptor_iostream_write_xml_element(), 712 * raptor_new_xml_writer(). 713 */ 714 typedef void (*raptor_simple_message_handler)(void *user_data, const char *message, ...); 715 716 /** 717 * raptor_message_handler: 718 * @user_data: user data 719 * @locator: location associated with message or NULL 720 * @message: message to report 721 * 722 * Message with location handler function. 723 * 724 * Used during parsing and serializing for errors and warnings that 725 * may include location information. Multiple handlers may be set for 726 * parsers and serializers by raptor_set_fatal_error_handler(), 727 * raptor_set_error_handler(), raptor_set_warning_handler(), 728 * raptor_serializer_set_error_handler() and 729 * raptor_serializer_set_warning_handler(). 730 * 731 * Also used by raptor_www_set_error_handler() for location-based errors 732 * in WWW retrieval. 733 */ 734 typedef void (*raptor_message_handler)(void *user_data, raptor_locator* locator, const char *message); 735 736 737 /** 738 * raptor_message_handler_closure: 739 * @user_data: user data for handler invocation 740 * @handler: handler function 741 * 742 * The combination of a message handler and the user data to send to it. 743 */ 744 typedef struct { 745 void *user_data; 746 raptor_message_handler handler; 747 } raptor_message_handler_closure; 748 749 750 /** 751 * raptor_statement_handler: 752 * @user_data: user data 753 * @statement: statement to report 754 * 755 * Statement (triple) reporting handler function. 756 */ 757 typedef void (*raptor_statement_handler)(void *user_data, const raptor_statement *statement); 758 759 /** 760 * raptor_graph_handler: 761 * @user_data: user data 762 * @graph: graph to report, 0 for the default graph 763 * 764 * Named graph reporting handler function. Due to historic reasons the named graph 765 * API is separated from the statement handler. A graph is reported after all its 766 * statements. 767 */ 768 typedef void (*raptor_graph_handler)(void *user_data, raptor_uri *graph); 769 770 /** 771 * raptor_generate_id_handler: 772 * @user_data: user data 773 * @type: type of ID to create 774 * @user_bnodeid: a user-specified ID or NULL if none available. 775 * 776 * Generate an identifier handler function. 777 * 778 * Return value: new ID to use 779 */ 780 typedef unsigned char* (*raptor_generate_id_handler)(void *user_data, raptor_genid_type type, unsigned char* user_bnodeid); 781 782 /** 783 * raptor_namespace_handler: 784 * @user_data: user data 785 * @nspace: #raptor_namespace declared 786 * 787 * XML Namespace declaration reporting handler set by 788 * raptor_set_namespace_handler(). 789 */ 790 typedef void (*raptor_namespace_handler)(void* user_data, raptor_namespace *nspace); 791 792 /** 793 * raptor_www_write_bytes_handler: 794 * @www: WWW object 795 * @userdata: user data 796 * @ptr: data pointer 797 * @size: size of individual item 798 * @nmemb: number of items 799 * 800 * Receiving bytes of data from WWW retrieval handler. 801 * 802 * Set by raptor_www_set_write_bytes_handler(). 803 */ 804 typedef void (*raptor_www_write_bytes_handler)(raptor_www* www, void *userdata, const void *ptr, size_t size, size_t nmemb); 805 806 /** 807 * raptor_www_content_type_handler: 808 * @www: WWW object 809 * @userdata: user data 810 * @content_type: content type seen 811 * 812 * Receiving Content-Type: header from WWW retrieval handler. 813 * 814 * Set by raptor_www_set_content_type_handler(). 815 */ 816 typedef void (*raptor_www_content_type_handler)(raptor_www* www, void *userdata, const char *content_type); 817 818 /** 819 * raptor_www_final_uri_handler: 820 * @www: WWW object 821 * @userdata: user data 822 * @final_uri: final URI seen 823 * 824 * Receiving the final resolved URI from a WWW retrieval 825 * 826 * Set by raptor_www_set_final_uri_handler(). 827 */ 828 typedef void (*raptor_www_final_uri_handler)(raptor_www* www, void *userdata, raptor_uri *final_uri); 829 830 /** 831 * raptor_uri_filter_func: 832 * @user_data: user data 833 * @uri: #raptor_uri URI to check 834 * 835 * Callback function for #raptor_www_set_uri_filter 836 * 837 * Return value: non-0 to filter the URI 838 */ 839 typedef int (*raptor_uri_filter_func)(void *user_data, raptor_uri* uri); 840 841 842 /** 843 * raptor_libxml_flags: 844 * @RAPTOR_LIBXML_FLAGS_GENERIC_ERROR_SAVE: if set - save/restore the libxml generic error handler when parsing (default unset) 845 * @RAPTOR_LIBXML_FLAGS_STRUCTURED_ERROR_SAVE: if set - save/restore the libxml structured error handler when parsing (default unset) 846 * 847 * libxml library flags 848 * 849 * These are used by raptor_world_set_libxml_flags() and 850 * raptor_set_libxml_flags() to control common libxml features. 851 * 852 * If any handler saving/restoring is enabled, any existing handler 853 * and context is saved before parsing and restored afterwards. 854 * Otherwise, no saving/restoring is performed. 855 * 856 */ 857 typedef enum { 858 RAPTOR_LIBXML_FLAGS_GENERIC_ERROR_SAVE = 1, 859 RAPTOR_LIBXML_FLAGS_STRUCTURED_ERROR_SAVE = 2 860 } raptor_libxml_flags; 861 862 863 /* Public functions */ 864 865 RAPTOR_API 866 raptor_world* raptor_new_world(void); 867 RAPTOR_API 868 int raptor_world_open(raptor_world* world); 869 RAPTOR_API 870 void raptor_free_world(raptor_world* world); 871 RAPTOR_API 872 void raptor_world_set_libxslt_security_preferences(raptor_world *world, void *security_preferences); 873 RAPTOR_API 874 void raptor_world_set_libxml_flags(raptor_world *world, int flags); 875 876 #ifndef RAPTOR_DISABLE_V1 877 RAPTOR_API RAPTOR_V1 878 void raptor_init(void); 879 RAPTOR_API RAPTOR_V1 880 void raptor_finish(void); 881 RAPTOR_API RAPTOR_V1 882 void raptor_set_libxslt_security_preferences(void *security_preferences); 883 void raptor_set_libxml_flags(int flags); 884 #endif 885 886 /* Get parser names */ 887 #ifndef RAPTOR_DISABLE_V1 888 RAPTOR_API RAPTOR_V1 889 int raptor_parsers_enumerate(const unsigned int counter, const char **name, const char **label); 890 RAPTOR_API RAPTOR_V1 891 int raptor_syntaxes_enumerate(const unsigned int counter, const char **name, const char **label, const char **mime_type, const unsigned char **uri_string); 892 RAPTOR_API RAPTOR_V1 893 int raptor_syntax_name_check(const char *name); 894 RAPTOR_API RAPTOR_V1 895 const char* raptor_guess_parser_name(raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier); 896 #endif 897 #ifdef RAPTOR_V2_AVAILABLE 898 RAPTOR_API 899 int raptor_parsers_enumerate_v2(raptor_world* world, const unsigned int counter, const char **name, const char **label); 900 RAPTOR_API 901 int raptor_syntaxes_enumerate_v2(raptor_world* world, const unsigned int counter, const char **name, const char **label, const char **mime_type, const unsigned char **uri_string); 902 RAPTOR_API 903 int raptor_syntax_name_check_v2(raptor_world* world, const char *name); 904 RAPTOR_API 905 const char* raptor_guess_parser_name_v2(raptor_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier); 906 #endif 907 908 /* Create */ 909 #ifndef RAPTOR_DISABLE_V1 910 RAPTOR_API RAPTOR_V1 911 raptor_parser* raptor_new_parser(const char *name); 912 RAPTOR_API RAPTOR_V1 913 raptor_parser* raptor_new_parser_for_content(raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier); 914 #endif 915 #ifdef RAPTOR_V2_AVAILABLE 916 RAPTOR_API 917 raptor_parser* raptor_new_parser_v2(raptor_world* world, const char *name); 918 RAPTOR_API 919 raptor_parser* raptor_new_parser_for_content_v2(raptor_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier); 920 #endif 921 922 923 RAPTOR_API 924 int raptor_start_parse(raptor_parser *rdf_parser, raptor_uri *uri); 925 926 /* Destroy */ 927 RAPTOR_API 928 void raptor_free_parser(raptor_parser* parser); 929 930 /* Handlers */ 931 RAPTOR_API 932 void raptor_set_fatal_error_handler(raptor_parser* parser, void *user_data, raptor_message_handler handler); 933 RAPTOR_API 934 void raptor_set_error_handler(raptor_parser* parser, void *user_data, raptor_message_handler handler); 935 RAPTOR_API 936 void raptor_set_warning_handler(raptor_parser* parser, void *user_data, raptor_message_handler handler); 937 RAPTOR_API 938 void raptor_set_statement_handler(raptor_parser* parser, void *user_data, raptor_statement_handler handler); 939 RAPTOR_API 940 void raptor_set_graph_handler(raptor_parser* parser, void *user_data, raptor_graph_handler handler); 941 RAPTOR_API 942 void raptor_set_generate_id_handler(raptor_parser* parser, void *user_data, raptor_generate_id_handler handler); 943 RAPTOR_API 944 void raptor_set_namespace_handler(raptor_parser* parser, void *user_data, raptor_namespace_handler handler); 945 RAPTOR_API 946 void raptor_parser_set_uri_filter(raptor_parser* parser, raptor_uri_filter_func filter, void* user_data); 947 948 #ifndef RAPTOR_DISABLE_V1 949 RAPTOR_API RAPTOR_V1 950 void raptor_print_statement(const raptor_statement * statement, FILE *stream); 951 RAPTOR_API RAPTOR_V1 952 void raptor_print_statement_as_ntriples(const raptor_statement * statement, FILE *stream); 953 #endif 954 #ifdef RAPTOR_V2_AVAILABLE 955 RAPTOR_API 956 void raptor_print_statement_v2(const raptor_statement_v2 * statement, FILE *stream); 957 RAPTOR_API 958 void raptor_print_statement_as_ntriples_v2(const raptor_statement_v2 * statement, FILE *stream); 959 #endif 960 #if !defined(RAPTOR_DISABLE_DEPRECATED) && !defined(RAPTOR_DISABLE_V1) 961 RAPTOR_API RAPTOR_DEPRECATED 962 void raptor_print_statement_detailed(const raptor_statement * statement, int detailed, FILE *stream); 963 #endif 964 #ifndef RAPTOR_DISABLE_V1 965 RAPTOR_API RAPTOR_V1 966 unsigned char* raptor_statement_part_as_counted_string(const void *term, raptor_identifier_type type, raptor_uri* literal_datatype, const unsigned char *literal_language, size_t* len_p); 967 RAPTOR_API RAPTOR_V1 968 unsigned char* raptor_statement_part_as_string(const void *term, raptor_identifier_type type, raptor_uri* literal_datatype, const unsigned char *literal_language); 969 RAPTOR_API RAPTOR_V1 970 int raptor_statement_compare(const raptor_statement *s1, const raptor_statement *s2); 971 #endif 972 #ifdef RAPTOR_V2_AVAILABLE 973 RAPTOR_API 974 unsigned char* raptor_statement_part_as_counted_string_v2(raptor_world* world, const void *term, raptor_identifier_type type, raptor_uri* literal_datatype, const unsigned char *literal_language, size_t* len_p); 975 RAPTOR_API 976 unsigned char* raptor_statement_part_as_string_v2(raptor_world* world, const void *term, raptor_identifier_type type, raptor_uri* literal_datatype, const unsigned char *literal_language); 977 RAPTOR_API 978 int raptor_statement_compare_v2(const raptor_statement_v2 *s1, const raptor_statement_v2 *s2); 979 #endif 980 981 982 RAPTOR_API 983 raptor_locator* raptor_get_locator(raptor_parser* rdf_parser); 984 985 RAPTOR_API 986 void raptor_set_default_generate_id_parameters(raptor_parser* rdf_parser, char *prefix, int base); 987 988 /* Parsing functions */ 989 RAPTOR_API 990 int raptor_parse_chunk(raptor_parser* rdf_parser, const unsigned char *buffer, size_t len, int is_end); 991 RAPTOR_API 992 int raptor_parse_file_stream(raptor_parser* rdf_parser, FILE *stream, const char *filename, raptor_uri *base_uri); 993 RAPTOR_API 994 int raptor_parse_file(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri); 995 RAPTOR_API 996 int raptor_parse_uri(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri); 997 RAPTOR_API 998 int raptor_parse_uri_with_connection(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri, void *connection); 999 RAPTOR_API 1000 void raptor_parse_abort(raptor_parser* rdf_parser); 1001 1002 /* Utility functions */ 1003 #ifndef RAPTOR_DISABLE_V1 1004 RAPTOR_API RAPTOR_V1 1005 void raptor_print_locator(FILE *stream, raptor_locator* locator); 1006 RAPTOR_API RAPTOR_V1 1007 int raptor_format_locator(char *buffer, size_t length, raptor_locator* locator); 1008 RAPTOR_API RAPTOR_V1 1009 const char * raptor_locator_uri(raptor_locator *locator); 1010 #endif 1011 #ifdef RAPTOR_V2_AVAILABLE 1012 RAPTOR_API 1013 void raptor_print_locator_v2(raptor_world* world, FILE *stream, raptor_locator* locator); 1014 RAPTOR_API 1015 int raptor_format_locator_v2(raptor_world* world, char *buffer, size_t length, raptor_locator* locator); 1016 #endif 1017 RAPTOR_API 1018 int raptor_locator_line(raptor_locator *locator); 1019 RAPTOR_API 1020 int raptor_locator_column(raptor_locator *locator); 1021 RAPTOR_API 1022 int raptor_locator_byte(raptor_locator *locator); 1023 RAPTOR_API 1024 const char * raptor_locator_file(raptor_locator *locator); 1025 #ifdef RAPTOR_V2_AVAILABLE 1026 RAPTOR_API 1027 const char * raptor_locator_uri_v2(raptor_world* world, raptor_locator *locator); 1028 #endif 1029 1030 1031 RAPTOR_API 1032 const char* raptor_get_name(raptor_parser *rdf_parser); 1033 RAPTOR_API 1034 const char* raptor_get_label(raptor_parser *rdf_parser); 1035 RAPTOR_API 1036 const char* raptor_get_mime_type(raptor_parser *rdf_parser); 1037 RAPTOR_API 1038 int raptor_get_need_base_uri(raptor_parser *rdf_parser); 1039 1040 #ifndef RAPTOR_DISABLE_V1 1041 RAPTOR_API RAPTOR_V1 1042 int raptor_features_enumerate(const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); 1043 #endif 1044 #ifdef RAPTOR_V2_AVAILABLE 1045 RAPTOR_API 1046 int raptor_features_enumerate_v2(raptor_world* world, const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); 1047 #endif 1048 RAPTOR_API 1049 int raptor_set_feature(raptor_parser *parser, raptor_feature feature, int value); 1050 RAPTOR_API 1051 int raptor_parser_set_feature_string(raptor_parser *parser, raptor_feature feature, const unsigned char *value); 1052 RAPTOR_API 1053 int raptor_get_feature(raptor_parser *parser, raptor_feature feature); 1054 RAPTOR_API 1055 const unsigned char* raptor_parser_get_feature_string(raptor_parser *parser, raptor_feature feature); 1056 RAPTOR_API 1057 unsigned int raptor_get_feature_count(void); 1058 RAPTOR_API 1059 void raptor_set_parser_strict(raptor_parser* rdf_parser, int is_strict); 1060 RAPTOR_API 1061 const char* raptor_parser_get_accept_header(raptor_parser* rdf_parser); 1062 1063 unsigned char* raptor_parser_generate_id(raptor_parser *rdf_parser, raptor_genid_type type); 1064 1065 RAPTOR_API 1066 raptor_world* raptor_parser_get_world(raptor_parser* rdf_parser); 1067 1068 /* Get serializer names */ 1069 #ifndef RAPTOR_DISABLE_V1 1070 RAPTOR_API RAPTOR_V1 1071 int raptor_serializers_enumerate(const unsigned int counter, const char **name, const char **label, const char **mime_type, const unsigned char **uri_string); 1072 RAPTOR_API RAPTOR_V1 1073 int raptor_serializer_syntax_name_check(const char *name); 1074 #endif 1075 #ifdef RAPTOR_V2_AVAILABLE 1076 RAPTOR_API 1077 int raptor_serializers_enumerate_v2(raptor_world* world, const unsigned int counter, const char **name, const char **label, const char **mime_type, const unsigned char **uri_string); 1078 RAPTOR_API 1079 int raptor_serializer_syntax_name_check_v2(raptor_world* world, const char *name); 1080 #endif 1081 1082 /* Serializing */ 1083 #ifndef RAPTOR_DISABLE_V1 1084 RAPTOR_API RAPTOR_V1 1085 raptor_serializer* raptor_new_serializer(const char *name); 1086 #endif 1087 #ifdef RAPTOR_V2_AVAILABLE 1088 RAPTOR_API 1089 raptor_serializer* raptor_new_serializer_v2(raptor_world* world, const char *name); 1090 #endif 1091 RAPTOR_API 1092 void raptor_free_serializer(raptor_serializer* rdf_serializer); 1093 1094 RAPTOR_API 1095 int raptor_serialize_start(raptor_serializer *rdf_serializer, raptor_uri *uri, raptor_iostream *iostream); 1096 RAPTOR_API 1097 int raptor_serialize_start_to_iostream(raptor_serializer *rdf_serializer, raptor_uri *uri, raptor_iostream *iostream); 1098 RAPTOR_API 1099 int raptor_serialize_start_to_filename(raptor_serializer *rdf_serializer, const char *filename); 1100 RAPTOR_API 1101 int raptor_serialize_start_to_string(raptor_serializer *rdf_serializer, raptor_uri *uri, void **string_p, size_t *length_p); 1102 RAPTOR_API 1103 int raptor_serialize_start_to_file_handle(raptor_serializer *rdf_serializer, raptor_uri *uri, FILE *fh); 1104 RAPTOR_API 1105 int raptor_serialize_set_namespace(raptor_serializer* rdf_serializer, raptor_uri *uri, const unsigned char *prefix); 1106 RAPTOR_API 1107 int raptor_serialize_set_namespace_from_namespace(raptor_serializer* rdf_serializer, raptor_namespace *nspace); 1108 RAPTOR_API 1109 int raptor_serialize_statement(raptor_serializer* rdf_serializer, const raptor_statement *statement); 1110 RAPTOR_API 1111 int raptor_serialize_end(raptor_serializer *rdf_serializer); 1112 RAPTOR_API 1113 raptor_iostream* raptor_serializer_get_iostream(raptor_serializer *serializer); 1114 RAPTOR_API 1115 void raptor_serializer_set_error_handler(raptor_serializer* serializer, void *user_data, raptor_message_handler handler); 1116 RAPTOR_API 1117 void raptor_serializer_set_warning_handler(raptor_serializer* serializer, void *user_data, raptor_message_handler handler); 1118 RAPTOR_API 1119 raptor_locator* raptor_serializer_get_locator(raptor_serializer *rdf_serializer); 1120 #ifndef RAPTOR_DISABLE_V1 1121 RAPTOR_API RAPTOR_V1 1122 int raptor_serializer_features_enumerate(const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); 1123 #endif 1124 #ifdef RAPTOR_V2_AVAILABLE 1125 RAPTOR_API 1126 int raptor_serializer_features_enumerate_v2(raptor_world* world, const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); 1127 #endif 1128 RAPTOR_API 1129 int raptor_serializer_set_feature(raptor_serializer *serializer, raptor_feature feature, int value); 1130 RAPTOR_API 1131 int raptor_serializer_set_feature_string(raptor_serializer *serializer, raptor_feature feature, const unsigned char *value); 1132 RAPTOR_API 1133 int raptor_serializer_get_feature(raptor_serializer *serializer, raptor_feature feature); 1134 RAPTOR_API 1135 const unsigned char *raptor_serializer_get_feature_string(raptor_serializer *serializer, raptor_feature feature); 1136 1137 RAPTOR_API 1138 raptor_world* raptor_serializer_get_world(raptor_serializer* rdf_serializer); 1139 1140 /* memory functions */ 1141 RAPTOR_API 1142 void raptor_free_memory(void *ptr); 1143 RAPTOR_API 1144 void* raptor_alloc_memory(size_t size); 1145 RAPTOR_API 1146 void* raptor_calloc_memory(size_t nmemb, size_t size); 1147 1148 /* URI functions */ 1149 #ifndef RAPTOR_DISABLE_V1 1150 RAPTOR_API RAPTOR_V1 1151 raptor_uri* raptor_new_uri(const unsigned char *uri_string); 1152 RAPTOR_API RAPTOR_V1 1153 raptor_uri* raptor_new_uri_from_uri_local_name(raptor_uri *uri, const unsigned char *local_name); 1154 RAPTOR_API RAPTOR_V1 1155 raptor_uri* raptor_new_uri_relative_to_base(raptor_uri *base_uri, const unsigned char *uri_string); 1156 RAPTOR_API RAPTOR_V1 1157 raptor_uri* raptor_new_uri_from_id(raptor_uri *base_uri, const unsigned char *id); 1158 RAPTOR_API RAPTOR_V1 1159 raptor_uri* raptor_new_uri_for_rdf_concept(const char *name); 1160 RAPTOR_API RAPTOR_V1 1161 void raptor_free_uri(raptor_uri *uri); 1162 RAPTOR_API RAPTOR_V1 1163 int raptor_uri_equals(raptor_uri* uri1, raptor_uri* uri2); 1164 RAPTOR_API RAPTOR_V1 1165 int raptor_uri_compare(raptor_uri* uri1, raptor_uri* uri2); 1166 RAPTOR_API RAPTOR_V1 1167 raptor_uri* raptor_uri_copy(raptor_uri *uri); 1168 RAPTOR_API RAPTOR_V1 1169 unsigned char* raptor_uri_as_string(raptor_uri *uri); 1170 RAPTOR_API RAPTOR_V1 1171 unsigned char* raptor_uri_as_counted_string(raptor_uri *uri, size_t* len_p); 1172 #endif 1173 #ifdef RAPTOR_V2_AVAILABLE 1174 RAPTOR_API 1175 raptor_uri* raptor_new_uri_v2(raptor_world* world, const unsigned char *uri_string); 1176 RAPTOR_API 1177 raptor_uri* raptor_new_uri_from_uri_local_name_v2(raptor_world* world, raptor_uri *uri, const unsigned char *local_name); 1178 RAPTOR_API 1179 raptor_uri* raptor_new_uri_relative_to_base_v2(raptor_world* world, raptor_uri *base_uri, const unsigned char *uri_string); 1180 RAPTOR_API 1181 raptor_uri* raptor_new_uri_from_id_v2(raptor_world* world, raptor_uri *base_uri, const unsigned char *id); 1182 RAPTOR_API 1183 raptor_uri* raptor_new_uri_for_rdf_concept_v2(raptor_world* world, const char *name); 1184 RAPTOR_API 1185 void raptor_free_uri_v2(raptor_world* world, raptor_uri *uri); 1186 RAPTOR_API 1187 int raptor_uri_equals_v2(raptor_world* world, raptor_uri* uri1, raptor_uri* uri2); 1188 RAPTOR_API 1189 int raptor_uri_compare_v2(raptor_world* world, raptor_uri* uri1, raptor_uri* uri2); 1190 RAPTOR_API 1191 raptor_uri* raptor_uri_copy_v2(raptor_world* world, raptor_uri *uri); 1192 RAPTOR_API 1193 unsigned char* raptor_uri_as_string_v2(raptor_world* world, raptor_uri *uri); 1194 RAPTOR_API 1195 unsigned char* raptor_uri_as_counted_string_v2(raptor_world* world, raptor_uri *uri, size_t* len_p); 1196 #endif 1197 1198 /* Make an xml:base-compatible URI from an existing one */ 1199 #ifndef RAPTOR_DISABLE_V1 1200 RAPTOR_API RAPTOR_V1 1201 raptor_uri* raptor_new_uri_for_xmlbase(raptor_uri* old_uri); 1202 #endif 1203 #ifdef RAPTOR_V2_AVAILABLE 1204 RAPTOR_API 1205 raptor_uri* raptor_new_uri_for_xmlbase_v2(raptor_world* world, raptor_uri* old_uri); 1206 #endif 1207 /* Make a URI suitable for retrieval (no fragment, has path) from an existing one */ 1208 #ifndef RAPTOR_DISABLE_V1 1209 RAPTOR_API RAPTOR_V1 1210 raptor_uri* raptor_new_uri_for_retrieval(raptor_uri* old_uri); 1211 #endif 1212 #ifdef RAPTOR_V2_AVAILABLE 1213 RAPTOR_API 1214 raptor_uri* raptor_new_uri_for_retrieval_v2(raptor_world* world, raptor_uri* old_uri); 1215 #endif 1216 1217 /* Identifier functions */ 1218 #ifndef RAPTOR_DISABLE_V1 1219 RAPTOR_API RAPTOR_V1 1220 raptor_identifier* raptor_new_identifier(raptor_identifier_type type, raptor_uri *uri, raptor_uri_source uri_source, const unsigned char *id, const unsigned char *literal, raptor_uri *literal_datatype, const unsigned char *literal_language); 1221 #endif 1222 #ifdef RAPTOR_V2_AVAILABLE 1223 RAPTOR_API 1224 raptor_identifier* raptor_new_identifier_v2(raptor_world* world, raptor_identifier_type type, raptor_uri *uri, raptor_uri_source uri_source, const unsigned char *id, const unsigned char *literal, raptor_uri *literal_datatype, const unsigned char *literal_language); 1225 #endif 1226 RAPTOR_API 1227 int raptor_copy_identifier(raptor_identifier *dest, raptor_identifier *src); 1228 RAPTOR_API 1229 void raptor_free_identifier(raptor_identifier *identifier); 1230 1231 /* Utility functions */ 1232 RAPTOR_API 1233 int raptor_print_ntriples_string(FILE *stream, const unsigned char *string, const char delim); 1234 #ifndef RAPTOR_DISABLE_DEPRECATED 1235 RAPTOR_API RAPTOR_DEPRECATED 1236 unsigned char* raptor_ntriples_string_as_utf8_string(raptor_parser* rdf_parser, const unsigned char *src, int len, size_t *dest_lenp); 1237 #endif 1238 #ifndef RAPTOR_DISABLE_DEPRECATED 1239 RAPTOR_API RAPTOR_DEPRECATED 1240 const char* raptor_ntriples_term_as_string(raptor_ntriples_term_type term); 1241 #endif 1242 RAPTOR_API 1243 int raptor_iostream_write_string_ntriples(raptor_iostream *iostr, const unsigned char *string, size_t len, const char delim); 1244 RAPTOR_API 1245 int raptor_iostream_write_string_python(raptor_iostream *iostr, const unsigned char *string, size_t len, const char delim, int flags); 1246 #ifndef RAPTOR_DISABLE_DEPRECATED 1247 RAPTOR_API RAPTOR_DEPRECATED 1248 void raptor_iostream_write_string_turtle(raptor_iostream *iostr, const unsigned char *string, size_t len); 1249 #endif 1250 #ifndef RAPTOR_DISABLE_V1 1251 RAPTOR_API RAPTOR_V1 1252 void raptor_iostream_write_statement_ntriples(raptor_iostream* iostr, const raptor_statement *statement); 1253 RAPTOR_API 1254 #endif 1255 #ifdef RAPTOR_V2_AVAILABLE 1256 void raptor_iostream_write_statement_ntriples_v2(raptor_world* world, raptor_iostream* iostr, const raptor_statement *statement); 1257 #endif 1258 RAPTOR_API 1259 int raptor_xml_any_escape_string(const unsigned char *string, size_t len, unsigned char *buffer, size_t length, char quote, int xml_version, raptor_simple_message_handler error_handler, void *error_data); 1260 RAPTOR_API 1261 int raptor_iostream_write_xml_any_escaped_string(raptor_iostream* iostr, const unsigned char *string, size_t len, char quote, int xml_version, raptor_simple_message_handler error_handler, void *error_data); 1262 RAPTOR_API 1263 int raptor_xml_escape_string(const unsigned char *string, size_t len, unsigned char *buffer, size_t length, char quote, raptor_simple_message_handler error_handler, void *error_data); 1264 RAPTOR_API 1265 int raptor_iostream_write_xml_escaped_string(raptor_iostream* iostr, const unsigned char *string, size_t len, char quote, raptor_simple_message_handler error_handler, void *error_data); 1266 1267 RAPTOR_API 1268 char* raptor_vsnprintf(const char *message, va_list arguments) RAPTOR_PRINTF_FORMAT(1, 0); 1269 1270 RAPTOR_API 1271 int raptor_xml_name_check(const unsigned char *string, size_t length, int xml_version); 1272 1273 /* raptor_rfc2396.c */ 1274 RAPTOR_API 1275 void raptor_uri_resolve_uri_reference(const unsigned char *base_uri, const unsigned char *reference_uri, unsigned char* buffer, size_t length); 1276 1277 /* raptor_uri.c */ 1278 RAPTOR_API 1279 unsigned char *raptor_uri_filename_to_uri_string(const char *filename); 1280 RAPTOR_API 1281 char *raptor_uri_uri_string_to_filename(const unsigned char *uri_string); 1282 RAPTOR_API 1283 char *raptor_uri_uri_string_to_filename_fragment(const unsigned char *uri_string, unsigned char **fragment_p); 1284 #ifndef RAPTOR_DISABLE_DEPRECATED 1285 RAPTOR_API RAPTOR_DEPRECATED 1286 int raptor_uri_is_file_uri(const unsigned char* uri_string); 1287 #endif 1288 RAPTOR_API 1289 int raptor_uri_uri_string_is_file_uri(const unsigned char* uri_string); 1290 #ifndef RAPTOR_DISABLE_V1 1291 RAPTOR_API RAPTOR_V1 1292 unsigned char* raptor_uri_to_relative_counted_uri_string(raptor_uri *base_uri, raptor_uri *reference_uri, size_t *length_p); 1293 RAPTOR_API RAPTOR_V1 1294 unsigned char* raptor_uri_to_relative_uri_string(raptor_uri *base_uri, raptor_uri *reference_uri); 1295 RAPTOR_API RAPTOR_V1 1296 void raptor_uri_print(const raptor_uri* uri, FILE *stream); 1297 RAPTOR_API RAPTOR_V1 1298 unsigned char* raptor_uri_to_counted_string(raptor_uri *uri, size_t *len_p); 1299 RAPTOR_API RAPTOR_V1 1300 unsigned char* raptor_uri_to_string(raptor_uri *uri); 1301 RAPTOR_API RAPTOR_V1 1302 void raptor_uri_set_handler(const raptor_uri_handler *handler, void *context); 1303 RAPTOR_API RAPTOR_V1 1304 void raptor_uri_get_handler(const raptor_uri_handler **handler, void **context); 1305 #endif 1306 #ifdef RAPTOR_V2_AVAILABLE 1307 RAPTOR_API 1308 unsigned char* raptor_uri_to_relative_counted_uri_string_v2(raptor_world* world, raptor_uri *base_uri, raptor_uri *reference_uri, size_t *length_p); 1309 RAPTOR_API 1310 unsigned char* raptor_uri_to_relative_uri_string_v2(raptor_world* world, raptor_uri *base_uri, raptor_uri *reference_uri); 1311 1312 RAPTOR_API 1313 void raptor_uri_print_v2(raptor_world* world, const raptor_uri* uri, FILE *stream); 1314 RAPTOR_API 1315 unsigned char* raptor_uri_to_counted_string_v2(raptor_world* world, raptor_uri *uri, size_t *len_p); 1316 RAPTOR_API 1317 unsigned char* raptor_uri_to_string_v2(raptor_world* world, raptor_uri *uri); 1318 1319 RAPTOR_API 1320 void raptor_uri_set_handler_v2(raptor_world* world, const raptor_uri_handler *handler, void *context); 1321 RAPTOR_API 1322 void raptor_uri_get_handler_v2(raptor_world* world, const raptor_uri_handler **handler, void **context); 1323 #endif 1324 1325 /** 1326 * RAPTOR_RDF_MS_URI: 1327 * 1328 * RDF Namespace URI (rdf:). 1329 * 1330 * Copy with raptor_uri_copy() to use. 1331 */ 1332 #define RAPTOR_RDF_MS_URI raptor_rdf_namespace_uri 1333 1334 /** 1335 * RAPTOR_RDF_SCHEMA_URI: 1336 * 1337 * RDF Schema Namespace URI (rdfs:). 1338 * 1339 * Copy with raptor_uri_copy() to use. 1340 */ 1341 #define RAPTOR_RDF_SCHEMA_URI raptor_rdf_schema_namespace_uri 1342 1343 /** 1344 * RAPTOR_XMLSCHEMA_DATATYPES_URI: 1345 * 1346 * XML Schema Datatypes URI (xsd:). 1347 * 1348 * Copy with raptor_uri_copy() to use. 1349 */ 1350 #define RAPTOR_XMLSCHEMA_DATATYPES_URI raptor_xmlschema_datatypes_namespace_uri 1351 1352 /** 1353 * RAPTOR_OWL_URI: 1354 * 1355 * OWL Namespace URI (owl:). 1356 * 1357 * Copy with raptor_uri_copy() to use. 1358 */ 1359 #define RAPTOR_OWL_URI raptor_owl_namespace_uri 1360 1361 1362 /* raptor_www */ 1363 #ifndef RAPOR_DISABLE_V1 1364 RAPTOR_API RAPTOR_V1 1365 void raptor_www_init(void); 1366 RAPTOR_API RAPTOR_V1 1367 void raptor_www_finish(void); 1368 RAPTOR_API RAPTOR_V1 1369 void raptor_www_no_www_library_init_finish(void); 1370 #endif 1371 #ifdef RAPTOR_V2_AVAILABLE 1372 RAPTOR_API 1373 int raptor_www_init_v2(raptor_world* world); 1374 RAPTOR_API 1375 void raptor_www_finish_v2(raptor_world* world); 1376 RAPTOR_API 1377 void raptor_www_no_www_library_init_finish_v2(raptor_world* world); 1378 #endif 1379 1380 1381 #ifndef RAPTOR_DISABLE_V1 1382 RAPTOR_API RAPTOR_V1 1383 raptor_www *raptor_www_new(void); 1384 RAPTOR_API RAPTOR_V1 1385 raptor_www *raptor_www_new_with_connection(void* connection); 1386 #endif 1387 #ifdef RAPTOR_V2_AVAILABLE 1388 RAPTOR_API 1389 raptor_www *raptor_www_new_v2(raptor_world* world); 1390 RAPTOR_API 1391 raptor_www *raptor_www_new_with_connection_v2(raptor_world* world, void* connection); 1392 #endif 1393 RAPTOR_API 1394 void raptor_www_free(raptor_www *www); 1395 RAPTOR_API 1396 void raptor_www_set_user_agent(raptor_www *www, const char *user_agent); 1397 RAPTOR_API 1398 void raptor_www_set_proxy(raptor_www *www, const char *proxy); 1399 RAPTOR_API 1400 void raptor_www_set_http_accept(raptor_www *www, const char *value); 1401 RAPTOR_API 1402 void raptor_www_set_write_bytes_handler(raptor_www *www, raptor_www_write_bytes_handler handler, void *user_data); 1403 RAPTOR_API 1404 void raptor_www_set_content_type_handler(raptor_www *www, raptor_www_content_type_handler handler, void *user_data); 1405 RAPTOR_API 1406 void raptor_www_set_final_uri_handler(raptor_www* www, raptor_www_final_uri_handler handler, void *user_data); 1407 RAPTOR_API 1408 void raptor_www_set_error_handler(raptor_www *www, raptor_message_handler error_handler, void *error_data); 1409 RAPTOR_API 1410 void raptor_www_set_uri_filter(raptor_www* www, raptor_uri_filter_func filter, void* user_data); 1411 RAPTOR_API 1412 void raptor_www_set_connection_timeout(raptor_www* www, int timeout); 1413 RAPTOR_API 1414 int raptor_www_set_http_cache_control(raptor_www* www, const char* cache_control); 1415 RAPTOR_API 1416 int raptor_www_fetch(raptor_www *www, raptor_uri *uri); 1417 RAPTOR_API 1418 int raptor_www_fetch_to_string(raptor_www *www, raptor_uri *uri, void **string_p, size_t *length_p, void *(*malloc_handler)(size_t size)); 1419 RAPTOR_API 1420 void* raptor_www_get_connection(raptor_www *www); 1421 RAPTOR_API 1422 void raptor_www_abort(raptor_www *www, const char *reason); 1423 RAPTOR_API 1424 raptor_uri* raptor_www_get_final_uri(raptor_www* www); 1425 1426 1427 /* raptor_qname - XML qnames */ 1428 RAPTOR_API 1429 raptor_qname* raptor_new_qname(raptor_namespace_stack *nstack, const unsigned char *name, const unsigned char *value, raptor_simple_message_handler error_handler, void *error_data); 1430 #ifndef RAPTOR_DISABLE_V1 1431 RAPTOR_API RAPTOR_V1 1432 raptor_qname* raptor_new_qname_from_namespace_local_name(raptor_namespace *ns, const unsigned char *local_name, const unsigned char *value); 1433 #endif 1434 #ifdef RAPTOR_V2_AVAILABLE 1435 RAPTOR_API 1436 raptor_qname* raptor_new_qname_from_namespace_local_name_v2(raptor_world* world, raptor_namespace *ns, const unsigned char *local_name, const unsigned char *value); 1437 #endif 1438 RAPTOR_API 1439 raptor_qname* raptor_qname_copy(raptor_qname *qname); 1440 RAPTOR_API 1441 void raptor_free_qname(raptor_qname* name); 1442 RAPTOR_API 1443 int raptor_qname_equal(raptor_qname *name1, raptor_qname *name2); 1444 /* utility function */ 1445 RAPTOR_API 1446 raptor_uri* raptor_qname_string_to_uri(raptor_namespace_stack *nstack, const unsigned char *name, size_t name_len, raptor_simple_message_handler error_handler, void *error_data); 1447 RAPTOR_API 1448 int raptor_iostream_write_qname(raptor_iostream* iostr, raptor_qname *qname); 1449 RAPTOR_API 1450 unsigned char* raptor_qname_to_counted_name(raptor_qname *qname, size_t* length_p); 1451 RAPTOR_API 1452 const raptor_namespace* raptor_qname_get_namespace(raptor_qname* name); 1453 RAPTOR_API 1454 const unsigned char* raptor_qname_get_local_name(raptor_qname* name); 1455 RAPTOR_API 1456 const unsigned char* raptor_qname_get_value(raptor_qname* name); 1457 RAPTOR_API 1458 const unsigned char* raptor_qname_get_counted_value(raptor_qname* name, size_t* length_p); 1459 1460 /* raptor_namespace_stack - stack of XML namespaces */ 1461 RAPTOR_API 1462 raptor_namespace* raptor_new_namespace_from_uri(raptor_namespace_stack *nstack, const unsigned char *prefix, raptor_uri* ns_uri, int depth); 1463 #ifndef RAPTOR_DISABLE_V1 1464 RAPTOR_API RAPTOR_V1 1465 raptor_namespace_stack* raptor_new_namespaces(const raptor_uri_handler *uri_handler, void *uri_context, raptor_simple_message_handler error_handler, void *error_data, int defaults); 1466 RAPTOR_API RAPTOR_V1 1467 int raptor_namespaces_init(raptor_namespace_stack *nstack, const raptor_uri_handler *uri_handler, void *uri_context, raptor_simple_message_handler error_handler, void *error_data, int defaults); 1468 #endif 1469 #ifdef RAPTOR_V2_AVAILABLE 1470 RAPTOR_API 1471 raptor_namespace_stack* raptor_new_namespaces_v2(raptor_world* world, raptor_simple_message_handler error_handler, void *error_data, int defaults); 1472 RAPTOR_API 1473 int raptor_namespaces_init_v2(raptor_world* world, raptor_namespace_stack *nstack, raptor_simple_message_handler error_handler, void *error_data, int defaults); 1474 #endif 1475 RAPTOR_API 1476 void raptor_namespaces_clear(raptor_namespace_stack *nstack); 1477 RAPTOR_API 1478 void raptor_free_namespaces(raptor_namespace_stack *nstack); 1479 RAPTOR_API 1480 void raptor_namespaces_start_namespace(raptor_namespace_stack *nstack, raptor_namespace *nspace); 1481 RAPTOR_API 1482 int raptor_namespaces_start_namespace_full(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth); 1483 RAPTOR_API 1484 void raptor_namespaces_end_for_depth(raptor_namespace_stack *nstack, int depth); 1485 RAPTOR_API 1486 raptor_namespace* raptor_namespaces_get_default_namespace(raptor_namespace_stack *nstack); 1487 RAPTOR_API 1488 raptor_namespace *raptor_namespaces_find_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, int prefix_length); 1489 RAPTOR_API 1490 raptor_namespace* raptor_namespaces_find_namespace_by_uri(raptor_namespace_stack *nstack, raptor_uri *ns_uri); 1491 RAPTOR_API 1492 int raptor_namespaces_namespace_in_scope(raptor_namespace_stack *nstack, const raptor_namespace *nspace); 1493 RAPTOR_API 1494 raptor_qname* raptor_namespaces_qname_from_uri(raptor_namespace_stack *nstack, raptor_uri *uri, int xml_version); 1495 1496 /* raptor_namespace - XML namespace */ 1497 RAPTOR_API 1498 raptor_namespace* raptor_new_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth); 1499 RAPTOR_API 1500 void raptor_free_namespace(raptor_namespace *ns); 1501 RAPTOR_API 1502 int raptor_namespace_copy(raptor_namespace_stack *nstack, raptor_namespace *ns, int new_depth); 1503 RAPTOR_API 1504 raptor_uri* raptor_namespace_get_uri(const raptor_namespace *ns); 1505 RAPTOR_API 1506 const unsigned char* raptor_namespace_get_prefix(const raptor_namespace *ns); 1507 RAPTOR_API 1508 const unsigned char* raptor_namespace_get_counted_prefix(const raptor_namespace *ns, size_t *length_p); 1509 RAPTOR_API 1510 unsigned char *raptor_namespaces_format(const raptor_namespace *ns, size_t *length_p); 1511 RAPTOR_API 1512 int raptor_iostream_write_namespace(raptor_iostream* iostr, raptor_namespace *ns); 1513 RAPTOR_API 1514 int raptor_new_namespace_parts_from_string(const unsigned char *string, unsigned char **prefix, unsigned char **uri_string); 1515 1516 /** 1517 * raptor_stringbuffer: 1518 * 1519 * Raptor string buffer class 1520 */ 1521 typedef struct raptor_stringbuffer_s raptor_stringbuffer; 1522 1523 /* Sequence class */ 1524 /** 1525 * raptor_sequence: 1526 * 1527 * Raptor sequence class 1528 */ 1529 typedef struct raptor_sequence_s raptor_sequence; 1530 1531 /** 1532 * raptor_sequence_free_handler: 1533 * @object: object to free 1534 * 1535 * Handler function for freeing a sequence item. 1536 * 1537 * Set by raptor_new_sequence(). 1538 */ 1539 typedef void (raptor_sequence_free_handler(void* object)); 1540 1541 #ifdef RAPTOR_V2_AVAILABLE 1542 /** 1543 * raptor_sequence_free_handler_v2: 1544 * @context: context data for the free handler 1545 * @object: object to free 1546 * 1547 * Handler function for freeing a sequence item. 1548 * 1549 * Set by raptor_new_sequence_v2(). 1550 */ 1551 typedef void (raptor_sequence_free_handler_v2(void* context, void* object)); 1552 #endif 1553 1554 /** 1555 * raptor_sequence_print_handler: 1556 * @object: object to print 1557 * @fh: FILE* to print to 1558 * 1559 * Handler function for printing a sequence item. 1560 * 1561 * Set by raptor_new_sequence() or raptor_sequence_set_print_handler(). 1562 */ 1563 typedef void (raptor_sequence_print_handler(void *object, FILE *fh)); 1564 1565 #ifdef RAPTOR_V2_AVAILABLE 1566 /** 1567 * raptor_sequence_print_handler_v2: 1568 * @context: context data for the print handler 1569 * @object: object to print 1570 * @fh: FILE* to print to 1571 * 1572 * Handler function for printing a sequence item. 1573 * 1574 * Set by raptor_new_sequence_v2() or raptor_sequence_set_print_handler_v2(). 1575 */ 1576 typedef void (raptor_sequence_print_handler_v2(void *context, void *object, FILE *fh)); 1577 #endif 1578 1579 /* Create */ 1580 RAPTOR_API 1581 raptor_sequence* raptor_new_sequence(raptor_sequence_free_handler* free_handler, raptor_sequence_print_handler* print_handler); 1582 #ifdef RAPTOR_V2_AVAILABLE 1583 RAPTOR_API 1584 raptor_sequence* raptor_new_sequence_v2(raptor_sequence_free_handler_v2* free_handler, raptor_sequence_print_handler_v2* print_handler, void* handler_context); 1585 #endif 1586 /* Destroy */ 1587 RAPTOR_API 1588 void raptor_free_sequence(raptor_sequence* seq); 1589 /* Methods */ 1590 RAPTOR_API 1591 int raptor_sequence_size(raptor_sequence* seq); 1592 RAPTOR_API 1593 int raptor_sequence_set_at(raptor_sequence* seq, int idx, void *data); 1594 RAPTOR_API 1595 int raptor_sequence_push(raptor_sequence* seq, void *data); 1596 RAPTOR_API 1597 int raptor_sequence_shift(raptor_sequence* seq, void *data); 1598 RAPTOR_API 1599 void* raptor_sequence_get_at(raptor_sequence* seq, int idx); 1600 RAPTOR_API 1601 void* raptor_sequence_pop(raptor_sequence* seq); 1602 RAPTOR_API 1603 void* raptor_sequence_unshift(raptor_sequence* seq); 1604 RAPTOR_API 1605 void* raptor_sequence_delete_at(raptor_sequence* seq, int idx); 1606 1607 RAPTOR_API 1608 int raptor_compare_strings(const void *a, const void *b); 1609 1610 RAPTOR_API 1611 void raptor_sequence_sort(raptor_sequence* seq, int(*compare)(const void *, const void *)); 1612 1613 /* helper for printing sequences of strings */ 1614 RAPTOR_API 1615 void raptor_sequence_print_string(char *data, FILE *fh); 1616 RAPTOR_API RAPTOR_DEPRECATED 1617 void raptor_sequence_print_uri(char *data, FILE *fh); 1618 RAPTOR_API 1619 void raptor_sequence_set_print_handler(raptor_sequence *seq, raptor_sequence_print_handler *print_handler); 1620 #ifdef RAPTOR_V2_AVAILABLE 1621 RAPTOR_API 1622 void raptor_sequence_set_print_handler_v2(raptor_sequence *seq, raptor_sequence_print_handler_v2 *print_handler); 1623 #endif 1624 RAPTOR_API 1625 void raptor_sequence_print(raptor_sequence* seq, FILE* fh); 1626 RAPTOR_API 1627 int raptor_sequence_join(raptor_sequence* dest, raptor_sequence *src); 1628 1629 1630 /* Unicode and UTF8 */ 1631 1632 /** 1633 * raptor_unichar: 1634 * 1635 * raptor Unicode codepoint 1636 */ 1637 typedef unsigned long raptor_unichar; 1638 RAPTOR_API 1639 int raptor_unicode_char_to_utf8(raptor_unichar c, unsigned char *output); 1640 RAPTOR_API 1641 int raptor_utf8_to_unicode_char(raptor_unichar *output, const unsigned char *input, int length); 1642 RAPTOR_API 1643 int raptor_unicode_is_xml11_namestartchar(raptor_unichar c); 1644 RAPTOR_API 1645 int raptor_unicode_is_xml10_namestartchar(raptor_unichar c); 1646 RAPTOR_API 1647 int raptor_unicode_is_xml11_namechar(raptor_unichar c); 1648 RAPTOR_API 1649 int raptor_unicode_is_xml10_namechar(raptor_unichar c); 1650 RAPTOR_API 1651 int raptor_utf8_check(const unsigned char *string, size_t length); 1652 1653 /* raptor_stringbuffer */ 1654 RAPTOR_API 1655 raptor_stringbuffer* raptor_new_stringbuffer(void); 1656 RAPTOR_API 1657 void raptor_free_stringbuffer(raptor_stringbuffer *stringbuffer); 1658 RAPTOR_API 1659 int raptor_stringbuffer_append_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy); 1660 RAPTOR_API 1661 int raptor_stringbuffer_append_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy); 1662 RAPTOR_API 1663 int raptor_stringbuffer_append_decimal(raptor_stringbuffer* stringbuffer, int integer); 1664 RAPTOR_API 1665 int raptor_stringbuffer_append_stringbuffer(raptor_stringbuffer* stringbuffer, raptor_stringbuffer* append); 1666 RAPTOR_API 1667 int raptor_stringbuffer_prepend_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy); 1668 RAPTOR_API 1669 int raptor_stringbuffer_prepend_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy); 1670 RAPTOR_API 1671 unsigned char * raptor_stringbuffer_as_string(raptor_stringbuffer* stringbuffer); 1672 RAPTOR_API 1673 size_t raptor_stringbuffer_length(raptor_stringbuffer* stringbuffer); 1674 RAPTOR_API 1675 int raptor_stringbuffer_copy_to_string(raptor_stringbuffer* stringbuffer, unsigned char *string, size_t length); 1676 1677 /** 1678 * raptor_iostream_init_func: 1679 * @context: stream context data 1680 * 1681 * Handler function for #raptor_iostream initialising. 1682 * 1683 * Return value: non-0 on failure. 1684 */ 1685 typedef int (*raptor_iostream_init_func) (void *context); 1686 1687 /** 1688 * raptor_iostream_finish_func: 1689 * @context: stream context data 1690 * 1691 * Handler function for #raptor_iostream terminating. 1692 * 1693 */ 1694 typedef void (*raptor_iostream_finish_func) (void *context); 1695 1696 /** 1697 * raptor_iostream_write_byte_func 1698 * @context: stream context data 1699 * @byte: byte to write 1700 * 1701 * Handler function for implementing raptor_iostream_write_byte(). 1702 * 1703 * Return value: non-0 on failure. 1704 */ 1705 typedef int (*raptor_iostream_write_byte_func) (void *context, const int byte); 1706 1707 /** 1708 * raptor_iostream_write_bytes_func: 1709 * @context: stream context data 1710 * @ptr: pointer to bytes to write 1711 * @size: size of item 1712 * @nmemb: number of items 1713 * 1714 * Handler function for implementing raptor_iostream_write_bytes(). 1715 * 1716 * Return value: non-0 on failure. 1717 */ 1718 typedef int (*raptor_iostream_write_bytes_func) (void *context, const void *ptr, size_t size, size_t nmemb); 1719 1720 /** 1721 * raptor_iostream_write_end_func: 1722 * @context: stream context data 1723 * 1724 * Handler function for implementing raptor_iostream_write_end(). 1725 * 1726 */ 1727 typedef void (*raptor_iostream_write_end_func) (void *context); 1728 1729 /** 1730 * raptor_iostream_read_bytes_func: 1731 * @context: stream context data 1732 * @ptr: pointer to buffer to read into 1733 * @size: size of buffer 1734 * @nmemb: number of items 1735 * 1736 * Handler function for implementing raptor_iostream_read_bytes(). 1737 * 1738 * Return value: number of items read, 0 or < @size on EOF, <0 on failure 1739 */ 1740 typedef int (*raptor_iostream_read_bytes_func) (void *context, void *ptr, size_t size, size_t nmemb); 1741 1742 /** 1743 * raptor_iostream_read_eof_func: 1744 * @context: stream context data 1745 * 1746 * Handler function for implementing raptor_iostream_read_eof(). 1747 * 1748 * Return value: non-0 if EOF 1749 */ 1750 typedef int (*raptor_iostream_read_eof_func) (void *context); 1751 1752 #ifndef RAPTOR_DISABLE_DEPRECATED 1753 /** 1754 * raptor_iostream_handler: 1755 * @init: initialisation handler - optional, called at most once 1756 * @finish: finishing handler - optional, called at most once 1757 * @write_byte: write byte handler - required (for writing) 1758 * @write_bytes: write bytes handler - required (for writing) 1759 * @write_end: write end handler - optional (for writing), called at most once 1760 * 1761 * I/O stream implementation handler structure. 1762 * 1763 * DEPRECATED: Use #raptor_iostream_handler2 1764 */ 1765 typedef struct { 1766 raptor_iostream_init_func init; 1767 raptor_iostream_finish_func finish; 1768 raptor_iostream_write_byte_func write_byte; 1769 raptor_iostream_write_bytes_func write_bytes; 1770 raptor_iostream_write_end_func write_end; 1771 } raptor_iostream_handler; 1772 #endif 1773 1774 /** 1775 * raptor_iostream_handler2: 1776 * @version: interface version. Presently 1 or 2. 1777 * @init: initialisation handler - optional, called at most once (V1) 1778 * @finish: finishing handler - optional, called at most once (V1) 1779 * @write_byte: write byte handler - required (for writing) (V1) 1780 * @write_bytes: write bytes handler - required (for writing) (V1) 1781 * @write_end: write end handler - optional (for writing), called at most once (V1) 1782 * @read_bytes: read bytes handler - required (for reading) (V2) 1783 * @read_eof: read EOF handler - required (for reading) (V2) 1784 * 1785 * I/O stream implementation handler structure. 1786 * 1787 */ 1788 typedef struct { 1789 int version; 1790 1791 /* V1 functions */ 1792 raptor_iostream_init_func init; 1793 raptor_iostream_finish_func finish; 1794 raptor_iostream_write_byte_func write_byte; 1795 raptor_iostream_write_bytes_func write_bytes; 1796 raptor_iostream_write_end_func write_end; 1797 1798 /* V2 functions */ 1799 raptor_iostream_read_bytes_func read_bytes; 1800 raptor_iostream_read_eof_func read_eof; 1801 } raptor_iostream_handler2; 1802 1803 1804 #ifndef RAPTOR_DISABLE_DEPRECATED 1805 RAPTOR_API RAPTOR_DEPRECATED 1806 raptor_iostream* raptor_new_iostream_from_handler(void *context, const raptor_iostream_handler *handler); 1807 #endif 1808 RAPTOR_API 1809 raptor_iostream* raptor_new_iostream_from_handler2(void *user_data, const raptor_iostream_handler2* const handler2); 1810 RAPTOR_API 1811 raptor_iostream* raptor_new_iostream_to_sink(void); 1812 RAPTOR_API 1813 raptor_iostream* raptor_new_iostream_to_filename(const char *filename); 1814 RAPTOR_API 1815 raptor_iostream* raptor_new_iostream_to_file_handle(FILE *handle); 1816 RAPTOR_API 1817 raptor_iostream* raptor_new_iostream_to_string(void **string_p, size_t *length_p, void *(*malloc_handler)(size_t size)); 1818 RAPTOR_API 1819 raptor_iostream* raptor_new_iostream_from_sink(void); 1820 RAPTOR_API 1821 raptor_iostream* raptor_new_iostream_from_filename(const char *filename); 1822 RAPTOR_API 1823 raptor_iostream* raptor_new_iostream_from_file_handle(FILE *handle); 1824 RAPTOR_API 1825 raptor_iostream* raptor_new_iostream_from_string(void *string, size_t length); 1826 RAPTOR_API 1827 void raptor_free_iostream(raptor_iostream *iostr); 1828 1829 RAPTOR_API 1830 int raptor_iostream_write_bytes(raptor_iostream *iostr, const void *ptr, size_t size, size_t nmemb); 1831 RAPTOR_API 1832 int raptor_iostream_write_byte(raptor_iostream *iostr, const int byte); 1833 RAPTOR_API 1834 void raptor_iostream_write_end(raptor_iostream *iostr); 1835 RAPTOR_API 1836 int raptor_iostream_write_string(raptor_iostream *iostr, const void *string); 1837 RAPTOR_API 1838 int raptor_iostream_write_counted_string(raptor_iostream *iostr, const void *string, size_t len); 1839 #ifndef RAPTOR_DISABLE_DEPRECATED 1840 RAPTOR_API RAPTOR_DEPRECATED 1841 size_t raptor_iostream_get_bytes_written_count(raptor_iostream *iostr); 1842 #endif 1843 RAPTOR_API 1844 unsigned long raptor_iostream_tell(raptor_iostream *iostr); 1845 RAPTOR_API 1846 int raptor_iostream_write_decimal(raptor_iostream* iostr, int integer); 1847 RAPTOR_API 1848 int raptor_iostream_format_hexadecimal(raptor_iostream* iostr, unsigned int integer, int width); 1849 RAPTOR_API 1850 int raptor_iostream_write_stringbuffer(raptor_iostream* iostr, raptor_stringbuffer *sb); 1851 #ifndef RAPTOR_DISABLE_V1 1852 RAPTOR_API RAPTOR_V1 1853 int raptor_iostream_write_uri(raptor_iostream *iostr, raptor_uri *uri); 1854 #endif 1855 #ifdef RAPTOR_V2_AVAILABLE 1856 RAPTOR_API 1857 int raptor_iostream_write_uri_v2(raptor_world* world, raptor_iostream *iostr, raptor_uri *uri); 1858 #endif 1859 RAPTOR_API 1860 int raptor_iostream_read_bytes(raptor_iostream* iostr, void *ptr, size_t size, size_t nmemb); 1861 RAPTOR_API 1862 int raptor_iostream_read_eof(raptor_iostream *iostr); 1863 1864 /* Parser and Serializer features */ 1865 #ifndef RAPTOR_DISABLE_V1 1866 RAPTOR_API RAPTOR_V1 1867 raptor_feature raptor_feature_from_uri(raptor_uri *uri); 1868 #endif 1869 #ifdef RAPTOR_V2_AVAILABLE 1870 RAPTOR_API 1871 raptor_feature raptor_feature_from_uri_v2(raptor_world* world, raptor_uri *uri); 1872 #endif 1873 RAPTOR_API 1874 int raptor_feature_value_type(const raptor_feature feature); 1875 1876 /* SAX2 element Class (raptor_xml_element) */ 1877 RAPTOR_API 1878 raptor_xml_element* raptor_new_xml_element(raptor_qname* name, const unsigned char* xml_language, raptor_uri* xml_base); 1879 RAPTOR_API 1880 raptor_xml_element* raptor_new_xml_element_from_namespace_local_name(raptor_namespace *ns, const unsigned char *name, const unsigned char *xml_language, raptor_uri *xml_base); 1881 RAPTOR_API 1882 void raptor_free_xml_element(raptor_xml_element *element); 1883 RAPTOR_API 1884 raptor_qname* raptor_xml_element_get_name(raptor_xml_element *xml_element); 1885 RAPTOR_API 1886 void raptor_xml_element_set_attributes(raptor_xml_element* xml_element, raptor_qname **attributes, int count); 1887 RAPTOR_API 1888 raptor_qname** raptor_xml_element_get_attributes(raptor_xml_element* xml_element); 1889 RAPTOR_API 1890 int raptor_xml_element_get_attributes_count(raptor_xml_element* xml_element); 1891 RAPTOR_API 1892 int raptor_xml_element_declare_namespace(raptor_xml_element* xml_element, raptor_namespace *nspace); 1893 RAPTOR_API 1894 int raptor_iostream_write_xml_element(raptor_iostream *iostr, raptor_xml_element *element, raptor_namespace_stack *nstack, int is_empty, int is_end, raptor_simple_message_handler error_handler, void *error_data, int depth); 1895 RAPTOR_API 1896 int raptor_xml_element_is_empty(raptor_xml_element* xml_element); 1897 RAPTOR_API 1898 const unsigned char* raptor_xml_element_get_language(raptor_xml_element* xml_element); 1899 1900 /* XML Writer Class (raptor_xml_writer) */ 1901 #ifndef RAPTOR_DISABLE_V1 1902 RAPTOR_API RAPTOR_V1 1903 raptor_xml_writer* raptor_new_xml_writer(raptor_namespace_stack *nstack, const raptor_uri_handler *uri_handler, void *uri_context, raptor_iostream* iostr, raptor_simple_message_handler error_handler, void *error_data, int canonicalize); 1904 #endif 1905 #ifdef RAPTOR_V2_AVAILABLE 1906 RAPTOR_API 1907 raptor_xml_writer* raptor_new_xml_writer_v2(raptor_world* world, raptor_namespace_stack *nstack, raptor_iostream* iostr, raptor_simple_message_handler error_handler, void *error_data, int canonicalize); 1908 #endif 1909 RAPTOR_API 1910 void raptor_free_xml_writer(raptor_xml_writer* xml_writer); 1911 RAPTOR_API 1912 void raptor_xml_writer_empty_element(raptor_xml_writer* xml_writer, raptor_xml_element *element); 1913 RAPTOR_API 1914 void raptor_xml_writer_start_element(raptor_xml_writer* xml_writer, raptor_xml_element *element); 1915 RAPTOR_API 1916 void raptor_xml_writer_end_element(raptor_xml_writer* xml_writer, raptor_xml_element *element); 1917 RAPTOR_API 1918 void raptor_xml_writer_newline(raptor_xml_writer* xml_writer); 1919 RAPTOR_API 1920 void raptor_xml_writer_cdata(raptor_xml_writer* xml_writer, const unsigned char *s); 1921 RAPTOR_API 1922 void raptor_xml_writer_cdata_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len); 1923 RAPTOR_API 1924 void raptor_xml_writer_raw(raptor_xml_writer* xml_writer, const unsigned char *s); 1925 RAPTOR_API 1926 void raptor_xml_writer_raw_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len); 1927 RAPTOR_API 1928 void raptor_xml_writer_comment(raptor_xml_writer* xml_writer, const unsigned char *s); 1929 RAPTOR_API 1930 void raptor_xml_writer_comment_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len); 1931 RAPTOR_API 1932 void raptor_xml_writer_flush(raptor_xml_writer* xml_writer); 1933 #ifndef RAPTOR_DISABLE_V1 1934 RAPTOR_API RAPTOR_V1 1935 int raptor_xml_writer_features_enumerate(const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); 1936 #endif 1937 #ifdef RAPTOR_V2_AVAILABLE 1938 RAPTOR_API 1939 int raptor_xml_writer_features_enumerate_v2(raptor_world* world, const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); 1940 #endif 1941 RAPTOR_API 1942 int raptor_xml_writer_set_feature(raptor_xml_writer *xml_writer, raptor_feature feature, int value); 1943 RAPTOR_API 1944 int raptor_xml_writer_set_feature_string(raptor_xml_writer *xml_writer, raptor_feature feature, const unsigned char *value); 1945 RAPTOR_API 1946 int raptor_xml_writer_get_feature(raptor_xml_writer *xml_writer, raptor_feature feature); 1947 RAPTOR_API 1948 const unsigned char *raptor_xml_writer_get_feature_string(raptor_xml_writer *xml_writer, raptor_feature feature); 1949 RAPTOR_API 1950 int raptor_xml_writer_get_depth(raptor_xml_writer *xml_writer); 1951 1952 /** 1953 * raptor_sax2_start_element_handler: 1954 * @user_data: user data 1955 * @xml_element: XML element 1956 * 1957 * SAX2 start element handler 1958 */ 1959 typedef void (*raptor_sax2_start_element_handler)(void *user_data, raptor_xml_element *xml_element); 1960 1961 /** 1962 * raptor_sax2_end_element_handler: 1963 * @user_data: user data 1964 * @xml_element: XML element 1965 * 1966 * SAX2 end element handler 1967 */ 1968 typedef void (*raptor_sax2_end_element_handler)(void *user_data, raptor_xml_element* xml_element); 1969 1970 /** 1971 * raptor_sax2_characters_handler: 1972 * @user_data: user data 1973 * @xml_element: XML element 1974 * @s: string 1975 * @len: string len 1976 * 1977 * SAX2 characters handler 1978 */ 1979 typedef void (*raptor_sax2_characters_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len); 1980 1981 /** 1982 * raptor_sax2_cdata_handler: 1983 * @user_data: user data 1984 * @xml_element: XML element 1985 * @s: string 1986 * @len: string len 1987 1988 * SAX2 CDATA section handler 1989 */ 1990 typedef void (*raptor_sax2_cdata_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len); 1991 1992 /** 1993 * raptor_sax2_comment_handler: 1994 * @user_data: user data 1995 * @xml_element: XML element 1996 * @s: string 1997 * 1998 * SAX2 XML comment handler 1999 */ 2000 typedef void (*raptor_sax2_comment_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s); 2001 2002 /** 2003 * raptor_sax2_unparsed_entity_decl_handler: 2004 * @user_data: user data 2005 * @entityName: entity name 2006 * @base: base URI 2007 * @systemId: system ID 2008 * @publicId: public ID 2009 * @notationName: notation name 2010 * 2011 * SAX2 unparsed entity (NDATA) handler 2012 */ 2013 typedef void (*raptor_sax2_unparsed_entity_decl_handler)(void *user_data, const unsigned char* entityName, const unsigned char* base, const unsigned char* systemId, const unsigned char* publicId, const unsigned char* notationName); 2014 2015 /** 2016 * raptor_sax2_external_entity_ref_handler: 2017 * @user_data: user data 2018 * @context: context 2019 * @base: base URI 2020 * @systemId: system ID 2021 * @publicId: public ID 2022 * 2023 * SAX2 external entity reference handler 2024 * 2025 * Return value: 0 if processing should not continue because of a 2026 * fatal error in the handling of the external entity. 2027 */ 2028 typedef int (*raptor_sax2_external_entity_ref_handler)(void *user_data, const unsigned char* context, const unsigned char* base, const unsigned char* systemId, const unsigned char* publicId); 2029 2030 2031 /** 2032 * raptor_log_level: 2033 * @RAPTOR_LOG_LEVEL_NONE: Internal 2034 * @RAPTOR_LOG_LEVEL_FATAL: Fatal error message 2035 * @RAPTOR_LOG_LEVEL_ERROR: Error message 2036 * @RAPTOR_LOG_LEVEL_WARNING: Warning message 2037 * @RAPTOR_LOG_LEVEL_LAST: Internal 2038 * 2039 * Log levels 2040 */ 2041 typedef enum { 2042 RAPTOR_LOG_LEVEL_NONE, 2043 RAPTOR_LOG_LEVEL_FATAL, 2044 RAPTOR_LOG_LEVEL_ERROR, 2045 RAPTOR_LOG_LEVEL_WARNING, 2046 /* RAPTOR V2 FIXME - this enum list cannot be extended before V2 2047 * API is released else binary compatibility will be broken in the 2048 * #raptor_error_handlers structure - it causes an array to grow. 2049 */ 2050 RAPTOR_LOG_LEVEL_LAST=RAPTOR_LOG_LEVEL_WARNING 2051 } raptor_log_level; 2052 2053 2054 /** 2055 * raptor_error_handlers: 2056 * @magic: magic value - must use raptor_error_handlers_init() to set this 2057 * @locator: raptor locator of the error 2058 * @last_log_level: number of log levels; size of @handlers arrays 2059 * @handlers: user handlers per log level 2060 * @world: raptor_world object 2061 * 2062 * Error handlers structure 2063 */ 2064 typedef struct { 2065 unsigned int magic; 2066 2067 raptor_locator* locator; 2068 2069 /* size of handlers array */ 2070 raptor_log_level last_log_level; 2071 2072 raptor_message_handler_closure handlers[RAPTOR_LOG_LEVEL_LAST+1]; 2073 2074 /* Raptor V2 FIXME - this should NOT be at the end of the structure 2075 * since it prevents increasing the size of the @handlers array but 2076 * it it is here to preserve Raptor V1 ABI. 2077 */ 2078 raptor_world *world; 2079 } raptor_error_handlers; 2080 2081 #ifndef RAPTOR_DISABLE_V1 2082 RAPTOR_API RAPTOR_V1 2083 void raptor_error_handlers_init(raptor_error_handlers* error_handlers); 2084 #endif 2085 #ifdef RAPTOR_V2_AVAILABLE 2086 RAPTOR_API 2087 void raptor_error_handlers_init_v2(raptor_world* world, raptor_error_handlers* error_handlers); 2088 #endif 2089 2090 2091 /* SAX2 API */ 2092 RAPTOR_API 2093 raptor_sax2* raptor_new_sax2(void *user_data, raptor_error_handlers* error_handlers); 2094 RAPTOR_API 2095 void raptor_free_sax2(raptor_sax2 *sax2); 2096 2097 RAPTOR_API 2098 void raptor_sax2_set_start_element_handler(raptor_sax2* sax2, raptor_sax2_start_element_handler handler); 2099 RAPTOR_API 2100 void raptor_sax2_set_end_element_handler(raptor_sax2* sax2, raptor_sax2_end_element_handler handler); 2101 RAPTOR_API 2102 void raptor_sax2_set_characters_handler(raptor_sax2* sax2, raptor_sax2_characters_handler handler); 2103 RAPTOR_API 2104 void raptor_sax2_set_cdata_handler(raptor_sax2* sax2, raptor_sax2_cdata_handler handler); 2105 RAPTOR_API 2106 void raptor_sax2_set_comment_handler(raptor_sax2* sax2, raptor_sax2_comment_handler handler); 2107 RAPTOR_API 2108 void raptor_sax2_set_unparsed_entity_decl_handler(raptor_sax2* sax2, raptor_sax2_unparsed_entity_decl_handler handler); 2109 RAPTOR_API 2110 void raptor_sax2_set_external_entity_ref_handler(raptor_sax2* sax2, raptor_sax2_external_entity_ref_handler handler); 2111 RAPTOR_API 2112 void raptor_sax2_set_namespace_handler(raptor_sax2* sax2, raptor_namespace_handler handler); 2113 RAPTOR_API 2114 void raptor_sax2_parse_start(raptor_sax2 *sax2, raptor_uri *base_uri); 2115 RAPTOR_API 2116 int raptor_sax2_parse_chunk(raptor_sax2* sax2, const unsigned char *buffer, size_t len, int is_end); 2117 RAPTOR_API 2118 const unsigned char* raptor_sax2_inscope_xml_language(raptor_sax2* sax2); 2119 RAPTOR_API 2120 raptor_uri* raptor_sax2_inscope_base_uri(raptor_sax2* sax2); 2121 2122 #ifdef __cplusplus 2123 } 2124 #endif 2125 2126 #endif 2127