term.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. #ifndef _LSUP_TERM_H
  2. #define _LSUP_TERM_H
  3. #include <assert.h>
  4. #include <regex.h>
  5. #include "buffer.h"
  6. #include "namespace.h"
  7. #define UUID4_URN_SIZE UUIDSTR_SIZE + 10
  8. // Some common RDF term values.
  9. #define LSUP_RDF_TYPE "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
  10. #define LSUP_RDF_TYPE_NS "rdf:type"
  11. /// Default data type for untyped literals (prefixed IRI).
  12. #define DEFAULT_DTYPE "http://www.w3.org/2001/XMLSchema#string"
  13. #define DEFAULT_DTYPE_NS "xsd:string"
  14. /** @brief URI parsing regular expression.
  15. *
  16. * Based on RFC3986 (see https://tools.ietf.org/html/rfc3986#appendix-B) and
  17. * modified for use in this application. Relevant matching groups are the
  18. * following, for a sample URI `http://example.org/123/456/?query=blah#frag`:
  19. *
  20. * #0: Full parsed URI (http://example.org/123/456/?query=blah#frag)
  21. * #1: Domain prefix (http://example.org)
  22. * #2: Protocol (http:)
  23. * #4: Authority (example.org)
  24. * #5: Path relative to domain (/123/456/?query=blah#frag)
  25. * #6: Path, excluding query and fragment (/123/456/)
  26. * #8: Query (query=blah)
  27. * #10: Fragment (frag)
  28. *
  29. * For URN-like URIs, such as `urn:s:0`, the prefix part (#1) is `urn:` and
  30. * the path (#4) is `s:0`.
  31. */
  32. #define LSUP_URI_REGEX_STR \
  33. "^(([^:/?#]+:)?(//([^/?#]*))?)?(([^?#]*)(\\?([^#]*))?(#(.*))?)"
  34. /*
  35. * Data types.
  36. */
  37. /// Language tag, currently restricted to 7 characters.
  38. typedef char LSUP_LangTag[8];
  39. /// Term type.
  40. typedef enum {
  41. LSUP_TERM_UNDEFINED = 0,/**<
  42. * Undefined placeholder or result of an error.
  43. * Invalid for most operations.
  44. */
  45. LSUP_TERM_IRIREF, ///< IRI reference.
  46. LSUP_TERM_NS_IRIREF, ///< Namespace-prefixed IRI reference.
  47. LSUP_TERM_LITERAL, ///< Literal without language tag.
  48. LSUP_TERM_LT_LITERAL, ///< Language-tagged string literal.
  49. LSUP_TERM_BNODE, ///< Blank node.
  50. } LSUP_TermType;
  51. /** @brief IRI information.
  52. *
  53. * See regex matching group for #LSUP_URI_REGEX_STR for more information.
  54. */
  55. typedef struct iri_info_t LSUP_IRIInfo;
  56. typedef struct link_map_iter LSUP_LinkMapIterator;
  57. /// RDF term.
  58. typedef struct term_t {
  59. char * data; // URI, literal value, or BNode label.
  60. union {
  61. struct term_t * datatype; // Data type IRI for LSUP_TERM_LITERAL.
  62. LSUP_LangTag lang; // Lang tag for LSUP_TERM_LT_LITERAL.
  63. LSUP_Key bnode_id; // BNode ID for comparison & skolemization.
  64. LSUP_IRIInfo * iri_info; // IRI information structure.
  65. };
  66. LSUP_TermType type; // Term type.
  67. } LSUP_Term;
  68. /** @brief Shorthand to test if a term is a IRI of any kind.
  69. */
  70. #define LSUP_IS_IRI(term) \
  71. ((term)->type == LSUP_TERM_IRIREF || (term)->type == LSUP_TERM_NS_IRIREF)
  72. /** @brief Shorthand to test if a term is a literal of any kind.
  73. */
  74. #define LSUP_IS_LITERAL(term) \
  75. ((term)->type == LSUP_TERM_LITERAL || (term)->type == LSUP_TERM_LT_LITERAL)
  76. /** @brief RDF triple.
  77. *
  78. * This represents a complete RDF statement. Triple terms can be accessed
  79. * directly via the `s`, `p`, `o` members or sequentially via
  80. * #LSUP_triple_pos().
  81. */
  82. typedef struct triple_t {
  83. LSUP_Term *s; ///< Subject.
  84. LSUP_Term *p; ///< Predicate.
  85. LSUP_Term *o; ///< Object.
  86. } LSUP_Triple;
  87. /// Link type.
  88. typedef enum {
  89. LSUP_LINK_INBOUND, ///< Inbound link (sp).
  90. LSUP_LINK_OUTBOUND, ///< Outbound link (po).
  91. LSUP_LINK_EDGE, ///< Edge link (so).
  92. } LSUP_LinkType;
  93. /** @brief The immediate neighborhood of terms connected to a term.
  94. *
  95. * This is a hash map whose each term is related to a set of one or more other
  96. * terms. The hash map is inside an opaque handle and is manipulated via the
  97. * `LSUP_link_map_*` functions.
  98. *
  99. * If the type of the link map is `LSUP_LINK_INBOUND`, the map keys
  100. * represent predicates and the sets related to them are the objects, and the
  101. * term associated to the link map is the object; if
  102. * `LSUP_LINK_OUTBOUND`, the keys represent predicates, the related sets
  103. * objects, and the associated term is the subject. If `LSUP_LINK_EDGE`, the
  104. * keys represent subjects and the related sets objects, and the associated
  105. * term is the predicate.
  106. */
  107. typedef struct link_map LSUP_LinkMap;
  108. /** @brief a set of unique terms.
  109. *
  110. * This is used to bulk-add terms to a link map.
  111. */
  112. typedef struct hashmap LSUP_TermSet;
  113. /*
  114. * External variables.
  115. */
  116. /** @brief Compiled hash of default literal data type.
  117. */
  118. extern uint32_t LSUP_default_dtype_key;
  119. /** @brief URI validation pattern, compiled in #LSUP_init().
  120. */
  121. extern regex_t *LSUP_uri_ptn;
  122. /** @brief Default literal data type URI.
  123. *
  124. * Literal terms created with undefined data type will have it set to this
  125. * URI implicitly.
  126. */
  127. extern LSUP_Term *LSUP_default_datatype;
  128. /** @brief Global term cache.
  129. *
  130. * Stores frequently used terms, e.g. data type URIs.
  131. */
  132. extern LSUP_TermSet *LSUP_term_cache;
  133. /*
  134. * API functions.
  135. */
  136. /** @brief Create a new term.
  137. *
  138. * This is a generic function; it is recommended to use specialized functions
  139. * such as #LSUP_term_new(), #LSUP_literal_new(), etc. as they have strict type
  140. * checks for the metadata parameter.
  141. *
  142. * @param type[in] Term type. One of #LSUP_TermType.
  143. *
  144. * @param data[in] Term data: textual URI, literal value without data type
  145. * or langtag, etc. It may be NULL for IRI refs and BNodes, in which case a
  146. * random identifier is generated.
  147. *
  148. * @param metadata[in] Namespace map (LSUP_NSMap *) for IRI refs; language tag
  149. * (LSUP_LangTag *) for language-tagged literals; or data type (LSUP_Term *)
  150. * for other literals. It may be NULL.
  151. *
  152. * @return New term, which must be freed with #LSUP_term_free after use; or
  153. * NULL on error.
  154. */
  155. LSUP_Term *
  156. LSUP_term_new (LSUP_TermType type, const char *data, void *metadata);
  157. /** @brief Placeholder term to use with LSUP_term_reset.
  158. */
  159. #define TERM_DUMMY LSUP_term_new (LSUP_TERM_UNDEFINED, NULL, NULL)
  160. /** @brief Shortcut to create an IRI reference.
  161. *
  162. * Must be freed with #LSUP_term_free.
  163. *
  164. * @param data[in] The URI string. If NULL, a UUID4-based URN is generated.
  165. * This cannot be NULL if the nsm parameter is not NULL.
  166. *
  167. * @param nsm[in] Namespace map. If not NULL, a namespace-prefixed
  168. * (#LSUP_TERM_NS_IRIREF) is created, otherwise a regular one
  169. * (#LSUP_TERM_IRIREF).
  170. *
  171. * @return same as #LSUP_term_new().
  172. */
  173. inline LSUP_Term *
  174. LSUP_iriref_new (const char *data, LSUP_NSMap *nsm)
  175. {
  176. return (
  177. nsm ? LSUP_term_new (LSUP_TERM_NS_IRIREF, data, nsm) :
  178. LSUP_term_new (LSUP_TERM_IRIREF, data, NULL));
  179. }
  180. /** @brief Create a new absolute IRI from a path relative to a root IRI.
  181. *
  182. * The term is always of type LSUP_TERM_IRIREF (i.e. not namespace-prefixed).
  183. *
  184. * If the provided IRI is already a fully qualified IRI (i.e. it has a prefix)
  185. * the result is semantically identical to the input.
  186. *
  187. * If the relative IRI begins with a '/', the resulting IRI is relative to the
  188. * web root of the root IRI. I.e. if a root IRI has a path after the webroot,
  189. * it is ignored.
  190. *
  191. * Otherwise, the resulting IRI is relative to the full root string.
  192. *
  193. * @param[in] root Root IRI that the new IRI should be relative to.
  194. *
  195. * @param[in] iri Term with an IRI relative to the webroot.
  196. *
  197. * @return New absolute IRI, or NULL if either term is not an IRI.
  198. */
  199. LSUP_Term *
  200. LSUP_iriref_absolute (const LSUP_Term *root, const LSUP_Term *iri);
  201. /** @brief Create a new relative IRI from an absolute IRI and a web root IRI.
  202. *
  203. * This works with namespace-prefixed IRIs and returns a term of the same type
  204. * as the input.
  205. *
  206. * @param[in] iri Full IRI.
  207. *
  208. * @param[in] root Root IRI that the new IRI should be relative to.
  209. *
  210. * @return New IRI, or NULL if either term is not an IRI. If the input IRI is
  211. * not a path under the root IRI, the result will be identical to the input.
  212. */
  213. LSUP_Term *
  214. LSUP_iriref_relative (const LSUP_Term *root, const LSUP_Term *iri);
  215. /** @brief Shortcut to create a literal term.
  216. *
  217. * Must be freed with #LSUP_term_free.
  218. *
  219. * @param data[in] The literal string.
  220. *
  221. * @param datatype[in] Data type URI string. If NULL, the default data type
  222. * (xsd:string) is used. The new term takes ownership of the pointer.
  223. *
  224. * @return same as #LSUP_term_new().
  225. */
  226. inline LSUP_Term *
  227. LSUP_literal_new (const char *data, LSUP_Term *datatype)
  228. { return LSUP_term_new (LSUP_TERM_LITERAL, data, datatype); }
  229. /** @brief Shortcut to create a language-tagged literal term.
  230. *
  231. * Must be freed with #LSUP_term_free.
  232. *
  233. * @param data[in] The literal string.
  234. *
  235. * @param lang[in] Language tag string.
  236. *
  237. * @return same as #LSUP_term_new().
  238. */
  239. inline LSUP_Term *
  240. LSUP_lt_literal_new (const char *data, char *lang)
  241. { return LSUP_term_new (LSUP_TERM_LT_LITERAL, data, lang); }
  242. /** @brief Shortcut to create a blank node.
  243. *
  244. * Must be freed with #LSUP_term_free.
  245. *
  246. * @param data[in] The BNode identifier.
  247. *
  248. * @return same as #LSUP_term_new().
  249. */
  250. inline LSUP_Term *
  251. LSUP_bnode_new (const char *data)
  252. { return LSUP_term_new (LSUP_TERM_BNODE, data, NULL); }
  253. /** @brief Copy a term.
  254. *
  255. * @param[in] src The term to copy.
  256. *
  257. * @return A new duplicate term handle.
  258. */
  259. LSUP_Term *
  260. LSUP_term_copy (const LSUP_Term *src);
  261. /** @brief Deserialize a buffer into a term.
  262. *
  263. * @param[in] sterm Buffer to convert into a term. It must be a valid
  264. * serialized term from store or obtained with #LSUP_term_serialize().
  265. *
  266. * @return New term handle. It must be freed with #LSUP_term_free().
  267. */
  268. LSUP_Term *
  269. LSUP_term_new_from_buffer (const LSUP_Buffer *sterm);
  270. /** @brief Serialize a term into a buffer.
  271. *
  272. * @param[in] sterm Term to convert into a buffer.
  273. *
  274. * @return New buffer handle. It must be freed with #LSUP_buffer_free().
  275. */
  276. LSUP_Buffer *
  277. LSUP_term_serialize (const LSUP_Term *term);
  278. /** @brief Hash a buffer.
  279. */
  280. LSUP_Key
  281. LSUP_term_hash (const LSUP_Term *term);
  282. /** @brief Compare two terms.
  283. *
  284. * The terms evaluate as equal if their hashes are equal—i.e. if they are
  285. * semantically equivalent.
  286. */
  287. inline bool LSUP_term_equals (const LSUP_Term *term1, const LSUP_Term *term2)
  288. { return LSUP_term_hash (term1) == LSUP_term_hash (term2); }
  289. void
  290. LSUP_term_free (LSUP_Term *term);
  291. /** @brief Namespace map of a IRI ref.
  292. *
  293. * @param[in] iri IRI reference handle.
  294. *
  295. * @return A pointer to the namespace map associated with the IRI. It is
  296. * freed at program shutdown.
  297. */
  298. LSUP_NSMap *
  299. LSUP_iriref_nsm (const LSUP_Term *iri);
  300. /** @brief Get the prefix portion of a IRI ref.
  301. *
  302. * @param[in] iri IRI reference handle.
  303. *
  304. * @return String containing the protocol and domain name part of the IRI. It
  305. * should be freed after use.
  306. */
  307. char *
  308. LSUP_iriref_prefix (const LSUP_Term *iri);
  309. /** @brief Get the path portion of a IRI ref.
  310. *
  311. * @param[in] iri IRI reference handle.
  312. *
  313. * @return String containing the path of the IRI relative to the web root. For
  314. * a URN, such as `urn:myns:myid`, it would be `myns:myid`. This string should
  315. * be freed after use.
  316. */
  317. char *
  318. LSUP_iriref_path (const LSUP_Term *iri);
  319. /** @brief Get the fragment portion of a IRI ref.
  320. *
  321. * @param[in] iri IRI reference handle.
  322. *
  323. * @return String containing the fragment part of the IRI, or NULL if the IRI
  324. * contains no fragment. It should be freed after use.
  325. */
  326. char *
  327. LSUP_iriref_frag (const LSUP_Term *iri);
  328. /*
  329. * TRIPLES
  330. */
  331. /** @brief Create a new triple from three terms.
  332. *
  333. * Terms are NOT copied. To free them with the triple, use #LSUP_triple_free().
  334. * To only free the triple, use free().
  335. *
  336. * TODO Term types are not validated at the moment.
  337. *
  338. * @param[in] s Triple subject. It must be an IRIRef or BNode.
  339. *
  340. * @param[in] p Triple predicate. It must be an IRIRef.
  341. *
  342. * @param[in] o Triple object.
  343. *
  344. */
  345. LSUP_Triple *
  346. LSUP_triple_new(LSUP_Term *s, LSUP_Term *p, LSUP_Term *o);
  347. /** @brief Dummy triple with NULL slots. It is not a valid triple.
  348. */
  349. #define TRP_DUMMY LSUP_triple_new (NULL, NULL, NULL)
  350. LSUP_Triple *
  351. LSUP_triple_new_from_btriple (const LSUP_BufferTriple *sspo);
  352. LSUP_BufferTriple *
  353. LSUP_triple_serialize (const LSUP_Triple *spo);
  354. /** @brief Initialize internal term pointers in a heap-allocated triple.
  355. *
  356. * Terms are NOT copied. To free them with the triple, use #LSUP_triple_free().
  357. * To only free the triple, use free().
  358. *
  359. * @param spo[in] Triple pointer to initialize.
  360. */
  361. LSUP_rc
  362. LSUP_triple_init (LSUP_Triple *spo, LSUP_Term *s, LSUP_Term *p, LSUP_Term *o);
  363. /** @brief Free the internal pointers of a triple.
  364. *
  365. * @param spo[in] Triple to be freed.
  366. */
  367. void
  368. LSUP_triple_done (LSUP_Triple *spo);
  369. /** @brief Free a triple and all its internal pointers.
  370. *
  371. * NOTE: If the term pointers are not to be freed (e.g. they are owned by a
  372. * back end), use a simple free(spo) instead of this.
  373. *
  374. * @param spo[in] Triple to be freed.
  375. */
  376. void
  377. LSUP_triple_free (LSUP_Triple *spo);
  378. /** @brief Get triple by term position.
  379. *
  380. * Useful for looping over all terms.
  381. *
  382. * @param trp[in] Triple pointer.
  383. *
  384. * @param n[in] A number between 0÷2.
  385. *
  386. * @return Corresponding triple term or NULL if n is out of range.
  387. */
  388. inline LSUP_Term *
  389. LSUP_triple_pos (const LSUP_Triple *trp, LSUP_TriplePos n)
  390. {
  391. if (n == TRP_POS_S) return trp->s;
  392. if (n == TRP_POS_P) return trp->p;
  393. if (n == TRP_POS_O) return trp->o;
  394. return NULL;
  395. }
  396. /** @brief Hash a triple.
  397. *
  398. * TODO This doesn't handle blank nodes correctly.
  399. */
  400. inline LSUP_Key
  401. LSUP_triple_hash (const LSUP_Triple *trp)
  402. {
  403. LSUP_BufferTriple *strp = LSUP_triple_serialize (trp);
  404. LSUP_Key hash = LSUP_btriple_hash (strp);
  405. LSUP_btriple_free (strp);
  406. return hash;
  407. }
  408. /** @brief Create a new term set.
  409. *
  410. * @return New empty term set.
  411. */
  412. LSUP_TermSet *
  413. LSUP_term_set_new (void);
  414. /** @brief Free a term set.
  415. *
  416. * @param[in] ts Term set handle.
  417. */
  418. void
  419. LSUP_term_set_free (LSUP_TermSet *ts);
  420. /** @brief Add term to a term set.
  421. *
  422. * If the same term is already in the set, it is not replaced, and the existing
  423. * term's handle is made available in the `existing` variable. In this case,
  424. * the caller may want to free the passed term which has not been added.
  425. *
  426. * @param[in] tl Term set to be added to.
  427. *
  428. * @param[in] term Term to be added to the list. The term set will take
  429. * ownership of the term and free it when it's freed with
  430. * #LSUP_term_set_free()—only if the return code is LSUP_OK.
  431. *
  432. * @param[out] existing If not NULL, and if the term being added is a
  433. * duplicate, this variable will be populated with the existing term handle.
  434. *
  435. * @return LSUP_OK on success; LSUP_NOACTION if the term is duplicate;
  436. * LSUP_MEM_ERR on memory error. Note: if not LSUP_OK, the caller is in charge
  437. * of freeing the `term` handle.
  438. */
  439. LSUP_rc
  440. LSUP_term_set_add (LSUP_TermSet *ts, LSUP_Term *term, LSUP_Term **existing);
  441. /** @brief Get a term from a term set.
  442. *
  443. * @param[in] ts Term set handle.
  444. *
  445. * @param[in] key Key for the queried term.
  446. *
  447. * @return The retrieved term if found, or NULL. The term must not be
  448. * modified or freed.
  449. */
  450. const LSUP_Term *
  451. LSUP_term_set_get (LSUP_TermSet *ts, LSUP_Key key);
  452. /** @brief Iterate trough a term set.
  453. *
  454. * @param[in] ts Term set handle.
  455. *
  456. * @param[in,out] i Iterator to be initially set to 0.
  457. *
  458. * @param[out] term Pointer to be populated with the next term on success. It
  459. * may be NULL.
  460. *
  461. * @return LSUP_OK if the next term was retrieved; LSUP_END if the end of the
  462. * set has been reached.
  463. */
  464. LSUP_rc
  465. LSUP_term_set_next (LSUP_TermSet *ts, size_t *i, LSUP_Term **term);
  466. /** @brief New link map.
  467. *
  468. * The initial state of the returned list is: `{t: [NULL], tl: [NULL]}`
  469. *
  470. * Predicates and term lists can be added with #LSUP_link_map_add, and terms
  471. * can be added to a term list with #LSUP_term_list_add.
  472. *
  473. * @return a new empty predicate-object list.
  474. */
  475. LSUP_LinkMap *
  476. LSUP_link_map_new (LSUP_LinkType type);
  477. /** @brief Free a link map.
  478. *
  479. * All arrays and term handles are recursively freed.
  480. *
  481. * @param[in] pol link map handle obtained with #LSUP_link_map_new().
  482. */
  483. void
  484. LSUP_link_map_free (LSUP_LinkMap *pol);
  485. /// Return the link map type.
  486. LSUP_LinkType
  487. LSUP_link_map_type (const LSUP_LinkMap *map);
  488. /** @brief Add a term - term set pair to a link map.
  489. *
  490. * If there is already a term set for the given term, items from the added term
  491. * are added to the existing term set (if not duplicated). Otherwise, the term
  492. * set handle is linked to the new term.
  493. *
  494. * In any case, the caller should not directly use the term and term set after
  495. * passing them to this function.
  496. *
  497. * @param[in] cm Link map handle obtained with #LSUP_link_map_new().
  498. *
  499. * @param[in] t Term to be associated with the given object list. The
  500. * link map structure takes ownership of the term.
  501. *
  502. * @param[in] ts term set to be associated with the given term. The link
  503. * list structire takes ownership of the term set and the terms in it.
  504. *
  505. * @return LSUP_OK on success; LSUP_MEM_ERR on allocation error.
  506. */
  507. LSUP_rc
  508. LSUP_link_map_add (
  509. LSUP_LinkMap *cmap, LSUP_Term *term, LSUP_TermSet *tset);
  510. /** @brief Create a new iterator to loop through a link map.
  511. *
  512. * @param[in] lmap Map handle to iterate.
  513. *
  514. * @param[in] ext External term to look for connections.
  515. */
  516. LSUP_LinkMapIterator *
  517. LSUP_link_map_iter_new (const LSUP_LinkMap *lmap, LSUP_Term *ext);
  518. /// Free a link map iterator.
  519. void
  520. LSUP_link_map_iter_free (LSUP_LinkMapIterator *it);
  521. /** @brief Iterate through a link map.
  522. *
  523. * Each call to this function yields a linked term and the related term set.
  524. *
  525. * @param[in] it Link map iterator obtained with #LSUP_link_map_iter_new().
  526. *
  527. * @param[out] lt Linked term returned.
  528. *
  529. * @param[out] ts Term set returned.
  530. *
  531. * @return LSUP_OK if a result was yielded; LSUP_END if the end of the link map
  532. * has been reached.
  533. */
  534. LSUP_rc
  535. LSUP_link_map_next (
  536. LSUP_LinkMapIterator *it, LSUP_Term **lt, LSUP_TermSet **ts);
  537. /**@brief Iterate over a link map and generate triples.
  538. *
  539. * Calling this function repeatedly builds triples for all the linked terms and
  540. * term sets in the map, based on a given related term.
  541. *
  542. * @param[in] it Link map iterator handle, obtained with
  543. * #LSUP_link_map_iter_new().
  544. *
  545. * @param[in] term Term to relate to the link map.
  546. *
  547. * @param[in|out] spo Result triple. The triple handle must be pre-allocated
  548. * (it may be TRP_DUMMY) and calls to this function will be set its memebers
  549. * to term handles owned by the link map. If rc != LSUP_OK, the contents are
  550. * undefined.
  551. *
  552. * @return LSUP_OK if a new triple was yielded; LSUP_END if the end of the loop
  553. * has been reached; <0 on error.
  554. */
  555. LSUP_rc
  556. LSUP_link_map_triples (
  557. LSUP_LinkMapIterator *it, LSUP_Triple *spo);
  558. #endif