void wb_volume::nextObjectAref(pwr_tCid cid, pwr_sAttrRef *arp,
				pwr_sAttrRef *oarp)
{
  tree_sTable *catt_tt = m_vrep->merep()->catt_tt();
  int bd_size;

  wb_orep *op = m_vrep->object(&m_sts, arp->Objid);
  if (evenSts()) return;

  // Get body size
  wb_cdrep *cd = m_vrep->merep()->cdrep(&m_sts, cid);
  if (evenSts()) return;

  wb_bdrep *bd = cd->bdrep(&m_sts, pwr_eBix_rt);
  if (oddSts()) {
    bd_size = bd->size();
    delete bd;
  }
  else
    bd_size = 0;
  delete cd;

  op->ref();

  // Find next attribute object in current object
  merep_sClassAttrKey key;
  merep_sClassAttr *item;

  key.subCid = cid;
  key.hostCid = op->cid();
  key.idx = 0;
  for (item = (merep_sClassAttr*)tree_Find(&m_sts, catt_tt, &key);
       item && item->key.subCid == cid && item->key.hostCid == op->cid();
       item = (merep_sClassAttr*)tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
    // Find next offset
    for (int i = 0; i < item->numOffset; i++) {
      if (item->offset[i] > arp->Offset) {

	*oarp = pwr_cNAttrRef;
	oarp->Objid = op->oid();
	oarp->Flags.b.ObjectAttr = 1;
	oarp->Offset = item->offset[i];
	oarp->Size = bd_size;
	oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);

	if (item->flags[i] & PWR_MASK_DISABLEATTR) {
	  wb_attribute a = attribute(oarp);
	  if (a.disabled())
	    continue;
	}
	op->unref();
	return;
      }
    }
  }
  m_sts = LDH__NONEXT;
  op->unref();
}
Exemple #2
0
bool wb_session::moveObject(wb_object o, wb_destination d)
{
  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  validateDestination(d, o.cid());
  if (evenSts())
    return false;

  // Check that object is not ancestor to destination
  wb_object dest = object(d.oid());
  while (dest) {
    if (cdh_ObjidIsEqual(dest.oid(), o.oid()))
      throw wb_error(LDH__BADDEST);
    dest = dest.parent();
  }

  wb_object parent;
  switch (d.code()) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(d.oid());
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(d.oid()).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  wb_object old_parent = o.parent();
  m_sts = triggAnteMove(o, parent, old_parent);
  if (evenSts())
    return false;
  m_sts = triggAnteUnadopt(old_parent, o);
  if (evenSts())
    return false;
  m_sts = triggAnteAdopt(parent, o.cid());
  if (evenSts())
    return false;

  ldh_sEvent* ep = m_srep->eventStart(o.oid(), ldh_eEvent_ObjectMoved);
  m_srep->eventOldFamily(ep, o);

  bool rsts = m_vrep->moveObject(&m_sts, (wb_orep*)o, d);
  m_srep->update();

  triggPostMove(o);
  triggPostUnadopt(old_parent, o);
  triggPostAdopt(parent, o);

  m_srep->eventNewFamily(ep, o);
  m_srep->eventSend(ep);

  return rsts;
}
Exemple #3
0
wb_object wb_session::createObject(wb_cdef cdef, wb_destination d, wb_name name)
{
  wb_orep* orep = 0;

  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  validateDestination(d, cdef.cid());
  if (evenSts())
    throw wb_error(sts());

  wb_object parent;
  switch (d.code()) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(d.oid());
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(d.oid()).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  m_sts = triggAnteCreate(parent, cdef.cid());
  if (evenSts())
    throw wb_error(sts());
  m_sts = triggAnteAdopt(parent, cdef.cid());
  if (evenSts())
    throw wb_error(sts());

  orep = m_vrep->createObject(&m_sts, cdef, d, name);
  if (evenSts())
    throw wb_error(sts());
  m_srep->update();

  wb_object o = wb_object(m_sts, orep);
  ldh_sEvent* ep = m_srep->eventStart(o.oid(), ldh_eEvent_ObjectCreated);
  m_srep->eventNewFamily(ep, o);
  triggPostCreate(o);
  triggPostAdopt(parent, o);
  m_srep->eventSend(ep);
  return o;
}
Exemple #4
0
void wb_build::planthier( pwr_tOid oid)
{
  pwr_tStatus 		sumsts;

  m_hierarchy = oid;

  // Build all plcpgm
  classlist( pwr_cClass_plc);
  if ( evenSts()) return;
  sumsts = m_sts;

  // Build all XttGraph
  classlist( pwr_cClass_XttGraph);
  if ( evenSts()) return;
  if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
    sumsts = m_sts;

  m_sts = sumsts;
}
Exemple #5
0
void wb_build::classlist( pwr_tCid cid)
{
  pwr_tStatus 		sumsts;

  // Build all objects of specified class
  sumsts = PWRB__NOBUILT;
  for ( wb_object o = m_session.object( cid); o.oddSts(); o = o.next()) {

    // Call build method for object
    switch ( cid) {
    case pwr_cClass_plc:
      plcpgm( o.oid());
      break;
    case pwr_cClass_XttGraph:
      xttgraph( o.oid());
      break;
    case pwr_cClass_WebHandler:
      webhandler( o.oid());
      break;
    case pwr_cClass_WebBrowserConfig:
      webbrowserconfig( o.oid());
      break;
    case pwr_cClass_WebGraph:
      webgraph( o.oid());
      break;
    case pwr_cClass_AppGraph:
      appgraph( o.oid());
      break;
    case pwr_cClass_Application:
      application( o.oid());
      break;
    case pwr_cClass_PlcProcess:
      application( o.oid());
      break;
    case pwr_eClass_ClassDef:
      classdef( o.oid());
      break;
    default: 
      m_sts = PWRB__NOBUILT;
    }
    if ( evenSts())
      sumsts = m_sts;
    else if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT && m_sts != PWRB__INLIBHIER)
      sumsts = m_sts;
  }
  m_sts = sumsts;
}
void wb_volume::aref(pwr_tCid cid, wb_object o, pwr_sAttrRef *arp)
{
  tree_sTable *catt_tt = m_vrep->merep()->buildCatt(&m_sts);

  merep_sClassAttrKey key;
  merep_sClassAttr *item;

  key.subCid = cid;
  key.hostCid = o.cid();
  key.idx = 0;
  item = (merep_sClassAttr *) tree_Find(&m_sts, catt_tt, &key);
  if (item == NULL) {
    m_sts = LDH__CLASSLIST;
    return;
  }

  wb_cdrep *cd = m_vrep->merep()->cdrep(&m_sts, cid);
  if (evenSts()) return;

  int bd_size;
  wb_bdrep *bd = cd->bdrep(&m_sts, pwr_eBix_rt);
  if (oddSts()) {
    bd_size = bd->size();
    delete bd;
  }
  else
    bd_size = 0;
  delete cd;
  
  *arp = pwr_cNAttrRef;
  arp->Objid = o.oid();
  arp->Flags.b.ObjectAttr = 1;
  arp->Offset = item->offset[0];
  arp->Size = bd_size;
  arp->Body = cdh_cidToBid( cid, pwr_eBix_rt);

  if (item->flags[0] & PWR_MASK_DISABLEATTR) {
    wb_attribute a = attribute(arp);
    if (a.disabled()) {
      pwr_sAttrRef aref = *arp;
      nextObjectAref(cid, &aref, arp);
    }
  }
}
Exemple #7
0
void wb_build::nodehier( pwr_tOid oid)
{
  pwr_tStatus sumsts;
  m_hierarchy = oid;

  // Build all XttGraph
  classlist( pwr_cClass_XttGraph);
  if ( evenSts()) return;
  sumsts = m_sts;

  classlist( pwr_cClass_WebHandler);
  if ( evenSts()) return;
  if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
    sumsts = m_sts;

  classlist( pwr_cClass_WebBrowserConfig);
  if ( evenSts()) return;
  if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
    sumsts = m_sts;

  classlist( pwr_cClass_WebGraph);
  if ( evenSts()) return;
  if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
    sumsts = m_sts;

  classlist( pwr_cClass_AppGraph);
  if ( evenSts()) return;
  if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
    sumsts = m_sts;

  classlist( pwr_cClass_Application);
  if ( evenSts()) return;
  if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
    sumsts = m_sts;

  classlist( pwr_cClass_PlcProcess);
  if ( evenSts()) return;
  if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
    sumsts = m_sts;

  m_sts = sumsts;
}
Exemple #8
0
bool wb_session::pasteOset(
    pwr_tOid doid, ldh_eDest dest, bool keepoid, bool recycleix, char* buffer)
{
  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  m_sts = LDH__SUCCESS;
  wb_destination d = wb_destination(doid, dest);

  wb_vrepmem* mem;
  // Get last buffer
  if (!buffer) {
    mem = (wb_vrepmem*)m_vrep->erep()->bufferVolume(&m_sts);
    if (EVEN(m_sts))
      return false;

    wb_vrepmem* prev = NULL;
    while (mem) {
      prev = mem;
      mem = (wb_vrepmem*)mem->next();
    }
    mem = prev;
  } else {
    // Get specified buffer
    mem = (wb_vrepmem*)m_vrep->erep()->bufferVolume(&m_sts, buffer);
    if (EVEN(m_sts))
      return false;
  }

  if (mem == m_vrep) {
    m_sts = LDH__PASTESELF;
    return false;
  }

  // Check that rootobjects are valid for this destination
  pwr_tStatus sts;
  wb_orep* orep = mem->object(&sts);
  while (ODD(sts)) {
    orep->ref();
    validateDestination(d, orep->cid());
    if (evenSts())
      return false;
    wb_orep* prev = orep;
    orep = orep->after(&sts);
    prev->unref();
  }

  // Trigg ante adopt
  wb_object parent;
  switch (dest) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(doid);
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(doid).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  if (parent) {
    wb_orep* orep = mem->object(&sts);
    while (ODD(sts)) {
      orep->ref();
      m_sts = triggAnteAdopt(parent, orep->cid());
      if (evenSts())
        return false;
      wb_orep* prev = orep;
      orep = orep->after(&sts);
      prev->unref();
    }
  }

  wb_recix* recix = 0;
  if (recycleix)
    recix = m_srep->recix();
  pwr_tOid* olist;
  mem->exportPaste(*m_vrep, doid, dest, keepoid, recix, &olist);
  m_srep->update();
  if (recycleix)
    m_srep->recix_clear();

  if (parent) {
    for (pwr_tOid* oidp = olist; cdh_ObjidIsNotNull(*oidp); oidp++) {
      wb_object o = object(*oidp);
      triggPostAdopt(parent, o);
    }
  }
  free(olist);

  if (dest == ldh_eDest_After || dest == ldh_eDest_Before)
    doid = pwr_cNOid;
  ldh_sEvent* ep = m_srep->eventStart(doid, ldh_eEvent_ObjectTreeCopied);
  m_srep->eventSend(ep);

  return true;
}
void wb_volume::aref(pwr_tCid cid, pwr_sAttrRef *arp)
{
  tree_sTable *catt_tt = m_vrep->merep()->buildCatt(&m_sts);

  // Look in classlist
  wb_orep *o = m_vrep->object(&m_sts, cid);
  if (oddSts()) {
    o->ref();
    *arp = cdh_ObjidToAref(o->oid());
    o->unref();
    return;
  }
  else {
    // Find attribute object
    pwr_tCid hostCid = 0;
    merep_sClassAttrKey key;
    merep_sClassAttr *item;

    key.subCid = cid;
    key.hostCid = 0;
    key.idx = 0;
    for (item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &key);
	  item;
	  item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
      if ( item->key.subCid != cid) {
	m_sts = LDH__CLASSLIST;
	break;
      }
      if (hostCid && item->key.hostCid == hostCid)
	// Same class with other index
	continue;

      hostCid = item->key.hostCid;

      wb_orep *o = m_vrep->object(&m_sts, item->key.hostCid);
      if (oddSts()) {
	o->ref();

	wb_cdrep *cd = m_vrep->merep()->cdrep(&m_sts, cid);
	if (evenSts()) return;

	int bd_size;
	wb_bdrep *bd = cd->bdrep(&m_sts, pwr_eBix_rt);
	if (oddSts()) {
	  bd_size = bd->size();
	  delete bd;
	}
	else
	  bd_size = 0;
	delete cd;

	*arp = pwr_cNAttrRef;
	arp->Objid = o->oid();
	arp->Flags.b.ObjectAttr = 1;
	arp->Offset = item->offset[0];
	arp->Size = bd_size;
	arp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
	o->unref();
	return;
      }      
    }
  }
}
Exemple #10
0
void wb_build::classvolume( pwr_tVid vid)
{
  pwr_tCmd cmd;
  pwr_tFileName fname;
  pwr_tObjName name;
  pwr_tTime wbl_time, dbs_time, h_time;
  pwr_tStatus fsts;
  pwr_tStatus sumsts = PWRB__NOBUILT;

  wb_log::push();

  if ( !opt.manual) {
    // Build all ClassDef
    classlist( pwr_eClass_ClassDef);
    if ( evenSts()) return;
    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;
  }

  wb_log::pull();

  if ( vid == 0) {
    // Build current volume
    cdh_ToLower( name, m_session.name());
  }
  else {
    wb_env env = m_session.env();
    wb_volume v = env.volume(vid);
    if ( !v) {
      m_sts = v.sts();
      return;
    }
    strcpy( name, v.name());
  }

  // Get time for wb_load file
  sprintf( fname, "$pwrp_db/%s.wb_load", name);
  dcli_translate_filename( fname, fname);
  m_sts = dcli_file_time( fname, &wbl_time);
  if ( evenSts())
    return;

  // Get time for dbs file
  sprintf( fname, "$pwrp_load/%s.dbs", name);
  dcli_translate_filename( fname, fname);
  fsts = dcli_file_time( fname, &dbs_time);

  // Get time for classvolumes
  wb_merep *merep = ((wb_erep *)m_session.env())->merep();
  pwr_tTime mtime = pwr_cNTime;
  pwr_tTime t;
  pwr_tStatus sts;
  for ( wb_mvrep *mvrep = merep->volume( &sts);
	ODD(sts);
	mvrep = merep->nextVolume( &sts, mvrep->vid())) {
    if ( m_session.vid() == mvrep->vid())
      continue;
    // Check only system class and manufact class volumes
    if ( mvrep->vid() > cdh_cSystemClassVolMax &&
	 (mvrep->vid() < cdh_cManufactClassVolMin ||
	  mvrep->vid() > cdh_cManufactClassVolMax))
      continue;

    mvrep->time( &t);
    if ( time_Acomp( &t, &mtime) == 1)
      mtime = t;
  }


  // Create new loadfile
  if ( opt.force || EVEN(fsts) || wbl_time.tv_sec > dbs_time.tv_sec ||
       mtime.tv_sec > dbs_time.tv_sec) {
    sprintf( cmd, "create snapshot/file=\"$pwrp_db/%s.wb_load\"", name);
    m_sts = m_wnav->command( cmd);
    sumsts = m_sts;
  }
  else
    m_sts = sumsts;

  // Get time for struct file
  sprintf( fname, "$pwrp_inc/pwr_%sclasses.h", name);
  dcli_translate_filename( fname, fname);
  fsts = dcli_file_time( fname, &h_time);

  // Create new struct file
  if ( opt.force || EVEN(fsts) || wbl_time.tv_sec > h_time.tv_sec) {
    sprintf( cmd, "create struct/file=\"$pwrp_db/%s.wb_load\"", name);
    m_sts = m_wnav->command( cmd);
    sumsts = m_sts;
  }
  else
    m_sts = sumsts;

  if ( sumsts != PWRB__NOBUILT) {
    char msg[80];

    sprintf( msg, "Build:    Volume   %s", name);
    MsgWindow::message('I', msg, msgw_ePop_No);
  }
}
Exemple #11
0
void wb_build::rootvolume( pwr_tVid vid)
{
  pwr_tStatus 		sumsts, plcsts;
  pwr_tOid		oid;
  pwr_tTime		modtime;
  pwr_tObjName		vname;
  pwr_tFileName		fname;
  pwr_tTime		dbs_time, rtt_time;
  pwr_tCmd		cmd;
  char			msg[80];

  wb_log::push();

  if ( !opt.manual) {
    // Build all plcpgm
    classlist( pwr_cClass_plc);
    if ( evenSts()) return;
    plcsts = sumsts = m_sts;

    // Build all XttGraph
    classlist( pwr_cClass_XttGraph);
    if ( evenSts()) return;
    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;

    classlist( pwr_cClass_WebHandler);
    if ( evenSts()) return;
    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;

    classlist( pwr_cClass_WebBrowserConfig);
    if ( evenSts()) return;
    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;

    // Build all WebGraph
    classlist( pwr_cClass_WebGraph);
    if ( evenSts()) return;
    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;

    // Build all AppGraph
    classlist( pwr_cClass_AppGraph);
    if ( evenSts()) return;
    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;

    classlist( pwr_cClass_Application);
    if ( evenSts()) return;
    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;

    classlist( pwr_cClass_PlcProcess);
    if ( evenSts()) return;
    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;
  }
  wb_log::pull();

  // Create loadfiles
  oid.oix = 0;
  oid.vid = m_session.vid();
  wb_attribute a = m_session.attribute( oid, "SysBody", "Modified");
  if ( !a) {
    m_sts = a.sts();
    return;
  }

  a.value( &modtime);
  if ( !a) {
    m_sts = a.sts();
    return;
  }

  cdh_ToLower( vname, m_session.name());
  sprintf( fname, "$pwrp_load/%s.dbs", vname);
  dcli_translate_filename( fname, fname);
  m_sts = dcli_file_time( fname, &dbs_time);

  // Get time for classvolumes
  wb_merep *merep = ((wb_vrep *)m_session)->merep();
  pwr_tTime mtime = pwr_cNTime;
  pwr_tTime t;
  pwr_tStatus sts;
  for ( wb_mvrep *mvrep = merep->volume( &sts);
	ODD(sts);
	mvrep = merep->nextVolume( &sts, mvrep->vid())) {
    mvrep->time( &t);
    if ( time_Acomp( &t, &mtime) == 1)
      mtime = t;
  }

  if ( opt.force || opt.manual || evenSts() || time_Acomp( &modtime, &dbs_time) == 1 ||
       time_Acomp( &mtime, &dbs_time) == 1 || plcsts != PWRB__NOBUILT) {
    m_sts = lfu_create_loadfile( (ldh_tSession *) &m_session);
    if ( evenSts()) return;
    m_sts = ldh_CreateLoadFile( (ldh_tSession *) &m_session);
    if ( evenSts()) return;

    sprintf( msg, "Build:    Volume   Loadfiles created volume %s", m_session.name());
    MsgWindow::message('I', msg, msgw_ePop_No);

    wb_log::log( &m_session, wlog_eCategory_VolumeBuild, m_session.vid());

    sumsts = PWRB__SUCCESS;
  }
  else
    m_sts = sumsts;

  cdh_uVolumeId	uvid;
  uvid.pwr = m_session.vid();
  sprintf( fname, "$pwrp_load/" load_cNameRttCrr,
	   uvid.v.vid_3, uvid.v.vid_2, uvid.v.vid_1, uvid.v.vid_0);
  dcli_translate_filename( fname, fname);
  m_sts = dcli_file_time( fname, &rtt_time);
  if ( opt.crossref && ( evenSts() || time_Acomp( &modtime, &rtt_time) == 1)) {
    strcpy( cmd, "create crossreferencefiles");
    m_wnav->command( cmd);
    if ( ODD(sumsts))
      sumsts = PWRB__SUCCESS;
	 
    sprintf( msg, "Build:    Volume   Crossreference file generated volume %s", m_session.name());
    MsgWindow::message('I', msg, msgw_ePop_No);
  }


  m_sts = sumsts;
}
Exemple #12
0
void wb_build::classdef( pwr_tOid oid)
{
  pwr_tFileName src_fname, dest_fname;
  pwr_tCmd	cmd;
  pwr_tString80	action;
  pwr_tString80	name;
  pwr_tTime	dest_time, src_time;
  int 		check_hierarchy = cdh_ObjidIsNotNull( m_hierarchy);
  int 		hierarchy_found = 0;
  char  	*s;

  wb_object o = m_session.object(oid);
  if ( !o) {
    m_sts = o.sts();
    return;
  }
  
  // Check that no ancestor is a LibHier
  for ( wb_object p = o.parent(); p.oddSts(); p = p.parent()) {
    if ( p.cid() == pwr_eClass_LibHier) {
      m_sts = PWRB__INLIBHIER;
      return;
    }
    if ( check_hierarchy && cdh_ObjidIsEqual( m_hierarchy, p.oid()))
      hierarchy_found = 1;
  }

  if ( check_hierarchy && !hierarchy_found) {
    m_sts = PWRB__NOBUILT;
    return;
  }

  strcpy( action, cdh_Low( o.name()));
  strcat( action, ".pwg");

  strcpy( src_fname, "$pwrp_pop/");
  strcat( src_fname, action);
  dcli_translate_filename( src_fname, src_fname);
  m_sts = dcli_file_time( src_fname, &src_time);
  if ( evenSts()) {
    m_sts = PWRB__NOBUILT;
    return;
  }

  strcpy( dest_fname, "$pwrp_exe/");
  strcat( dest_fname, action);
  dcli_translate_filename( dest_fname, dest_fname);
  m_sts = dcli_file_time( dest_fname, &dest_time);
  if ( opt.force || evenSts() || src_time.tv_sec > dest_time.tv_sec) {
    sprintf( cmd, "cp %s %s", src_fname, dest_fname);
    system( cmd);
    sprintf( cmd, "Build:    ClassDef copy $pwrp_pop/%s -> $pwrp_exe", action);
    MsgWindow::message( 'I', cmd, msgw_ePop_No, oid);
    
    strcpy( name, action);
    if (( s = strrchr( name, '.')))
      *s = 0;
    wb_log::log( wlog_eCategory_GeBuild, name, 0);
    m_sts = PWRB__SUCCESS;
  }
  else
    m_sts = PWRB__NOBUILT;
}
Exemple #13
0
void wb_build::webhandler( pwr_tOid oid)
{
  pwr_tTime	modtime;
  pwr_tString80 file_name, name;
  pwr_tFileName fname;
  pwr_tTime 	ftime;
  pwr_tTime	xtthelp_time, html_time;
  char 		*s;
  pwr_tStatus   fsts;

  wb_object o = m_session.object(oid);
  if ( !o) {
    m_sts = o.sts();
    return;
  }

  modtime = o.modTime();

  wb_attribute a = m_session.attribute( oid, "RtBody", "FileName");
  if ( !a) {
    m_sts = a.sts();
    return;
  }
  a.value( &file_name);
  if ( !a) {
    m_sts = a.sts();
    return;
  }
  // Parse the name of the start page
  if ( (s = strrchr( file_name, '/')) ||
       (s = strrchr( file_name, '<')) ||
       (s = strrchr( file_name, ':')))
    strcpy( name, s+1);
  else
    strcpy( name, file_name);

  if ( (s = strrchr( name, '.')))
    *s = 0;

  sprintf( fname, "$pwrp_web/%s_opwin_menu.html", name);
  dcli_translate_filename( fname, fname);
  fsts = dcli_file_time( fname, &ftime);

  m_sts = PWRB__NOBUILT;
  if ( opt.force || EVEN(fsts) || time_Acomp( &modtime, &ftime) == 1) {
    // modtime > ftime
    m_sts = Graph::generate_web( (ldh_tSession *)&m_session);
    if ( evenSts()) return;

    char msg[200];
    sprintf( msg, "Build:    WebHandler Webpage generated %s", fname);
    MsgWindow::message( 'I', msg, msgw_ePop_No, oid);
  }

  // Check if xtthelp should be converted to html
  dcli_translate_filename( fname, "$pwrp_exe/xtt_help.dat");
  fsts = dcli_file_time( fname, &xtthelp_time);
  if ( EVEN(fsts)) return;
  
  dcli_translate_filename( fname, "$pwrp_web/xtt_help_index.html");
  fsts = dcli_file_time( fname, &html_time);
  if ( opt.force || EVEN(fsts) || time_Acomp( &xtthelp_time, &html_time) == 1) {
    system( "co_convert -d $pwrp_web -t $pwrp_exe/xtt_help.dat");

    char msg[200];
    sprintf( msg, "Build:    WebHandler xtt_help.dat converted to html");
    MsgWindow::message( 'I', msg, msgw_ePop_No, oid);
    m_sts = PWRB__SUCCESS;
  }

  // Generate wb history html file
  pwr_tCmd cmd;
  strcpy( cmd, "generate history");
  m_wnav->command( cmd);

}
Exemple #14
0
void wb_build::node( char *nodename, void *volumelist, int volumecnt)
{
  lfu_t_volumelist *vlist = (lfu_t_volumelist *)volumelist;
  pwr_tTime vtime;
  pwr_tTime btime;
  pwr_tFileName fname;
  pwr_tObjName vname;
  int bussid = -1;
  int rebuild = 1;
  pwr_tStatus status;
  char currentnode[80];
  char node[80];
  pwr_tStatus sumsts;

  printf( "-- Build node %s\n", nodename);

  wb_log::push();

  if ( !opt.manual) {
    // Check if there is any new dbsfile
    rebuild = 0;
    for ( int i = 0; i < volumecnt; i++) {
      if ( cdh_NoCaseStrcmp( nodename, vlist[i].p1) == 0) {
	if ( bussid == -1) {
	  char systemname[80], systemgroup[80];
	  pwr_tVid *vl;
	  pwr_tString40 *vnl;
	  int vcnt;
	
	  // Get time for current bootfile
	  status = sscanf( vlist[i].p3, "%d", &bussid);
	  if ( status != 1) {
	    // Bussid error
	  }
	
	  sprintf( fname, load_cNameBoot, 
		   load_cDirectory, vlist[i].p2, bussid);
	  cdh_ToLower( fname, fname);
	  dcli_translate_filename( fname, fname);
	  status = lfu_ReadBootFile( fname, &btime, systemname, systemgroup, &vl, &vnl, 
				     &vcnt, 0, 0);
	  if ( EVEN(status)) {
	    rebuild = 1;
	  }	 
	  strcpy( node, vlist[i].p2);
	}
      
	if ( vlist[i].volume_id == m_session.vid()) {
	  // Build current volume
	  volume();
	  if ( evenSts()) 
	    return;
	}
      
	cdh_ToLower( vname, vlist[i].volume_name);
	if ( vlist[i].volume_id >= cdh_cUserVolMin &&
	     vlist[i].volume_id <= cdh_cUserVolMax) {
	  sprintf( fname, "$pwrp_load/%s.dbs", vname);
	  dcli_translate_filename( fname, fname);
	  m_sts = dcli_file_time( fname, &vtime);
	  if ( evenSts()) {
	    // Dbs file is missing
	    char msg[200];
	    sprintf( msg, "Loadfile for volume %s not created", vname);
	    MsgWindow::message('E', msg, msgw_ePop_Yes);
	    return;
	  }
	  if ( vtime.tv_sec > btime.tv_sec)
	    rebuild = 1;
	}
      }
    }
  }
  wb_log::pull();

  if ( m_wnav && m_wnav->ldhses) {
    wb_erep *erep = *(wb_env *)ldh_SessionToWB( m_wnav->ldhses);
    erep->checkVolumes( &m_sts, nodename);

    if ( evenSts())
      return;
  }

  if ( opt.force || opt.manual || rebuild) {

    m_sts = lfu_create_bootfile( nodename, (lfu_t_volumelist *)volumelist, volumecnt,
				 opt.debug);
    if ( ODD(m_sts))
      wb_log::log( wlog_eCategory_NodeBuild, nodename, 0);      
  }
  else
    m_sts = PWRB__NOBUILT;


  sumsts = m_sts;

  syi_NodeName( &m_sts, currentnode, sizeof(currentnode));

  // if ( cdh_NoCaseStrcmp( node, currentnode) == 0) 
  {
    pwr_tFileName src_fname, dest_fname;
    pwr_tCmd	cmd;
    pwr_tTime	dest_time, src_time;


    // Copy xtt_help.dat from $pwrp_cnf to $pwrp_exe
    sprintf( src_fname, "$pwrp_cnf/%s/xtt_help.dat", node);
    dcli_translate_filename( src_fname, src_fname);
    m_sts = dcli_file_time( src_fname, &src_time);
    if ( evenSts()) {
      strcpy( src_fname, "$pwrp_cnf/xtt_help.dat");
      dcli_translate_filename( src_fname, src_fname);
      m_sts = dcli_file_time( src_fname, &src_time);
      if ( evenSts()) {
	char msg[200];
	sprintf( msg, "File is missing $pwrp_cnf/xtt_help.dat");
	MsgWindow::message('E', msg, msgw_ePop_Yes);
      }
    }

    if ( oddSts()) {
      strcpy( dest_fname, "$pwrp_exe/xtt_help.dat");
      dcli_translate_filename( dest_fname, dest_fname);
      m_sts = dcli_file_time( dest_fname, &dest_time);
      if ( opt.force || evenSts() || src_time.tv_sec > dest_time.tv_sec) {
	sprintf( cmd, "cp %s %s", src_fname, dest_fname);
	system( cmd);
	sprintf( cmd, "Build:    Copy %s -> $pwrp_exe", src_fname);
	MsgWindow::message( 'I', cmd, msgw_ePop_No);
	m_sts = PWRB__SUCCESS;
      }
      else
	m_sts = PWRB__NOBUILT;
    }  
    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;

    // Copy pwrp_alias.dat from $pwrp_cnf to $pwrp_load
    sprintf( src_fname, "$pwrp_cnf/%s/pwrp_alias.dat", node);
    dcli_translate_filename( src_fname, src_fname);
    m_sts = dcli_file_time( src_fname, &src_time);
    if ( evenSts()) {
      strcpy( src_fname, "$pwrp_cnf/pwrp_alias.dat");
      dcli_translate_filename( src_fname, src_fname);
      m_sts = dcli_file_time( src_fname, &src_time);
    }
    
    if ( oddSts()) {
      strcpy( dest_fname, "$pwrp_load/pwrp_alias.dat");
      dcli_translate_filename( dest_fname, dest_fname);
      m_sts = dcli_file_time( dest_fname, &dest_time);
      if ( opt.force || evenSts() || src_time.tv_sec > dest_time.tv_sec) {
	sprintf( cmd, "cp %s %s", src_fname, dest_fname);
	system( cmd);
	sprintf( cmd, "Build:    Copy %s -> $pwrp_load", src_fname);
	MsgWindow::message( 'I', cmd, msgw_ePop_No);
	m_sts = PWRB__SUCCESS;
      }
      else
	m_sts = PWRB__NOBUILT;
    }
    else
      m_sts = PWRB__NOBUILT;

    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;

    // Copy ld_appl_...txt from $pwrp_cnf to $pwrp_load
    sprintf( src_fname, load_cNameAppl, "$pwrp_cnf", cdh_Low(node), bussid);
    dcli_translate_filename( src_fname, src_fname);
    m_sts = dcli_file_time( src_fname, &src_time);
    if ( evenSts()) {
      char dir[80];
      strcpy( dir, "$pwrp_cnf/");
      sprintf( src_fname, load_cNameAppl, dir, cdh_Low(node), bussid);
      dcli_translate_filename( src_fname, src_fname);
      m_sts = dcli_file_time( src_fname, &src_time);
    }

    if ( oddSts()) {
      sprintf( dest_fname, load_cNameAppl, "$pwrp_load/", cdh_Low(node), bussid);
      dcli_translate_filename( dest_fname, dest_fname);
      m_sts = dcli_file_time( dest_fname, &dest_time);
      if ( opt.force || evenSts() || src_time.tv_sec > dest_time.tv_sec) {
	sprintf( cmd, "cp %s %s", src_fname, dest_fname);
	system( cmd);
	sprintf( cmd, "Build:    %s -> $pwrp_load", src_fname);
	MsgWindow::message( 'I', cmd, msgw_ePop_No);
	m_sts = PWRB__SUCCESS;
      }
      else
	m_sts = PWRB__NOBUILT;
    }
    else
      m_sts = PWRB__NOBUILT;

    if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
      sumsts = m_sts;
  }

  if ( sumsts != PWRB__NOBUILT) {
    char msg[200];

    sprintf( msg, "Build:    Node     %s", nodename);
    MsgWindow::message('I', msg, msgw_ePop_No);
  }

  m_sts = sumsts;
}
Exemple #15
0
void wb_attribute::check() const
{
  if ( evenSts())
    throw wb_error( m_sts);
}
Exemple #16
0
void wb_build::xttgraph( pwr_tOid oid)
{
  pwr_tFileName src_fname, dest_fname;
  pwr_tCmd	cmd;
  pwr_tString80	action;
  pwr_tString80	name;
  pwr_tTime	dest_time, src_time;
  int 		check_hierarchy = cdh_ObjidIsNotNull( m_hierarchy);
  int 		hierarchy_found = 0;
  int 		is_frame, is_applet;
  char 		java_name[80];
  pwr_tStatus  	fsts;
  int		jexport;
  char		*s;

  wb_object o = m_session.object(oid);
  if ( !o) {
    m_sts = o.sts();
    return;
  }

  // Check that no ancestor is a LibHier
  for ( wb_object p = o.parent(); p.oddSts(); p = p.parent()) {
    if ( p.cid() == pwr_eClass_LibHier) {
      m_sts = PWRB__INLIBHIER;
      return;
    }
    if ( check_hierarchy && cdh_ObjidIsEqual( m_hierarchy, p.oid()))
      hierarchy_found = 1;
  }

  if ( check_hierarchy && !hierarchy_found) {
    m_sts = PWRB__NOBUILT;
    return;
  }

  wb_attribute a = m_session.attribute( oid, "RtBody", "Action");
  if ( !a) {
    m_sts = a.sts();
    return;
  }

  a.value( &action);
  if ( !a) {
    m_sts = a.sts();
    return;
  }

  if ( strstr( action, ".pwg")) {
    strcpy( src_fname, "$pwrp_pop/");
    strcat( src_fname, action);
    dcli_translate_filename( src_fname, src_fname);
    m_sts = dcli_file_time( src_fname, &src_time);
    if ( evenSts()) {
      m_sts = PWRB__NOBUILT;
      return;
    }

    strcpy( dest_fname, "$pwrp_exe/");
    strcat( dest_fname, action);
    dcli_translate_filename( dest_fname, dest_fname);
    m_sts = dcli_file_time( dest_fname, &dest_time);
    if ( opt.force || evenSts() || src_time.tv_sec > dest_time.tv_sec) {
      sprintf( cmd, "cp %s %s", src_fname, dest_fname);
      system( cmd);
      sprintf( cmd, "Build:    XttGraph copy $pwrp_pop/%s -> $pwrp_exe", action);
      MsgWindow::message( 'I', cmd, msgw_ePop_No, oid);

      strcpy( name, action);
      if (( s = strrchr( name, '.')))
	*s = 0;
      wb_log::log( wlog_eCategory_GeBuild, name, 0);
      m_sts = PWRB__SUCCESS;
    }
    else
      m_sts = PWRB__NOBUILT;

    jexport = 0;
    fsts = grow_IsJava( src_fname, &is_frame, &is_applet, java_name);
    if ( EVEN(fsts)) {
      m_sts = fsts;
      return;
    }
    if ( (is_frame || is_applet)  && 
	 strcmp( java_name, "") == 0) {
      // Java name is not yet set, use the default java name
      strcpy( java_name, action);
      if ( (s = strchr( java_name, '.')) != 0)
	*s = 0;
      java_name[0] = _toupper( java_name[0]);
    }
    if ( is_frame) {
      // Check exported java frame
      sprintf( dest_fname, "$pwrp_pop/%s.java", java_name);
      dcli_translate_filename( dest_fname, dest_fname);
      fsts = dcli_file_time( dest_fname, &dest_time);
      if ( opt.force || EVEN(fsts) || time_Acomp( &src_time, &dest_time) == 1)
	jexport = 1;
    }
    if ( is_applet) {
      // Check exported java applet
      sprintf( dest_fname, "$pwrp_pop/%s_A.java", java_name);
      dcli_translate_filename( dest_fname, dest_fname);
      fsts = dcli_file_time( dest_fname, &dest_time);
      if ( opt.force || EVEN(fsts) || time_Acomp( &src_time, &dest_time) == 1)
	jexport = 1;
    }
    if ( jexport) {
      if ( !m_wnav) {
	sprintf( cmd, "Build:    XttGraph  Unable to export java in this environment %s", action);
	MsgWindow::message('W', cmd, msgw_ePop_No, oid);
      }
      else {
	Ge *gectx = m_wnav->ge_new( action, 1);
	strcpy( cmd, "export java");
	m_sts = gectx->command( cmd);
	if ( evenSts()) {
	  msg_GetMsg( m_sts, cmd, sizeof(cmd));
	  MsgWindow::message('E', cmd, msgw_ePop_Yes, oid);
	  m_sts = PWRB__NOBUILT;
	  delete gectx;
	  return;
	}

	sprintf( cmd, "Build:    XttGraph  Export java %s", action);
	MsgWindow::message('I', cmd, msgw_ePop_No, oid);

	delete gectx;

	m_sts = PWRB__SUCCESS;
      }
    }
  }
}
Exemple #17
0
void wb_volume::nextAref(pwr_tCid cid, pwr_sAttrRef *arp,
			 pwr_sAttrRef *oarp)
{
  tree_sTable *catt_tt = m_vrep->merep()->catt_tt();
  int bd_size;

  if (!catt_tt) throw wb_error(LDH__CATT);

  wb_orep *op = m_vrep->object(&m_sts, arp->Objid);
  if (evenSts()) return;

  // Get body size
  wb_cdrep *cd = m_vrep->merep()->cdrep(&m_sts, cid);
  if (evenSts()) return;

  wb_bdrep *bd = cd->bdrep(&m_sts, pwr_eBix_rt);
  if (oddSts()) {
    bd_size = bd->size();
    delete bd;
  }
  else
    bd_size = 0;
  delete cd;

  op->ref();
  if (op->cid() == cid) {
    // Find next object in class list
    wb_orep *ol = m_vrep->next(&m_sts, op);
    if (oddSts()) {
      *oarp = pwr_cNAttrRef;
      oarp->Objid = ol->oid();
      oarp->Flags.b.Object = 1;
      oarp->Size = bd_size;
      oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
      ol->unref();
      op->unref();
      return;
    } 
    else {
      // Find first attribute object
      merep_sClassAttrKey key;
      merep_sClassAttr *item;
      pwr_tCid hostCid = 0;

      key.subCid = cid;
      key.hostCid = 0;
      key.idx = 0;
      for (item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &key);
	    item && item->key.subCid == cid;
	    item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
	if (cd && item->key.hostCid == hostCid)
	  // Same class with other index
	  continue;
	  
	hostCid = item->key.hostCid;

	  
	wb_orep *ol = m_vrep->object(&m_sts, item->key.hostCid);
	if (oddSts()) {
	  ol->ref();
	  *oarp = pwr_cNAttrRef;
	  oarp->Objid = ol->oid();
	  oarp->Flags.b.ObjectAttr = 1;
	  oarp->Size = bd_size;
	  oarp->Offset = item->offset[0];
	  oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
	  ol->unref();
	  op->unref();

	  if (item->flags[0] & PWR_MASK_DISABLEATTR) {
	    wb_attribute a = attribute(oarp);
	    if (a.disabled()) {
	      pwr_sAttrRef aref = *oarp;
	      nextAref(cid, &aref, oarp);
	    }
	  }
	  return;
	}
      }
      op->unref();
      m_sts = LDH__NONEXT;
      return;
    }
  }

  // Find next attribute object in current object
  merep_sClassAttrKey key;
  merep_sClassAttr *item;
  int first_offset = 0;

  key.subCid = cid;
  key.hostCid = op->cid();
  key.idx = 0;
  for (item = (merep_sClassAttr*)tree_Find(&m_sts, catt_tt, &key);
	item && item->key.subCid == cid && item->key.hostCid == op->cid();
	item = (merep_sClassAttr*)tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
    // Find next offset
    for (int i = 0; i < item->numOffset; i++) {
      if (i == 0 && item->key.idx == 0)
	first_offset = item->offset[0];
      if (item->offset[i] > arp->Offset) {
	*oarp = pwr_cNAttrRef;
	oarp->Objid = op->oid();
	oarp->Flags.b.ObjectAttr = 1;
	oarp->Offset = item->offset[i];
	oarp->Size = bd_size;
	oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
	op->unref();

	if (item->flags[0] & PWR_MASK_DISABLEATTR) {
	  wb_attribute a = attribute(oarp);
	  if (a.disabled()) {
	    pwr_sAttrRef aref = *oarp;
	    nextAref(cid, &aref, oarp);
	  }
	}
	return;
      }
    }
  }

  // Find first attribute in next object
  wb_orep *ol = m_vrep->next(&m_sts, op);
  if (oddSts()) {
    ol->ref();
    *oarp = pwr_cNAttrRef;
    oarp->Objid = ol->oid();
    oarp->Flags.b.ObjectAttr = 1;
    oarp->Offset = first_offset;
    oarp->Size = bd_size;
    oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
    ol->unref();
    op->unref();

    if (item->flags[0] & PWR_MASK_DISABLEATTR) {
      wb_attribute a = attribute(oarp);
      if (a.disabled()) {
	pwr_sAttrRef aref = *oarp;
	nextAref(cid, &aref, oarp);
      }
    }

    return;
  }

  // Find first offset in first object of next class
  key.subCid = cid;
  key.hostCid = op->cid();
  key.idx = 0;
  for (item = (merep_sClassAttr*) tree_Find(&m_sts, catt_tt, &key);
       item && item->key.subCid == cid;
       item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
    
    if (item->key.hostCid == key.hostCid)
      continue;

    wb_orep *ol = m_vrep->object(&m_sts, item->key.hostCid);
    if (oddSts()) {
      ol->ref();
      *oarp = pwr_cNAttrRef;
      oarp->Objid = ol->oid();
      oarp->Flags.b.ObjectAttr = 1;
      oarp->Offset = item->offset[0];
      oarp->Size = bd_size;
      oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
      ol->unref();
      op->unref();

      if (item->flags[0] & PWR_MASK_DISABLEATTR) {
	wb_attribute a = attribute(oarp);
	if (a.disabled()) {
	  pwr_sAttrRef aref = *oarp;
	  nextAref(cid, &aref, oarp);
	}
      }
      return;
    }
  }
  m_sts = LDH__NONEXT;
  op->unref();
}
Exemple #18
0
wb_object wb_session::copyObject(wb_object o, wb_destination d, wb_name name)
{
  wb_orep* orep = 0;

  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  validateDestination(d, o.cid());
  if (evenSts())
    throw wb_error(sts());

  wb_object parent;
  switch (d.code()) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(d.oid());
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(d.oid()).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  m_sts = triggAnteCreate(parent, o.cid());
  if (evenSts())
    throw wb_error(sts());
  m_sts = triggAnteAdopt(parent, o.cid());
  if (evenSts())
    throw wb_error(sts());

  if (m_vrep->vid() == o.vid()) {
    orep = m_vrep->copyObject(&m_sts, (wb_orep*)o, d, name);
    if (evenSts())
      throw wb_error(sts());

    orep->ref();
  } else {
    wb_cdef c = cdef(o.cid());

    orep = m_vrep->createObject(&m_sts, c, d, name);
    orep->ref();
    wb_attribute rba(o.sts(), (wb_orep*)o, "RtBody");
    if (rba) {
      void* p = rba.value();
      wb_attribute rban(m_sts, orep, "RtBody");
      writeAttribute(rban, p);
    }
    wb_attribute dba(o.sts(), (wb_orep*)o, "DevBody");
    if (dba) {
      void* p = dba.value();
      wb_attribute dban(m_sts, orep, "DevBody");
      writeAttribute(dban, p);
    }
    wb_attribute sba(o.sts(), (wb_orep*)o, "SysBody");
    if (sba) {
      void* p = sba.value();
      wb_attribute sban(m_sts, orep, "SysBody");
      writeAttribute(sban, p);
    }
  }
  m_srep->update();

  wb_object onew = wb_object(m_sts, orep);
  orep->unref();
  ldh_sEvent* ep = m_srep->eventStart(onew.oid(), ldh_eEvent_ObjectCreated);
  m_srep->eventNewFamily(ep, onew);
  triggPostCreate(onew);
  triggPostAdopt(parent, onew);
  m_srep->eventSend(ep);

  return onew;
}
Exemple #19
0
void wb_name::check() const
{
  if (evenSts())
    throw wb_error(m_sts);
}
Exemple #20
0
void wb_volume::nextTemplateAref(pwr_tCid cid, pwr_sAttrRef *arp,
				 pwr_sAttrRef *oarp)
{
  tree_sTable *catt_tt = m_vrep->merep()->buildCatt(&m_sts);
  int bd_size;

  wb_object o = object(arp->Objid);
  if (!o) {
    m_sts = o.sts();
    return;
  }
  wb_orep *op = o;

  // Get body size
  wb_cdrep *cd = m_vrep->merep()->cdrep(&m_sts, cid);
  if (evenSts()) return;

  wb_bdrep *bd = cd->bdrep(&m_sts, pwr_eBix_rt);
  if (oddSts()) {
    bd_size = bd->size();
    delete bd;
  }
  else
    bd_size = 0;
  delete cd;

  if ( cid == op->cid()) {
    // Find attribute object
    pwr_tCid hostCid = 0;
    merep_sClassAttrKey key;
    merep_sClassAttr *item;

    key.subCid = cid;
    key.hostCid = 0;
    key.idx = 0;
    for (item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &key);
	  item;
	  item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
      if ( item->key.subCid != cid) {
	m_sts = LDH__CLASSLIST;
	break;
      }
      if (hostCid && item->key.hostCid == hostCid)
	// Same class with other index
	continue;

      hostCid = item->key.hostCid;

      wb_object to = templateObject( item->key.hostCid);
      if ( to) {
	wb_orep *o = to;

	wb_cdrep *cd = m_vrep->merep()->cdrep(&m_sts, cid);
	if (evenSts()) return;

	int bd_size;
	wb_bdrep *bd = cd->bdrep(&m_sts, pwr_eBix_rt);
	if (oddSts()) {
	  bd_size = bd->size();
	  delete bd;
	}
	else
	  bd_size = 0;
	delete cd;

	*oarp = pwr_cNAttrRef;
	oarp->Objid = o->oid();
	oarp->Flags.b.ObjectAttr = 1;
	oarp->Offset = item->offset[0];
	oarp->Size = bd_size;
	oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
	return;
      }      
    }
  }

  // Find next attribute object in current object
  merep_sClassAttrKey key;
  merep_sClassAttr *item;
  int first_offset = 0;

  key.subCid = cid;
  key.hostCid = op->cid();
  key.idx = 0;
  for (item = (merep_sClassAttr*)tree_Find(&m_sts, catt_tt, &key);
	item && item->key.subCid == cid && item->key.hostCid == op->cid();
	item = (merep_sClassAttr*)tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
    // Find next offset
    for (int i = 0; i < item->numOffset; i++) {
      if (i == 0 && item->key.idx == 0)
	first_offset = item->offset[0];
      if (item->offset[i] > arp->Offset) {
	*oarp = pwr_cNAttrRef;
	oarp->Objid = op->oid();
	oarp->Flags.b.ObjectAttr = 1;
	oarp->Offset = item->offset[i];
	oarp->Size = bd_size;
	oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
	return;
      }
    }
  }

  // Find first offset in first object of next class
  key.subCid = cid;
  key.hostCid = op->cid();
  key.idx = 0;
  for (item = (merep_sClassAttr*) tree_Find(&m_sts, catt_tt, &key);
       item && item->key.subCid == cid;
       item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
    
    if (item->key.hostCid == key.hostCid)
      continue;

    wb_object ol = templateObject( item->key.hostCid);
    if (oddSts()) {
      *oarp = pwr_cNAttrRef;
      oarp->Objid = ol.oid();
      oarp->Flags.b.ObjectAttr = 1;
      oarp->Offset = item->offset[0];
      oarp->Size = bd_size;
      oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);

      return;
    }
  }
  m_sts = LDH__NONEXT;
}
Exemple #21
0
void wb_build::webgraph( pwr_tOid oid)
{
  pwr_tFileName dest_fname;
  pwr_tFileName src_fname;
  pwr_tCmd	cmd;
  pwr_tString80	java_name;
  pwr_tString80	name;
  pwr_tTime	dest_time, src_time;
  int 		check_hierarchy = cdh_ObjidIsNotNull( m_hierarchy);
  int 		hierarchy_found = 0;
  int 		is_frame, is_applet;
  char		jname[80];
  pwr_tStatus  	fsts;
  int		jexport;
  int 		found;
  pwr_tFileName found_file, file_spec;
  pwr_tFileName graph_name, dir;
  char		dev[80], type[80];
  int		version;
  pwr_tString80	appletsignature = "";
  char 		*s;

  wb_object o = m_session.object(oid);
  if ( !o) {
    m_sts = o.sts();
    return;
  }

  // Check that no ancestor is a LibHier
  for ( wb_object p = o.parent(); p.oddSts(); p = p.parent()) {
    if ( p.cid() == pwr_eClass_LibHier) {
      m_sts = PWRB__INLIBHIER;
      return;
    }
    if ( check_hierarchy && cdh_ObjidIsEqual( m_hierarchy, p.oid()))
      hierarchy_found = 1;
  }

  if ( check_hierarchy && !hierarchy_found) {
    m_sts = PWRB__NOBUILT;
    return;
  }

  wb_attribute a = m_session.attribute( oid, "RtBody", "Name");
  if ( !a) {
    m_sts = a.sts();
    return;
  }

  a.value( java_name);
  if ( !a) {
    m_sts = a.sts();
    return;
  }

  if ( isupper(java_name[0])) {
    cdh_ToLower( java_name, java_name);
    java_name[0] = toupper(java_name[0]);

    // Get the .pwg file for this javaname
    strcpy( graph_name, cdh_Low(java_name));
    sprintf( name, "$pwrp_pop/%s.pwg", graph_name);

    dcli_translate_filename( name, name);
    m_sts = dcli_file_time( name, &src_time);
    if ( evenSts()) {
      // Search in all pwg files
      found = 0;
      strcpy( file_spec, "$pwrp_pop/*.pwg");
      for ( fsts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT);
	    ODD(fsts);
	    fsts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_NEXT)) {
	
	fsts = grow_IsJava( found_file, &is_frame, &is_applet, jname);
	if ( EVEN(fsts)) continue;
	
	if ( is_frame && strcmp( jname, java_name) == 0) {
	  dcli_parse_filename( found_file, dev, dir, graph_name, type, &version);
	  strcpy( name, found_file);
	  found = 1;
	  break;
	}      
      }
      dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END);

      if ( !found) {
	char msg[200];
	sprintf( msg, "Graph for %s not found", java_name);
	MsgWindow::message('E', msg, msgw_ePop_Yes, oid);
	m_sts = PWRB__NOBUILT;
	return;
      }
    }

    m_sts = dcli_file_time( name, &src_time);
    if ( evenSts()) return;

    // Check exported java frame
    jexport = 0;
    sprintf( dest_fname, "$pwrp_pop/%s.java", java_name);
    dcli_translate_filename( dest_fname, dest_fname);
    fsts = dcli_file_time( dest_fname, &dest_time);
    if ( opt.force || EVEN(fsts) || time_Acomp( &src_time, &dest_time) == 1)
      jexport = 1;


    if ( jexport) {
      if ( !m_wnav) {
	sprintf( cmd, "Build:    WebGraph  Unable to export java in this environment %s", java_name);
	MsgWindow::message('W', cmd, msgw_ePop_No, oid);
      }
      else {
	// Get signature from WebHandler
	for ( wb_object p = o.parent(); p.oddSts(); p = p.parent()) {
	  if ( p.cid() == pwr_cClass_WebHandler) {
	    wb_attribute a = m_session.attribute( p.oid(), "RtBody", "AppletSignature");
	    if ( !a) {
	      m_sts = a.sts();
	      return;
	    }

	    a.value( appletsignature);
	    if ( !a) {
	      m_sts = a.sts();
	      return;
	    }
	    dcli_trim( appletsignature, appletsignature);
	    break;
	  }
	}
	

	Ge *gectx = m_wnav->ge_new( graph_name, 1);
	if ( strcmp( appletsignature, "") == 0)
	  strcpy( cmd, "export java");
	else
	  sprintf( cmd, "export java /signature=\"%s\"", appletsignature);
	m_sts = gectx->command( cmd);
	if ( evenSts()) {
	  msg_GetMsg( m_sts, cmd, sizeof(cmd));
	  MsgWindow::message('E', cmd, msgw_ePop_Yes, oid);
	  m_sts = PWRB__NOBUILT;
	  delete gectx;
	  return;
	}
	delete gectx;

	sprintf( cmd, "Build:    WebGraph  Export java %s", java_name);
	MsgWindow::message('I', cmd, msgw_ePop_No, oid);
	
	m_sts = PWRB__SUCCESS;
      }
    }
  }
  else {
    // Copy from $pwrp_pop to $pwrp_web

    strcpy( graph_name, cdh_Low(java_name));

    cdh_ToLower( graph_name, graph_name);

    strcpy( src_fname, "$pwrp_pop/");
    strcat( src_fname, graph_name);

    if ( strstr( src_fname, ".pwg") == 0)
      strcat( src_fname, ".pwg");

    dcli_translate_filename( src_fname, src_fname);
    m_sts = dcli_file_time( src_fname, &src_time);
    if ( evenSts()) {
      m_sts = PWRB__NOBUILT;
      return;
    }

    strcpy( dest_fname, "$pwrp_web/");
    strcat( dest_fname, graph_name);

    if ( strstr( dest_fname, ".pwg") == 0)
      strcat( dest_fname, ".pwg");

    dcli_translate_filename( dest_fname, dest_fname);
    m_sts = dcli_file_time( dest_fname, &dest_time);
    if ( opt.force || evenSts() || src_time.tv_sec > dest_time.tv_sec) {
      sprintf( cmd, "cp %s %s", src_fname, dest_fname);
      system( cmd);
      sprintf( cmd, "Build:    WebGraph copy $pwrp_pop/%s -> $pwrp_web", graph_name);
      MsgWindow::message( 'I', cmd, msgw_ePop_No, oid);
      
      strcpy( name, graph_name);
      if (( s = strrchr( name, '.')))
	*s = 0;
      wb_log::log( wlog_eCategory_GeBuild, name, 0);
      m_sts = PWRB__SUCCESS;
    }
    else
      m_sts = PWRB__NOBUILT;

  }
}
Exemple #22
0
wb_attribute::wb_attribute(const wb_attribute& pa, int pidx, const char *aname, int aidx) :
  wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0), m_size(0), m_offset(0), m_tid(0),
  m_elements(1), m_is_elem(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__), m_body(0), 
  m_shadowed(false)
{
  pwr_tCid cid;
  wb_attrname n;
  pwr_tAName attrname;
  
  if ( !cdh_tidIsCid( pa.tid()) || pa.m_orep == 0)
    return;

  if ( pidx == -1)
    pidx = pa.m_idx;

  if ( pa.m_flags & PWR_MASK_ARRAY && !pa.m_is_elem &&
       (pidx < 0 || pidx >= pa.m_elements))
    throw wb_error_str("Invalid subscript");
    
  strcpy( attrname, pa.attrName());
  if ( pa.m_flags & PWR_MASK_ARRAY) {
    if ( attrname[strlen(attrname)-1] == ']') {
      // Replace the index
      char *s = strrchr( attrname, '[');
      if ( s)
	sprintf( s, "[%d]", pidx);
    }
    else
      // Add index
      sprintf( &attrname[strlen(attrname)], "[%d]", pidx);
  }
  strcat( attrname, ".");
  if ( aname != 0)
    strcat( attrname, aname);
  else {
    // First attribute
    if ( pa.isClass())
      cid = pa.subClass();
    else
      cid = pa.tid();
    wb_cdrep *cd = pa.m_orep->vrep()->merep()->cdrep(&m_sts, cid);
    if ( evenSts()) return;
    
    wb_bdrep* bd = cd->bdrep(&m_sts, pwr_eBix_sys);
    if ( evenSts()) { delete cd; return;}

    wb_adrep *adrep = bd->adrep(&m_sts);
    if ( evenSts()) { delete cd; delete bd; return;}

    strcat( attrname, adrep->name());
    delete adrep;
    delete bd;
    delete cd;
  }

  n = attrname;

  cid = pa.cid();

  wb_cdrep *cd = pa.m_orep->vrep()->merep()->cdrep(&m_sts, cid);
  if (evenSts()) return;

  wb_bdrep* bd = cd->bdrep(&m_sts, pwr_eBix_sys);
  if (evenSts()) {
    // Try devbody
    bd = cd->bdrep(&m_sts, pwr_eBix_dev);
    if (evenSts()) { delete cd; return;}
  }

  m_adrep = bd->adrep(&m_sts, n.attributesAllTrue());
  if (evenSts()) {
    // Try devbody
    bd = cd->bdrep(&m_sts, pwr_eBix_dev);
    if (evenSts()) { delete cd; return;}

    m_adrep = bd->adrep(&m_sts, n.attributesAllTrue());
    if (evenSts()) { delete cd; delete bd; return;}
  }
  m_adrep->ref();
  m_size = m_adrep->size();
  m_offset = m_adrep->offset();
  m_tid = m_original_tid = m_adrep->tid();
  m_elements = m_adrep->nElement();
  m_flags = m_adrep->flags();
  m_type = m_adrep->type();  
  m_idx = aidx;

  m_orep = pa.m_orep;
  m_orep->ref();
  m_bix = bd->bix();

  if ( m_flags & PWR_MASK_CASTATTR) {
    pwr_tCastId castid;

    castId( &castid);
    if ( castid != pwr_cNCastId)
      m_tid = castid;
  }

#if 0
  if ( pa.isClass()) {
    m_flags |= PWR_MASK_SUBCLASS;

    if (pa.m_flags & PWR_MASK_SUBCLASS)
      m_bix = pa.m_bix;
    else
      m_bix = pa.m_adrep->bix();
  }
  else
    m_bix = pa.m_bix;
#endif

  delete bd;
  delete cd;
}