Пример #1
0
int       _TreeRemoveNodesTags(void *dbid, int nid)
{
  PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
  NODE *node;
  NID *nid_ptr = (NID *)&nid;
  int tagidx, next_tag;

  int       status;
  
  if (!(IS_OPEN_FOR_EDIT(dblist)))
    return TreeNOEDIT;

/**********************************
 For every tag found for this node
   Remove it from tree
***********************************/

  status = TreeTNF;
  nid_to_node(dblist, nid_ptr, node);
  for (tagidx=swapint((char *)&node->tag_link); tagidx !=0; tagidx = next_tag) {
    next_tag = swapint((char *)&dblist->tree_info->tag_info[tagidx-1].tag_link);
    _RemoveTagIdx(dblist, tagidx);
  }
  return status;
}
Пример #2
0
int       _TreeSetDbi(void *dbid, DBI_ITM *dbi_itm_ptr)
{
  PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
  int       status = TreeNORMAL;
  DBI_ITM  *itm_ptr;
/*------------------------------------------------------------------------------

 Executable:
*/
  if (!(IS_OPEN_FOR_EDIT(dblist)))
    return TreeNOEDIT;
  if (dblist->remote)
    return SetDbiRemote(dbid,dbi_itm_ptr);
  for (itm_ptr = dbi_itm_ptr; itm_ptr->code != NciEND_OF_LIST && status & 1; itm_ptr++) {
    switch (itm_ptr->code) {
    case DbiVERSIONS_IN_MODEL:
      dblist->tree_info->header->versions_in_model = (*(unsigned int *) itm_ptr->pointer) != 0;
      dblist->modified=1;
      break;
    case DbiVERSIONS_IN_PULSE:
      dblist->tree_info->header->versions_in_pulse = (*(unsigned int *) itm_ptr->pointer) != 0;
      dblist->modified=1;
      break;
    default:
      status = TreeILLEGAL_ITEM;
      break;
    }
  }
  return status;
}
Пример #3
0
int _TreeRemoveTag(void *dbid, char *name)
{
  PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
  int idx;
  int status;
  TREE_INFO *info;
  NODE *node;
  if (!(IS_OPEN_FOR_EDIT(dblist)))
    return TreeNOEDIT;

  info = dblist->tree_info;
  if ((status = _TreeFindTag(dblist, info->node, (short)strlen(info->treenam),info->treenam, (short)strlen(name), name, &node, &idx))&1 && idx >=0)
    _RemoveTagIdx(dblist, idx);
  return status;
}
Пример #4
0
int _TreeDeleteNodeInitialize(void *dbid, int nidin, int *count, int reset)
{
  PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
  NID *nid = (NID *)&nidin;
  static int list_vm = 0;
  int       vm_needed;
  if (!IS_OPEN_FOR_EDIT(dblist))
    return TreeNOEDIT;
  vm_needed = dblist->tree_info->header->nodes / 8 + 4;
  if (vm_needed != list_vm)
  {
    unsigned char *old_list = TREE_DELETE_LIST;
    TREE_DELETE_LIST = malloc(vm_needed);
    if (!TREE_DELETE_LIST)
      return TreeFAILURE;
    if (reset)
    {
      memset(TREE_DELETE_LIST,0,vm_needed);
      if (count)
	*count = 0;
    }
    else
    {
      memcpy(TREE_DELETE_LIST,old_list,(list_vm < vm_needed) ? list_vm : vm_needed);
      if (vm_needed > list_vm)
        memset(TREE_DELETE_LIST+list_vm,0,vm_needed-list_vm);
    }
    if (list_vm)
      free(old_list);
    list_vm = vm_needed;
  }
  else if (reset)
  {
    memset(TREE_DELETE_LIST,0,list_vm);
    if (count)
      *count = 0;
  }
  if (nidin)
    check_nid(dblist, nid, count);
  return TreeNORMAL;
}
Пример #5
0
int       _TreeSetNci(void *dbid, int nid_in, NCI_ITM *nci_itm_ptr)
{
  PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
  NID *nid_ptr = (NID *)&nid_in;
  int       status;
  int       node_number;
  TREE_INFO *tree_info;
  NCI_ITM  *itm_ptr;
  NCI       nci;
/*------------------------------------------------------------------------------

 Executable:
*/
  if (!(IS_OPEN(dblist)))
    return TreeNOTOPEN;
  if (dblist->open_readonly)
      return TreeREADONLY;
  if (dblist->remote)
    return SetNciRemote(dbid,nid_in,nci_itm_ptr);
  nid_to_tree_nidx(dblist, nid_ptr, tree_info, node_number);
  if (!tree_info)
    return TreeNNF;
  status = TreeCallHook(PutNci, tree_info, nid_in);
  if (status && !(status & 1))
    return status;
  status = TreeGetNciLw(tree_info, node_number, &nci);
  if (status & 1)
  {
    for (itm_ptr = nci_itm_ptr; itm_ptr->code != NciEND_OF_LIST && status & 1; itm_ptr++)
    {
      switch (itm_ptr->code)
      {

       case NciSET_FLAGS:
	nci.flags |= *(unsigned int *) itm_ptr->pointer;
	break;
       case NciCLEAR_FLAGS:
	nci.flags &= ~(*(unsigned int *) itm_ptr->pointer);
	break;
       case NciSTATUS:
	nci.status = *(unsigned int *) itm_ptr->pointer;
	break;
      case NciUSAGE:
	{
	  NODE     *node_ptr;

/**************************************************
 First we must check to make sure we are editting
 a valid tree.
**************************************************/

	  if (!(IS_OPEN_FOR_EDIT(dblist)))
	    return TreeNOEDIT;

	  nid_to_node(dblist, nid_ptr, node_ptr);
	  if (node_ptr->usage != *(unsigned char *)itm_ptr->pointer) {
	    node_ptr->usage = *(unsigned char *)itm_ptr->pointer;
	    dblist->modified = 1;
	  }
	  return TreeNORMAL;
	}
       default:
	status = TreeILLEGAL_ITEM;
	break;
      }
    }
    if (status & 1)
      status = TreePutNci(tree_info, node_number, &nci, 1);
  }
  return status;
}