コード例 #1
0
ファイル: TreeSetNci.c プロジェクト: LucyScott/mdsplus
int _TreeTurnOn(void *dbid, int nid_in)
{
  PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
  NID *nid = (NID *)&nid_in;
  int       status;
  int       node_num;
  TREE_INFO *info;
  NCI       nci;
  NODE     *node;
  if (!(IS_OPEN(dblist)))
    return TreeNOT_OPEN;
  if (dblist->remote)
    return TreeTurnOnRemote(dbid,nid_in);
  nid_to_tree_nidx(dblist, nid, info, node_num);
  if (!info)
    return TreeNNF;
  status = TreeGetNciLw(info, node_num, &nci);
  if (~status & 1)
    return status;
      
  if (nci.flags & NciM_STATE)
  {
    bitassign(0,nci.flags,NciM_STATE);
    status = TreePutNci(info, node_num, &nci, 0);
    if (~status & 1)
      return status;
    if (!(nci.flags & NciM_PARENT_STATE))
    {
      nid_to_node(dblist, nid, node);
      if (node->INFO.TREE_INFO.child)
	status = SetParentState(dblist, child_of(node), 0);
      if (node->INFO.TREE_INFO.member)
	status = SetParentState(dblist, member_of(node), 0);
    }
    else
      status = TreePARENT_OFF;
  }
  else
  {
    status = TreeUnLockNci(info, 0, node_num);
    if (status & 1)
      status = TreeALREADY_ON;
  }
  return status;
}
コード例 #2
0
ファイル: TreeSetNci.c プロジェクト: LucyScott/mdsplus
static int SetNodeParentState(PINO_DATABASE *db, NODE *node, NCI *nci, unsigned int state)
{
  TREE_INFO *info;
  int       node_num;
  int status;
  for (info = db->tree_info; 
       info && ((node < info->node) || (node > (info->node + info->header->nodes))); info = info->next_info);
  if (!info)
    return TreeNNF;
  node_num = (int)(node - info->node);
  status = TreeGetNciLw(info, node_num, nci);
  if (status & 1)

  {
    bitassign(state,nci->flags,NciM_PARENT_STATE);
    status = TreePutNci(info, node_num, nci, 0);
  }
  return status;
}
コード例 #3
0
ファイル: TreePutRecord.c プロジェクト: petermilne/mdsshell
int       _TreePutRecord(void *dbid, int nid, struct descriptor *descriptor_ptr, int utility_update)
{
  PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
  NID       *nid_ptr = (NID *)&nid;
  int       status;
  int       open_status;
  TREE_INFO *info_ptr;
  int       nidx;
  unsigned int old_record_length;
  static int saved_uic = 0;
  int       id = 0;
  int       length = 0;
  int       shot_open;
  compress_utility = utility_update == 2;
#if !defined(HAVE_WINDOWS_H) && !defined(HAVE_VXWORKS_H)
  if (!saved_uic)
    saved_uic = (getgid() << 16) | getuid();
#endif
  if (!(IS_OPEN(dblist)))
    return TreeNOT_OPEN;
  if (dblist->open_readonly)
    return TreeREADONLY;
  if (dblist->remote)
    return PutRecordRemote(dblist,nid,descriptor_ptr,utility_update);
  shot_open = (dblist->shotid != -1);
  nid_to_tree_nidx(dblist, nid_ptr, info_ptr, nidx);
  if (info_ptr)
  {
    int       stv;
    NCI       local_nci;
    status = TreeCallHook(PutData,info_ptr,nid);
    if (status && !(status & 1))
      return status;
    if (info_ptr->reopen)
      TreeCloseFiles(info_ptr);
    if (info_ptr->data_file ? (!info_ptr->data_file->open_for_write) : 1)
      open_status = TreeOpenDatafileW(info_ptr, &stv, 0);
    else
      open_status = 1;
    status = TreeGetNciLw(info_ptr, nidx, &local_nci);
    if (status & 1)
    {
      if (utility_update)
      {
	length = local_nci.length = 0;
	local_nci.DATA_INFO.DATA_LOCATION.record_length = 0;
      }
      else
      {
        unsigned int m1;
        unsigned int m2 = 10000000;
        _int64 addin = LONG_LONG_CONSTANT(0x7c95674beb4000);
        _int64 zero = 0;
        _int64 temp = 0;
        bitassign(dblist->setup_info, local_nci.flags, NciM_SETUP_INFORMATION);
	local_nci.owner_identifier = saved_uic;
	/* VMS time = unixtime * 10,000,000 + 0x7c95674beb4000q */
#ifndef HAVE_VXWORKS_H
        tzset();
#endif

#ifdef USE_TM_GMTOFF      
    /* this is a suggestion to change all code 
       for this as timezone is depricated unix
       annother alternative is to use gettimeofday */
       { struct tm *tm;
         time_t t;
         t = time(NULL);
         tm = localtime(&t);
         m1 = (unsigned int)t + tm->tm_gmtoff;
       }
#else
        m1 = (unsigned int)time(NULL) - timezone + daylight * 3600;
#endif
	LibEmul(&m1,&m2,&zero,&temp);
        local_nci.time_inserted = temp + addin;
      }
      if (!(open_status & 1))
      {
	local_nci.DATA_INFO.ERROR_INFO.stv = stv;
        bitassign_c(1,local_nci.flags2,NciM_ERROR_ON_PUT);
	local_nci.DATA_INFO.ERROR_INFO.error_status = open_status;
	length = local_nci.length = 0;
	TreePutNci(info_ptr, nidx, &local_nci, 1);
	return open_status;
      }
      else
      {
	NCI      *nci = info_ptr->data_file->asy_nci->nci;
	*nci = local_nci;
	if (!utility_update)
	{
	  old_record_length = (nci->flags2 & NciM_DATA_IN_ATT_BLOCK) ? 0 : 
                        nci->DATA_INFO.DATA_LOCATION.record_length;
	  if ((nci->flags & NciM_WRITE_ONCE) && nci->length)
	    status = TreeNOOVERWRITE;
	  if ((status & 1) && (shot_open && (nci->flags & NciM_NO_WRITE_SHOT)))
	    status = TreeNOWRITESHOT;
	  if ((status & 1) && (!shot_open && (nci->flags & NciM_NO_WRITE_MODEL)))
	    status = TreeNOWRITEMODEL;
	}
	if (status & 1)
	{
          unsigned char tree = (unsigned char)nid_ptr->tree;
          int compressible;
          int data_in_altbuf;
          nid_reference = 0;
          path_reference = 0;
	  status = MdsSerializeDscOutZ(descriptor_ptr, info_ptr->data_file->data,FixupNid,&tree,FixupPath,0,
            (compress_utility || (nci->flags & NciM_COMPRESS_ON_PUT)) && !(nci->flags & NciM_DO_NOT_COMPRESS),
            &compressible,&nci->length,&nci->DATA_INFO.DATA_LOCATION.record_length,&nci->dtype,&nci->class,
            sizeof(nci->DATA_INFO.DATA_IN_RECORD.data),nci->DATA_INFO.DATA_IN_RECORD.data,&data_in_altbuf);
          bitassign(path_reference,nci->flags,NciM_PATH_REFERENCE);
          bitassign(nid_reference,nci->flags,NciM_NID_REFERENCE);
          bitassign(compressible,nci->flags,NciM_COMPRESSIBLE);
          bitassign_c(data_in_altbuf,nci->flags2,NciM_DATA_IN_ATT_BLOCK);
        }
	if ((status & 1) && nci->length && (!utility_update))
	  status = CheckUsage(dblist, nid_ptr, nci);
	if (status & 1)
	{
	  if (nci->flags2 & NciM_DATA_IN_ATT_BLOCK)
	  {
	    bitassign_c(0,nci->flags2,NciM_ERROR_ON_PUT);
	    status = TreePutNci(info_ptr, nidx, nci, 1);
	  }
	  else
	  {
	    if ((nci->DATA_INFO.DATA_LOCATION.record_length != old_record_length) ||
		(nci->DATA_INFO.DATA_LOCATION.record_length >= DATAF_C_MAX_RECORD_SIZE) ||
		utility_update ||
		(nci->flags2 & NciM_ERROR_ON_PUT))
	      status = PutDatafile(info_ptr, nidx, nci, info_ptr->data_file->data);
	    else
	      status = UpdateDatafile(info_ptr, nidx, nci, info_ptr->data_file->data);
	  }
	}
      }
    }
  }