12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #include "desc.h"
- LSUP_rc
- LSR_desc_new (LSUP_Graph *data, LSR_Desc **rsrc_p)
- {
- LSUP_rc rc = LSUP_NOACTION;
- LSR_Desc *rsrc;
- MALLOC_GUARD (rsrc, LSUP_MEM_ERR);
- LSUP_GraphIterator
- *lu_it = LSUP_graph_lookup (data, NULL, NULL, NULL, NULL),
- *uattr_it = LSUP_graph_add_init (rsrc->user_attr),
- *aattr_it = LSUP_graph_add_init (rsrc->admin_attr),
- *urel_it = LSUP_graph_add_init (rsrc->user_rel),
- *arel_it = LSUP_graph_add_init (rsrc->admin_rel);
- LSUP_Triple src_spo;
- while (LSUP_graph_iter_next (lu_it, &src_spo) == LSUP_OK) {
- LSUP_Triple dest_spo = {
- LSUP_term_copy (src_spo.s),
- LSUP_term_copy (src_spo.p),
- LSUP_term_copy (src_spo.o),
- };
- // TODO if the pred is managed, ignore the triple and send a warning.
- // TODO Else if the resource is a structure type, handle special workflow.
- // TODO Else if the subject or object is a resource, check if it exists; if
- // it does, add triple to urel; if not, return an error.
- // TODO Else add triple to user_attr.
- }
- finally:
- LSUP_graph_iter_free (lu_it);
- LSUP_graph_add_done (uattr_it);
- LSUP_graph_add_done (aattr_it);
- LSUP_graph_add_done (urel_it);
- LSUP_graph_add_done (arel_it);
- if (rc == LSUP_OK) *rsrc_p = rsrc;
- else {
- LSR_desc_free (rsrc);
- *rsrc_p = NULL;
- }
- return rc;
- }
- void LSR_desc_free (LSR_Desc *rsrc)
- {
- LSUP_graph_free (rsrc->user_attr);
- LSUP_graph_free (rsrc->admin_attr);
- LSUP_graph_free (rsrc->user_rel);
- LSUP_graph_free (rsrc->admin_rel);
- free (rsrc);
- }
|