summaryrefslogtreecommitdiff
path: root/src/raptor.h
blob: b8b5497eea36feac03ce6aad67b4ee3b500279f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
/* -*- Mode: c; c-basic-offset: 2 -*-
 *
 * raptor.h - Redland Parser Toolkit for RDF (Raptor) interfaces and definition
 *
 * Copyright (C) 2000-2008, David Beckett http://www.dajobe.org/
 * Copyright (C) 2000-2005, University of Bristol, UK http://www.bristol.ac.uk/
 * 
 * This package is Free Software and part of Redland http://librdf.org/
 * 
 * It is licensed under the following three licenses as alternatives:
 *   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
 *   2. GNU General Public License (GPL) V2 or any newer version
 *   3. Apache License, V2.0 or any newer version
 * 
 * You may not use this file except in compliance with at least one of
 * the above three licenses.
 * 
 * See LICENSE.html or LICENSE.txt at the top of this package for the
 * complete terms and further detail along with the license texts for
 * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
 * 
 * 
 */



#ifndef RAPTOR_H
#define RAPTOR_H


#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>

/* Required for va_list in raptor_vsnprintf */
#include <stdarg.h>


/**
 * RAPTOR_API:
 *
 * Macro for wrapping API function call declarations.
 *
 */
#ifndef RAPTOR_API
#  ifdef WIN32
#    ifdef __GNUC__
#      undef _declspec
#      define _declspec(x) __declspec(x)
#    endif
#    ifdef RAPTOR_STATIC
#      define RAPTOR_API
#    else
#      ifdef RAPTOR_INTERNAL
#        define RAPTOR_API _declspec(dllexport)
#      else
#        define RAPTOR_API _declspec(dllimport)
#      endif
#    endif
#  else
#    define RAPTOR_API
#  endif
#endif

/* Use gcc 3.1+ feature to allow marking of deprecated API calls.
 * This gives a warning during compiling.
 */
#if( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
#ifdef __APPLE_CC__
/* OSX gcc cpp-precomp is broken */
#define RAPTOR_DEPRECATED
#else
#define RAPTOR_DEPRECATED __attribute__((deprecated))
#endif
#else
#define RAPTOR_DEPRECATED
#endif

/* V2 is always available now - FIXME - remove this define */
#undef RAPTOR_V2_AVAILABLE
#define RAPTOR_V2_AVAILABLE 1

/**
 * RAPTOR_PRINTF_FORMAT:
 * @string_index: ignore me
 * @first_to_check_index: ignore me
 *
 * Internal macro
 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index) \
  __attribute__((__format__(__printf__, string_index, first_to_check_index)))
#else
#define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index)
#endif

/**
 * raptor_uri:
 *
 * Raptor URI Class.
 */
typedef void* raptor_uri;


/* Public statics */
RAPTOR_API
extern const char * const raptor_short_copyright_string;
RAPTOR_API
extern const char * const raptor_copyright_string;
RAPTOR_API
extern const char * const raptor_version_string;
RAPTOR_API
extern const unsigned int raptor_version_major;
RAPTOR_API
extern const unsigned int raptor_version_minor;
RAPTOR_API
extern const unsigned int raptor_version_release;
RAPTOR_API
extern const unsigned int raptor_version_decimal;
RAPTOR_API
extern const char * const raptor_license_string;
RAPTOR_API
extern const char * const raptor_home_url_string;

RAPTOR_API
extern const unsigned char * const raptor_xml_namespace_uri;
RAPTOR_API
extern const unsigned char * const raptor_rdf_namespace_uri;
RAPTOR_API
extern const unsigned char * const raptor_rdf_schema_namespace_uri;
RAPTOR_API
extern const unsigned char * const raptor_xmlschema_datatypes_namespace_uri;
RAPTOR_API
extern const unsigned char * const raptor_owl_namespace_uri;

/**
 * raptor_rdf_namespace_uri_len:
 *
 * Length of #raptor_rdf_namespace_uri string
 */
RAPTOR_API
extern const unsigned int raptor_rdf_namespace_uri_len;

RAPTOR_API
extern const unsigned char * const raptor_xml_literal_datatype_uri_string;

/**
 * raptor_xml_literal_datatype_uri_string_len:
 *
 * Length of #raptor_xml_literal_datatype_uri_string
 */
RAPTOR_API
extern const unsigned int raptor_xml_literal_datatype_uri_string_len;


/* Public structure */
#ifndef RAPTOR_WORLD_DECLARED
#define RAPTOR_WORLD_DECLARED 1
/**
 * raptor_world:
 *
 * Raptor world class.
 */
typedef struct raptor_world_s raptor_world;
#endif
/**
 * raptor_parser:
 *
 * Raptor Parser class
 */
typedef struct raptor_parser_s raptor_parser;
/**
 * raptor_serializer:
 *
 * Raptor Serializer class
 */
typedef struct raptor_serializer_s raptor_serializer;

/**
 * raptor_www:
 *
 * Raptor WWW class
 */
typedef struct raptor_www_s raptor_www;
/**
 * raptor_iostream:
 *
 * Raptor I/O Stream class
 */
typedef struct raptor_iostream_s raptor_iostream;
/**
 * raptor_xml_element:
 *
 * Raptor XML Element class
 */
typedef struct raptor_xml_element_s raptor_xml_element;
/**
 * raptor_xml_writer:
 *
 * Raptor XML Writer class
 */
typedef struct raptor_xml_writer_s raptor_xml_writer;
/**
 * raptor_qname:
 *
 * Raptor XML qname class
 */
typedef struct raptor_qname_s raptor_qname;
/**
 * raptor_namespace:
 *
 * Raptor XML Namespace class
 */
typedef struct raptor_namespace_s raptor_namespace;
/**
 * raptor_namespace_stack:
 *
 * Raptor XML Namespace Stack class
 */
typedef struct raptor_namespace_stack_s raptor_namespace_stack;

/**
 * raptor_sax2:
 *
 * Raptor SAX2 class
 */
typedef struct raptor_sax2_s raptor_sax2;


/**
 * raptor_identifier_type:
 * @RAPTOR_IDENTIFIER_TYPE_RESOURCE:    Resource URI (e.g. <literal>rdf:about</literal>)
 * @RAPTOR_IDENTIFIER_TYPE_ANONYMOUS:   <literal>_:foo</literal> N-Triples, or generated
 * @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.
 * @RAPTOR_IDENTIFIER_TYPE_LITERAL:     regular literal
 * @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>.
 * @RAPTOR_IDENTIFIER_TYPE_UNKNOWN:     Internal
 *
 * Type of identifier in a #raptor_statement
 *
 */
typedef enum {
  RAPTOR_IDENTIFIER_TYPE_UNKNOWN,
  RAPTOR_IDENTIFIER_TYPE_RESOURCE,
  RAPTOR_IDENTIFIER_TYPE_ANONYMOUS,
  RAPTOR_IDENTIFIER_TYPE_ORDINAL,
  RAPTOR_IDENTIFIER_TYPE_LITERAL,
  RAPTOR_IDENTIFIER_TYPE_XML_LITERAL
} raptor_identifier_type;


/**
 * raptor_ntriples_term_type:
 * @RAPTOR_NTRIPLES_TERM_TYPE_URI_REF: Internal
 * @RAPTOR_NTRIPLES_TERM_TYPE_BLANK_NODE: Internal
 * @RAPTOR_NTRIPLES_TERM_TYPE_LITERAL: I
 *
 * N-Triples term types
 * 
 * Used for the deprecated function raptor_ntriples_term_as_string() only.
 *
 */
typedef enum { RAPTOR_NTRIPLES_TERM_TYPE_URI_REF, RAPTOR_NTRIPLES_TERM_TYPE_BLANK_NODE, RAPTOR_NTRIPLES_TERM_TYPE_LITERAL } raptor_ntriples_term_type;


/**
 * raptor_locator:
 * @uri: URI of location (or NULL)
 * @file: Filename of location (or NULL)
 * @line: Line number of location (or <0 for no line)
 * @column: Column number of location (or <0 for no column)
 * @byte: Byte number of location (or <0 for no byte)
 *
 * Location information for an error, warning or information message.
 */
typedef struct {
  raptor_uri *uri;
  const char *file;
  int line;
  int column;
  int byte;  
} raptor_locator;

/**
 * raptor_feature:
 * @RAPTOR_FEATURE_SCANNING: If true (default false), the RDF/XML
 *   parser will look for embedded rdf:RDF elements inside the XML
 *   content, and not require that the XML start with an rdf:RDF root
 *   element.
 * @RAPTOR_FEATURE_ASSUME_IS_RDF: If true (default false) then the
 *   RDF/XML parser will assume the content is RDF/XML, not require
 *   that rdf:RDF root element, and immediately interpret the content
 *   as RDF/XML.
 * @RAPTOR_FEATURE_ALLOW_NON_NS_ATTRIBUTES: If true (default true)
 *   then the RDF/XML parser will allow non-XML namespaced attributes
 *   to be accepted as well as rdf: namespaced ones.  For example,
 *   'about' and 'ID' will be interpreted as if they were rdf:about
 *   and rdf:ID respectively.
 * @RAPTOR_FEATURE_ALLOW_OTHER_PARSETYPES: If true (default true)
 *   then the RDF/XML parser will allow unknown parsetypes to be
 *   present and will pass them on to the user.  Unimplemented at
 *   present.
 * @RAPTOR_FEATURE_ALLOW_BAGID: If true (default true) then the
 *   RDF/XML parser will support the rdf:bagID attribute that was
 *   removed from the RDF/XML language when it was revised.  This
 *   support may be removed in future.
 * @RAPTOR_FEATURE_ALLOW_RDF_TYPE_RDF_LIST: If true (default false)
 *   then the RDF/XML parser will generate the idList rdf:type
 *   rdf:List triple in the handling of rdf:parseType="Collection".
 *   This triple was removed during the revising of RDF/XML after
 *   collections were initially added.
 * @RAPTOR_FEATURE_NORMALIZE_LANGUAGE: If true (default true) then
 *   XML language values such as from xml:lang will be normalized to
 *   lowercase.
 * @RAPTOR_FEATURE_NON_NFC_FATAL: If true (default false) then
 *  illegal Unicode Normal Form C in literals will give a fatal
 *  error, otherwise just a warning.
 * @RAPTOR_FEATURE_WARN_OTHER_PARSETYPES: If true (default true) then 
 *   the RDF/XML parser will warn about unknown rdf:parseType values.
 * @RAPTOR_FEATURE_CHECK_RDF_ID: If true (default true) then the
 *   RDF/XML will check rdf:ID attribute values for duplicates and
 *   cause an error if any are found.
 * @RAPTOR_FEATURE_RELATIVE_URIS: If true (default true) then
 *   relative URIs will be used wherever possible when serializing.
 * @RAPTOR_FEATURE_START_URI: Set the start URI for serlalizing to use.
 * @RAPTOR_FEATURE_WRITER_AUTO_INDENT: Automatically indent elements when
 *   seriailizing.
 * @RAPTOR_FEATURE_WRITER_AUTO_EMPTY: Automatically detect and
 *   abbreviate empty elements when serializing.
 * @RAPTOR_FEATURE_WRITER_INDENT_WIDTH: Integer number of spaces to use
 *   for each indent level when serializing with auto indent.
 * @RAPTOR_FEATURE_WRITER_XML_VERSION: Integer XML version XML 1.0 (10) or XML 1.1 (11)
 * @RAPTOR_FEATURE_WRITER_XML_DECLARATION: Write XML 1.0 or 1.1 declaration.
 * @RAPTOR_FEATURE_NO_NET: Deny network requests.
 * @RAPTOR_FEATURE_RESOURCE_BORDER: Border color of resource
 *   nodes for GraphViz DOT serializer.
 * @RAPTOR_FEATURE_LITERAL_BORDER: Border color of literal nodes
 *   for GraphViz DOT serializer.
 * @RAPTOR_FEATURE_BNODE_BORDER: Border color of blank nodes for
 *   GraphViz DOT serializer.
 * @RAPTOR_FEATURE_RESOURCE_FILL: Fill color of resource nodes
 *   for GraphViz DOT serializer.
 * @RAPTOR_FEATURE_LITERAL_FILL: Fill color of literal nodes for
 *   GraphViz DOT serializer.
 * @RAPTOR_FEATURE_BNODE_FILL: Fill color of blank nodes for
 *   GraphViz DOT serializer.
 * @RAPTOR_FEATURE_HTML_TAG_SOUP: Use a lax HTML parser if an XML parser
 *   fails when read HTML for GRDDL parser.
 * @RAPTOR_FEATURE_MICROFORMATS: Look for microformats for GRDDL parser.
 * @RAPTOR_FEATURE_HTML_LINK: Look for head &lt;link&gt; to type rdf/xml
 *   for GRDDL parser.
 * @RAPTOR_FEATURE_WWW_TIMEOUT: Set timeout for internal WWW URI requests
 *   for GRDDL parser.
 * @RAPTOR_FEATURE_WRITE_BASE_URI: Write @base directive for Turtle/N3.
 * @RAPTOR_FEATURE_WWW_HTTP_CACHE_CONTROL: HTTP Cache-Control: header
 * @RAPTOR_FEATURE_WWW_HTTP_USER_AGENT: HTTP User-Agent: header
 * @RAPTOR_FEATURE_JSON_CALLBACK: JSON serializer callback function.
 * @RAPTOR_FEATURE_JSON_EXTRA_DATA: JSON serializer extra top-level data
 * @RAPTOR_FEATURE_RSS_TRIPLES: Atom/RSS serializer writes extra RDF triples it finds (none, rdf-xml, atom-triples)
 * @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.
 * @RAPTOR_FEATURE_PREFIX_ELEMENTS: Integer. If set, generate Atom/RSS1.0 documents with prefixed elements, otherwise unprefixed.
 * @RAPTOR_FEATURE_LAST: Internal
 *
 * Raptor parser, serializer or XML writer features.
 */
typedef enum {
  RAPTOR_FEATURE_SCANNING,
  RAPTOR_FEATURE_ASSUME_IS_RDF,
  RAPTOR_FEATURE_ALLOW_NON_NS_ATTRIBUTES,
  RAPTOR_FEATURE_ALLOW_OTHER_PARSETYPES,
  RAPTOR_FEATURE_ALLOW_BAGID,
  RAPTOR_FEATURE_ALLOW_RDF_TYPE_RDF_LIST,
  RAPTOR_FEATURE_NORMALIZE_LANGUAGE,
  RAPTOR_FEATURE_NON_NFC_FATAL,
  RAPTOR_FEATURE_WARN_OTHER_PARSETYPES,
  RAPTOR_FEATURE_CHECK_RDF_ID,
  RAPTOR_FEATURE_RELATIVE_URIS,
  RAPTOR_FEATURE_START_URI,
  RAPTOR_FEATURE_WRITER_AUTO_INDENT,
  RAPTOR_FEATURE_WRITER_AUTO_EMPTY,
  RAPTOR_FEATURE_WRITER_INDENT_WIDTH,
  RAPTOR_FEATURE_WRITER_XML_VERSION,
  RAPTOR_FEATURE_WRITER_XML_DECLARATION,
  RAPTOR_FEATURE_NO_NET,
  RAPTOR_FEATURE_RESOURCE_BORDER,
  RAPTOR_FEATURE_LITERAL_BORDER,
  RAPTOR_FEATURE_BNODE_BORDER,
  RAPTOR_FEATURE_RESOURCE_FILL,
  RAPTOR_FEATURE_LITERAL_FILL,
  RAPTOR_FEATURE_BNODE_FILL,
  RAPTOR_FEATURE_HTML_TAG_SOUP,
  RAPTOR_FEATURE_MICROFORMATS,
  RAPTOR_FEATURE_HTML_LINK,
  RAPTOR_FEATURE_WWW_TIMEOUT,
  RAPTOR_FEATURE_WRITE_BASE_URI,
  RAPTOR_FEATURE_WWW_HTTP_CACHE_CONTROL,
  RAPTOR_FEATURE_WWW_HTTP_USER_AGENT,
  RAPTOR_FEATURE_JSON_CALLBACK,
  RAPTOR_FEATURE_JSON_EXTRA_DATA,
  RAPTOR_FEATURE_RSS_TRIPLES,
  RAPTOR_FEATURE_ATOM_ENTRY_URI,
  RAPTOR_FEATURE_PREFIX_ELEMENTS,
  RAPTOR_FEATURE_LAST = RAPTOR_FEATURE_PREFIX_ELEMENTS
} raptor_feature;


/**
 * raptor_genid_type:
 * @RAPTOR_GENID_TYPE_BNODEID: Generated ID is for a blank node
 * @RAPTOR_GENID_TYPE_BAGID: Generated ID is for rdf:bagID
 *
 * Intended type for a generated identifier asked for by the handler
 * registered with raptor_set_generate_id_handler().
 */
typedef enum {
  RAPTOR_GENID_TYPE_BNODEID,
  RAPTOR_GENID_TYPE_BAGID
} raptor_genid_type;


/**
 * raptor_identifier:
 * @type: Type of identifier
 * @uri: URI of identifier for types %RAPTOR_IDENTIFIER_TYPE_RESOURCE
 * @uri_source: where the identifier (URI or blank node) came from
 * @id: blank node identifier for type %RAPTOR_IDENTIFIER_TYPE_ANONYMOUS
 * @ordinal: integer ordinal for type %RAPTOR_IDENTIFIER_TYPE_ORDINAL
 * @is_malloced: internal
 * @literal: literal string for types %RAPTOR_IDENTIFIER_TYPE_LITERAL and
 *    %RAPTOR_IDENTIFIER_TYPE_XML_LITERAL
 * @literal_datatype: RDF literal datatype URI for types
 *   %RAPTOR_IDENTIFIER_TYPE_LITERAL and %RAPTOR_IDENTIFIER_TYPE_XML_LITERAL
 * @literal_language: RDF literal language for type
 *   %RAPTOR_IDENTIFIER_TYPE_LITERAL
 * @world: raptor_world object
 *
 * Raptor RDF term identifier.
*/
typedef struct {
  raptor_identifier_type type;
  raptor_uri *uri;
  const unsigned char *id;
  int ordinal;
  int is_malloced;
  const unsigned char *literal;
  raptor_uri *literal_datatype;
  const unsigned char *literal_language;
  raptor_world *world;
} raptor_identifier;


/**
 * raptor_term:
 * @value: term value
 * @type: term type
 * @literal_datatype: datatype URI (or NULL) when type is ltieral
 * @literal_language: language string (or NULL) with type is literal
 *
 * An RDF triple term
 *
 */
typedef struct {
  raptor_world* world;

  const void *value;
  raptor_identifier_type type;
  raptor_uri *literal_datatype;
  const unsigned char *literal_language;
} raptor_term;


/**
 * raptor_statement:
 * @world: world pointer
 * @subject: statement subject
 * @predicate: statement predicate
 * @object: statement object
 *
 * An RDF triple with graph
 *
 * See #raptor_identifier for a description of how the fields may be used.
 * As returned by a parser statement_handler.
 */
typedef struct {
  raptor_world* world;
  raptor_term subject;
  raptor_term predicate;
  raptor_term object;
} raptor_statement;


/**
 * raptor_new_uri_func:
 * @context: URI context data
 * @uri_string: URI string
 *
 * Handler function for implementing raptor_new_uri().
 *
 * Return value: new URI object or NULL on failure
 */
typedef raptor_uri* (*raptor_new_uri_func) (void *context, const unsigned char *uri_string);

/**
 * raptor_new_uri_from_uri_local_name_func:
 * @context: URI context data
 * @uri: URI object
 * @local_name: local name string
 *
 * Handler function for implementing raptor_new_uri_from_uri_local_name().
 *
 * Return value: new URI object or NULL on failure
 */
typedef raptor_uri* (*raptor_new_uri_from_uri_local_name_func) (void *context, raptor_uri *uri, const unsigned char *local_name);

/**
 * raptor_new_uri_relative_to_base_func:
 * @context: URI context data
 * @base_uri: base URI object
 * @uri_string: relative URI string
 *
 * Handler function for implementing raptor_new_uri_relative_to_base().
 *
 * Return value: new URI object or NULL on failure
 */
typedef raptor_uri* (*raptor_new_uri_relative_to_base_func) (void *context, raptor_uri *base_uri, const unsigned char *uri_string);

/**
 * raptor_new_uri_for_rdf_concept_func:
 * @context: URI context data
 * @name: RDF term
 *
 * Handler function for implementing raptor_new_uri_for_rdf_concept().
 *
 * Return value: new URI object or NULL on failure
 */
typedef raptor_uri* (*raptor_new_uri_for_rdf_concept_func) (void *context, const char *name);

/**
 * raptor_free_uri_func:
 * @context: URI context data
 * @uri: URI object
 *
 * Handler function for implementing raptor_free_uri().
 */
typedef void (*raptor_free_uri_func) (void *context, raptor_uri *uri);

/**
 * raptor_uri_equals_func:
 * @context: URI context data
 * @uri1: URI object 1
 * @uri2: URI object 2
 *
 * Handler function for implementing raptor_uri_equals().
 *
 * Return value: non-0 if the URIs are equal
 */
typedef int (*raptor_uri_equals_func) (void *context, raptor_uri* uri1, raptor_uri* uri2);

/**
 * raptor_uri_compare_func:
 * @context: URI context data
 * @uri1: URI object 1
 * @uri2: URI object 2
 *
 * Handler function for implementing raptor_uri_equals().
 *
 * Return value: -1 if uri1 < uri2, 0 if equal, 1 if uri1 > uri2
 */
typedef int (*raptor_uri_compare_func) (void *context, raptor_uri* uri1, raptor_uri* uri2);

/**
 * raptor_uri_copy_func:
 * @context: URI context data
 * @uri: URI object
 *
 * Handler function for implementing raptor_uri_copy().
 *
 * Return value: new URI object or NULL on failure
 */
typedef raptor_uri* (*raptor_uri_copy_func) (void *context, raptor_uri *uri);

/**
 * raptor_uri_as_string_func:
 * @context: URI context data
 * @uri: URI object
 *
 * Handler function for implementing raptor_uri_as_string().
 *
 * Return value: shared string representation of the URI
 */
typedef unsigned char* (*raptor_uri_as_string_func)(void *context, raptor_uri *uri);

/**
 * raptor_uri_as_counted_string_func:
 * @context: URI context data
 * @uri: URI object
 * @len_p: length
 *
 * Handler function for implementing raptor_uri_as_counted_string().
 *
 * Return value: shared string representation of the URI
 */
typedef unsigned char* (*raptor_uri_as_counted_string_func)(void *context, raptor_uri *uri, size_t* len_p);


/**
 * raptor_uri_handler:
 * @new_uri: function for raptor_new_uri()
 * @new_uri_from_uri_local_name: function for raptor_new_uri_from_uri_local_name()
 * @new_uri_relative_to_base: function for raptor_new_uri_relative_to_base()
 * @new_uri_for_rdf_concept: function for raptor_new_uri_for_rdf_concept()
 * @free_uri: function for raptor_free_uri()
 * @uri_equals: function for raptor_uri_equals()
 * @uri_compare: function for raptor_uri_compare()
 * @uri_copy: function for raptor_uri_copy()
 * @uri_as_string: function for raptor_uri_as_string()
 * @uri_as_counted_string: function for raptor_uri_as_counted_string()
 * @initialised: API version - set to API version implemented: 1..2
 *
 * URI implementation handler structure.
 */
typedef struct {
  /* constructors - URI Interface V1 */
  raptor_new_uri_func                     new_uri;
  raptor_new_uri_from_uri_local_name_func new_uri_from_uri_local_name;
  raptor_new_uri_relative_to_base_func    new_uri_relative_to_base;
  raptor_new_uri_for_rdf_concept_func     new_uri_for_rdf_concept;
  /* destructor - URI Interface V1 */
  raptor_free_uri_func                    free_uri;
  /* methods - URI Interface V1 */
  raptor_uri_equals_func                  uri_equals;
  raptor_uri_copy_func                    uri_copy; /* well, copy constructor */
  raptor_uri_as_string_func               uri_as_string;
  raptor_uri_as_counted_string_func       uri_as_counted_string;
  int initialised;
  /* methods - URI Interface V2 */
  raptor_uri_compare_func                 uri_compare;
} raptor_uri_handler;


/**
 * raptor_simple_message_handler:
 * @user_data: user data
 * @message: message to report
 * @...: arguments for message
 *
 * Simple message handler function.
 *
 * Used by multiple functions including raptor_xml_escape_string(),
 * raptor_iostream_write_xml_escaped_string(), raptor_new_qname(),
 * raptor_qname_string_to_uri(), raptor_new_namespaces(),
 * raptor_namespaces_init(), raptor_iostream_write_xml_element(),
 * raptor_new_xml_writer().
 */
typedef void (*raptor_simple_message_handler)(void *user_data, const char *message, ...);

/**
 * raptor_message_handler:
 * @user_data: user data
 * @locator: location associated with message or NULL
 * @message: message to report
 *
 * Message with location handler function.
 *
 * Used during parsing and serializing for errors and warnings that
 * may include location information. Multiple handlers may be set for
 * parsers and serializers by raptor_set_fatal_error_handler(),
 * raptor_set_error_handler(), raptor_set_warning_handler(),
 * raptor_serializer_set_error_handler() and
 * raptor_serializer_set_warning_handler().
 *
 * Also used by raptor_www_set_error_handler() for location-based errors
 * in WWW retrieval.
 */
typedef void (*raptor_message_handler)(void *user_data, raptor_locator* locator, const char *message);


/**
 * raptor_message_handler_closure:
 * @user_data: user data for handler invocation
 * @handler: handler function
 *
 * The combination of a message handler and the user data to send to it.
 */
typedef struct {
  void *user_data;
  raptor_message_handler handler;
} raptor_message_handler_closure;


/**
 * raptor_statement_handler:
 * @user_data: user data
 * @statement: statement to report
 *
 * Statement (triple) reporting handler function.
 */
typedef void (*raptor_statement_handler)(void *user_data, const raptor_statement *statement);

/**
 * raptor_graph_handler:
 * @user_data: user data
 * @graph: graph to report, 0 for the default graph
 *
 * Named graph reporting handler function. Due to historic reasons the named graph
 * API is separated from the statement handler. A graph is reported after all its 
 * statements.
 */
typedef void (*raptor_graph_handler)(void *user_data, raptor_uri *graph);

/**
 * raptor_generate_id_handler:
 * @user_data: user data
 * @type: type of ID to create
 * @user_bnodeid: a user-specified ID or NULL if none available.
 *
 * Generate an identifier handler function.
 *
 * Return value: new ID to use
 */
typedef unsigned char* (*raptor_generate_id_handler)(void *user_data, raptor_genid_type type, unsigned char* user_bnodeid);

/**
 * raptor_namespace_handler:
 * @user_data: user data
 * @nspace: #raptor_namespace declared
 *
 * XML Namespace declaration reporting handler set by 
 * raptor_set_namespace_handler().
 */
typedef void (*raptor_namespace_handler)(void* user_data, raptor_namespace *nspace);

/**
 * raptor_www_write_bytes_handler:
 * @www: WWW object
 * @userdata: user data
 * @ptr: data pointer
 * @size: size of individual item
 * @nmemb: number of items
 *
 * Receiving bytes of data from WWW retrieval handler.
 *
 * Set by raptor_www_set_write_bytes_handler().
 */
typedef void (*raptor_www_write_bytes_handler)(raptor_www* www, void *userdata, const void *ptr, size_t size, size_t nmemb);

/**
 * raptor_www_content_type_handler:
 * @www: WWW object
 * @userdata: user data
 * @content_type: content type seen
 *
 * Receiving Content-Type: header from WWW retrieval handler.
 *
 * Set by raptor_www_set_content_type_handler().
 */
typedef void (*raptor_www_content_type_handler)(raptor_www* www, void *userdata, const char *content_type);

/**
 * raptor_www_final_uri_handler:
 * @www: WWW object
 * @userdata: user data
 * @final_uri: final URI seen
 *
 * Receiving the final resolved URI from a WWW retrieval
 *
 * Set by raptor_www_set_final_uri_handler().
 */
typedef void (*raptor_www_final_uri_handler)(raptor_www* www, void *userdata, raptor_uri *final_uri);

/**
 * raptor_uri_filter_func:
 * @user_data: user data
 * @uri: #raptor_uri URI to check
 *
 * Callback function for #raptor_www_set_uri_filter
 *
 * Return value: non-0 to filter the URI
 */
typedef int (*raptor_uri_filter_func)(void *user_data, raptor_uri* uri);


/**
 * raptor_libxml_flags:
 * @RAPTOR_LIBXML_FLAGS_GENERIC_ERROR_SAVE: if set - save/restore the libxml generic error handler when parsing (default unset)
 * @RAPTOR_LIBXML_FLAGS_STRUCTURED_ERROR_SAVE: if set - save/restore the libxml structured error handler when parsing (default unset)
 *
 * libxml library flags
 *
 * These are used by raptor_world_set_libxml_flags() and
 * raptor_set_libxml_flags() to control common libxml features.
 *
 * If any handler saving/restoring is enabled, any existing handler
 * and context is saved before parsing and restored afterwards.
 * Otherwise, no saving/restoring is performed.
 *
 */
typedef enum {
  RAPTOR_LIBXML_FLAGS_GENERIC_ERROR_SAVE    = 1,
  RAPTOR_LIBXML_FLAGS_STRUCTURED_ERROR_SAVE = 2
} raptor_libxml_flags;


/* Public functions */

RAPTOR_API
raptor_world* raptor_new_world(void);
RAPTOR_API
int raptor_world_open(raptor_world* world);
RAPTOR_API
void raptor_free_world(raptor_world* world);
RAPTOR_API
void raptor_world_set_libxslt_security_preferences(raptor_world *world, void *security_preferences);
RAPTOR_API
void raptor_world_set_libxml_flags(raptor_world *world,  int flags);

/* Get parser names */
RAPTOR_API
int raptor_parsers_enumerate_v2(raptor_world* world, const unsigned int counter, const char **name, const char **label);
RAPTOR_API
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);
RAPTOR_API
int raptor_syntax_name_check_v2(raptor_world* world, const char *name);
RAPTOR_API
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);

/* Create */
RAPTOR_API
raptor_parser* raptor_new_parser_v2(raptor_world* world, const char *name);
RAPTOR_API
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);


RAPTOR_API
int raptor_start_parse(raptor_parser *rdf_parser, raptor_uri *uri);

/* Destroy */
RAPTOR_API
void raptor_free_parser(raptor_parser* parser);

/* Handlers */
RAPTOR_API
void raptor_set_fatal_error_handler(raptor_parser* parser, void *user_data, raptor_message_handler handler);
RAPTOR_API
void raptor_set_error_handler(raptor_parser* parser, void *user_data, raptor_message_handler handler);
RAPTOR_API
void raptor_set_warning_handler(raptor_parser* parser, void *user_data, raptor_message_handler handler);
RAPTOR_API
void raptor_set_statement_handler(raptor_parser* parser, void *user_data, raptor_statement_handler handler);
RAPTOR_API
void raptor_set_graph_handler(raptor_parser* parser, void *user_data, raptor_graph_handler handler);
RAPTOR_API
void raptor_set_generate_id_handler(raptor_parser* parser, void *user_data, raptor_generate_id_handler handler);
RAPTOR_API
void raptor_set_namespace_handler(raptor_parser* parser, void *user_data, raptor_namespace_handler handler);
RAPTOR_API
void raptor_parser_set_uri_filter(raptor_parser* parser, raptor_uri_filter_func filter, void* user_data);

RAPTOR_API
void raptor_print_statement(const raptor_statement * statement, FILE *stream);
RAPTOR_API
void raptor_print_statement_as_ntriples(const raptor_statement * statement, FILE *stream);
RAPTOR_API
unsigned char* raptor_statement_part_as_counted_string(raptor_world* world, const void *term, raptor_identifier_type type, raptor_uri* literal_datatype, const unsigned char *literal_language, size_t* len_p);
RAPTOR_API
unsigned char* raptor_statement_part_as_string(raptor_world* world, const void *term, raptor_identifier_type type, raptor_uri* literal_datatype, const unsigned char *literal_language);  
RAPTOR_API
int raptor_statement_compare(const raptor_statement *s1, const raptor_statement *s2);


RAPTOR_API
raptor_locator* raptor_get_locator(raptor_parser* rdf_parser);

RAPTOR_API
void raptor_set_default_generate_id_parameters(raptor_parser* rdf_parser, char *prefix, int base);

/* Parsing functions */
RAPTOR_API
int raptor_parse_chunk(raptor_parser* rdf_parser, const unsigned char *buffer, size_t len, int is_end);
RAPTOR_API
int raptor_parse_file_stream(raptor_parser* rdf_parser, FILE *stream, const char *filename, raptor_uri *base_uri);
RAPTOR_API
int raptor_parse_file(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri);
RAPTOR_API
int raptor_parse_uri(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri);
RAPTOR_API
int raptor_parse_uri_with_connection(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri, void *connection);
RAPTOR_API
void raptor_parse_abort(raptor_parser* rdf_parser);

/* Utility functions */
RAPTOR_API
void raptor_print_locator_v2(raptor_world* world, FILE *stream, raptor_locator* locator);
RAPTOR_API
int raptor_format_locator_v2(raptor_world* world, char *buffer, size_t length, raptor_locator* locator);
RAPTOR_API
int raptor_locator_line(raptor_locator *locator);
RAPTOR_API
int raptor_locator_column(raptor_locator *locator);
RAPTOR_API
int raptor_locator_byte(raptor_locator *locator);
RAPTOR_API
const char * raptor_locator_file(raptor_locator *locator);
RAPTOR_API
const char * raptor_locator_uri_v2(raptor_world* world, raptor_locator *locator);


RAPTOR_API
const char* raptor_get_name(raptor_parser *rdf_parser);
RAPTOR_API
const char* raptor_get_label(raptor_parser *rdf_parser);
RAPTOR_API
const char* raptor_get_mime_type(raptor_parser *rdf_parser);
RAPTOR_API
int raptor_get_need_base_uri(raptor_parser *rdf_parser);

RAPTOR_API
int raptor_features_enumerate_v2(raptor_world* world, const raptor_feature feature, const char **name, raptor_uri **uri, const char **label);
RAPTOR_API
int raptor_set_feature(raptor_parser *parser, raptor_feature feature, int value);
RAPTOR_API
int raptor_parser_set_feature_string(raptor_parser *parser, raptor_feature feature, const unsigned char *value);
RAPTOR_API
int raptor_get_feature(raptor_parser *parser, raptor_feature feature);
RAPTOR_API
const unsigned char* raptor_parser_get_feature_string(raptor_parser *parser, raptor_feature feature);
RAPTOR_API
unsigned int raptor_get_feature_count(void);
RAPTOR_API
void raptor_set_parser_strict(raptor_parser* rdf_parser, int is_strict);
RAPTOR_API
const char* raptor_parser_get_accept_header(raptor_parser* rdf_parser);

unsigned char* raptor_parser_generate_id(raptor_parser *rdf_parser, raptor_genid_type type);

RAPTOR_API
raptor_world* raptor_parser_get_world(raptor_parser* rdf_parser);

/* Get serializer names */
RAPTOR_API
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);
RAPTOR_API
int raptor_serializer_syntax_name_check_v2(raptor_world* world, const char *name);

/* Serializing */
RAPTOR_API
raptor_serializer* raptor_new_serializer_v2(raptor_world* world, const char *name);
RAPTOR_API
void raptor_free_serializer(raptor_serializer* rdf_serializer);

RAPTOR_API
int raptor_serialize_start(raptor_serializer *rdf_serializer, raptor_uri *uri, raptor_iostream *iostream);
RAPTOR_API
int raptor_serialize_start_to_iostream(raptor_serializer *rdf_serializer, raptor_uri *uri, raptor_iostream *iostream);
RAPTOR_API
int raptor_serialize_start_to_filename(raptor_serializer *rdf_serializer, const char *filename);
RAPTOR_API
int raptor_serialize_start_to_string(raptor_serializer *rdf_serializer, raptor_uri *uri, void **string_p, size_t *length_p);
RAPTOR_API
int raptor_serialize_start_to_file_handle(raptor_serializer *rdf_serializer, raptor_uri *uri, FILE *fh);
RAPTOR_API
int raptor_serialize_set_namespace(raptor_serializer* rdf_serializer, raptor_uri *uri, const unsigned char *prefix);
RAPTOR_API
int raptor_serialize_set_namespace_from_namespace(raptor_serializer* rdf_serializer, raptor_namespace *nspace);
RAPTOR_API
int raptor_serialize_statement(raptor_serializer* rdf_serializer, const raptor_statement *statement);
RAPTOR_API
int raptor_serialize_end(raptor_serializer *rdf_serializer);
RAPTOR_API
raptor_iostream* raptor_serializer_get_iostream(raptor_serializer *serializer);
RAPTOR_API
void raptor_serializer_set_error_handler(raptor_serializer* serializer, void *user_data, raptor_message_handler handler);
RAPTOR_API
void raptor_serializer_set_warning_handler(raptor_serializer* serializer, void *user_data, raptor_message_handler handler);
RAPTOR_API
raptor_locator* raptor_serializer_get_locator(raptor_serializer *rdf_serializer);
RAPTOR_API
int raptor_serializer_features_enumerate_v2(raptor_world* world, const raptor_feature feature, const char **name,  raptor_uri **uri, const char **label);
RAPTOR_API
int raptor_serializer_set_feature(raptor_serializer *serializer, raptor_feature feature, int value);
RAPTOR_API
int raptor_serializer_set_feature_string(raptor_serializer *serializer, raptor_feature feature, const unsigned char *value);
RAPTOR_API
int raptor_serializer_get_feature(raptor_serializer *serializer, raptor_feature feature);
RAPTOR_API
const unsigned char *raptor_serializer_get_feature_string(raptor_serializer *serializer, raptor_feature feature);

RAPTOR_API
raptor_world* raptor_serializer_get_world(raptor_serializer* rdf_serializer);

/* memory functions */
RAPTOR_API
void raptor_free_memory(void *ptr);
RAPTOR_API
void* raptor_alloc_memory(size_t size);
RAPTOR_API
void* raptor_calloc_memory(size_t nmemb, size_t size);

/* URI functions */
RAPTOR_API
raptor_uri* raptor_new_uri_v2(raptor_world* world, const unsigned char *uri_string);
RAPTOR_API
raptor_uri* raptor_new_uri_from_uri_local_name_v2(raptor_world* world, raptor_uri *uri, const unsigned char *local_name);
RAPTOR_API
raptor_uri* raptor_new_uri_relative_to_base_v2(raptor_world* world, raptor_uri *base_uri, const unsigned char *uri_string);
RAPTOR_API
raptor_uri* raptor_new_uri_from_id_v2(raptor_world* world, raptor_uri *base_uri, const unsigned char *id);
RAPTOR_API
raptor_uri* raptor_new_uri_for_rdf_concept_v2(raptor_world* world, const char *name);
RAPTOR_API
void raptor_free_uri_v2(raptor_world* world, raptor_uri *uri);
RAPTOR_API
int raptor_uri_equals_v2(raptor_world* world, raptor_uri* uri1, raptor_uri* uri2);
RAPTOR_API
int raptor_uri_compare_v2(raptor_world* world, raptor_uri* uri1, raptor_uri* uri2);
RAPTOR_API
raptor_uri* raptor_uri_copy_v2(raptor_world* world, raptor_uri *uri);
RAPTOR_API
unsigned char* raptor_uri_as_string_v2(raptor_world* world, raptor_uri *uri);
RAPTOR_API
unsigned char* raptor_uri_as_counted_string_v2(raptor_world* world, raptor_uri *uri, size_t* len_p);
RAPTOR_API
raptor_uri* raptor_new_uri_for_xmlbase_v2(raptor_world* world, raptor_uri* old_uri);
RAPTOR_API
raptor_uri* raptor_new_uri_for_retrieval_v2(raptor_world* world, raptor_uri* old_uri);

/* Identifier functions */
RAPTOR_API
raptor_identifier* raptor_new_identifier_v2(raptor_world* world, raptor_identifier_type type, raptor_uri *uri, const unsigned char *id, const unsigned char *literal, raptor_uri *literal_datatype, const unsigned char *literal_language);
RAPTOR_API
int raptor_copy_identifier(raptor_identifier *dest, raptor_identifier *src);
RAPTOR_API
void raptor_free_identifier(raptor_identifier *identifier);

/* Utility functions */
RAPTOR_API
int raptor_print_ntriples_string(FILE *stream, const unsigned char *string, const char delim);
RAPTOR_API
int raptor_iostream_write_string_ntriples(raptor_iostream *iostr, const unsigned char *string, size_t len, const char delim);
RAPTOR_API
int raptor_iostream_write_string_python(raptor_iostream *iostr, const unsigned char *string, size_t len, const char delim, int flags);
void raptor_iostream_write_statement_ntriples_v2(raptor_world* world, raptor_iostream* iostr, const raptor_statement *statement);
RAPTOR_API
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);
RAPTOR_API
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);
RAPTOR_API
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);
RAPTOR_API
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);

RAPTOR_API
char* raptor_vsnprintf(const char *message, va_list arguments) RAPTOR_PRINTF_FORMAT(1, 0);

RAPTOR_API
int raptor_xml_name_check(const unsigned char *string, size_t length, int xml_version);

/* raptor_rfc2396.c */
RAPTOR_API
void raptor_uri_resolve_uri_reference(const unsigned char *base_uri, const unsigned char *reference_uri, unsigned char* buffer, size_t length);

/* raptor_uri.c */
RAPTOR_API
unsigned char *raptor_uri_filename_to_uri_string(const char *filename);
RAPTOR_API
char *raptor_uri_uri_string_to_filename(const unsigned char *uri_string);
RAPTOR_API
char *raptor_uri_uri_string_to_filename_fragment(const unsigned char *uri_string, unsigned char **fragment_p);
RAPTOR_API
int raptor_uri_uri_string_is_file_uri(const unsigned char* uri_string);
RAPTOR_API
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);
RAPTOR_API
unsigned char* raptor_uri_to_relative_uri_string_v2(raptor_world* world, raptor_uri *base_uri,  raptor_uri *reference_uri);

RAPTOR_API
void raptor_uri_print_v2(raptor_world* world, const raptor_uri* uri, FILE *stream);
RAPTOR_API
unsigned char* raptor_uri_to_counted_string_v2(raptor_world* world, raptor_uri *uri, size_t *len_p);
RAPTOR_API
unsigned char* raptor_uri_to_string_v2(raptor_world* world, raptor_uri *uri);

RAPTOR_API
void raptor_uri_set_handler_v2(raptor_world* world, const raptor_uri_handler *handler, void *context);
RAPTOR_API
void raptor_uri_get_handler_v2(raptor_world* world, const raptor_uri_handler **handler, void **context);


/**
 * RAPTOR_RDF_MS_URI:
 *
 * RDF Namespace URI (rdf:).
 *
 * Copy with raptor_uri_copy() to use.
 */
#define RAPTOR_RDF_MS_URI raptor_rdf_namespace_uri

/**
 * RAPTOR_RDF_SCHEMA_URI:
 *
 * RDF Schema Namespace URI (rdfs:).
 *
 * Copy with raptor_uri_copy() to use.
 */
#define RAPTOR_RDF_SCHEMA_URI raptor_rdf_schema_namespace_uri

/**
 * RAPTOR_XMLSCHEMA_DATATYPES_URI:
 *
 * XML Schema Datatypes URI (xsd:).
 *
 * Copy with raptor_uri_copy() to use.
 */
#define RAPTOR_XMLSCHEMA_DATATYPES_URI raptor_xmlschema_datatypes_namespace_uri

/**
 * RAPTOR_OWL_URI:
 *
 * OWL Namespace URI (owl:).
 *
 * Copy with raptor_uri_copy() to use.
 */
#define RAPTOR_OWL_URI raptor_owl_namespace_uri


/* raptor_www */
RAPTOR_API
int raptor_www_init_v2(raptor_world* world);
RAPTOR_API
void raptor_www_finish_v2(raptor_world* world);
RAPTOR_API
void raptor_www_no_www_library_init_finish_v2(raptor_world* world);


RAPTOR_API
raptor_www *raptor_www_new_v2(raptor_world* world);
RAPTOR_API
raptor_www *raptor_www_new_with_connection_v2(raptor_world* world, void* connection);
RAPTOR_API
void raptor_www_free(raptor_www *www);
RAPTOR_API
void raptor_www_set_user_agent(raptor_www *www, const char *user_agent);
RAPTOR_API
void raptor_www_set_proxy(raptor_www *www, const char *proxy);
RAPTOR_API
void raptor_www_set_http_accept(raptor_www *www, const char *value);
RAPTOR_API
void raptor_www_set_write_bytes_handler(raptor_www *www, raptor_www_write_bytes_handler handler, void *user_data);
RAPTOR_API
void raptor_www_set_content_type_handler(raptor_www *www, raptor_www_content_type_handler handler, void *user_data);
RAPTOR_API
void raptor_www_set_final_uri_handler(raptor_www* www, raptor_www_final_uri_handler handler, void *user_data);
RAPTOR_API
void raptor_www_set_error_handler(raptor_www *www, raptor_message_handler error_handler, void *error_data);
RAPTOR_API
void raptor_www_set_uri_filter(raptor_www* www, raptor_uri_filter_func filter, void* user_data);
RAPTOR_API
void raptor_www_set_connection_timeout(raptor_www* www, int timeout);
RAPTOR_API
int raptor_www_set_http_cache_control(raptor_www* www, const char* cache_control);
RAPTOR_API
int raptor_www_fetch(raptor_www *www, raptor_uri *uri);
RAPTOR_API
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));
RAPTOR_API
void* raptor_www_get_connection(raptor_www *www);
RAPTOR_API
void raptor_www_abort(raptor_www *www, const char *reason);
RAPTOR_API
raptor_uri* raptor_www_get_final_uri(raptor_www* www);


/* raptor_qname - XML qnames */
RAPTOR_API
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);
RAPTOR_API
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);
RAPTOR_API
raptor_qname* raptor_qname_copy(raptor_qname *qname);
RAPTOR_API
void raptor_free_qname(raptor_qname* name);
RAPTOR_API
int raptor_qname_equal(raptor_qname *name1, raptor_qname *name2);
/* utility function */
RAPTOR_API
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);
RAPTOR_API
int raptor_iostream_write_qname(raptor_iostream* iostr, raptor_qname *qname);
RAPTOR_API
unsigned char* raptor_qname_to_counted_name(raptor_qname *qname, size_t* length_p);
RAPTOR_API
const raptor_namespace* raptor_qname_get_namespace(raptor_qname* name);
RAPTOR_API
const unsigned char* raptor_qname_get_local_name(raptor_qname* name);
RAPTOR_API
const unsigned char* raptor_qname_get_value(raptor_qname* name);
RAPTOR_API
const unsigned char* raptor_qname_get_counted_value(raptor_qname* name, size_t* length_p);

/* raptor_namespace_stack - stack of XML namespaces */
RAPTOR_API
raptor_namespace* raptor_new_namespace_from_uri(raptor_namespace_stack *nstack, const unsigned char *prefix,  raptor_uri* ns_uri, int depth);
RAPTOR_API
raptor_namespace_stack* raptor_new_namespaces_v2(raptor_world* world, raptor_simple_message_handler error_handler, void *error_data, int defaults);
RAPTOR_API
int raptor_namespaces_init_v2(raptor_world* world, raptor_namespace_stack *nstack, raptor_simple_message_handler error_handler, void *error_data, int defaults);
RAPTOR_API
void raptor_namespaces_clear(raptor_namespace_stack *nstack);
RAPTOR_API
void raptor_free_namespaces(raptor_namespace_stack *nstack);
RAPTOR_API
void raptor_namespaces_start_namespace(raptor_namespace_stack *nstack, raptor_namespace *nspace);
RAPTOR_API
int raptor_namespaces_start_namespace_full(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth);
RAPTOR_API
void raptor_namespaces_end_for_depth(raptor_namespace_stack *nstack, int depth);
RAPTOR_API
raptor_namespace* raptor_namespaces_get_default_namespace(raptor_namespace_stack *nstack);
RAPTOR_API
raptor_namespace *raptor_namespaces_find_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, int prefix_length);
RAPTOR_API
raptor_namespace* raptor_namespaces_find_namespace_by_uri(raptor_namespace_stack *nstack, raptor_uri *ns_uri);
RAPTOR_API
int raptor_namespaces_namespace_in_scope(raptor_namespace_stack *nstack, const raptor_namespace *nspace);
RAPTOR_API
raptor_qname* raptor_namespaces_qname_from_uri(raptor_namespace_stack *nstack,  raptor_uri *uri, int xml_version);

/* raptor_namespace - XML namespace */
RAPTOR_API
raptor_namespace* raptor_new_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth);
RAPTOR_API
void raptor_free_namespace(raptor_namespace *ns);
RAPTOR_API
int raptor_namespace_copy(raptor_namespace_stack *nstack, raptor_namespace *ns, int new_depth);
RAPTOR_API
raptor_uri* raptor_namespace_get_uri(const raptor_namespace *ns);
RAPTOR_API
const unsigned char* raptor_namespace_get_prefix(const raptor_namespace *ns);
RAPTOR_API
const unsigned char* raptor_namespace_get_counted_prefix(const raptor_namespace *ns, size_t *length_p);
RAPTOR_API
unsigned char *raptor_namespaces_format(const raptor_namespace *ns, size_t *length_p);
RAPTOR_API
int raptor_iostream_write_namespace(raptor_iostream* iostr, raptor_namespace *ns);
RAPTOR_API
int raptor_new_namespace_parts_from_string(const unsigned char *string, unsigned char **prefix, unsigned char **uri_string);

/**
 * raptor_stringbuffer:
 *
 * Raptor string buffer class
 */
typedef struct raptor_stringbuffer_s raptor_stringbuffer;

/* Sequence class */
/**
 * raptor_sequence:
 *
 * Raptor sequence class
 */
typedef struct raptor_sequence_s raptor_sequence;

/**
 * raptor_sequence_free_handler:
 * @object: object to free
 *
 * Handler function for freeing a sequence item.
 *
 * Set by raptor_new_sequence().
*/
typedef void (raptor_sequence_free_handler(void* object));

/**
 * raptor_sequence_free_handler_v2:
 * @context: context data for the free handler
 * @object: object to free
 *
 * Handler function for freeing a sequence item.
 *
 * Set by raptor_new_sequence_v2().
*/
typedef void (raptor_sequence_free_handler_v2(void* context, void* object));

/**
 * raptor_sequence_print_handler:
 * @object: object to print
 * @fh: FILE* to print to
 *
 * Handler function for printing a sequence item.
 *
 * Set by raptor_new_sequence() or raptor_sequence_set_print_handler().
 */
typedef void (raptor_sequence_print_handler(void *object, FILE *fh));

/**
 * raptor_sequence_print_handler_v2:
 * @context: context data for the print handler
 * @object: object to print
 * @fh: FILE* to print to
 *
 * Handler function for printing a sequence item.
 *
 * Set by raptor_new_sequence_v2() or raptor_sequence_set_print_handler_v2().
 */
typedef void (raptor_sequence_print_handler_v2(void *context, void *object, FILE *fh));

/* Create */
RAPTOR_API
raptor_sequence* raptor_new_sequence(raptor_sequence_free_handler* free_handler, raptor_sequence_print_handler* print_handler);
RAPTOR_API
raptor_sequence* raptor_new_sequence_v2(raptor_sequence_free_handler_v2* free_handler, raptor_sequence_print_handler_v2* print_handler, void* handler_context);
/* Destroy */
RAPTOR_API
void raptor_free_sequence(raptor_sequence* seq);
/* Methods */
RAPTOR_API
int raptor_sequence_size(raptor_sequence* seq);
RAPTOR_API
int raptor_sequence_set_at(raptor_sequence* seq, int idx, void *data);
RAPTOR_API
int raptor_sequence_push(raptor_sequence* seq, void *data);
RAPTOR_API
int raptor_sequence_shift(raptor_sequence* seq, void *data);
RAPTOR_API
void* raptor_sequence_get_at(raptor_sequence* seq, int idx);
RAPTOR_API
void* raptor_sequence_pop(raptor_sequence* seq);
RAPTOR_API
void* raptor_sequence_unshift(raptor_sequence* seq);
RAPTOR_API
void* raptor_sequence_delete_at(raptor_sequence* seq, int idx);

RAPTOR_API
int raptor_compare_strings(const void *a, const void *b);

RAPTOR_API
void raptor_sequence_sort(raptor_sequence* seq, int(*compare)(const void *, const void *));

/* helper for printing sequences of strings */ 
RAPTOR_API
void raptor_sequence_print_string(char *data, FILE *fh);
RAPTOR_API
void raptor_sequence_set_print_handler(raptor_sequence *seq, raptor_sequence_print_handler *print_handler);
RAPTOR_API
void raptor_sequence_set_print_handler_v2(raptor_sequence *seq, raptor_sequence_print_handler_v2 *print_handler);
RAPTOR_API
void raptor_sequence_print(raptor_sequence* seq, FILE* fh);
RAPTOR_API
int raptor_sequence_join(raptor_sequence* dest, raptor_sequence *src);


/* Unicode and UTF8 */

/**
 * raptor_unichar:
 *
 * raptor Unicode codepoint
 */
typedef unsigned long raptor_unichar;
RAPTOR_API
int raptor_unicode_char_to_utf8(raptor_unichar c, unsigned char *output);
RAPTOR_API
int raptor_utf8_to_unicode_char(raptor_unichar *output, const unsigned char *input, int length);
RAPTOR_API
int raptor_unicode_is_xml11_namestartchar(raptor_unichar c);
RAPTOR_API
int raptor_unicode_is_xml10_namestartchar(raptor_unichar c);
RAPTOR_API
int raptor_unicode_is_xml11_namechar(raptor_unichar c);
RAPTOR_API
int raptor_unicode_is_xml10_namechar(raptor_unichar c);
RAPTOR_API
int raptor_utf8_check(const unsigned char *string, size_t length);

/* raptor_stringbuffer */
RAPTOR_API
raptor_stringbuffer* raptor_new_stringbuffer(void);
RAPTOR_API
void raptor_free_stringbuffer(raptor_stringbuffer *stringbuffer);
RAPTOR_API
int raptor_stringbuffer_append_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy);
RAPTOR_API
int raptor_stringbuffer_append_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy);
RAPTOR_API
int raptor_stringbuffer_append_decimal(raptor_stringbuffer* stringbuffer, int integer);
RAPTOR_API
int raptor_stringbuffer_append_stringbuffer(raptor_stringbuffer* stringbuffer, raptor_stringbuffer* append);
RAPTOR_API
int raptor_stringbuffer_prepend_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy);
RAPTOR_API
int raptor_stringbuffer_prepend_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy);
RAPTOR_API
unsigned char * raptor_stringbuffer_as_string(raptor_stringbuffer* stringbuffer);
RAPTOR_API
size_t raptor_stringbuffer_length(raptor_stringbuffer* stringbuffer);
RAPTOR_API
int raptor_stringbuffer_copy_to_string(raptor_stringbuffer* stringbuffer, unsigned char *string, size_t length);

/**
 * raptor_iostream_init_func:
 * @context: stream context data
 *
 * Handler function for #raptor_iostream initialising.
 *
 * Return value: non-0 on failure.
 */
typedef int (*raptor_iostream_init_func) (void *context);

/**
 * raptor_iostream_finish_func:
 * @context: stream context data
 *
 * Handler function for #raptor_iostream terminating.
 *
 */
typedef void (*raptor_iostream_finish_func) (void *context);

/**
 * raptor_iostream_write_byte_func
 * @context: stream context data
 * @byte: byte to write
 *
 * Handler function for implementing raptor_iostream_write_byte().
 *
 * Return value: non-0 on failure.
 */
typedef int (*raptor_iostream_write_byte_func) (void *context, const int byte);

/**
 * raptor_iostream_write_bytes_func:
 * @context: stream context data
 * @ptr: pointer to bytes to write
 * @size: size of item
 * @nmemb: number of items
 *
 * Handler function for implementing raptor_iostream_write_bytes().
 *
 * Return value: non-0 on failure.
 */
typedef int (*raptor_iostream_write_bytes_func) (void *context, const void *ptr, size_t size, size_t nmemb);

/**
 * raptor_iostream_write_end_func:
 * @context: stream context data
 *
 * Handler function for implementing raptor_iostream_write_end().
 *
 */
typedef void (*raptor_iostream_write_end_func) (void *context);

/**
 * raptor_iostream_read_bytes_func:
 * @context: stream context data
 * @ptr: pointer to buffer to read into
 * @size: size of buffer
 * @nmemb: number of items
 *
 * Handler function for implementing raptor_iostream_read_bytes().
 *
 * Return value: number of items read, 0 or < @size on EOF, <0 on failure
 */
typedef int (*raptor_iostream_read_bytes_func) (void *context, void *ptr, size_t size, size_t nmemb);

/**
 * raptor_iostream_read_eof_func:
 * @context: stream context data
 *
 * Handler function for implementing raptor_iostream_read_eof().
 *
 * Return value: non-0 if EOF
 */
typedef int (*raptor_iostream_read_eof_func) (void *context);

/**
 * raptor_iostream_handler2:
 * @version: interface version.  Presently 1 or 2.
 * @init:  initialisation handler - optional, called at most once (V1)
 * @finish: finishing handler -  optional, called at most once (V1)
 * @write_byte: write byte handler - required (for writing) (V1)
 * @write_bytes: write bytes handler - required (for writing) (V1)
 * @write_end: write end handler - optional (for writing), called at most once (V1)
 * @read_bytes: read bytes handler - required (for reading) (V2)
 * @read_eof: read EOF handler - required (for reading) (V2)
 *
 * I/O stream implementation handler structure.
 * 
 */
typedef struct {
  int version;

  /* V1 functions */
  raptor_iostream_init_func         init;
  raptor_iostream_finish_func       finish;
  raptor_iostream_write_byte_func   write_byte;
  raptor_iostream_write_bytes_func  write_bytes;
  raptor_iostream_write_end_func    write_end;

  /* V2 functions */
  raptor_iostream_read_bytes_func   read_bytes;
  raptor_iostream_read_eof_func     read_eof;
} raptor_iostream_handler2;


RAPTOR_API
raptor_iostream* raptor_new_iostream_from_handler2(void *user_data, const raptor_iostream_handler2* const handler2);
RAPTOR_API
raptor_iostream* raptor_new_iostream_to_sink(void);
RAPTOR_API
raptor_iostream* raptor_new_iostream_to_filename(const char *filename);
RAPTOR_API
raptor_iostream* raptor_new_iostream_to_file_handle(FILE *handle);
RAPTOR_API
raptor_iostream* raptor_new_iostream_to_string(void **string_p, size_t *length_p, void *(*malloc_handler)(size_t size));
RAPTOR_API
raptor_iostream* raptor_new_iostream_from_sink(void);
RAPTOR_API
raptor_iostream* raptor_new_iostream_from_filename(const char *filename);
RAPTOR_API
raptor_iostream* raptor_new_iostream_from_file_handle(FILE *handle);
RAPTOR_API
raptor_iostream* raptor_new_iostream_from_string(void *string, size_t length);
RAPTOR_API
void raptor_free_iostream(raptor_iostream *iostr);

RAPTOR_API
int raptor_iostream_write_bytes(raptor_iostream *iostr, const void *ptr, size_t size, size_t nmemb);
RAPTOR_API
int raptor_iostream_write_byte(raptor_iostream *iostr, const int byte);
RAPTOR_API
void raptor_iostream_write_end(raptor_iostream *iostr);
RAPTOR_API
int raptor_iostream_write_string(raptor_iostream *iostr, const void *string);
RAPTOR_API
int raptor_iostream_write_counted_string(raptor_iostream *iostr, const void *string, size_t len);
RAPTOR_API
unsigned long raptor_iostream_tell(raptor_iostream *iostr);
RAPTOR_API
int raptor_iostream_write_decimal(raptor_iostream* iostr, int integer);
RAPTOR_API
int raptor_iostream_format_hexadecimal(raptor_iostream* iostr, unsigned int integer, int width);
RAPTOR_API
int raptor_iostream_write_stringbuffer(raptor_iostream* iostr, raptor_stringbuffer *sb);
RAPTOR_API
int raptor_iostream_write_uri_v2(raptor_world* world, raptor_iostream *iostr,  raptor_uri *uri);
RAPTOR_API
int raptor_iostream_read_bytes(raptor_iostream* iostr, void *ptr, size_t size, size_t nmemb);
RAPTOR_API
int raptor_iostream_read_eof(raptor_iostream *iostr);

/* Parser and Serializer features */
RAPTOR_API
raptor_feature raptor_feature_from_uri_v2(raptor_world* world, raptor_uri *uri);
RAPTOR_API
int raptor_feature_value_type(const raptor_feature feature);

/* SAX2 element Class (raptor_xml_element) */
RAPTOR_API
raptor_xml_element* raptor_new_xml_element(raptor_qname* name, const unsigned char* xml_language, raptor_uri* xml_base);
RAPTOR_API
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);
RAPTOR_API
void raptor_free_xml_element(raptor_xml_element *element);
RAPTOR_API
raptor_qname* raptor_xml_element_get_name(raptor_xml_element *xml_element);
RAPTOR_API
void raptor_xml_element_set_attributes(raptor_xml_element* xml_element, raptor_qname **attributes, int count);
RAPTOR_API
raptor_qname** raptor_xml_element_get_attributes(raptor_xml_element* xml_element);
RAPTOR_API
int raptor_xml_element_get_attributes_count(raptor_xml_element* xml_element);
RAPTOR_API
int raptor_xml_element_declare_namespace(raptor_xml_element* xml_element, raptor_namespace *nspace);
RAPTOR_API
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);
RAPTOR_API
int raptor_xml_element_is_empty(raptor_xml_element* xml_element);
RAPTOR_API
const unsigned char* raptor_xml_element_get_language(raptor_xml_element* xml_element);

/* XML Writer Class (raptor_xml_writer) */
RAPTOR_API
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);
RAPTOR_API
void raptor_free_xml_writer(raptor_xml_writer* xml_writer);
RAPTOR_API
void raptor_xml_writer_empty_element(raptor_xml_writer* xml_writer, raptor_xml_element *element);
RAPTOR_API
void raptor_xml_writer_start_element(raptor_xml_writer* xml_writer, raptor_xml_element *element);
RAPTOR_API
void raptor_xml_writer_end_element(raptor_xml_writer* xml_writer, raptor_xml_element *element);
RAPTOR_API
void raptor_xml_writer_newline(raptor_xml_writer* xml_writer);
RAPTOR_API
void raptor_xml_writer_cdata(raptor_xml_writer* xml_writer, const unsigned char *s);
RAPTOR_API
void raptor_xml_writer_cdata_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len);
RAPTOR_API
void raptor_xml_writer_raw(raptor_xml_writer* xml_writer, const unsigned char *s);
RAPTOR_API
void raptor_xml_writer_raw_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len);
RAPTOR_API
void raptor_xml_writer_comment(raptor_xml_writer* xml_writer, const unsigned char *s);
RAPTOR_API
void raptor_xml_writer_comment_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len);
RAPTOR_API
void raptor_xml_writer_flush(raptor_xml_writer* xml_writer);
RAPTOR_API
int raptor_xml_writer_features_enumerate_v2(raptor_world* world, const raptor_feature feature, const char **name,  raptor_uri **uri, const char **label);
RAPTOR_API
int raptor_xml_writer_set_feature(raptor_xml_writer *xml_writer, raptor_feature feature, int value);
RAPTOR_API
int raptor_xml_writer_set_feature_string(raptor_xml_writer *xml_writer, raptor_feature feature, const unsigned char *value);
RAPTOR_API
int raptor_xml_writer_get_feature(raptor_xml_writer *xml_writer, raptor_feature feature);
RAPTOR_API
const unsigned char *raptor_xml_writer_get_feature_string(raptor_xml_writer *xml_writer, raptor_feature feature);
RAPTOR_API
int raptor_xml_writer_get_depth(raptor_xml_writer *xml_writer);

/**
 * raptor_sax2_start_element_handler:
 * @user_data: user data
 * @xml_element: XML element
 *
 * SAX2 start element handler
 */
typedef void (*raptor_sax2_start_element_handler)(void *user_data, raptor_xml_element *xml_element);

/**
 * raptor_sax2_end_element_handler:
 * @user_data: user data
 * @xml_element: XML element
 *
 * SAX2 end element handler
 */
typedef void (*raptor_sax2_end_element_handler)(void *user_data, raptor_xml_element* xml_element);

/**
 * raptor_sax2_characters_handler:
 * @user_data: user data
 * @xml_element: XML element
 * @s: string
 * @len: string len
 *
 * SAX2 characters handler
 */
typedef void (*raptor_sax2_characters_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len);

/**
 * raptor_sax2_cdata_handler:
 * @user_data: user data
 * @xml_element: XML element
 * @s: string
 * @len: string len

 * SAX2 CDATA section handler
 */
typedef void (*raptor_sax2_cdata_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len);

/**
 * raptor_sax2_comment_handler:
 * @user_data: user data
 * @xml_element: XML element
 * @s: string
 *
 * SAX2 XML comment handler
 */
typedef void (*raptor_sax2_comment_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s);

/**
 * raptor_sax2_unparsed_entity_decl_handler:
 * @user_data: user data
 * @entityName: entity name
 * @base: base URI
 * @systemId: system ID
 * @publicId: public ID
 * @notationName: notation name
 *
 * SAX2 unparsed entity (NDATA) handler
 */
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);

/**
 * raptor_sax2_external_entity_ref_handler:
 * @user_data: user data
 * @context: context
 * @base: base URI
 * @systemId: system ID
 * @publicId: public ID
 *
 * SAX2 external entity reference handler
 * 
 * Return value: 0 if processing should not continue because of a
 * fatal error in the handling of the external entity.
 */
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);


/**
 * raptor_log_level:
 * @RAPTOR_LOG_LEVEL_NONE: Internal
 * @RAPTOR_LOG_LEVEL_FATAL: Fatal error message
 * @RAPTOR_LOG_LEVEL_ERROR: Error message
 * @RAPTOR_LOG_LEVEL_WARNING: Warning message
 * @RAPTOR_LOG_LEVEL_LAST: Internal
 *
 * Log levels
 */
typedef enum {
  RAPTOR_LOG_LEVEL_NONE,
  RAPTOR_LOG_LEVEL_FATAL,
  RAPTOR_LOG_LEVEL_ERROR,
  RAPTOR_LOG_LEVEL_WARNING,
  /* RAPTOR V2 FIXME - this enum list cannot be extended before V2
   * API is released else binary compatibility will be broken in the
   * #raptor_error_handlers structure - it causes an array to grow.
   */
  RAPTOR_LOG_LEVEL_LAST = RAPTOR_LOG_LEVEL_WARNING
} raptor_log_level;


/**
 * raptor_error_handlers:
 * @magic: magic value - must use raptor_error_handlers_init() to set this
 * @locator: raptor locator of the error
 * @last_log_level: number of log levels; size of @handlers arrays
 * @handlers: user handlers per log level
 * @world: raptor_world object
 *
 * Error handlers structure
 */
typedef struct {
  unsigned int magic;

  raptor_locator* locator;

  /* size of handlers array */
  raptor_log_level last_log_level;

  raptor_message_handler_closure handlers[RAPTOR_LOG_LEVEL_LAST+1];

  /* Raptor V2 FIXME - this should NOT be at the end of the structure
   * since it prevents increasing the size of the @handlers array but
   * it it is here to preserve Raptor V1 ABI.
   */
  raptor_world *world;
} raptor_error_handlers;

RAPTOR_API
void raptor_error_handlers_init_v2(raptor_world* world, raptor_error_handlers* error_handlers);


/* SAX2 API */
RAPTOR_API
raptor_sax2* raptor_new_sax2(void *user_data, raptor_error_handlers* error_handlers);
RAPTOR_API
void raptor_free_sax2(raptor_sax2 *sax2);

RAPTOR_API
void raptor_sax2_set_start_element_handler(raptor_sax2* sax2, raptor_sax2_start_element_handler handler);
RAPTOR_API
void raptor_sax2_set_end_element_handler(raptor_sax2* sax2, raptor_sax2_end_element_handler handler);
RAPTOR_API
void raptor_sax2_set_characters_handler(raptor_sax2* sax2, raptor_sax2_characters_handler handler);
RAPTOR_API
void raptor_sax2_set_cdata_handler(raptor_sax2* sax2, raptor_sax2_cdata_handler handler);
RAPTOR_API
void raptor_sax2_set_comment_handler(raptor_sax2* sax2, raptor_sax2_comment_handler handler);
RAPTOR_API
void raptor_sax2_set_unparsed_entity_decl_handler(raptor_sax2* sax2, raptor_sax2_unparsed_entity_decl_handler handler);
RAPTOR_API
void raptor_sax2_set_external_entity_ref_handler(raptor_sax2* sax2, raptor_sax2_external_entity_ref_handler handler);
RAPTOR_API
void raptor_sax2_set_namespace_handler(raptor_sax2* sax2, raptor_namespace_handler handler);
RAPTOR_API
void raptor_sax2_parse_start(raptor_sax2 *sax2, raptor_uri *base_uri);
RAPTOR_API
int raptor_sax2_parse_chunk(raptor_sax2* sax2, const unsigned char *buffer, size_t len, int is_end);
RAPTOR_API
const unsigned char* raptor_sax2_inscope_xml_language(raptor_sax2* sax2);
RAPTOR_API
raptor_uri* raptor_sax2_inscope_base_uri(raptor_sax2* sax2);

#ifdef __cplusplus
}
#endif

#endif