1 /* -*- Mode: c; c-basic-offset: 2 -*- 2 * 3 * raptor.h - Redland Parser Toolkit for RDF (Raptor) - public API 4 * 5 * Copyright (C) 2000-2013, 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_V2_AVAILABLE 43 * 44 * Flag for marking raptor2 API availability. 45 */ 46 #define RAPTOR_V2_AVAILABLE 1 47 48 49 /** 50 * RAPTOR_VERSION: 51 * 52 * Raptor library version number 53 * 54 * Format: major * 10000 + minor * 100 + release 55 */ 56 #define RAPTOR_VERSION 20015 57 58 /** 59 * RAPTOR_VERSION_STRING: 60 * 61 * Raptor library version string 62 */ 63 #define RAPTOR_VERSION_STRING "2.0.15" 64 65 /** 66 * RAPTOR_VERSION_MAJOR: 67 * 68 * Raptor library major version 69 */ 70 #define RAPTOR_VERSION_MAJOR 2 71 72 /** 73 * RAPTOR_VERSION_MINOR: 74 * 75 * Raptor library minor version 76 */ 77 #define RAPTOR_VERSION_MINOR 0 78 79 /** 80 * RAPTOR_VERSION_RELEASE: 81 * 82 * Raptor library release 83 */ 84 #define RAPTOR_VERSION_RELEASE 15 85 86 /** 87 * RAPTOR_API: 88 * 89 * Macro for wrapping API function call declarations. 90 * 91 */ 92 #ifndef RAPTOR_API 93 # ifdef _WIN32 94 # ifdef __GNUC__ 95 # undef _declspec 96 # define _declspec(x) __declspec(x) 97 # endif 98 # ifdef RAPTOR_STATIC 99 # define RAPTOR_API 100 # else 101 # ifdef RAPTOR_INTERNAL 102 # define RAPTOR_API _declspec(dllexport) 103 # else 104 # define RAPTOR_API _declspec(dllimport) 105 # endif 106 # endif 107 # else 108 # define RAPTOR_API 109 # endif 110 #endif 111 112 /* Use gcc 3.1+ feature to allow marking of deprecated API calls. 113 * This gives a warning during compiling. 114 */ 115 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) 116 #define RAPTOR_DEPRECATED __attribute__((deprecated)) 117 #define RAPTOR_NORETURN __attribute__((__noreturn__)) 118 #else 119 #define RAPTOR_DEPRECATED 120 #define RAPTOR_NORETURN 121 #endif 122 123 /** 124 * RAPTOR_PRINTF_FORMAT: 125 * @string_index: ignore me 126 * @first_to_check_index: ignore me 127 * 128 * Internal macro 129 */ 130 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)) 131 #define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index) \ 132 __attribute__((__format__(__printf__, string_index, first_to_check_index))) 133 #else 134 #define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index) 135 #endif 136 137 /** 138 * raptor_uri: 139 * 140 * Raptor URI Class. 141 */ 142 typedef struct raptor_uri_s raptor_uri; 143 144 145 /* Public statics */ 146 147 /** 148 * raptor_short_copyright_string: 149 * 150 * Short copyright string (one line). 151 */ 152 RAPTOR_API 153 extern const char * const raptor_short_copyright_string; 154 155 /** 156 * raptor_copyright_string: 157 * 158 * Copyright string (multiple lines). 159 */ 160 RAPTOR_API 161 extern const char * const raptor_copyright_string; 162 163 /** 164 * raptor_version_string: 165 * 166 * Raptor version as a string. 167 */ 168 RAPTOR_API 169 extern const char * const raptor_version_string; 170 171 /** 172 * raptor_version_major: 173 * 174 * Raptor major version number. 175 */ 176 RAPTOR_API 177 extern const unsigned int raptor_version_major; 178 179 /** 180 * raptor_version_minor: 181 * 182 * Raptor minor version number. 183 */ 184 RAPTOR_API 185 extern const unsigned int raptor_version_minor; 186 187 /** 188 * raptor_version_release: 189 * 190 * Raptor release version number. 191 */ 192 RAPTOR_API 193 extern const unsigned int raptor_version_release; 194 195 /** 196 * raptor_version_decimal: 197 * 198 * Raptor version as a decimal number. 199 * 200 * Format: major * 10000 + minor * 100 + release 201 */ 202 RAPTOR_API 203 extern const unsigned int raptor_version_decimal; 204 205 /** 206 * raptor_license_string: 207 * 208 * Raptor license string. 209 */ 210 RAPTOR_API 211 extern const char * const raptor_license_string; 212 213 /** 214 * raptor_home_url_string: 215 * 216 * Raptor home page URL. 217 */ 218 RAPTOR_API 219 extern const char * const raptor_home_url_string; 220 221 /** 222 * raptor_xml_namespace_uri: 223 * 224 * XML Namespace (xml:) URI string. 225 */ 226 RAPTOR_API 227 extern const unsigned char * const raptor_xml_namespace_uri; 228 229 230 /** 231 * raptor_rdf_namespace_uri: 232 * 233 * RDF Namespace (rdf:) URI string. 234 */ 235 RAPTOR_API 236 extern const unsigned char * const raptor_rdf_namespace_uri; 237 238 /** 239 * raptor_rdf_namespace_uri_len: 240 * 241 * Length of #raptor_rdf_namespace_uri string 242 */ 243 RAPTOR_API 244 extern const unsigned int raptor_rdf_namespace_uri_len; 245 246 /** 247 * raptor_rdf_schema_namespace_uri: 248 * 249 * RDF Schema (rdfs:) Namespace URI string. 250 */ 251 RAPTOR_API 252 extern const unsigned char * const raptor_rdf_schema_namespace_uri; 253 254 /** 255 * raptor_xmlschema_datatypes_namespace_uri: 256 * 257 * XML Schema datatypes (xsd:) namespace URI string. 258 */ 259 RAPTOR_API 260 extern const unsigned char * const raptor_xmlschema_datatypes_namespace_uri; 261 262 /** 263 * raptor_owl_namespace_uri: 264 * 265 * OWL (owl:) Namespace URI string. 266 */ 267 RAPTOR_API 268 extern const unsigned char * const raptor_owl_namespace_uri; 269 270 /** 271 * raptor_xml_literal_datatype_uri_string: 272 * 273 * XML Literal datatype (rdf:XMLLiteral) URI string. 274 */ 275 RAPTOR_API 276 extern const unsigned char * const raptor_xml_literal_datatype_uri_string; 277 278 /** 279 * raptor_xml_literal_datatype_uri_string_len: 280 * 281 * Length of #raptor_xml_literal_datatype_uri_string 282 */ 283 RAPTOR_API 284 extern const unsigned int raptor_xml_literal_datatype_uri_string_len; 285 286 287 /* Public structure */ 288 /** 289 * raptor_world: 290 * 291 * Raptor world class. 292 */ 293 typedef struct raptor_world_s raptor_world; 294 /** 295 * raptor_parser: 296 * 297 * Raptor Parser class 298 */ 299 typedef struct raptor_parser_s raptor_parser; 300 /** 301 * raptor_serializer: 302 * 303 * Raptor Serializer class 304 */ 305 typedef struct raptor_serializer_s raptor_serializer; 306 307 /** 308 * raptor_www: 309 * 310 * Raptor WWW class 311 */ 312 typedef struct raptor_www_s raptor_www; 313 /** 314 * raptor_iostream: 315 * 316 * Raptor I/O Stream class 317 */ 318 typedef struct raptor_iostream_s raptor_iostream; 319 /** 320 * raptor_xml_element: 321 * 322 * Raptor XML Element class 323 */ 324 typedef struct raptor_xml_element_s raptor_xml_element; 325 /** 326 * raptor_xml_writer: 327 * 328 * Raptor XML Writer class 329 */ 330 typedef struct raptor_xml_writer_s raptor_xml_writer; 331 /** 332 * raptor_qname: 333 * 334 * Raptor XML qname class 335 */ 336 typedef struct raptor_qname_s raptor_qname; 337 /** 338 * raptor_namespace: 339 * 340 * Raptor XML Namespace class 341 */ 342 typedef struct raptor_namespace_s raptor_namespace; 343 /** 344 * raptor_namespace_stack: 345 * 346 * Raptor XML Namespace Stack class 347 */ 348 typedef struct raptor_namespace_stack_s raptor_namespace_stack; 349 350 /** 351 * raptor_sax2: 352 * 353 * Raptor SAX2 class 354 */ 355 typedef struct raptor_sax2_s raptor_sax2; 356 357 358 /** 359 * raptor_type_q: 360 * @mime_type: MIME type string 361 * @mime_type_len: length of @mime_type 362 * @q: Q value 0-10 standing for decimal 0.0-1.0 363 * 364 * (MIME Type, Q) pair 365 */ 366 typedef struct { 367 const char* mime_type; 368 size_t mime_type_len; 369 unsigned char q; 370 } raptor_type_q; 371 372 373 /** 374 * raptor_syntax_bitflags: 375 * @RAPTOR_SYNTAX_NEED_BASE_URI: the syntax requires a base URI 376 * 377 * Bit flags for #raptor_syntax_description flags field 378 */ 379 typedef enum { 380 RAPTOR_SYNTAX_NEED_BASE_URI = 1 381 } raptor_syntax_bitflags; 382 383 384 /** 385 * raptor_syntax_description: 386 * @names: array of syntax names - the first one (required) is the public name, the rest are aliases. The array is NULL terminated. 387 * @names_count: size of @names array 388 * @label: long descriptive label for syntax 389 * @mime_types: Array of (MIME type, Q) values associated with the syntax (or NULL). If present the array is NULL terminated. 390 * @mime_types_count: size of @mime_types array 391 * @uri_strings: array of URIs identifying the syntax (or NULL). The first one if present is the main URI, the rest are aliases. The array is NULL terminated. 392 * @uri_strings_count: size of @uri_strings array 393 * @flags: See #raptor_syntax_bitflags for the bits 394 * 395 * Description of a syntax or file format. 396 * 397 */ 398 typedef struct { 399 const char* const* names; 400 unsigned int names_count; 401 402 const char* label; 403 404 const raptor_type_q* mime_types; 405 unsigned int mime_types_count; 406 407 const char* const* uri_strings; 408 unsigned int uri_strings_count; 409 410 unsigned int flags; 411 } raptor_syntax_description; 412 413 414 /** 415 * raptor_term_type: 416 * @RAPTOR_TERM_TYPE_URI: RDF URI 417 * @RAPTOR_TERM_TYPE_LITERAL: RDF literal 418 * @RAPTOR_TERM_TYPE_BLANK: RDF blank node 419 * @RAPTOR_TERM_TYPE_UNKNOWN: Internal 420 * 421 * Type of term in a #raptor_statement 422 * 423 * Node type 3 is unused but exists to preserve numeric compatibility 424 * with librdf_node_type values. 425 */ 426 typedef enum { 427 RAPTOR_TERM_TYPE_UNKNOWN = 0, 428 RAPTOR_TERM_TYPE_URI = 1, 429 RAPTOR_TERM_TYPE_LITERAL = 2, 430 /* unused type 3 */ 431 RAPTOR_TERM_TYPE_BLANK = 4 432 } raptor_term_type; 433 434 435 /** 436 * raptor_locator: 437 * @uri: URI of location (or NULL) 438 * @file: Filename of location (or NULL) 439 * @line: Line number of location (or <0 for no line) 440 * @column: Column number of location (or <0 for no column) 441 * @byte: Byte number of location (or <0 for no byte) 442 * 443 * Location information for an error, warning or information message. 444 */ 445 typedef struct { 446 raptor_uri *uri; 447 const char *file; 448 int line; 449 int column; 450 int byte; 451 } raptor_locator; 452 453 /** 454 * raptor_option: 455 * @RAPTOR_OPTION_SCANNING: If true (default false), the RDF/XML 456 * parser will look for embedded rdf:RDF elements inside the XML 457 * content, and not require that the XML start with an rdf:RDF root 458 * element. 459 * @RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES: If true (default true) 460 * then the RDF/XML parser will allow non-XML namespaced attributes 461 * to be accepted as well as rdf: namespaced ones. For example, 462 * 'about' and 'ID' will be interpreted as if they were rdf:about 463 * and rdf:ID respectively. 464 * @RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES: If true (default true) 465 * then the RDF/XML parser will allow unknown parsetypes to be 466 * present and will pass them on to the user. Unimplemented at 467 * present. 468 * @RAPTOR_OPTION_ALLOW_BAGID: If true (default true) then the 469 * RDF/XML parser will support the rdf:bagID attribute that was 470 * removed from the RDF/XML language when it was revised. This 471 * support may be removed in future. 472 * @RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST: If true (default false) 473 * then the RDF/XML parser will generate the idList rdf:type 474 * rdf:List triple in the handling of rdf:parseType="Collection". 475 * This triple was removed during the revising of RDF/XML after 476 * collections were initially added. 477 * @RAPTOR_OPTION_NORMALIZE_LANGUAGE: If true (default true) then 478 * XML language values such as from xml:lang will be normalized to 479 * lowercase. 480 * @RAPTOR_OPTION_NON_NFC_FATAL: If true (default false) then 481 * illegal Unicode Normal Form C in literals will give a fatal 482 * error, otherwise just a warning. 483 * @RAPTOR_OPTION_WARN_OTHER_PARSETYPES: If true (default true) then 484 * the RDF/XML parser will warn about unknown rdf:parseType values. 485 * @RAPTOR_OPTION_CHECK_RDF_ID: If true (default true) then the 486 * RDF/XML will check rdf:ID attribute values for duplicates and 487 * cause an error if any are found. 488 * @RAPTOR_OPTION_RELATIVE_URIS: If true (default true) then 489 * relative URIs will be used wherever possible when serializing. 490 * @RAPTOR_OPTION_WRITER_AUTO_INDENT: Automatically indent elements when 491 * seriailizing. 492 * @RAPTOR_OPTION_WRITER_AUTO_EMPTY: Automatically detect and 493 * abbreviate empty elements when serializing. 494 * @RAPTOR_OPTION_WRITER_INDENT_WIDTH: Integer number of spaces to use 495 * for each indent level when serializing with auto indent. 496 * @RAPTOR_OPTION_WRITER_XML_VERSION: Integer XML version XML 1.0 (10) or XML 1.1 (11) 497 * @RAPTOR_OPTION_WRITER_XML_DECLARATION: Write XML 1.0 or 1.1 declaration. 498 * @RAPTOR_OPTION_NO_NET: Deny network requests inside other requests. 499 * @RAPTOR_OPTION_RESOURCE_BORDER: Border color of resource 500 * nodes for GraphViz DOT serializer. 501 * @RAPTOR_OPTION_LITERAL_BORDER: Border color of literal nodes 502 * for GraphViz DOT serializer. 503 * @RAPTOR_OPTION_BNODE_BORDER: Border color of blank nodes for 504 * GraphViz DOT serializer. 505 * @RAPTOR_OPTION_RESOURCE_FILL: Fill color of resource nodes 506 * for GraphViz DOT serializer. 507 * @RAPTOR_OPTION_LITERAL_FILL: Fill color of literal nodes for 508 * GraphViz DOT serializer. 509 * @RAPTOR_OPTION_BNODE_FILL: Fill color of blank nodes for 510 * GraphViz DOT serializer. 511 * @RAPTOR_OPTION_HTML_TAG_SOUP: Use a lax HTML parser if an XML parser 512 * fails when read HTML for GRDDL parser. 513 * @RAPTOR_OPTION_MICROFORMATS: Look for microformats for GRDDL parser. 514 * @RAPTOR_OPTION_HTML_LINK: Look for head <link> to type rdf/xml 515 * for GRDDL parser. 516 * @RAPTOR_OPTION_WWW_TIMEOUT: Set timeout for internal WWW URI requests 517 * for GRDDL parser. 518 * @RAPTOR_OPTION_WRITE_BASE_URI: Write @base directive for Turtle/N3. 519 * @RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL: HTTP Cache-Control: header 520 * @RAPTOR_OPTION_WWW_HTTP_USER_AGENT: HTTP User-Agent: header 521 * @RAPTOR_OPTION_JSON_CALLBACK: JSON serializer callback function. 522 * @RAPTOR_OPTION_JSON_EXTRA_DATA: JSON serializer extra top-level data 523 * @RAPTOR_OPTION_RSS_TRIPLES: Atom/RSS serializer writes extra RDF triples it finds (none, rdf-xml, atom-triples) 524 * @RAPTOR_OPTION_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. 525 * @RAPTOR_OPTION_PREFIX_ELEMENTS: Integer. If set, generate Atom/RSS1.0 documents with prefixed elements, otherwise unprefixed. 526 * @RAPTOR_OPTION_STRICT: Boolean. If set, operate in strict conformance mode. 527 * @RAPTOR_OPTION_WWW_CERT_FILENAME: String. SSL client certificate filename 528 * @RAPTOR_OPTION_WWW_CERT_TYPE: String. SSL client certificate type 529 * @RAPTOR_OPTION_WWW_CERT_PASSPHRASE: String. SSL client certificate passphrase 530 * @RAPTOR_OPTION_WWW_SSL_VERIFY_PEER: Integer. SSL verify peer - non-0 to verify peer SSL certificate (default) 531 * @RAPTOR_OPTION_WWW_SSL_VERIFY_HOST: Integer. SSL verify host - 0 none, 1 CN match, 2 host match (default). Other values are ignored. 532 * @RAPTOR_OPTION_NO_FILE: Deny file reading requests inside other requests. 533 * @RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES: When reading XML, load external entities. 534 * @RAPTOR_OPTION_LAST: Internal 535 * 536 * Raptor parser, serializer or XML writer options. 537 */ 538 typedef enum { 539 RAPTOR_OPTION_SCANNING, 540 RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES, 541 RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES, 542 RAPTOR_OPTION_ALLOW_BAGID, 543 RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST, 544 RAPTOR_OPTION_NORMALIZE_LANGUAGE, 545 RAPTOR_OPTION_NON_NFC_FATAL, 546 RAPTOR_OPTION_WARN_OTHER_PARSETYPES, 547 RAPTOR_OPTION_CHECK_RDF_ID, 548 RAPTOR_OPTION_RELATIVE_URIS, 549 RAPTOR_OPTION_WRITER_AUTO_INDENT, 550 RAPTOR_OPTION_WRITER_AUTO_EMPTY, 551 RAPTOR_OPTION_WRITER_INDENT_WIDTH, 552 RAPTOR_OPTION_WRITER_XML_VERSION, 553 RAPTOR_OPTION_WRITER_XML_DECLARATION, 554 RAPTOR_OPTION_NO_NET, 555 RAPTOR_OPTION_RESOURCE_BORDER, 556 RAPTOR_OPTION_LITERAL_BORDER, 557 RAPTOR_OPTION_BNODE_BORDER, 558 RAPTOR_OPTION_RESOURCE_FILL, 559 RAPTOR_OPTION_LITERAL_FILL, 560 RAPTOR_OPTION_BNODE_FILL, 561 RAPTOR_OPTION_HTML_TAG_SOUP, 562 RAPTOR_OPTION_MICROFORMATS, 563 RAPTOR_OPTION_HTML_LINK, 564 RAPTOR_OPTION_WWW_TIMEOUT, 565 RAPTOR_OPTION_WRITE_BASE_URI, 566 RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL, 567 RAPTOR_OPTION_WWW_HTTP_USER_AGENT, 568 RAPTOR_OPTION_JSON_CALLBACK, 569 RAPTOR_OPTION_JSON_EXTRA_DATA, 570 RAPTOR_OPTION_RSS_TRIPLES, 571 RAPTOR_OPTION_ATOM_ENTRY_URI, 572 RAPTOR_OPTION_PREFIX_ELEMENTS, 573 RAPTOR_OPTION_STRICT, 574 RAPTOR_OPTION_WWW_CERT_FILENAME, 575 RAPTOR_OPTION_WWW_CERT_TYPE, 576 RAPTOR_OPTION_WWW_CERT_PASSPHRASE, 577 RAPTOR_OPTION_NO_FILE, 578 RAPTOR_OPTION_WWW_SSL_VERIFY_PEER, 579 RAPTOR_OPTION_WWW_SSL_VERIFY_HOST, 580 RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES, 581 RAPTOR_OPTION_LAST = RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES 582 } raptor_option; 583 584 585 /** 586 * raptor_term_literal_value: 587 * @string: literal string 588 * @string_len: length of string 589 * @datatype: datatype URI (or NULL) 590 * @language: literal language (or NULL) 591 * @language_len: length of language 592 * 593 * Literal term value - this typedef exists solely for use in #raptor_term 594 * 595 * Either @datatype or @language may be non-NULL but not both. 596 */ 597 typedef struct { 598 unsigned char *string; 599 unsigned int string_len; 600 601 raptor_uri *datatype; 602 603 unsigned char *language; 604 unsigned char language_len; 605 } raptor_term_literal_value; 606 607 608 /** 609 * raptor_term_blank_value: 610 * @string: literal string 611 * @string_len: length of string 612 * 613 * Blank term value - this typedef exists solely for use in #raptor_term 614 * 615 */ 616 typedef struct { 617 unsigned char *string; 618 unsigned int string_len; 619 } raptor_term_blank_value; 620 621 622 /** 623 * raptor_term_value: 624 * @uri: uri value when term type is #RAPTOR_TERM_TYPE_URI 625 * @literal: literal value when term type is #RAPTOR_TERM_TYPE_LITERAL 626 * @blank: blank value when term type is #RAPTOR_TERM_TYPE_BLANK 627 * 628 * Term value - this typedef exists solely for use in #raptor_term 629 * 630 **/ 631 typedef union { 632 raptor_uri *uri; 633 634 raptor_term_literal_value literal; 635 636 raptor_term_blank_value blank; 637 } raptor_term_value; 638 639 640 /** 641 * raptor_term: 642 * @world: world 643 * @usage: usage reference count (if >0) 644 * @type: term type 645 * @value: term values per type 646 * 647 * An RDF statement term 648 * 649 */ 650 typedef struct { 651 raptor_world* world; 652 653 int usage; 654 655 raptor_term_type type; 656 657 raptor_term_value value; 658 659 } raptor_term; 660 661 662 /** 663 * raptor_statement: 664 * @world: world pointer 665 * @usage: usage count 666 * @subject: statement subject 667 * @predicate: statement predicate 668 * @object: statement object 669 * @graph: statement graph name (or NULL if not present) 670 * 671 * An RDF triple with optional graph name (quad) 672 * 673 * See #raptor_term for a description of how the fields may be used. 674 * As returned by a parser statement_handler. 675 */ 676 typedef struct { 677 raptor_world* world; 678 int usage; 679 raptor_term* subject; 680 raptor_term* predicate; 681 raptor_term* object; 682 raptor_term* graph; 683 } raptor_statement; 684 685 686 /** 687 * raptor_log_level: 688 * @RAPTOR_LOG_LEVEL_NONE: Internal 689 * @RAPTOR_LOG_LEVEL_TRACE: very fine-grained tracing messages information 690 * @RAPTOR_LOG_LEVEL_DEBUG: fine-grained tracing messages suitable for debugging 691 * @RAPTOR_LOG_LEVEL_INFO: coarse-grained information messages 692 * @RAPTOR_LOG_LEVEL_WARN: warning messages of potentially harmful problems 693 * @RAPTOR_LOG_LEVEL_ERROR: error messages where the application can continue 694 * @RAPTOR_LOG_LEVEL_FATAL: fatal error message where the application will likely abort 695 * @RAPTOR_LOG_LEVEL_LAST: Internal 696 * 697 * Log levels 698 */ 699 typedef enum { 700 RAPTOR_LOG_LEVEL_NONE, 701 RAPTOR_LOG_LEVEL_TRACE, 702 RAPTOR_LOG_LEVEL_DEBUG, 703 RAPTOR_LOG_LEVEL_INFO, 704 RAPTOR_LOG_LEVEL_WARN, 705 RAPTOR_LOG_LEVEL_ERROR, 706 RAPTOR_LOG_LEVEL_FATAL, 707 RAPTOR_LOG_LEVEL_LAST = RAPTOR_LOG_LEVEL_FATAL 708 } raptor_log_level; 709 710 711 /** 712 * raptor_domain: 713 * @RAPTOR_DOMAIN_IOSTREAM: I/O stream 714 * @RAPTOR_DOMAIN_NAMESPACE: XML Namespace / namespace stack 715 * @RAPTOR_DOMAIN_PARSER: RDF Parser 716 * @RAPTOR_DOMAIN_QNAME: XML QName 717 * @RAPTOR_DOMAIN_SAX2: XML SAX2 718 * @RAPTOR_DOMAIN_SERIALIZER: RDF Serializer 719 * @RAPTOR_DOMAIN_TERM: RDF Term 720 * @RAPTOR_DOMAIN_TURTLE_WRITER: Turtle Writer 721 * @RAPTOR_DOMAIN_URI: RDF Uri 722 * @RAPTOR_DOMAIN_WORLD: RDF world 723 * @RAPTOR_DOMAIN_WWW: WWW 724 * @RAPTOR_DOMAIN_XML_WRITER: XML Writer 725 * @RAPTOR_DOMAIN_NONE: Internal 726 * @RAPTOR_DOMAIN_LAST: Internal 727 * 728 * Log domain 729 */ 730 typedef enum { 731 RAPTOR_DOMAIN_NONE, 732 RAPTOR_DOMAIN_IOSTREAM, 733 RAPTOR_DOMAIN_NAMESPACE, 734 RAPTOR_DOMAIN_PARSER, 735 RAPTOR_DOMAIN_QNAME, 736 RAPTOR_DOMAIN_SAX2, 737 RAPTOR_DOMAIN_SERIALIZER, 738 RAPTOR_DOMAIN_TERM, 739 RAPTOR_DOMAIN_TURTLE_WRITER, 740 RAPTOR_DOMAIN_URI, 741 RAPTOR_DOMAIN_WORLD, 742 RAPTOR_DOMAIN_WWW, 743 RAPTOR_DOMAIN_XML_WRITER, 744 RAPTOR_DOMAIN_LAST = RAPTOR_DOMAIN_XML_WRITER 745 } raptor_domain; 746 747 748 /** 749 * raptor_log_message: 750 * @code: error code or < 0 if not used or known 751 * @domain: message domain or #RAPTOR_DOMAIN_NONE if not used or known 752 * @level: log message level 753 * @locator: location associated with message or NULL if not known 754 * @text: message string 755 * 756 * Log message. 757 */ 758 typedef struct { 759 int code; 760 raptor_domain domain; 761 raptor_log_level level; 762 raptor_locator *locator; 763 const char *text; 764 } raptor_log_message; 765 766 767 /** 768 * raptor_log_handler: 769 * @user_data: user data 770 * @message: log message 771 * 772 * Handler function for log messages with location 773 * 774 * Used during parsing and serializing for errors and warnings that 775 * may include location information. Handlers may be set 776 * by raptor_world_set_log_handler(). 777 * 778 */ 779 typedef void (*raptor_log_handler)(void *user_data, raptor_log_message *message); 780 781 782 /** 783 * raptor_statement_handler: 784 * @user_data: user data 785 * @statement: statement to report 786 * 787 * Statement (triple) reporting handler function. 788 * 789 * This handler function set with 790 * raptor_parser_set_statement_handler() on a parser receives 791 * statements as the parsing proceeds. The @statement argument to the 792 * handler is shared and must be copied by the caller with 793 * raptor_statement_copy(). 794 */ 795 typedef void (*raptor_statement_handler)(void *user_data, raptor_statement *statement); 796 797 /** 798 * raptor_graph_mark_flags: 799 * @RAPTOR_GRAPH_MARK_START: mark is start of graph (otherwise is end) 800 * @RAPTOR_GRAPH_MARK_DECLARED: mark was declared in syntax rather than implict 801 * 802 * Graph mark handler bitmask flags 803 */ 804 typedef enum { 805 RAPTOR_GRAPH_MARK_START = 1, 806 RAPTOR_GRAPH_MARK_DECLARED = 2 807 } raptor_graph_mark_flags; 808 809 810 /** 811 * raptor_graph_mark_handler: 812 * @user_data: user data 813 * @graph: graph to report, NULL for the default graph 814 * @flags: bitmask of #raptor_graph_mark_flags flags 815 * 816 * Graph start/end mark handler function. 817 * 818 * Records start and end of graphs happening in a stream of generated 819 * #raptor_statement via the statement handler. The callback starts a 820 * graph when @flags has #RAPTOR_GRAPH_MARK_START bit set. 821 * 822 * The start and ends may be either declared in the syntax via some 823 * keyword or mechanism such as TRiG {} syntax when @flags has bit 824 * #RAPTOR_GRAPH_MARK_DECLARED set, or be implied by the start/end of 825 * the data in other syntaxes, and the bit will be unset. 826 */ 827 typedef void (*raptor_graph_mark_handler)(void *user_data, raptor_uri *graph, int flags); 828 829 /** 830 * raptor_generate_bnodeid_handler: 831 * @user_data: user data 832 * @user_bnodeid: a user-specified ID or NULL if none available. 833 * 834 * Generate a blank node identifier handler function. 835 * 836 * Return value: new blank node ID to use 837 */ 838 typedef unsigned char* (*raptor_generate_bnodeid_handler)(void *user_data, unsigned char* user_bnodeid); 839 840 /** 841 * raptor_namespace_handler: 842 * @user_data: user data 843 * @nspace: #raptor_namespace declared 844 * 845 * XML Namespace declaration reporting handler set by 846 * raptor_parser_set_namespace_handler(). 847 */ 848 typedef void (*raptor_namespace_handler)(void* user_data, raptor_namespace *nspace); 849 850 851 /** 852 * raptor_www_write_bytes_handler: 853 * @www: WWW object 854 * @userdata: user data 855 * @ptr: data pointer 856 * @size: size of individual item 857 * @nmemb: number of items 858 * 859 * Receiving bytes of data from WWW retrieval handler. 860 * 861 * Set by raptor_www_set_write_bytes_handler(). 862 */ 863 typedef void (*raptor_www_write_bytes_handler)(raptor_www* www, void *userdata, const void *ptr, size_t size, size_t nmemb); 864 865 /** 866 * raptor_www_content_type_handler: 867 * @www: WWW object 868 * @userdata: user data 869 * @content_type: content type seen 870 * 871 * Receiving Content-Type: header from WWW retrieval handler. 872 * 873 * Set by raptor_www_set_content_type_handler(). 874 */ 875 typedef void (*raptor_www_content_type_handler)(raptor_www* www, void *userdata, const char *content_type); 876 877 /** 878 * raptor_www_final_uri_handler: 879 * @www: WWW object 880 * @userdata: user data 881 * @final_uri: final URI seen 882 * 883 * Receiving the final resolved URI from a WWW retrieval 884 * 885 * Set by raptor_www_set_final_uri_handler(). 886 */ 887 typedef void (*raptor_www_final_uri_handler)(raptor_www* www, void *userdata, raptor_uri *final_uri); 888 889 /** 890 * raptor_uri_filter_func: 891 * @user_data: user data 892 * @uri: #raptor_uri URI to check 893 * 894 * Callback function for #raptor_www_set_uri_filter 895 * 896 * Return value: non-0 to filter the URI 897 */ 898 typedef int (*raptor_uri_filter_func)(void *user_data, raptor_uri* uri); 899 900 901 /** 902 * raptor_world_flag: 903 * @RAPTOR_WORLD_FLAG_LIBXML_GENERIC_ERROR_SAVE: if set (non-0 value) - save/restore the libxml generic error handler when raptor library initializes (default set) 904 * @RAPTOR_WORLD_FLAG_LIBXML_STRUCTURED_ERROR_SAVE: if set (non-0 value) - save/restore the libxml structured error handler when raptor library terminates (default set) 905 * @RAPTOR_WORLD_FLAG_URI_INTERNING: if set (non-0 value) - each URI is saved interned in-memory and reused (default set) 906 * @RAPTOR_WORLD_FLAG_WWW_SKIP_INIT_FINISH: if set (non-0 value) the raptor will neither initialise or terminate the lower level WWW library. Usually in raptor initialising either curl_global_init (for libcurl) are called and in raptor cleanup, curl_global_cleanup is called. This flag allows the application finer control over these libraries such as setting other global options or potentially calling and terminating raptor several times. It does mean that applications which use this call must do their own extra work in order to allocate and free all resources to the system. 907 * 908 * Raptor world flags 909 * 910 * These are used by raptor_world_set_flags() to control raptor-wide 911 * options across classes. These must be set before 912 * raptor_world_open() is called explicitly or implicitly (by 913 * creating a raptor object). There is no enumeration function for 914 * these flags because they are not user options and must be set 915 * before the library is initialised. For similar reasons, there is 916 * no get function. 917 * 918 * If any libxml handler saving/restoring is enabled, any existing 919 * handler and context is saved before parsing and restored 920 * afterwards. Otherwise, no saving/restoring is performed. 921 * 922 */ 923 typedef enum { 924 RAPTOR_WORLD_FLAG_LIBXML_GENERIC_ERROR_SAVE = 1, 925 RAPTOR_WORLD_FLAG_LIBXML_STRUCTURED_ERROR_SAVE = 2, 926 RAPTOR_WORLD_FLAG_URI_INTERNING = 3, 927 RAPTOR_WORLD_FLAG_WWW_SKIP_INIT_FINISH = 4 928 } raptor_world_flag; 929 930 931 /** 932 * raptor_data_compare_arg_handler: 933 * @data1: first object 934 * @data2: second object 935 * @user_data: user data argument 936 * 937 * Function to compare two data objects with a user data argument 938 * 939 * Designed to be used with raptor_sort_r() and compatible functions 940 * such as raptor_sequence_sort_r() which uses it. 941 * 942 * Return value: compare value <0 if @data1 is before @data2, =0 if equal, >0 if @data1 is after @data2 943 */ 944 typedef int (*raptor_data_compare_arg_handler)(const void *data1, const void *data2, void *user_data); 945 946 947 /** 948 * raptor_data_compare_handler: 949 * @data1: first data object 950 * @data2: second data object 951 * 952 * Function to compare two data objects - signature like strcmp() and function pssed to qsort() 953 * 954 * Designed to be passed into generic data structure constructors 955 * like raptor_new_avltree(). 956 * 957 * Return value: compare value <0 if @data1 is before @data2, =0 if equal, >0 if @data1 is after @data2 958 */ 959 typedef int (*raptor_data_compare_handler)(const void* data1, const void* data2); 960 961 962 /** 963 * raptor_data_malloc_handler: 964 * @size: data size 965 * 966 * Typedef for a function to allocate memory - signature like malloc() 967 * 968 * Designed to be passed into constructors 969 * like raptor_www_fetch_to_string 970 * 971 * Return value: pointer to newly allocated memory or NULL on failure 972 */ 973 typedef void* (*raptor_data_malloc_handler)(size_t size); 974 975 976 /** 977 * raptor_data_free_handler: 978 * @data: data object or NULL 979 * 980 * Typedef for function to free a data object - signature like free() 981 * 982 * Designed to be passed into generic data structure constructors 983 * like raptor_new_avltree(). If @data is NULL, nothing should be done. 984 */ 985 typedef void (*raptor_data_free_handler)(void* data); 986 987 988 /** 989 * raptor_data_context_free_handler: 990 * @context: context data for the free function 991 * @object: object to free 992 * 993 * Handler function for freeing a sequence item with a contextual pointer. 994 * 995 * Set by raptor_new_sequence_with_context(). 996 */ 997 typedef void (*raptor_data_context_free_handler)(void* context, void* object); 998 999 /** 1000 * raptor_data_print_handler: 1001 * @object: object to print 1002 * @fh: FILE* to print to 1003 * 1004 * Handler function for printing an object to a stream. 1005 * 1006 * Set by raptor_new_sequence() 1007 * 1008 * Return value: non-0 on failure 1009 */ 1010 typedef int (*raptor_data_print_handler)(void *object, FILE *fh); 1011 1012 /** 1013 * raptor_data_context_print_handler: 1014 * @context: context data for the print function 1015 * @object: object to print 1016 * @fh: FILE* to print to 1017 * 1018 * Function function for printing an object with data context to a stream. 1019 * 1020 * Set by raptor_new_sequence_with_context() 1021 * 1022 * Return value: non-0 on failure 1023 */ 1024 typedef int (*raptor_data_context_print_handler)(void *context, void *object, FILE *fh); 1025 1026 /** 1027 * raptor_stringbuffer: 1028 * 1029 * Raptor string buffer class 1030 */ 1031 typedef struct raptor_stringbuffer_s raptor_stringbuffer; 1032 1033 1034 /* Public functions */ 1035 1036 #define raptor_new_world() raptor_new_world_internal(RAPTOR_VERSION) 1037 /* The real target of the raptor_new_world() macro */ 1038 RAPTOR_API 1039 raptor_world *raptor_new_world_internal(unsigned int version_decimal); 1040 RAPTOR_API 1041 int raptor_world_open(raptor_world* world); 1042 RAPTOR_API 1043 void raptor_free_world(raptor_world* world); 1044 RAPTOR_API 1045 int raptor_world_set_libxslt_security_preferences(raptor_world *world, void *security_preferences); 1046 RAPTOR_API 1047 int raptor_world_set_flag(raptor_world *world, raptor_world_flag flag, int value); 1048 RAPTOR_API 1049 int raptor_world_set_log_handler(raptor_world *world, void *user_data, raptor_log_handler handler); 1050 RAPTOR_API 1051 void raptor_world_set_generate_bnodeid_handler(raptor_world* world, void *user_data, raptor_generate_bnodeid_handler handler); 1052 RAPTOR_API 1053 unsigned char* raptor_world_generate_bnodeid(raptor_world *world); 1054 RAPTOR_API 1055 void raptor_world_set_generate_bnodeid_parameters(raptor_world* world, char *prefix, int base); 1056 RAPTOR_API 1057 const char* raptor_log_level_get_label(raptor_log_level level); 1058 RAPTOR_API 1059 const char* raptor_domain_get_label(raptor_domain domain); 1060 1061 /* Names */ 1062 RAPTOR_API 1063 int raptor_world_is_parser_name(raptor_world* world, const char *name); 1064 RAPTOR_API 1065 const char* raptor_world_guess_parser_name(raptor_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier); 1066 RAPTOR_API 1067 int raptor_world_is_serializer_name(raptor_world* world, const char *name); 1068 1069 /* Syntax descriptions */ 1070 RAPTOR_API 1071 int raptor_world_get_parsers_count(raptor_world* world); 1072 RAPTOR_API 1073 int raptor_world_get_serializers_count(raptor_world* world); 1074 RAPTOR_API 1075 const raptor_syntax_description* raptor_world_get_parser_description(raptor_world* world, unsigned int counter); 1076 RAPTOR_API 1077 const raptor_syntax_description* raptor_world_get_serializer_description(raptor_world* world, unsigned int counter); 1078 RAPTOR_API 1079 int raptor_syntax_description_validate(raptor_syntax_description* desc); 1080 1081 RAPTOR_API 1082 raptor_option raptor_world_get_option_from_uri(raptor_world* world, raptor_uri *uri); 1083 1084 1085 /* Term Class */ 1086 RAPTOR_API 1087 raptor_term* raptor_new_term_from_uri(raptor_world* world, raptor_uri* uri); 1088 RAPTOR_API 1089 raptor_term* raptor_new_term_from_counted_uri_string(raptor_world* world, const unsigned char *uri_string, size_t length); 1090 RAPTOR_API 1091 raptor_term* raptor_new_term_from_uri_string(raptor_world* world, const unsigned char *uri_string); 1092 RAPTOR_API 1093 raptor_term* raptor_new_term_from_literal(raptor_world* world, const unsigned char* literal, raptor_uri* datatype, const unsigned char* language); 1094 RAPTOR_API 1095 raptor_term* raptor_new_term_from_counted_literal(raptor_world* world, const unsigned char* literal, size_t literal_len, raptor_uri* datatype, const unsigned char* language, unsigned char language_len); 1096 RAPTOR_API 1097 raptor_term* raptor_new_term_from_blank(raptor_world* world, const unsigned char* blank); 1098 RAPTOR_API 1099 raptor_term* raptor_new_term_from_counted_blank(raptor_world* world, const unsigned char* blank, size_t length); 1100 RAPTOR_API 1101 raptor_term* raptor_new_term_from_counted_string(raptor_world* world, unsigned char* string, size_t length); 1102 RAPTOR_API 1103 raptor_term* raptor_term_copy(raptor_term* term); 1104 RAPTOR_API 1105 int raptor_term_compare(const raptor_term *t1, const raptor_term *t2); 1106 RAPTOR_API 1107 int raptor_term_equals(raptor_term* t1, raptor_term* t2); 1108 RAPTOR_API 1109 void raptor_free_term(raptor_term *term); 1110 1111 RAPTOR_API 1112 unsigned char* raptor_term_to_counted_string(raptor_term *term, size_t* len_p); 1113 RAPTOR_API 1114 unsigned char* raptor_term_to_string(raptor_term *term); 1115 RAPTOR_API 1116 int raptor_term_escaped_write(const raptor_term *term, unsigned int flags, raptor_iostream* iostr); 1117 RAPTOR_API RAPTOR_DEPRECATED 1118 int raptor_term_ntriples_write(const raptor_term *term, raptor_iostream* iostr); 1119 RAPTOR_API 1120 int raptor_uri_turtle_write(raptor_world *world, raptor_iostream* iostr, raptor_uri* uri, raptor_namespace_stack *nstack, raptor_uri *base_uri); 1121 RAPTOR_API 1122 int raptor_term_turtle_write(raptor_iostream* iostr, raptor_term* term, raptor_namespace_stack *nstack, raptor_uri *base_uri); 1123 RAPTOR_API 1124 unsigned char* raptor_uri_to_turtle_counted_string(raptor_world *world, raptor_uri* uri, raptor_namespace_stack *nstack, raptor_uri *base_uri, size_t *len_p); 1125 RAPTOR_API 1126 unsigned char* raptor_uri_to_turtle_string(raptor_world *world, raptor_uri* uri, raptor_namespace_stack *nstack, raptor_uri *base_uri); 1127 RAPTOR_API 1128 unsigned char* raptor_term_to_turtle_counted_string(raptor_term* term, raptor_namespace_stack *nstack, raptor_uri *base_uri, size_t *len_p); 1129 RAPTOR_API 1130 unsigned char* raptor_term_to_turtle_string(raptor_term* term, raptor_namespace_stack *nstack, raptor_uri *base_uri); 1131 1132 1133 /* Statement Class */ 1134 RAPTOR_API 1135 void raptor_statement_init(raptor_statement *statement, raptor_world *world); 1136 RAPTOR_API 1137 void raptor_statement_clear(raptor_statement *statement); 1138 RAPTOR_API 1139 raptor_statement* raptor_new_statement(raptor_world *world); 1140 RAPTOR_API 1141 raptor_statement* raptor_new_statement_from_nodes(raptor_world* world, raptor_term *subject, raptor_term *predicate, raptor_term *object, raptor_term *graph); 1142 RAPTOR_API 1143 raptor_statement* raptor_statement_copy(raptor_statement *statement); 1144 RAPTOR_API 1145 void raptor_free_statement(raptor_statement *statement); 1146 1147 RAPTOR_API 1148 int raptor_statement_print(const raptor_statement * statement, FILE *stream); 1149 RAPTOR_API 1150 int raptor_statement_print_as_ntriples(const raptor_statement * statement, FILE *stream); 1151 RAPTOR_API 1152 int raptor_statement_compare(const raptor_statement *s1, const raptor_statement *s2); 1153 RAPTOR_API 1154 int raptor_statement_equals(const raptor_statement* s1, const raptor_statement* s2); 1155 1156 1157 /* Parser Class */ 1158 RAPTOR_API 1159 raptor_parser* raptor_new_parser(raptor_world* world, const char *name); 1160 RAPTOR_API 1161 raptor_parser* raptor_new_parser_for_content(raptor_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier); 1162 RAPTOR_API 1163 void raptor_free_parser(raptor_parser* parser); 1164 1165 /* methods */ 1166 1167 /* Handlers */ 1168 RAPTOR_API 1169 void raptor_parser_set_statement_handler(raptor_parser* parser, void *user_data, raptor_statement_handler handler); 1170 RAPTOR_API 1171 void raptor_parser_set_graph_mark_handler(raptor_parser* parser, void *user_data, raptor_graph_mark_handler handler); 1172 RAPTOR_API 1173 void raptor_parser_set_namespace_handler(raptor_parser* parser, void *user_data, raptor_namespace_handler handler); 1174 RAPTOR_API 1175 void raptor_parser_set_uri_filter(raptor_parser* parser, raptor_uri_filter_func filter, void* user_data); 1176 RAPTOR_API 1177 raptor_locator* raptor_parser_get_locator(raptor_parser* rdf_parser); 1178 1179 1180 /* Parsing functions */ 1181 RAPTOR_API 1182 int raptor_parser_parse_start(raptor_parser *rdf_parser, raptor_uri *uri); 1183 RAPTOR_API 1184 int raptor_parser_parse_chunk(raptor_parser* rdf_parser, const unsigned char *buffer, size_t len, int is_end); 1185 RAPTOR_API 1186 int raptor_parser_parse_file_stream(raptor_parser* rdf_parser, FILE *stream, const char *filename, raptor_uri *base_uri); 1187 RAPTOR_API 1188 int raptor_parser_parse_file(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri); 1189 RAPTOR_API 1190 int raptor_parser_parse_uri(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri); 1191 RAPTOR_API 1192 int raptor_parser_parse_uri_with_connection(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri, void *connection); 1193 RAPTOR_API 1194 int raptor_parser_parse_iostream(raptor_parser* rdf_parser, raptor_iostream *iostr, raptor_uri *base_uri); 1195 RAPTOR_API 1196 void raptor_parser_parse_abort(raptor_parser* rdf_parser); 1197 RAPTOR_API 1198 const char* raptor_parser_get_name(raptor_parser *rdf_parser); 1199 RAPTOR_API 1200 const raptor_syntax_description* raptor_parser_get_description(raptor_parser *rdf_parser); 1201 1202 /* parser option methods */ 1203 RAPTOR_API 1204 int raptor_parser_set_option(raptor_parser *parser, raptor_option option, const char* string, int integer); 1205 RAPTOR_API 1206 int raptor_parser_get_option(raptor_parser *parser, raptor_option option, char** string_p, int* integer_p); 1207 1208 /* parser utility methods */ 1209 RAPTOR_API 1210 const char* raptor_parser_get_accept_header(raptor_parser* rdf_parser); 1211 RAPTOR_API 1212 raptor_world* raptor_parser_get_world(raptor_parser* rdf_parser); 1213 RAPTOR_API 1214 raptor_uri* raptor_parser_get_graph(raptor_parser* rdf_parser); 1215 1216 1217 /* Locator Class */ 1218 /* methods */ 1219 RAPTOR_API 1220 int raptor_locator_print(raptor_locator* locator, FILE *stream); 1221 RAPTOR_API 1222 int raptor_locator_format(char *buffer, size_t length, raptor_locator* locator); 1223 RAPTOR_API 1224 int raptor_locator_line(raptor_locator *locator); 1225 RAPTOR_API 1226 int raptor_locator_column(raptor_locator *locator); 1227 RAPTOR_API 1228 int raptor_locator_byte(raptor_locator *locator); 1229 RAPTOR_API 1230 const char* raptor_locator_file(raptor_locator *locator); 1231 RAPTOR_API 1232 const char* raptor_locator_uri(raptor_locator *locator); 1233 1234 1235 /* Serializer Class */ 1236 RAPTOR_API 1237 raptor_serializer* raptor_new_serializer(raptor_world* world, const char *name); 1238 RAPTOR_API 1239 void raptor_free_serializer(raptor_serializer* rdf_serializer); 1240 1241 /* methods */ 1242 RAPTOR_API 1243 int raptor_serializer_start_to_iostream(raptor_serializer *rdf_serializer, raptor_uri *uri, raptor_iostream *iostream); 1244 RAPTOR_API 1245 int raptor_serializer_start_to_filename(raptor_serializer *rdf_serializer, const char *filename); 1246 RAPTOR_API 1247 int raptor_serializer_start_to_string(raptor_serializer *rdf_serializer, raptor_uri *uri, void **string_p, size_t *length_p); 1248 RAPTOR_API 1249 int raptor_serializer_start_to_file_handle(raptor_serializer *rdf_serializer, raptor_uri *uri, FILE *fh); 1250 RAPTOR_API 1251 int raptor_serializer_set_namespace(raptor_serializer* rdf_serializer, raptor_uri *uri, const unsigned char *prefix); 1252 RAPTOR_API 1253 int raptor_serializer_set_namespace_from_namespace(raptor_serializer* rdf_serializer, raptor_namespace *nspace); 1254 RAPTOR_API 1255 int raptor_serializer_serialize_statement(raptor_serializer* rdf_serializer, raptor_statement *statement); 1256 RAPTOR_API 1257 int raptor_serializer_serialize_end(raptor_serializer *rdf_serializer); 1258 RAPTOR_API 1259 raptor_iostream* raptor_serializer_get_iostream(raptor_serializer *serializer); 1260 RAPTOR_API 1261 raptor_locator* raptor_serializer_get_locator(raptor_serializer *rdf_serializer); 1262 RAPTOR_API 1263 int raptor_serializer_flush(raptor_serializer *rdf_serializer); 1264 RAPTOR_API 1265 const raptor_syntax_description* raptor_serializer_get_description(raptor_serializer *rdf_serializer); 1266 1267 /* serializer option methods */ 1268 RAPTOR_API 1269 int raptor_serializer_set_option(raptor_serializer *serializer, raptor_option option, const char* string, int integer); 1270 RAPTOR_API 1271 int raptor_serializer_get_option(raptor_serializer *serializer, raptor_option option, char** string_p, int* integer_p); 1272 1273 /* utility methods */ 1274 RAPTOR_API 1275 raptor_world* raptor_serializer_get_world(raptor_serializer* rdf_serializer); 1276 1277 1278 /* memory functions */ 1279 RAPTOR_API 1280 void raptor_free_memory(void *ptr); 1281 RAPTOR_API 1282 void* raptor_alloc_memory(size_t size); 1283 RAPTOR_API 1284 void* raptor_calloc_memory(size_t nmemb, size_t size); 1285 1286 1287 /* URI Class */ 1288 RAPTOR_API 1289 raptor_uri* raptor_new_uri_from_counted_string(raptor_world* world, const unsigned char *uri_string, size_t length); 1290 RAPTOR_API 1291 raptor_uri* raptor_new_uri(raptor_world* world, const unsigned char *uri_string); 1292 RAPTOR_API 1293 raptor_uri* raptor_new_uri_from_uri_local_name(raptor_world* world, raptor_uri *uri, const unsigned char *local_name); 1294 RAPTOR_API 1295 raptor_uri* raptor_new_uri_relative_to_base(raptor_world* world, raptor_uri *base_uri, const unsigned char *uri_string); 1296 RAPTOR_API 1297 raptor_uri* raptor_new_uri_relative_to_base_counted(raptor_world* world, raptor_uri *base_uri, const unsigned char *uri_string, size_t uri_len); 1298 RAPTOR_API 1299 raptor_uri* raptor_new_uri_from_id(raptor_world* world, raptor_uri *base_uri, const unsigned char *id); 1300 RAPTOR_API 1301 raptor_uri* raptor_new_uri_from_uri_or_file_string(raptor_world* world, raptor_uri* base_uri, const unsigned char* uri_or_file_string); 1302 RAPTOR_API 1303 raptor_uri* raptor_new_uri_for_rdf_concept(raptor_world* world, const unsigned char *name); 1304 RAPTOR_API 1305 raptor_uri* raptor_new_uri_for_xmlbase(raptor_uri* old_uri); 1306 RAPTOR_API 1307 raptor_uri* raptor_new_uri_for_retrieval(raptor_uri* old_uri); 1308 RAPTOR_API 1309 void raptor_free_uri(raptor_uri *uri); 1310 1311 /* methods */ 1312 RAPTOR_API 1313 int raptor_uri_equals(raptor_uri* uri1, raptor_uri* uri2); 1314 RAPTOR_API 1315 int raptor_uri_compare(raptor_uri* uri1, raptor_uri* uri2); 1316 RAPTOR_API 1317 raptor_uri* raptor_uri_copy(raptor_uri *uri); 1318 RAPTOR_API 1319 unsigned char* raptor_uri_as_string(raptor_uri *uri); 1320 RAPTOR_API 1321 unsigned char* raptor_uri_as_counted_string(raptor_uri *uri, size_t* len_p); 1322 RAPTOR_API 1323 unsigned char* raptor_uri_to_relative_counted_uri_string(raptor_uri *base_uri, raptor_uri *reference_uri, size_t *length_p); 1324 RAPTOR_API 1325 unsigned char* raptor_uri_to_relative_uri_string(raptor_uri *base_uri, raptor_uri *reference_uri); 1326 RAPTOR_API 1327 int raptor_uri_print(const raptor_uri* uri, FILE *stream); 1328 RAPTOR_API 1329 unsigned char* raptor_uri_to_counted_string(raptor_uri *uri, size_t *len_p); 1330 RAPTOR_API 1331 unsigned char* raptor_uri_to_string(raptor_uri *uri); 1332 RAPTOR_API 1333 raptor_world* raptor_uri_get_world(raptor_uri *uri); 1334 RAPTOR_API 1335 int raptor_uri_file_exists(raptor_uri* uri); 1336 RAPTOR_API 1337 int raptor_uri_escaped_write(raptor_uri* uri, raptor_uri* base_uri, unsigned int flags, raptor_iostream *iostr); 1338 1339 /* XML utility functions */ 1340 RAPTOR_API 1341 int raptor_xml_escape_string_any(raptor_world* world, const unsigned char *string, size_t len, unsigned char *buffer, size_t length, char quote, int xml_version); 1342 RAPTOR_API 1343 int raptor_xml_escape_string_any_write(const unsigned char *string, size_t len, char quote, int xml_version, raptor_iostream* iostr); 1344 RAPTOR_API 1345 int raptor_xml_escape_string(raptor_world *world, const unsigned char *string, size_t len, unsigned char *buffer, size_t length, char quote); 1346 RAPTOR_API 1347 int raptor_xml_escape_string_write(const unsigned char *string, size_t len, char quote, raptor_iostream* iostr); 1348 RAPTOR_API 1349 int raptor_xml_name_check(const unsigned char *string, size_t length, int xml_version); 1350 1351 1352 /* portable vsnprintf utility function */ 1353 RAPTOR_API RAPTOR_DEPRECATED 1354 char* raptor_vsnprintf(const char *format, va_list arguments) RAPTOR_PRINTF_FORMAT(1, 0); 1355 RAPTOR_API 1356 int raptor_vsnprintf2(char *buffer, size_t size, const char *format, va_list arguments) RAPTOR_PRINTF_FORMAT(3, 0); 1357 RAPTOR_API 1358 int raptor_snprintf(char *buffer, size_t size, const char *format, ...) RAPTOR_PRINTF_FORMAT(3, 4); 1359 RAPTOR_API 1360 int raptor_vasprintf(char **ret, const char *format, va_list arguments) RAPTOR_PRINTF_FORMAT(2, 0); 1361 1362 /* RFC2396 URI resolving functions */ 1363 RAPTOR_API 1364 size_t raptor_uri_resolve_uri_reference(const unsigned char *base_uri, const unsigned char *reference_uri, unsigned char* buffer, size_t length); 1365 1366 /* URI String utility functions */ 1367 RAPTOR_API 1368 unsigned char* raptor_uri_counted_filename_to_uri_string(const char *filename, size_t filename_len); 1369 RAPTOR_API 1370 unsigned char* raptor_uri_filename_to_uri_string(const char *filename); 1371 RAPTOR_API 1372 int raptor_uri_filename_exists(const unsigned char* path); 1373 RAPTOR_API 1374 char* raptor_uri_uri_string_to_filename(const unsigned char *uri_string); 1375 RAPTOR_API 1376 char* raptor_uri_uri_string_to_filename_fragment(const unsigned char *uri_string, unsigned char **fragment_p); 1377 RAPTOR_API 1378 int raptor_uri_uri_string_is_file_uri(const unsigned char* uri_string); 1379 RAPTOR_API 1380 int raptor_stringbuffer_append_uri_escaped_counted_string(raptor_stringbuffer* sb, const char* string, size_t length, int space_is_plus); 1381 RAPTOR_API 1382 char* raptor_uri_uri_string_to_counted_filename_fragment(const unsigned char *uri_string, size_t* len_p, unsigned char **fragment_p, size_t* fragment_len_p); 1383 RAPTOR_API 1384 int raptor_uri_uri_string_is_absolute(const unsigned char* uri_string); 1385 1386 1387 /** 1388 * RAPTOR_RDF_MS_URI: 1389 * 1390 * RDF Namespace URI (rdf:). 1391 * 1392 * Copy with raptor_uri_copy() to use. 1393 */ 1394 #define RAPTOR_RDF_MS_URI raptor_rdf_namespace_uri 1395 1396 /** 1397 * RAPTOR_RDF_SCHEMA_URI: 1398 * 1399 * RDF Schema Namespace URI (rdfs:). 1400 * 1401 * Copy with raptor_uri_copy() to use. 1402 */ 1403 #define RAPTOR_RDF_SCHEMA_URI raptor_rdf_schema_namespace_uri 1404 1405 /** 1406 * RAPTOR_XMLSCHEMA_DATATYPES_URI: 1407 * 1408 * XML Schema Datatypes URI (xsd:). 1409 * 1410 * Copy with raptor_uri_copy() to use. 1411 */ 1412 #define RAPTOR_XMLSCHEMA_DATATYPES_URI raptor_xmlschema_datatypes_namespace_uri 1413 1414 /** 1415 * RAPTOR_OWL_URI: 1416 * 1417 * OWL Namespace URI (owl:). 1418 * 1419 * Copy with raptor_uri_copy() to use. 1420 */ 1421 #define RAPTOR_OWL_URI raptor_owl_namespace_uri 1422 1423 1424 /* raptor_www */ 1425 RAPTOR_API 1426 raptor_www* raptor_new_www(raptor_world* world); 1427 RAPTOR_API 1428 raptor_www* raptor_new_www_with_connection(raptor_world* world, void* connection); 1429 RAPTOR_API 1430 void raptor_free_www(raptor_www *www); 1431 RAPTOR_API 1432 int raptor_www_set_ssl_cert_options(raptor_www* www, const char* cert_filename, const char* cert_type, const char* cert_passphrase); 1433 RAPTOR_API 1434 int raptor_www_set_ssl_verify_options(raptor_www* www, int verify_peer, int verify_host); 1435 RAPTOR_API 1436 void raptor_www_set_user_agent(raptor_www *www, const char *user_agent); 1437 RAPTOR_API 1438 void raptor_www_set_proxy(raptor_www *www, const char *proxy); 1439 RAPTOR_API 1440 void raptor_www_set_http_accept(raptor_www *www, const char *value); 1441 RAPTOR_API 1442 void raptor_www_set_write_bytes_handler(raptor_www *www, raptor_www_write_bytes_handler handler, void *user_data); 1443 RAPTOR_API 1444 void raptor_www_set_content_type_handler(raptor_www *www, raptor_www_content_type_handler handler, void *user_data); 1445 RAPTOR_API 1446 void raptor_www_set_final_uri_handler(raptor_www* www, raptor_www_final_uri_handler handler, void *user_data); 1447 RAPTOR_API 1448 void raptor_www_set_uri_filter(raptor_www* www, raptor_uri_filter_func filter, void* user_data); 1449 RAPTOR_API 1450 void raptor_www_set_connection_timeout(raptor_www* www, int timeout); 1451 RAPTOR_API 1452 int raptor_www_set_http_cache_control(raptor_www* www, const char* cache_control); 1453 RAPTOR_API 1454 int raptor_www_fetch(raptor_www *www, raptor_uri *uri); 1455 RAPTOR_API 1456 int raptor_www_fetch_to_string(raptor_www *www, raptor_uri *uri, void **string_p, size_t *length_p, raptor_data_malloc_handler const malloc_handler); 1457 RAPTOR_API 1458 void* raptor_www_get_connection(raptor_www *www); 1459 RAPTOR_API 1460 void raptor_www_abort(raptor_www *www, const char *reason); 1461 RAPTOR_API 1462 raptor_uri* raptor_www_get_final_uri(raptor_www* www); 1463 1464 1465 /* XML QNames Class */ 1466 RAPTOR_API 1467 raptor_qname* raptor_new_qname(raptor_namespace_stack *nstack, const unsigned char *name, const unsigned char *value); 1468 RAPTOR_API 1469 raptor_qname* raptor_new_qname_from_namespace_local_name(raptor_world* world, raptor_namespace *ns, const unsigned char *local_name, const unsigned char *value); 1470 1471 /* methods */ 1472 RAPTOR_API 1473 raptor_qname* raptor_qname_copy(raptor_qname *qname); 1474 RAPTOR_API 1475 void raptor_free_qname(raptor_qname* name); 1476 RAPTOR_API 1477 int raptor_qname_equal(raptor_qname *name1, raptor_qname *name2); 1478 RAPTOR_API 1479 unsigned char* raptor_qname_to_counted_name(raptor_qname *qname, size_t* length_p); 1480 RAPTOR_API 1481 const raptor_namespace* raptor_qname_get_namespace(raptor_qname* name); 1482 RAPTOR_API 1483 const unsigned char* raptor_qname_get_local_name(raptor_qname* name); 1484 RAPTOR_API 1485 const unsigned char* raptor_qname_get_value(raptor_qname* name); 1486 RAPTOR_API 1487 const unsigned char* raptor_qname_get_counted_value(raptor_qname* name, size_t* length_p); 1488 RAPTOR_API 1489 int raptor_qname_write(raptor_qname *qname, raptor_iostream* iostr); 1490 1491 /* QName String utility functions */ 1492 RAPTOR_API 1493 raptor_uri* raptor_qname_string_to_uri(raptor_namespace_stack *nstack, const unsigned char *name, size_t name_len); 1494 RAPTOR_API 1495 unsigned char* raptor_qname_format_as_xml(const raptor_qname *qname, size_t *length_p); 1496 1497 /* XML Namespaces Stack class */ 1498 RAPTOR_API 1499 raptor_namespace* raptor_new_namespace_from_uri(raptor_namespace_stack *nstack, const unsigned char *prefix, raptor_uri* ns_uri, int depth); 1500 RAPTOR_API 1501 raptor_namespace_stack* raptor_new_namespaces(raptor_world* world, int defaults); 1502 RAPTOR_API 1503 int raptor_namespaces_init(raptor_world* world, raptor_namespace_stack *nstack, int defaults); 1504 RAPTOR_API 1505 void raptor_namespaces_clear(raptor_namespace_stack *nstack); 1506 RAPTOR_API 1507 void raptor_free_namespaces(raptor_namespace_stack *nstack); 1508 1509 /* methods */ 1510 RAPTOR_API 1511 void raptor_namespaces_start_namespace(raptor_namespace_stack *nstack, raptor_namespace *nspace); 1512 RAPTOR_API 1513 int raptor_namespaces_start_namespace_full(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth); 1514 RAPTOR_API 1515 void raptor_namespaces_end_for_depth(raptor_namespace_stack *nstack, int depth); 1516 RAPTOR_API 1517 raptor_namespace* raptor_namespaces_get_default_namespace(raptor_namespace_stack *nstack); 1518 RAPTOR_API 1519 raptor_namespace* raptor_namespaces_find_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, int prefix_length); 1520 RAPTOR_API 1521 raptor_namespace* raptor_namespaces_find_namespace_by_uri(raptor_namespace_stack *nstack, raptor_uri *ns_uri); 1522 RAPTOR_API 1523 int raptor_namespaces_namespace_in_scope(raptor_namespace_stack *nstack, const raptor_namespace *nspace); 1524 RAPTOR_API 1525 raptor_qname* raptor_new_qname_from_namespace_uri(raptor_namespace_stack *nstack, raptor_uri *uri, int xml_version); 1526 1527 1528 /* XML Namespace Class */ 1529 RAPTOR_API 1530 raptor_namespace* raptor_new_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth); 1531 RAPTOR_API 1532 void raptor_free_namespace(raptor_namespace *ns); 1533 RAPTOR_API 1534 int raptor_namespace_stack_start_namespace(raptor_namespace_stack *nstack, raptor_namespace *ns, int new_depth); 1535 RAPTOR_API 1536 raptor_uri* raptor_namespace_get_uri(const raptor_namespace *ns); 1537 RAPTOR_API 1538 const unsigned char* raptor_namespace_get_prefix(const raptor_namespace *ns); 1539 RAPTOR_API 1540 const unsigned char* raptor_namespace_get_counted_prefix(const raptor_namespace *ns, size_t *length_p); 1541 RAPTOR_API 1542 unsigned char* raptor_namespace_format_as_xml(const raptor_namespace *ns, size_t *length_p); 1543 RAPTOR_API 1544 int raptor_namespace_write(raptor_namespace *ns, raptor_iostream* iostr); 1545 1546 /* namespace string utility function */ 1547 RAPTOR_API 1548 int raptor_xml_namespace_string_parse(const unsigned char *string, unsigned char **prefix, unsigned char **uri_string); 1549 1550 /* Sequence class */ 1551 /** 1552 * raptor_sequence: 1553 * 1554 * Raptor sequence class 1555 */ 1556 typedef struct raptor_sequence_s raptor_sequence; 1557 1558 /* Sequence Class */ 1559 RAPTOR_API 1560 raptor_sequence* raptor_new_sequence(raptor_data_free_handler free_handler, raptor_data_print_handler print_handler); 1561 RAPTOR_API 1562 raptor_sequence* raptor_new_sequence_with_context(raptor_data_context_free_handler free_handler, raptor_data_context_print_handler print_handler, void* handler_context); 1563 RAPTOR_API 1564 void raptor_free_sequence(raptor_sequence* seq); 1565 1566 /* methods */ 1567 RAPTOR_API 1568 int raptor_sequence_size(raptor_sequence* seq); 1569 RAPTOR_API 1570 int raptor_sequence_set_at(raptor_sequence* seq, int idx, void *data); 1571 RAPTOR_API 1572 int raptor_sequence_push(raptor_sequence* seq, void *data); 1573 RAPTOR_API 1574 int raptor_sequence_shift(raptor_sequence* seq, void *data); 1575 RAPTOR_API 1576 void* raptor_sequence_get_at(raptor_sequence* seq, int idx); 1577 RAPTOR_API 1578 void* raptor_sequence_pop(raptor_sequence* seq); 1579 RAPTOR_API 1580 void* raptor_sequence_unshift(raptor_sequence* seq); 1581 RAPTOR_API 1582 void* raptor_sequence_delete_at(raptor_sequence* seq, int idx); 1583 1584 RAPTOR_API 1585 void raptor_sequence_sort(raptor_sequence* seq, raptor_data_compare_handler compare); 1586 RAPTOR_API 1587 void raptor_sequence_sort_r(raptor_sequence* seq, raptor_data_compare_arg_handler compare, void* user_data); 1588 RAPTOR_API 1589 int raptor_sequence_swap(raptor_sequence* seq, int i, int j); 1590 RAPTOR_API 1591 int raptor_sequence_reverse(raptor_sequence* seq, int start_index, int length); 1592 RAPTOR_API 1593 int raptor_sequence_next_permutation(raptor_sequence *seq, raptor_data_compare_handler compare); 1594 1595 /* helper for printing sequences of strings */ 1596 RAPTOR_API 1597 int raptor_sequence_print(raptor_sequence* seq, FILE* fh); 1598 RAPTOR_API 1599 int raptor_sequence_join(raptor_sequence* dest, raptor_sequence *src); 1600 1601 1602 /* Unicode and UTF8 */ 1603 1604 /** 1605 * raptor_unichar: 1606 * 1607 * raptor Unicode codepoint 1608 */ 1609 typedef unsigned long raptor_unichar; 1610 RAPTOR_API 1611 int raptor_unicode_utf8_string_put_char(raptor_unichar c, unsigned char *output, size_t length); 1612 RAPTOR_API 1613 int raptor_unicode_utf8_string_get_char(const unsigned char *input, size_t length, raptor_unichar *output); 1614 RAPTOR_API 1615 int raptor_unicode_is_xml11_namestartchar(raptor_unichar c); 1616 RAPTOR_API 1617 int raptor_unicode_is_xml10_namestartchar(raptor_unichar c); 1618 RAPTOR_API 1619 int raptor_unicode_is_xml11_namechar(raptor_unichar c); 1620 RAPTOR_API 1621 int raptor_unicode_is_xml10_namechar(raptor_unichar c); 1622 RAPTOR_API 1623 int raptor_unicode_check_utf8_string(const unsigned char *string, size_t length); 1624 RAPTOR_API 1625 int raptor_unicode_utf8_strlen(const unsigned char *string, size_t length); 1626 RAPTOR_API 1627 size_t raptor_unicode_utf8_substr(unsigned char* dest, size_t* dest_length_p, const unsigned char* src, size_t src_length, int startingLoc, int length); 1628 1629 /* Stringbuffer Class */ 1630 RAPTOR_API 1631 raptor_stringbuffer* raptor_new_stringbuffer(void); 1632 RAPTOR_API 1633 void raptor_free_stringbuffer(raptor_stringbuffer *stringbuffer); 1634 1635 /* methods */ 1636 RAPTOR_API 1637 int raptor_stringbuffer_append_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy); 1638 RAPTOR_API 1639 int raptor_stringbuffer_append_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy); 1640 RAPTOR_API 1641 int raptor_stringbuffer_append_decimal(raptor_stringbuffer* stringbuffer, int integer); 1642 RAPTOR_API 1643 int raptor_stringbuffer_append_hexadecimal(raptor_stringbuffer* stringbuffer, int hex); 1644 RAPTOR_API 1645 int raptor_stringbuffer_append_stringbuffer(raptor_stringbuffer* stringbuffer, raptor_stringbuffer* append); 1646 RAPTOR_API 1647 int raptor_stringbuffer_prepend_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy); 1648 RAPTOR_API 1649 int raptor_stringbuffer_prepend_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy); 1650 RAPTOR_API 1651 unsigned char* raptor_stringbuffer_as_string(raptor_stringbuffer* stringbuffer); 1652 RAPTOR_API 1653 size_t raptor_stringbuffer_length(raptor_stringbuffer* stringbuffer); 1654 RAPTOR_API 1655 int raptor_stringbuffer_copy_to_string(raptor_stringbuffer* stringbuffer, unsigned char *string, size_t length); 1656 1657 /** 1658 * raptor_iostream_init_func: 1659 * @context: stream context data 1660 * 1661 * Handler function for #raptor_iostream initialising. 1662 * 1663 * Return value: non-0 on failure. 1664 */ 1665 typedef int (*raptor_iostream_init_func) (void *context); 1666 1667 /** 1668 * raptor_iostream_finish_func: 1669 * @context: stream context data 1670 * 1671 * Handler function for #raptor_iostream terminating. 1672 * 1673 */ 1674 typedef void (*raptor_iostream_finish_func) (void *context); 1675 1676 /** 1677 * raptor_iostream_write_byte_func 1678 * @context: stream context data 1679 * @byte: byte to write 1680 * 1681 * Handler function for implementing raptor_iostream_write_byte(). 1682 * 1683 * Return value: non-0 on failure. 1684 */ 1685 typedef int (*raptor_iostream_write_byte_func) (void *context, const int byte); 1686 1687 /** 1688 * raptor_iostream_write_bytes_func: 1689 * @context: stream context data 1690 * @ptr: pointer to bytes to write 1691 * @size: size of item 1692 * @nmemb: number of items 1693 * 1694 * Handler function for implementing raptor_iostream_write_bytes(). 1695 * 1696 * Return value: non-0 on failure. 1697 */ 1698 typedef int (*raptor_iostream_write_bytes_func) (void *context, const void *ptr, size_t size, size_t nmemb); 1699 1700 /** 1701 * raptor_iostream_write_end_func: 1702 * @context: stream context data 1703 * 1704 * Handler function for implementing raptor_iostream_write_end(). 1705 * 1706 * Return value: non-0 on failure. 1707 */ 1708 typedef int (*raptor_iostream_write_end_func) (void *context); 1709 1710 /** 1711 * raptor_iostream_read_bytes_func: 1712 * @context: stream context data 1713 * @ptr: pointer to buffer to read into 1714 * @size: size of buffer 1715 * @nmemb: number of items 1716 * 1717 * Handler function for implementing raptor_iostream_read_bytes(). 1718 * 1719 * Return value: number of items read, 0 or < @size on EOF, <0 on failure 1720 */ 1721 typedef int (*raptor_iostream_read_bytes_func) (void *context, void *ptr, size_t size, size_t nmemb); 1722 1723 /** 1724 * raptor_iostream_read_eof_func: 1725 * @context: stream context data 1726 * 1727 * Handler function for implementing raptor_iostream_read_eof(). 1728 * 1729 * Return value: non-0 if EOF 1730 */ 1731 typedef int (*raptor_iostream_read_eof_func) (void *context); 1732 1733 /** 1734 * raptor_iostream_handler: 1735 * @version: interface version. Presently 1 or 2. 1736 * @init: initialisation handler - optional, called at most once (V1) 1737 * @finish: finishing handler - optional, called at most once (V1) 1738 * @write_byte: write byte handler - required (for writing) (V1) 1739 * @write_bytes: write bytes handler - required (for writing) (V1) 1740 * @write_end: write end handler - optional (for writing), called at most once (V1) 1741 * @read_bytes: read bytes handler - required (for reading) (V2) 1742 * @read_eof: read EOF handler - required (for reading) (V2) 1743 * 1744 * I/O stream implementation handler structure. 1745 * 1746 */ 1747 typedef struct { 1748 int version; 1749 1750 /* V1 functions */ 1751 raptor_iostream_init_func init; 1752 raptor_iostream_finish_func finish; 1753 raptor_iostream_write_byte_func write_byte; 1754 raptor_iostream_write_bytes_func write_bytes; 1755 raptor_iostream_write_end_func write_end; 1756 1757 /* V2 functions */ 1758 raptor_iostream_read_bytes_func read_bytes; 1759 raptor_iostream_read_eof_func read_eof; 1760 } raptor_iostream_handler; 1761 1762 1763 /* I/O Stream Class */ 1764 RAPTOR_API 1765 raptor_iostream* raptor_new_iostream_from_handler(raptor_world* world, void *user_data, const raptor_iostream_handler* const handler); 1766 RAPTOR_API 1767 raptor_iostream* raptor_new_iostream_to_sink(raptor_world* world); 1768 RAPTOR_API 1769 raptor_iostream* raptor_new_iostream_to_filename(raptor_world* world, const char *filename); 1770 RAPTOR_API 1771 raptor_iostream* raptor_new_iostream_to_file_handle(raptor_world* world, FILE *handle); 1772 RAPTOR_API 1773 raptor_iostream* raptor_new_iostream_to_string(raptor_world* world, void **string_p, size_t *length_p, raptor_data_malloc_handler const malloc_handler); 1774 RAPTOR_API 1775 raptor_iostream* raptor_new_iostream_from_sink(raptor_world* world); 1776 RAPTOR_API 1777 raptor_iostream* raptor_new_iostream_from_filename(raptor_world* world, const char *filename); 1778 RAPTOR_API 1779 raptor_iostream* raptor_new_iostream_from_file_handle(raptor_world* world, FILE *handle); 1780 RAPTOR_API 1781 raptor_iostream* raptor_new_iostream_from_string(raptor_world* world, void *string, size_t length); 1782 RAPTOR_API 1783 void raptor_free_iostream(raptor_iostream *iostr); 1784 1785 RAPTOR_API 1786 int raptor_iostream_write_bytes(const void *ptr, size_t size, size_t nmemb, raptor_iostream *iostr); 1787 RAPTOR_API 1788 int raptor_iostream_write_byte(const int byte, raptor_iostream *iostr); 1789 RAPTOR_API 1790 int raptor_iostream_write_end(raptor_iostream *iostr); 1791 RAPTOR_API 1792 int raptor_iostream_string_write(const void *string, raptor_iostream *iostr); 1793 RAPTOR_API 1794 int raptor_iostream_counted_string_write(const void *string, size_t len, raptor_iostream *iostr); 1795 RAPTOR_API 1796 unsigned long raptor_iostream_tell(raptor_iostream *iostr); 1797 RAPTOR_API 1798 int raptor_iostream_decimal_write(int integer, raptor_iostream* iostr); 1799 RAPTOR_API 1800 int raptor_iostream_hexadecimal_write(unsigned int integer, int width, raptor_iostream* iostr); 1801 RAPTOR_API 1802 int raptor_stringbuffer_write(raptor_stringbuffer *sb, raptor_iostream* iostr); 1803 RAPTOR_API 1804 int raptor_uri_write(raptor_uri *uri, raptor_iostream *iostr); 1805 RAPTOR_API 1806 int raptor_iostream_read_bytes(void *ptr, size_t size, size_t nmemb, raptor_iostream* iostr); 1807 RAPTOR_API 1808 int raptor_iostream_read_eof(raptor_iostream *iostr); 1809 1810 /* I/O Stream utility functions */ 1811 1812 /** 1813 * raptor_escaped_write_bitflags: 1814 * @RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF : Allow \b \f, 1815 * @RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU : ALlow \t \n \r \u 1816 * @RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8 : Allow UTF-8 for printable U * 1817 * @RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES: Must escape #x00-#x20<>\"{}|^` in URIs 1818 * @RAPTOR_ESCAPED_WRITE_NTRIPLES_LITERAL: N-Triples literal 1819 * @RAPTOR_ESCAPED_WRITE_NTRIPLES_URI: N-Triples URI 1820 * @RAPTOR_ESCAPED_WRITE_SPARQL_LITERAL: SPARQL literal: allows raw UTF8 for printable literals 1821 * @RAPTOR_ESCAPED_WRITE_SPARQL_LONG_LITERAL: SPARQL long literal: no BS-escapes allowed 1822 * @RAPTOR_ESCAPED_WRITE_SPARQL_URI: SPARQL uri: have to escape certain characters 1823 * @RAPTOR_ESCAPED_WRITE_TURTLE_URI: Turtle 2013 URIs (like SPARQL) 1824 * @RAPTOR_ESCAPED_WRITE_TURTLE_LITERAL: Turtle 2013 literals (like SPARQL) 1825 * @RAPTOR_ESCAPED_WRITE_TURTLE_LONG_LITERAL: Turtle 2013 long literals (like SPARQL) 1826 * @RAPTOR_ESCAPED_WRITE_JSON_LITERAL: JSON literals: \b \f \t \r \n and \u \U 1827 * 1828 * Bit flags for raptor_string_escaped_write() and friends. 1829 */ 1830 typedef enum { 1831 RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF = 1, 1832 RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU = 2, 1833 RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8 = 4, 1834 RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES = 8, 1835 1836 /* N-Triples - favour writing \u, \U over UTF8 */ 1837 RAPTOR_ESCAPED_WRITE_NTRIPLES_LITERAL = RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU | RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF, 1838 RAPTOR_ESCAPED_WRITE_NTRIPLES_URI = RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES, 1839 1840 /* SPARQL literal: allows raw UTF8 for printable literals */ 1841 RAPTOR_ESCAPED_WRITE_SPARQL_LITERAL = RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8, 1842 1843 /* SPARQL long literal: no BS-escapes allowed */ 1844 RAPTOR_ESCAPED_WRITE_SPARQL_LONG_LITERAL = RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8, 1845 1846 /* SPARQL uri: have to escape certain characters */ 1847 RAPTOR_ESCAPED_WRITE_SPARQL_URI = RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8 | RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES, 1848 1849 /* Turtle (2013) escapes are like SPARQL */ 1850 RAPTOR_ESCAPED_WRITE_TURTLE_URI = RAPTOR_ESCAPED_WRITE_SPARQL_URI, 1851 RAPTOR_ESCAPED_WRITE_TURTLE_LITERAL = RAPTOR_ESCAPED_WRITE_SPARQL_LITERAL, 1852 RAPTOR_ESCAPED_WRITE_TURTLE_LONG_LITERAL = RAPTOR_ESCAPED_WRITE_SPARQL_LONG_LITERAL, 1853 1854 /* JSON literals: \b \f \t \r \n and \u \U */ 1855 RAPTOR_ESCAPED_WRITE_JSON_LITERAL = RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU | RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF 1856 } raptor_escaped_write_bitflags; 1857 1858 1859 RAPTOR_API 1860 int raptor_string_ntriples_write(const unsigned char *string, size_t len, const char delim, raptor_iostream *iostr); 1861 RAPTOR_API 1862 int raptor_bnodeid_ntriples_write(const unsigned char *bnodeid, size_t len, raptor_iostream *iostr); 1863 RAPTOR_API RAPTOR_DEPRECATED 1864 int raptor_string_python_write(const unsigned char *string, size_t len, const char delim, unsigned int mode, raptor_iostream *iostr); 1865 RAPTOR_API 1866 int raptor_statement_ntriples_write(const raptor_statement *statement, raptor_iostream* iostr, int write_graph_term); 1867 RAPTOR_API 1868 int raptor_string_escaped_write(const unsigned char *string, size_t len, const char delim, unsigned int flags, raptor_iostream *iostr); 1869 1870 1871 /* Parser and Serializer options */ 1872 1873 /** 1874 * raptor_option_value_type: 1875 * @RAPTOR_OPTION_VALUE_TYPE_BOOL: Boolean integer value. Non-0 is true 1876 * @RAPTOR_OPTION_VALUE_TYPE_INT: Decimal integer value 1877 * @RAPTOR_OPTION_VALUE_TYPE_STRING: String value 1878 * @RAPTOR_OPTION_VALUE_TYPE_URI: URI String value. 1879 * @RAPTOR_OPTION_VALUE_TYPE_LAST: internal 1880 * 1881 * Option value types. 1882 */ 1883 typedef enum { 1884 RAPTOR_OPTION_VALUE_TYPE_BOOL, 1885 RAPTOR_OPTION_VALUE_TYPE_INT, 1886 RAPTOR_OPTION_VALUE_TYPE_STRING, 1887 RAPTOR_OPTION_VALUE_TYPE_URI, 1888 RAPTOR_OPTION_VALUE_TYPE_LAST = RAPTOR_OPTION_VALUE_TYPE_URI 1889 } raptor_option_value_type; 1890 1891 1892 /** 1893 * raptor_option_description: 1894 * @domain: domain ID 1895 * @option: option ID 1896 * @value_type: data type of option value 1897 * @name: short name for option 1898 * @name_len: length of @name 1899 * @label: description of option 1900 * @uri: URI identifying option 1901 * 1902 * Description of an option for a domain. 1903 */ 1904 typedef struct { 1905 raptor_domain domain; 1906 raptor_option option; 1907 raptor_option_value_type value_type; 1908 const char* name; 1909 size_t name_len; 1910 const char* label; 1911 raptor_uri* uri; 1912 } raptor_option_description; 1913 1914 1915 RAPTOR_API 1916 unsigned int raptor_option_get_count(void); 1917 RAPTOR_API 1918 const char* raptor_option_get_value_type_label(const raptor_option_value_type type); 1919 RAPTOR_API 1920 void raptor_free_option_description(raptor_option_description* option_description); 1921 RAPTOR_API 1922 raptor_option_description* raptor_world_get_option_description(raptor_world* world, const raptor_domain domain, const raptor_option option); 1923 1924 1925 /* SAX2 element Class (raptor_xml_element) */ 1926 RAPTOR_API 1927 raptor_xml_element* raptor_new_xml_element(raptor_qname* name, const unsigned char* xml_language, raptor_uri* xml_base); 1928 RAPTOR_API 1929 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); 1930 RAPTOR_API 1931 void raptor_free_xml_element(raptor_xml_element *element); 1932 1933 /* methods */ 1934 RAPTOR_API 1935 raptor_qname* raptor_xml_element_get_name(raptor_xml_element *xml_element); 1936 RAPTOR_API 1937 void raptor_xml_element_set_attributes(raptor_xml_element* xml_element, raptor_qname **attributes, int count); 1938 RAPTOR_API 1939 raptor_qname** raptor_xml_element_get_attributes(raptor_xml_element* xml_element); 1940 RAPTOR_API 1941 int raptor_xml_element_get_attributes_count(raptor_xml_element* xml_element); 1942 RAPTOR_API 1943 int raptor_xml_element_declare_namespace(raptor_xml_element* xml_element, raptor_namespace *nspace); 1944 RAPTOR_API 1945 int raptor_xml_element_write(raptor_xml_element *element, raptor_namespace_stack *nstack, int is_empty, int is_end, int depth, raptor_iostream *iostr); 1946 RAPTOR_API 1947 int raptor_xml_element_is_empty(raptor_xml_element* xml_element); 1948 RAPTOR_API 1949 const unsigned char* raptor_xml_element_get_language(raptor_xml_element* xml_element); 1950 1951 1952 /* XML Writer Class (raptor_xml_writer) */ 1953 RAPTOR_API 1954 raptor_xml_writer* raptor_new_xml_writer(raptor_world* world, raptor_namespace_stack *nstack, raptor_iostream* iostr); 1955 RAPTOR_API 1956 void raptor_free_xml_writer(raptor_xml_writer* xml_writer); 1957 1958 /* methods */ 1959 RAPTOR_API 1960 void raptor_xml_writer_empty_element(raptor_xml_writer* xml_writer, raptor_xml_element *element); 1961 RAPTOR_API 1962 void raptor_xml_writer_start_element(raptor_xml_writer* xml_writer, raptor_xml_element *element); 1963 RAPTOR_API 1964 void raptor_xml_writer_end_element(raptor_xml_writer* xml_writer, raptor_xml_element *element); 1965 RAPTOR_API 1966 void raptor_xml_writer_newline(raptor_xml_writer* xml_writer); 1967 RAPTOR_API 1968 void raptor_xml_writer_cdata(raptor_xml_writer* xml_writer, const unsigned char *s); 1969 RAPTOR_API 1970 void raptor_xml_writer_cdata_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len); 1971 RAPTOR_API 1972 void raptor_xml_writer_raw(raptor_xml_writer* xml_writer, const unsigned char *s); 1973 RAPTOR_API 1974 void raptor_xml_writer_raw_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len); 1975 RAPTOR_API 1976 void raptor_xml_writer_comment(raptor_xml_writer* xml_writer, const unsigned char *s); 1977 RAPTOR_API 1978 void raptor_xml_writer_comment_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len); 1979 RAPTOR_API 1980 void raptor_xml_writer_flush(raptor_xml_writer* xml_writer); 1981 RAPTOR_API 1982 int raptor_xml_writer_set_option(raptor_xml_writer *xml_writer, raptor_option option, char* string, int integer); 1983 RAPTOR_API 1984 int raptor_xml_writer_get_option(raptor_xml_writer *xml_writer, raptor_option option, char** string_p, int* integer_p); 1985 RAPTOR_API 1986 int raptor_xml_writer_get_depth(raptor_xml_writer *xml_writer); 1987 1988 /** 1989 * raptor_sax2_start_element_handler: 1990 * @user_data: user data 1991 * @xml_element: XML element 1992 * 1993 * SAX2 start element handler 1994 */ 1995 typedef void (*raptor_sax2_start_element_handler)(void *user_data, raptor_xml_element *xml_element); 1996 1997 /** 1998 * raptor_sax2_end_element_handler: 1999 * @user_data: user data 2000 * @xml_element: XML element 2001 * 2002 * SAX2 end element handler 2003 */ 2004 typedef void (*raptor_sax2_end_element_handler)(void *user_data, raptor_xml_element* xml_element); 2005 2006 /** 2007 * raptor_sax2_characters_handler: 2008 * @user_data: user data 2009 * @xml_element: XML element 2010 * @s: string 2011 * @len: string len 2012 * 2013 * SAX2 characters handler 2014 */ 2015 typedef void (*raptor_sax2_characters_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len); 2016 2017 /** 2018 * raptor_sax2_cdata_handler: 2019 * @user_data: user data 2020 * @xml_element: XML element 2021 * @s: string 2022 * @len: string len 2023 2024 * SAX2 CDATA section handler 2025 */ 2026 typedef void (*raptor_sax2_cdata_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len); 2027 2028 /** 2029 * raptor_sax2_comment_handler: 2030 * @user_data: user data 2031 * @xml_element: XML element 2032 * @s: string 2033 * 2034 * SAX2 XML comment handler 2035 */ 2036 typedef void (*raptor_sax2_comment_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s); 2037 2038 /** 2039 * raptor_sax2_unparsed_entity_decl_handler: 2040 * @user_data: user data 2041 * @entityName: entity name 2042 * @base: base URI 2043 * @systemId: system ID 2044 * @publicId: public ID 2045 * @notationName: notation name 2046 * 2047 * SAX2 unparsed entity (NDATA) handler 2048 */ 2049 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); 2050 2051 /** 2052 * raptor_sax2_external_entity_ref_handler: 2053 * @user_data: user data 2054 * @context: context 2055 * @base: base URI 2056 * @systemId: system ID 2057 * @publicId: public ID 2058 * 2059 * SAX2 external entity reference handler 2060 * 2061 * Return value: 0 if processing should not continue because of a 2062 * fatal error in the handling of the external entity. 2063 */ 2064 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); 2065 2066 2067 /* SAX2 API */ 2068 RAPTOR_API 2069 raptor_sax2* raptor_new_sax2(raptor_world *world, raptor_locator *locator, void* user_data); 2070 RAPTOR_API 2071 void raptor_free_sax2(raptor_sax2 *sax2); 2072 2073 /* methods */ 2074 RAPTOR_API 2075 void raptor_sax2_set_start_element_handler(raptor_sax2* sax2, raptor_sax2_start_element_handler handler); 2076 RAPTOR_API 2077 void raptor_sax2_set_end_element_handler(raptor_sax2* sax2, raptor_sax2_end_element_handler handler); 2078 RAPTOR_API 2079 void raptor_sax2_set_characters_handler(raptor_sax2* sax2, raptor_sax2_characters_handler handler); 2080 RAPTOR_API 2081 void raptor_sax2_set_cdata_handler(raptor_sax2* sax2, raptor_sax2_cdata_handler handler); 2082 RAPTOR_API 2083 void raptor_sax2_set_comment_handler(raptor_sax2* sax2, raptor_sax2_comment_handler handler); 2084 RAPTOR_API 2085 void raptor_sax2_set_unparsed_entity_decl_handler(raptor_sax2* sax2, raptor_sax2_unparsed_entity_decl_handler handler); 2086 RAPTOR_API 2087 void raptor_sax2_set_external_entity_ref_handler(raptor_sax2* sax2, raptor_sax2_external_entity_ref_handler handler); 2088 RAPTOR_API 2089 void raptor_sax2_set_namespace_handler(raptor_sax2* sax2, raptor_namespace_handler handler); 2090 RAPTOR_API 2091 void raptor_sax2_set_uri_filter(raptor_sax2* sax2, raptor_uri_filter_func filter, void *user_data); 2092 RAPTOR_API 2093 void raptor_sax2_parse_start(raptor_sax2 *sax2, raptor_uri *base_uri); 2094 RAPTOR_API 2095 int raptor_sax2_parse_chunk(raptor_sax2* sax2, const unsigned char *buffer, size_t len, int is_end); 2096 RAPTOR_API 2097 const unsigned char* raptor_sax2_inscope_xml_language(raptor_sax2* sax2); 2098 RAPTOR_API 2099 raptor_uri* raptor_sax2_inscope_base_uri(raptor_sax2* sax2); 2100 2101 2102 2103 /* AVL Trees */ 2104 2105 /** 2106 * raptor_avltree: 2107 * 2108 * AVL Tree 2109 */ 2110 typedef struct raptor_avltree_s raptor_avltree; 2111 2112 /** 2113 * raptor_avltree_iterator: 2114 * 2115 * AVL Tree Iterator as created by raptor_new_avltree_iterator() 2116 */ 2117 typedef struct raptor_avltree_iterator_s raptor_avltree_iterator; 2118 2119 /** 2120 * raptor_avltree_visit_handler: 2121 * @depth: depth of object in tree 2122 * @data: data object being visited 2123 * @user_data: user data arg to raptor_avltree_visit() 2124 * 2125 * AVL Tree visitor function as given to raptor_avltree_visit() 2126 * 2127 * Return value: non-0 to terminate visit early. 2128 */ 2129 typedef int (*raptor_avltree_visit_handler)(int depth, void* data, void *user_data); 2130 2131 2132 /** 2133 * raptor_avltree_bitflags: 2134 * @RAPTOR_AVLTREE_FLAG_REPLACE_DUPLICATES: If set raptor_avltree_add() will replace any duplicate items. If not set, raptor_avltree_add() will not replace them and will return status >0 when adding a duplicate. (Default is not set) 2135 * 2136 * Bit flags for AVL Tree class constructor raptor_new_avltree() 2137 **/ 2138 typedef enum { 2139 RAPTOR_AVLTREE_FLAG_REPLACE_DUPLICATES = 1 2140 } raptor_avltree_bitflags; 2141 2142 2143 RAPTOR_API 2144 raptor_avltree* raptor_new_avltree(raptor_data_compare_handler compare_handler, raptor_data_free_handler free_handler, unsigned int flags); 2145 RAPTOR_API 2146 void raptor_free_avltree(raptor_avltree* tree); 2147 2148 /* methods */ 2149 RAPTOR_API 2150 int raptor_avltree_add(raptor_avltree* tree, void* p_data); 2151 RAPTOR_API 2152 void* raptor_avltree_remove(raptor_avltree* tree, void* p_data); 2153 RAPTOR_API 2154 int raptor_avltree_delete(raptor_avltree* tree, void* p_data); 2155 RAPTOR_API 2156 void* raptor_avltree_search(raptor_avltree* tree, const void* p_data); 2157 RAPTOR_API 2158 int raptor_avltree_visit(raptor_avltree* tree, raptor_avltree_visit_handler visit_handler, void* user_data); 2159 RAPTOR_API 2160 int raptor_avltree_size(raptor_avltree* tree); 2161 RAPTOR_API 2162 void raptor_avltree_set_print_handler(raptor_avltree* tree, raptor_data_print_handler print_handler); 2163 RAPTOR_API 2164 int raptor_avltree_print(raptor_avltree* tree, FILE* stream); 2165 2166 RAPTOR_API 2167 raptor_avltree_iterator* raptor_new_avltree_iterator(raptor_avltree* tree, void* range, raptor_data_free_handler range_free_handler, int direction); 2168 RAPTOR_API 2169 void raptor_free_avltree_iterator(raptor_avltree_iterator* iterator); 2170 2171 RAPTOR_API 2172 int raptor_avltree_iterator_is_end(raptor_avltree_iterator* iterator); 2173 RAPTOR_API 2174 int raptor_avltree_iterator_next(raptor_avltree_iterator* iterator); 2175 RAPTOR_API 2176 void* raptor_avltree_iterator_get(raptor_avltree_iterator* iterator); 2177 2178 /* utility methods */ 2179 RAPTOR_API 2180 void raptor_sort_r(void *base, size_t nel, size_t width, raptor_data_compare_arg_handler compar, void *user_data); 2181 2182 2183 #ifdef __cplusplus 2184 } 2185 #endif 2186 2187 #endif 2188