3 Copyright 2011 David Robillard <http://drobilla.net>
5 Permission to use, copy, modify, and/or distribute this software for any
6 purpose with or without fee is hereby granted, provided that the above
7 copyright notice and this permission notice appear in all copies.
9 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 # define PACKED __attribute__((__packed__))
37 typedef struct _RDFF* RDFF;
40 Status codes for function returns.
43 RDFF_STATUS_OK = 0, /**< Success. */
44 RDFF_STATUS_UNKNOWN_ERROR = 1, /**< Unknown error. */
45 RDFF_STATUS_EOF = 2, /**< End of file. */
46 RDFF_STATUS_CORRUPT = 3 /**< Corrupt data. */
50 Generic RIFF chunk header.
53 char type[4]; /**< Chunk type ID. */
54 uint32_t size; /**< Size of chunk body (not including header). */
55 char data[]; /**< Chunk body. */
59 Body of a RDFF "urid" chunk.
62 uint32_t id; /**< Numeric ID of URI in this RDFF. */
63 char uri[]; /**< URI string. */
64 } PACKED RDFFURIChunk;
67 Body of a RDFF "trip" chunk.
70 uint32_t subject; /**< Subject URI ID. */
71 uint32_t predicate; /**< Predicate URI ID. */
72 uint32_t object_type; /**< Object type URI ID. */
73 uint32_t object_size; /**< Size of object data. */
74 char object[]; /**< Object data. */
75 } PACKED RDFFTripleChunk;
78 Open/Create a new RDFF file.
81 rdff_open(const char* path, bool write);
84 Write a URI ID to @a file.
87 rdff_write_uri(RDFF file,
93 Write a key/value record to @a file.
96 rdff_write_triple(RDFF file,
100 uint32_t object_size,
104 Read a chunk from @a file.
106 @param buf MUST point to an RDFFChunk dynamically allocated with malloc.
107 The @a size field (i.e. (*buf)->size) MUST be set to the amount of available
108 memory in the chunk (not including the header). If this is insufficient,
109 *buf will be resized using realloc.
112 rdff_read_chunk(RDFF file,
116 Return true iff @a chunk is a URI chunk.
119 rdff_chunk_is_uri(RDFFChunk* chunk);
122 Return true iff @a chunk is a Triple chunk.
125 rdff_chunk_is_triple(RDFFChunk* chunk);
129 After this call, @a file is invalid.
132 rdff_close(RDFF file);
138 #endif /* RDFF_RDFF_H */