コード例 #1
0
ファイル: core.c プロジェクト: AmericoBalboa/core
static void mxmlRemoveRef( mxml_node_t * node )
{
   if( node->parent )
   {
      mxmlRemove( node );
      mxmlRelease( node );
   }
}
コード例 #2
0
ファイル: hpd_xml.c プロジェクト: Tibo-lg/HomePort
/**
 * Removes a given device from the XML file
 *
 * @param _device The device to remove
 *
 * @return HPD_E_SERVICE_NOT_IN_LIST if the Device is not in the XML file, HPD_E_IMPOSSIBLE_TO_RETRIEVE_SERVICE_XML_NODE if the retrieving of the XML node failed, HPD_YES if successful
 */
  int 
remove_device_from_XML(Device *_device)
{
  if(device_is_in_xml_file (_device) == HPD_NO)
    return HPD_E_SERVICE_NOT_IN_LIST;

  mxml_node_t *device = get_xml_node_of_device(_device);
  if(device == NULL)
  {
    printf("Error while retrieving device node\n");
    return HPD_E_IMPOSSIBLE_TO_RETRIEVE_DEVICE_XML_NODE;
  }
  mxmlRemove(device);
  mxmlDelete(device);
  save_xml_tree ();
  return HPD_YES;
}
コード例 #3
0
ファイル: hpd_xml.c プロジェクト: Tibo-lg/HomePort
/**
 * Removes a given service from the XML file
 *
 * @param _service The service to remove
 *
 * @return HPD_E_SERVICE_NOT_IN_LIST if the Service is not in the XML file, HPD_E_IMPOSSIBLE_TO_RETRIEVE_SERVICE_XML_NODE if the retrieving of the XML node failed, HPD_YES if successful
 */
  int 
remove_service_from_XML(Service *_service)
{
  if(service_is_in_xml_file (_service) == HPD_NO)
    return HPD_E_SERVICE_NOT_IN_LIST;

  mxml_node_t *service = get_xml_node_of_service (_service);
  if(service == NULL)
  {
    printf("Impossible to retrieve Service XML node\n");
    return HPD_E_IMPOSSIBLE_TO_RETRIEVE_SERVICE_XML_NODE;
  }
  mxmlRemove(service);
  mxmlDelete(service);
  save_xml_tree ();
  return HPD_YES;
}
コード例 #4
0
ファイル: mxml-node.c プロジェクト: MyWifeRules/ufoai-1
void
mxmlAdd(mxml_node_t *parent,		/* I - Parent node */
        int         where,		/* I - Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER */
        mxml_node_t *child,		/* I - Child node for where or MXML_ADD_TO_PARENT */
	mxml_node_t *node)		/* I - Node to add */
{
#ifdef DEBUG
  fprintf(stderr, "mxmlAdd(parent=%p, where=%d, child=%p, node=%p)\n", parent,
          where, child, node);
#endif /* DEBUG */

 /*
  * Range check input...
  */

  if (!parent || !node)
    return;

#if DEBUG > 1
  fprintf(stderr, "    BEFORE: node->parent=%p\n", node->parent);
  if (parent)
  {
    fprintf(stderr, "    BEFORE: parent->child=%p\n", parent->child);
    fprintf(stderr, "    BEFORE: parent->last_child=%p\n", parent->last_child);
    fprintf(stderr, "    BEFORE: parent->prev=%p\n", parent->prev);
    fprintf(stderr, "    BEFORE: parent->next=%p\n", parent->next);
  }
#endif /* DEBUG > 1 */

 /*
  * Remove the node from any existing parent...
  */

  if (node->parent)
    mxmlRemove(node);

 /*
  * Reset pointers...
  */

  node->parent = parent;

  switch (where)
  {
    case MXML_ADD_BEFORE :
        if (!child || child == parent->child || child->parent != parent)
	{
	 /*
	  * Insert as first node under parent...
	  */

	  node->next = parent->child;

	  if (parent->child)
	    parent->child->prev = node;
	  else
	    parent->last_child = node;

	  parent->child = node;
	}
	else
	{
	 /*
	  * Insert node before this child...
	  */

	  node->next = child;
	  node->prev = child->prev;

	  if (child->prev)
	    child->prev->next = node;
	  else
	    parent->child = node;

	  child->prev = node;
	}
        break;

    case MXML_ADD_AFTER :
        if (!child || child == parent->last_child || child->parent != parent)
	{
	 /*
	  * Insert as last node under parent...
	  */

	  node->parent = parent;
	  node->prev   = parent->last_child;

	  if (parent->last_child)
	    parent->last_child->next = node;
	  else
	    parent->child = node;

	  parent->last_child = node;
        }
	else
	{
	 /*
	  * Insert node after this child...
	  */

	  node->prev = child;
	  node->next = child->next;

	  if (child->next)
	    child->next->prev = node;
	  else
	    parent->last_child = node;

	  child->next = node;
	}
        break;
  }

#if DEBUG > 1
  fprintf(stderr, "    AFTER: node->parent=%p\n", node->parent);
  if (parent)
  {
    fprintf(stderr, "    AFTER: parent->child=%p\n", parent->child);
    fprintf(stderr, "    AFTER: parent->last_child=%p\n", parent->last_child);
    fprintf(stderr, "    AFTER: parent->prev=%p\n", parent->prev);
    fprintf(stderr, "    AFTER: parent->next=%p\n", parent->next);
  }
#endif /* DEBUG > 1 */
}
コード例 #5
0
ファイル: mxml-node.c プロジェクト: MyWifeRules/ufoai-1
void
mxmlDelete(mxml_node_t *node)		/* I - Node to delete */
{
  int	i;				/* Looping var */


#ifdef DEBUG
  fprintf(stderr, "mxmlDelete(node=%p)\n", node);
#endif /* DEBUG */

 /*
  * Range check input...
  */

  if (!node)
    return;

 /*
  * Remove the node from its parent, if any...
  */

  mxmlRemove(node);

 /*
  * Delete children...
  */

  while (node->child)
    mxmlDelete(node->child);

 /*
  * Now delete any node data...
  */

  switch (node->type)
  {
    case MXML_ELEMENT :
        if (node->value.element.name)
	  free(node->value.element.name);

	if (node->value.element.num_attrs)
	{
	  for (i = 0; i < node->value.element.num_attrs; i ++)
	  {
	    if (node->value.element.attrs[i].name)
	      free(node->value.element.attrs[i].name);
	    if (node->value.element.attrs[i].value)
	      free(node->value.element.attrs[i].value);
	  }

          free(node->value.element.attrs);
	}
        break;
    case MXML_INTEGER :
       /* Nothing to do */
        break;
    case MXML_OPAQUE :
        if (node->value.opaque)
	  free(node->value.opaque);
        break;
    case MXML_REAL :
       /* Nothing to do */
        break;
    case MXML_TEXT :
        if (node->value.text.string)
	  free(node->value.text.string);
        break;
    case MXML_CUSTOM :
        if (node->value.custom.data &&
	    node->value.custom.destroy)
	  (*(node->value.custom.destroy))(node->value.custom.data);
	break;
    default :
        break;
  }

 /*
  * Free this node...
  */

  free(node);
}
コード例 #6
0
ファイル: mxml-node.c プロジェクト: VarolOkan/spatial-media
void
mxmlDelete(mxml_node_t *node)		/* I - Node to delete */
{
  mxml_node_t	*current,		/* Current node */
		*next;			/* Next node */


#ifdef DEBUG
  fprintf(stderr, "mxmlDelete(node=%p)\n", node);
#endif /* DEBUG */

 /*
  * Range check input...
  */

  if (!node)
    return;

 /*
  * Remove the node from its parent, if any...
  */

  mxmlRemove(node);

 /*
  * Delete children...
  */

  for (current = node->child; current; current = next)
  {
   /*
    * Get the next node...
    */

    if ((next = current->child) != NULL)
    {
     /*
      * Free parent nodes after child nodes have been freed...
      */

      current->child = NULL;
      continue;
    }

    if ((next = current->next) == NULL)
    {
      mxml_node_t *temp = current->parent;
					/* Pointer to parent node */

      if (temp == node)
      {
       /*
        * Got back to the top node...
        */

        next = NULL;
      }
      else if ((next = temp->next) == NULL)
      {
	if ((next = temp->parent) == node)
	  next = NULL;
      }
    }

    mxml_free(current);
  }

 /*
  * Then free the memory used by this node...
  */

  mxml_free(node);
}