Esempio n. 1
0
static void
init (
)
{
  pwr_sClass_ASup *asp;
  pwr_sClass_DSup *dsp; 
  pwr_tStatus sts;
  sAttribute *ap;
  sObject *op;
  sSupObject *sp;
  pwr_tObjid oid;

  ltp = tree_CreateTable(&sts, sizeof(pwr_tObjid), offsetof(sObject, oid),
    sizeof(sObject), 200, tree_Comp_oid);

  sts = gdh_GetClassList(pwr_cClass_ASup, &oid);
  while (ODD(sts)) {
    sts = gdh_ObjidToPointer(oid, (void **)&asp);
    op = tree_Find(&sts, ltp, &asp->Attribute.Objid);
    if (op == NULL) {
      op = tree_Insert(&sts, ltp, &asp->Attribute.Objid);
      LstIni(&op->attr_l);
    }

    ap = findAttribute(op, &asp->Attribute, pwr_cClass_ASup);
    
    sp = calloc(1, sizeof(*sp));
    (void)LstIns(LstEnd(&ap->sup_l), sp, sup_l); 
    sp->oid = oid;
    sp->p = asp;
    op->sup_c++;
    ap->sup_c++;

    sts = gdh_GetNextObject(oid, &oid);
  }

  sts = gdh_GetClassList(pwr_cClass_DSup, &oid);
  while (ODD(sts)) {
    sts = gdh_ObjidToPointer(oid, (void **)&dsp);
    op = tree_Find(&sts, ltp, &dsp->Attribute.Objid);
    if (op == NULL) {
      op = tree_Insert(&sts, ltp, &dsp->Attribute.Objid);
      LstIni(&op->attr_l);
    }

    ap = findAttribute(op, &dsp->Attribute, pwr_cClass_DSup);
    
    sp = calloc(1, sizeof(*sp));
    (void)LstIns(LstEnd(&ap->sup_l), sp, sup_l); 
    sp->oid = oid;
    sp->p = dsp;
    op->sup_c++;
    ap->sup_c++;

    sts = gdh_GetNextObject(oid, &oid);
  }

}
Esempio n. 2
0
bool
wb_dbs::importDbody(pwr_tOid oid, size_t size, void *body)
{
  pwr_tStatus sts;
  sOentry *oep;
  char b[dbs_dAlign(sizeof(dbs_sBody))];
    
  m_nDbodyObjects++;
    
  memset(b, 0, sizeof(b));
    
  oep = (sOentry *)tree_Find(&sts, m_oid_th, &oid);
  if (EVEN(sts)) {
  }

  if (oep->dbody.size == 0) {
    if (size != 0) printf("error dbody size %zd %s\n", size, cdh_ObjidToString(0,oid,0));
    return true;
  }

  oep->o.dbody.ref = dbs_dMakeRef(dbs_eSect_dbody, m_sect[dbs_eSect_dbody].size + dbs_dAlign(sizeof(dbs_sBody)));
  m_sect[dbs_eSect_dbody].size += oep->dbody.size + sizeof(b);

  memcpy(b, &oep->dbody, sizeof(oep->dbody));
    
  if (fwrite(b, sizeof(b), 1, m_fp) < 1)
    return false;

  /* @todo!!! objdid_self */

  if (fwrite(body, oep->dbody.size, 1, m_fp) < 1)
    return false;

  return true;
}
Esempio n. 3
0
static void
printname(pwr_tOid poid, pwr_tObjName name, pwr_tOid oid)
{
  pwr_tStatus sts;
  sOentry     *oep;
  count_name++;
    
  if (cdh_ObjidIsNull(poid) || poid.oix == 0) {
    printf("N [%10.10d.%10.10d] %d:%s\n", oid.vid, oid.oix, strlen(name), name);
  }
  
  oep = (sOentry *)tree_Find(&sts, oid_th, &oid);
  if (EVEN(sts)) {
    printf("Name: object not found %d.%d, %s\n", oid.vid, oid.oix, name);
  } else {
    oep->flags.b.inName = 1;
    if (strcmp(name, oep->o.normname) != 0) {
      printf("name: \"%s\" [%d] not same as: \"%s\"\n", oep->o.name, oep->o.oid.oix, name);
    }
#if 0
    if (memcmp(name, oep->o.normname, sizeof(name)) != 0) {
      printf("name memcmp: \"%s\" [%d] not same as: \"%s\"\n", oep->o.name, oep->o.oid.oix, name);
    }
#endif
    if (cdh_ObjidIsNotEqual(poid, oep->o.poid)) {
      printf("name: \"%s\" [%d] poid: [%d] is not same as: [%d]n", oep->o.name, oep->o.oid.oix, oep->o.poid.oix, poid.oix);
    }    
  }
}
Esempio n. 4
0
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();
}
Esempio n. 5
0
char *Lng::translate( const char *text) 
{
  static char result[200];
  lang_sKey key;
  lang_sRecord *record;
  int sts;
  char *in_p;

  if ( lang == lng_eLanguage_en_US || tree == 0) {
    // No translation is needed
    strncpy( result, text, sizeof(result));
    result[sizeof(result)-1] = 0;
    return result;
  }

  // Remove space
  for ( in_p = (char *)text; *in_p == ' ' && *in_p; in_p++)
    ;

  strncpy( key.text, text, sizeof(key.text));
  key.type = 0;
  record = (lang_sRecord *) tree_Find( &sts, tree, &key);
  if ( ODD(sts)) {
    switch ( record->key.type) {
    case 'B': {
      char *s = strrchr( record->transl, ',');
      if ( s) {
	const char *t = strrchr( text, ',');
	if ( t) {
	  long int len = (unsigned long)s - (unsigned long)record->transl + 1;
	  strncpy( result, record->transl, len);
	  result[len] = 0;
	  strcat( result, t+1);
	}
	else
	  strcpy( result, record->transl);
      }
      else
	strcpy( result, record->transl);
      break;
    }
    default:
      strcpy( result, record->transl);
    }
  }
  else {
    strncpy( result, text, sizeof(result));
    result[sizeof(result)-1] = 0;
  }
  return result;
}
Esempio n. 6
0
static void
printdbody(pwr_tOid oid)
{
  sOentry     *oep;
  pwr_tStatus  sts;

  count_dbody++;

  oep = (sOentry *)tree_Find(&sts, oid_th, &oid);
  if (EVEN(sts)) {
    printf("dbody: object not found %d.%d\n", oid.vid, oid.oix);
  } else {
    oep->flags.b.inDbody = 1;
  }

}
Esempio n. 7
0
int Lng::translate( char *text, char *out) 
{
  char result[200];
  lang_sKey key;
  lang_sRecord *record;
  int sts;
  char *in_p;

  if ( lang == lng_eLanguage_en_US || tree == 0) {
    // No translation is needed
    return 0;
  }

  // Remove space
  for ( in_p = text; *in_p == ' ' && *in_p; in_p++)
    ;

  strncpy( key.text, text, sizeof(key.text));
  key.type = 0;
  record = (lang_sRecord *) tree_Find( &sts, tree, &key);
  if ( ODD(sts)) {
    switch ( record->key.type) {
    case 'B': {
      char *s = strrchr( record->transl, ',');
      if ( s) {
	char *t = strrchr( text, ',');
	if ( t) {
	  strncpy( result, record->transl, 
		   (unsigned long)s - (unsigned long)record->transl + 1);
	  strcat( result, t+1);
	}
	else
	  strcpy( result, record->transl);
      }
      else
	strcpy( result, record->transl);
      break;
    }
    default:
      strcpy( result, record->transl);
    }
    strcpy( out, result);
    return 1;
  }
  // Not found
  return 0;
}
Esempio n. 8
0
static void
printclass(pwr_tOid oid, pwr_tCid cid)
{
  pwr_tStatus sts;
  sOentry     *oep;
  count_class++;

  //printf("C [%10.10d.%10.10d] <%d>\n", oid.vid, oid.oix, cid);
  
  oep = (sOentry *)tree_Find(&sts, oid_th, &oid);
  if (EVEN(sts)) {
    printf("Class: object not found %d.%d, %d\n", oid.vid, oid.oix, cid);
  } else {
    oep->flags.b.inClass = 1;
  }

}
Esempio n. 9
0
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);
    }
  }
}
Esempio n. 10
0
int
qini_ParseFile (
  FILE		*f,
  tree_sTable	*ntp,
  int		*warnings,
  int		*errors,
  int		*fatals
)
{
  pwr_tStatus	sts = 1;
  int		n;
  char		*s;
  char		buffer[256];
  int		error = 0;
  char		name[80];
  char		s_nid[80];
  char		s_naddr[80];
  char		s_port[80];
  char		s_connection[80];
  char		s_min_resend_time[80];
  char		s_max_resend_time[80];
  pwr_tNodeId	nid;
  struct in_addr	naddr;
  qini_sNode	*nep;
  struct arpreq	arpreq;

  while ((s = fgets(buffer, sizeof(buffer) - 1, f)) != NULL) {

    if (*s == '#' || *s == '!') {
      s++;
      continue;
    }

    n = sscanf(s, "%s %s %s %s %s %s %s", name, s_nid, s_naddr, s_port, s_connection,
	       s_min_resend_time, s_max_resend_time);
    if (n < 3) {
      errh_Error("error in line, <wrong number of arguments>, skip to next line.\n>> %s", s);
      (*errors)++;
      continue;
    }

    sts = cdh_StringToVolumeId(s_nid, (pwr_tVolumeId *)&nid);
    if (EVEN(sts)) {
      errh_Error("error in line, <node identity>, skip to next line.\n>> %s", s);
      (*errors)++;
      continue;
    }

    sts = net_StringToAddr( s_naddr, &naddr);
    if ( EVEN(sts)) {
      errh_Error("error in line, <network address>, skip to next line.\n>> %s", s);
      (*errors)++;
      continue;
    }

#if 0
    naddr.s_addr = inet_network(s_naddr);
#if defined(OS_VMS) 
    if (naddr.s_addr == (in_addr_t)-1) {
#else
    if (naddr.s_addr == (unsigned int)-1) {
#endif
      /* Try name instead */
      struct addrinfo hints;
      struct addrinfo *res;
      int err;

      memset((void*)&hints, 0, sizeof(hints));
      hints.ai_socktype = SOCK_STREAM;

      err = getaddrinfo(s_naddr, 0, &hints, &res);
      if ( err < 0) {
	errh_Error("error in line, <network address>, skip to next line.\n>> %s", s);
	(*errors)++;
	continue;
      }
      switch ( res->ai_family) {
      case AF_INET:
	// memcpy( &naddr.s_addr, (char *)&res->ai_addr->sa_data + 2, 4);
	memcpy( &naddr.s_addr, &((struct sock_addr_in *)res->ai_addr)->sin_addr, 4);
	naddr.s_addr = ntohl( naddr.s_addr);
	break;
      case AF_INET6:
	break;
      }
      freeaddrinfo( res);
    }
#endif

    nep = tree_Find(&sts, ntp, &nid);
    if (nep != NULL) {
      errh_Warning("node is allready defined: %s, skip to next line", s);
      (*warnings)++;
      continue;
    } else {
      nep = tree_Insert(&sts, ntp, &nid);
    }

    strcpy(nep->name, name);
    nep->naddr.s_addr = htonl(naddr.s_addr);
    if (n > 3) nep->port = htons(atoi(s_port));
    if (n > 4) nep->connection = atoi(s_connection);
    if (n > 5) nep->min_resend_time = atoi(s_min_resend_time);
    if (n > 6) nep->max_resend_time = atoi(s_max_resend_time);
    memset(&arpreq, 0, sizeof(arpreq));
    memcpy(&arpreq.arp_pa.sa_data, &naddr, sizeof(naddr));
    inet_GetArpEntry(&sts, 0, &arpreq);
  }

  return error;
}

pwr_tBoolean
qini_BuildDb (
  pwr_tStatus		*sts,
  tree_sTable		*nodes,
  qini_sNode		*me,
#if 0 /* change when new class NetConfig is deined */
  pwr_sNetConfig	*cp,
#else
  void			*cp,
#endif
  qcom_tBus		bus
)
{
  qdb_sInit		init;
  qdb_sNode		*np;
  qini_sNode		*nep;
  void			*p;
  qdb_sAppl		*ap;

  memset(&init, 0, sizeof(init));

  init.nid	      = me->nid;
  init.bus	      = bus;
  init.nodes	      = nodes->nNode;
#if 0	/* change when new class NetConfig is deined */
  init.queues	      = cp->Queues;
  init.applications   = cp->Applications;
  init.sbufs	      = cp->SmallCount;
  init.mbufs	      = cp->MediumCount;
  init.lbufs	      = cp->LargeCount;
  init.size_sbuf      = cp->SmallSize;
  init.size_mbuf      = cp->MediumSize;
  init.size_lbuf      = cp->LargeSize;
#endif

  p = qdb_CreateDb(sts, &init);
  if (p == NULL) return NO;

  qdb_ScopeLock {

    for (nep = tree_Minimum(sts, nodes); nep != NULL; nep = tree_Successor(sts, nodes, nep)) {
      np = addNode(nep);
    }

    ap = qdb_AddAppl(NULL, YES);

    qdb->exportque = addQueue(NULL, qdb_cIexport, "export", qdb_eQue_private, qdb_mQue_system);
    addQueue(ap, qcom_cInetEvent, "netEvent", qdb_eQue_forward, qdb_mQue_system);
    addQueue(ap, qcom_cIapplEvent, "applEvent", qdb_eQue_forward, qdb_mQue_system);
    addQueue(ap, qcom_cImhAllHandlers, "allHandlers", qdb_eQue_forward, qdb_mQue_broadcast);
    addQueue(ap, qcom_cImhAllOutunits, "allOutunits", qdb_eQue_forward, qdb_mQue_broadcast);
    addQueue(ap, qcom_cIhdServer, "hdServer", qdb_eQue_forward, qdb_mQue_broadcast);
    addQueue(ap, qcom_cIhdClient, "hdClient", qdb_eQue_forward, qdb_mQue_broadcast);
#if !defined OS_CYGWIN
    addQueue(NULL, qcom_cInacp, "nacp", qdb_eQue_private, qdb_mQue_system);
#endif
    addQueue(ap, qcom_cIini, "ini", qdb_eQue_forward, qdb_mQue_system | qdb_mQue_event);

  } qdb_ScopeUnlock;

  return (YES);
}
Esempio n. 11
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;
}
Esempio n. 12
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();
}
Esempio n. 13
0
void wb_dbs::getAliasServer(sOentry *oep, void *p)
{
  pwr_tStatus sts;
  pwr_sAlias *alias = (pwr_sAlias *)p;
  sOentry    *aep;

  oep->o.flags.b.isAliasClient = 0;
  
  if (cdh_ObjidIsNull(alias->Object)) {
    printf("!! Alias does not refer to any object!\n");
    printf("   Alias:  %s\n", pathName(oep));
    printf("   Alias will not be loaded.\n");
    m_warnings++;
    return; 
  }

  if (alias->Object.vid != m_volume.vid) {
    printf("!! Alias refers to object outside own volume!\n");
    printf("   Alias:  %s\n", pathName(oep));
    printf("   Object: %s\n", cdh_ObjidToString(NULL, alias->Object, 1));
    printf("   Alias will not be loaded.\n");
    m_warnings++;
    return; 
  }
  
  aep = (sOentry *)tree_Find(&sts, m_oid_th, &alias->Object);
  if (!aep) {
    printf("!! Alias refers to a non existing object!\n");
    printf("   Alias:  %s\n", pathName(oep));
    printf("   Alias will not be loaded.\n");
    m_warnings++;
    return; 
  }
  
  if (aep->o.flags.b.devOnly) {
    printf("!! An alias may not refer to a non runtime object!\n");
    printf("   Alias:  %s\n", pathName(oep));
    printf("   Object: %s\n", pathName(aep));
    printf("   Alias will not be loaded.\n");
    m_warnings++;
    return;
  }

  switch (aep->o.cid) {
  case pwr_eClass_Alias:
    printf("!! An alias may not refer to another alias!\n");
    printf("   Alias:  %s\n", pathName(oep));
    printf("   Object: %s\n", pathName(aep));
    printf("   Alias will not be loaded.\n");
    m_warnings++;
    return;
    break;
  case pwr_eClass_MountVolume:
  case pwr_eClass_CreateVolume:
  case pwr_eClass_MountObject:
    printf("!! An alias may not refer to a mount object!\n");
    printf("   Alias:  %s\n", pathName(oep));
    printf("   Object: %s\n", pathName(aep));
    printf("   Alias will not be loaded.\n");
    m_warnings++;
    return;
    break;
  }

  oep->o.flags.b.isAliasClient = 1;
  oep->o.soid = aep->o.oid;
}
Esempio n. 14
0
main ()
{
    tree_sTable	*tp;
    sNode		*np;
    int		key;
    int		i;
    char		s[256];
    char		*cp;
    char		c;

    tp = tree_CreateTable(sizeof(int), offsetof(sNode, key), sizeof(sNode), 100, tree_eComp_int32, NULL);

    for (i = 0; i < 1000; i += 10) {
        tree_Insert(tp, &i);
    }

    for ( ;;) {
        printf("Command: ");
        cp = gets(s);
        c = s[0];
        if (cp == NULL || c == '\0') {
            printf("\nGoodbye\n");
            return;
        }
        switch (c) {
        case 'i':
        case 'I':
            printf("Insert, Key: ");
            gets(s);
            key = atoi(s);
            if (tree_Find(tp, &key) == NULL) {
                tree_Insert(tp, &key);
            } else
                printf("\nKey allready exists!\n");
            break;
        case 'd':
        case 'D':
            printf("Delete, Key: ");
            gets(s);
            key = atoi(s);
            if ((np = tree_Find(tp, &key)) != NULL) {
                tree_Remove(tp, &key);
            } else
                printf("\nKey does not exist!\n");
            break;
        case 'f':
        case 'F':
            printf("Find, Key: ");
            gets(s);
            key = atoi(s);
            if ((np = tree_Find(tp, &key)) == NULL) {
                printf("\nKey does not exist!\n");
            } else
                printf("\nKey exists! %d\n", np->key);
            break;
        case 's':
        case 'S':
            printf("Find successor, Key: ");
            gets(s);
            key = atoi(s);
            if ((np = tree_FindSuccessor(tp, &key)) == NULL) {
                printf("\nKey does not exist!\n");
            } else
                printf("\nKey exists! %d\n", np->key);
            break;
        case 'p':
        case 'P':
            printf("Find predecessor, Key: ");
            gets(s);
            key = atoi(s);
            if ((np = tree_FindPredecessor(tp, &key)) == NULL) {
                printf("\nKey does not exist!\n");
            } else
                printf("\nKey exists! %d\n", np->key);
            break;
#if 0
        case 't':
        case 'T':
            printf("Start: ");
            gets(s);
            start = atoi(s);
            printf("Stop: ");
            gets(s);
            stop = atoi(s);
            printf("Order: ");
            gets(s);
            c = s[0];
            switch (c) {
            case 's':
            case 'S':
                printf("\navl-tree\n");
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    if (TreeSearch(tp,i) == tp->Null) {
                        np = TreeAlloc(tp, i);
                        TreeInsert(tp, np);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);

                i = start;
                j = stop;
                printf("\nlib$tree\n");
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    sts = lib$lookup_tree(&ltp, i, Compare, &lnp);
                    if (!(sts & 1)) {
                        lib$insert_tree(&ltp, i, &0, Compare, Alloc, &lnp, 0);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            case 'd':
            case 'D':
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    if ((np = TreeSearch(tp,i)) != tp->Null) {
                        TreeDelete(tp, np);
                    } else {
                        printf("Could not find %d\n", i);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            case 'f':
            case 'F':
                printf("\navl-tree\n");
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    if ((np = TreeSearch(tp,i)) != tp->Null) {
                    } else {
                        printf("Could not find %d\n", i);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);

                i = start;
                j = stop;
                printf("\nlib$tree\n");
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    sts = lib$lookup_tree(&ltp, i, Compare, &lnp);
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            case 'b':
            case 'B':
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; j--) {
                    if (TreeSearch(tp,j) == tp->Null) {
                        np = TreeAlloc(tp, j);
                        TreeInsert(tp, np);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            case 'r':
            case 'R':
                i = start;
                j = stop;
                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                cpu = cputim;
                page = pageflts;

                for (; i <= j; i++) {
                    k = 65535 & rand();
                    if (TreeSearch(tp,k) == tp->Null) {
                        np = TreeAlloc(tp, k);
                        TreeInsert(tp, np);
                    }
                }

                sts = sys$getjpiw(0, &pid, 0,item_list, 0, 0, 0);
                printf("Cputim: %d, Pageflts: %d\n", cputim - cpu, pageflts - page);
                break;
            default:
                printf("Illegal order!\n");
                break;
            }
            break;
        case 'p':
        case 'P':
            tp->ErrorCount = 0;
            tp->HZCount = 0;
            tp->HNCount = 0;
            tp->HPCount = 0;
            maxlevel = 0;
            count = 0;
            hight = 0;
            TreePrint(tp, tp->Root, NULL, NULL,0);
            TreeCheck (tp, tp->Root, &count, &maxlevel, &hight, 0);
            printf("Hight: %d\n", hight);
#if 0
            TreePrintInorder(tp, tp->Root, 0);
#endif
            sp = TreeMinimum(tp, tp->Root);
            ep = TreeMaximum(tp, tp->Root);
            op = sp;
            for (np = TreeSuccessor(tp, op); op != ep; np = TreeSuccessor(tp, np)) {
#if 0
                printf("Key: %d\n", op->Key);
#endif
                if (op->Key >= np->Key)
                    tp->ErrorCount++;
                op = np;
            }
            printf("Hight.......: %d\n", hight);
            printf("Insert......: %d\n", tp->Insert);
            printf("Search......: %d\n", tp->Search);
            printf("Delete......: %d\n", tp->Delete);
            printf("NodeCount...: %d\n", tp->NodeCount);
            printf("FreeCount...: %d\n", tp->FreeCount);
            printf("MaxDepth....: %d\n", tp->MaxDepth);
            printf("HZCount.....: %d\n", tp->HZCount);
            printf("HNCount.....: %d\n", tp->HNCount);
            printf("HPCount.....: %d\n", tp->HPCount);
            printf("LLCount.....: %d\n", tp->LLCount);
            printf("LRCount.....: %d\n", tp->LRCount);
            printf("RLCount.....: %d\n", tp->RLCount);
            printf("RRCount.....: %d\n", tp->RRCount);
            printf("AllocCount..: %d\n", tp->AllocCount);
            printf("MallocCount.: %d\n", tp->MallocCount);
            printf("ErrorCount..: %d\n", tp->ErrorCount);
            count = maxlevel = 0;
            Print(ltp, &count, &maxlevel, 0);
            printf("\nlib$tree\n");
            printf("Count.......: %d\n", count);
            printf("MaxDepth....: %d\n", maxlevel);
            break;
        case 'l':
        case 'L':
            TreePrintInorder(tp, tp->Root, 0);
            break;
#endif
        case 'q':
        case 'Q':
            printf("\nGoodbye\n");
            return;
            break;
        default:
            printf("Illegal command!\n");

            break;
        }
    }
}
Esempio n. 15
0
static alimsrv_sSupDataBuf *
buildBuffer (
  alimsrv_sRequest  *rqp,
  unsigned int      *size
)
{
  alimsrv_sSupDataBuf	*bp = NULL;
  alimsrv_sAttrSupList	*bap;
  alimsrv_sSupObjEntry	*bsp;
  sObject		*op;
  sAttribute		*ap;
  sSupObject		*sp;
  LstLink(sAttribute)	*al;
  LstLink(sSupObject)	*sl;
  pwr_tStatus           sts;

  *size = 0;

  op = tree_Find(&sts, ltp, &rqp->Attribute.Objid);
  if (op == NULL)
    return NULL;
  if (op->attr_c == 0)
    return NULL;

  *size = sizeof(alimsrv_sSupDataBuf) - sizeof(alimsrv_sAttrSupList) 
	+ op->attr_c * sizeof(alimsrv_sAttrSupList)
	+ (op->sup_c - op->attr_c) * sizeof(alimsrv_sSupObjEntry);

  bp = (alimsrv_sSupDataBuf *)calloc(1, *size);
  if (bp == NULL)
    return NULL;
 
  bp->NoOfSupAttr = op->attr_c;
  bap = bp->AttrSupList;

  for (al = LstFir(&op->attr_l); al != LstEnd(&op->attr_l); al = LstNex(al)) {
    ap = LstObj(al);
    bap->SupAttr = ap->aref;
    bap->NoOfSupObjs = ap->sup_c;
    bap->SupClass = ap->cid;
    bsp = bap->SupList;

    for (sl = LstFir(&ap->sup_l); sl != LstEnd(&ap->sup_l); sl = LstNex(sl)) {
      sp = LstObj(sl);      
      bsp->SupObjid = sp->oid;
      if (ap->cid == pwr_cClass_ASup) {
	pwr_sClass_ASup *asup = (pwr_sClass_ASup *) sp->p;

	bsp->SupData.A.EvType  = asup->EventType;
	bsp->SupData.A.EvPrio  = asup->EventPriority;
	bsp->SupData.A.High    = asup->High;
	bsp->SupData.A.Limit   = asup->CtrlLimit;
	bsp->SupData.A.Hyst    = asup->Hysteres;
	bsp->SupData.A.MsgOn   = asup->DetectOn;
      } else if (ap->cid == pwr_cClass_DSup) {
	pwr_sClass_DSup *dsup = (pwr_sClass_DSup *) sp->p;

	bsp->SupData.D.EvType  = dsup->EventType;
	bsp->SupData.D.EvPrio  = dsup->EventPriority;
	bsp->SupData.D.CtrlPos = dsup->CtrlPosition;
      }
      bsp++;
    } 
    bap = (void *)bsp;
  }

  return bp;
}
Esempio n. 16
0
static pwr_tStatus
start (
  ini_sContext *cp
)
{
  pwr_tStatus sts;
  char console[80];

#if defined OS_POSIX
  int	fd;

  if ( strcmp( cp->console, "") == 0)
    strcpy( console, "/dev/console");
  else
    strcpy( console, cp->console);
  if ((fd = open(console, O_APPEND | O_WRONLY)) == -1)
    errl_Init(NULL, ini_errl_cb, cp);
  else {
    close(fd);
    errl_Init(console, ini_errl_cb, cp);
  }
#else
  errl_Init("CONSOLE:", ini_errl_cb, cp);
#endif

  errh_Init("pwr_ini", errh_eAnix_ini);

  if ( cp->flags.b.interactive)    
    errh_Interactive();

  mh_UtilCreateEvent();

  ini_CheckContext(&sts, cp);

  ini_ReadBootFile(&sts, cp);
  ini_ReadNodeFile(&sts, cp);
  ini_CheckNode(&sts, cp);

  cp->me = tree_Find(&sts, cp->nid_t, &cp->node.nid);
  if (cp->me == NULL) {
    errh_LogFatal(&cp->log, "Cannot find my own node in %s\n", cp->nodefile.name);
    exit(QCOM__WEIRD);
  }

  if (!checkErrors(cp))
    exit(0);

  if (cp->flags.b.verbose)
    logCardinality(cp);

  ini_CreateDb(&sts, cp);

  ini_LoadNode(&sts, cp);

  ini_BuildNode(&sts, cp);

  if (cp->np != NULL) {
    if (cp->np->ErrLogTerm[0] != '\0') {
      errh_LogInfo(&cp->log, "Setting log terminal to: %s", cp->np->ErrLogTerm);
      errl_SetTerm(cp->np->ErrLogTerm);
    }

/* Logfile is always $pwrp_log/pwr.log from V4.0.0 and handled by Linux log rotation */ 

    char fname[256];
    sprintf(fname, "$pwrp_log/pwr_%s.log", cp->nodename);
    dcli_translate_filename(fname, fname);
    errl_SetFile(fname);
    errh_LogInfo(&cp->log, "Setting log file to: %s", fname);

/*
    if (cp->np->ErrLogFile[0] != '\0') {
      struct tm *tp;
      char fname[256];
      time_t t;

      time(&t);
      tp = localtime(&t);
      strftime(fname, sizeof(fname), cp->np->ErrLogFile, tp );
      dcli_translate_filename( fname, fname);
      errl_SetFile(fname);
      errh_LogInfo(&cp->log, "Setting log file to: %s", cp->np->ErrLogFile);
    }
*/
  }

  ini_SetSystemStatus( cp, PWR__STARTUP);
  errh_SetStatus( PWR__STARTUP);

  sts = ini_RcReadAndSet(cp->dir, cp->nodename, cp->busid);
  if (EVEN(sts))
    errh_LogError(&cp->log, "ini_RcReadAndSet, %m", sts);

  sts = ini_SetAttribute(cp->aliasfile.name, cp->nodename, 0);
  if (EVEN(sts) && sts != INI__FILE)
    errh_LogError(&cp->log, "ini_SetAttribute, %m", sts);

  qini_BuildDb(&sts, cp->nid_t, cp->me, NULL, cp->busid);

  io_init_signals();

  load_backup();

#if defined OS_ELN
  ker$initialization_done(NULL);
#endif

  ini_ProcTable(&sts, cp);
  ini_ProcIter(&sts, cp, proc_mProcess_system, 0, ini_ProcLoad);
  ini_ProcIter(&sts, cp, proc_mProcess_system, 0, ini_ProcStart);
  ini_ProcIter(&sts, cp, proc_mProcess_system, 0, ini_ProcPrio);

  net_Connect(&sts, &gdbroot->my_aid, &gdbroot->my_qid, NULL, "pwr_ini");
  /*if (!qcom_Init(&sts, 0)) {*/
  if (EVEN(sts)) {
    errh_LogFatal(&cp->log, "net_Connect, %m", sts);
    exit(sts);
  }   

  qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_newPlcInit | ini_mEvent_newPlcStart);

  ini_ProcIter(&sts, cp, proc_mProcess_user, 0, ini_ProcLoad);
  ini_ProcIter(&sts, cp, proc_mProcess_user, 0, ini_ProcStart);
  ini_ProcIter(&sts, cp, proc_mProcess_user, 0, ini_ProcPrio);

  qcom_CreateQ(&sts, &cp->eventQ, NULL, "iniEvent");
  if (EVEN(sts)) {
    errh_LogFatal(&cp->log, "qcom_CreateQ, %m", sts);
    exit(sts);
  }

  qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_newPlcStartDone | cp->plc_sigmask, qcom_cTmoEternal);

  sts = ini_SetAttributeAfterPlc(cp->aliasfile.name, cp->nodename, 0);
  if (EVEN(sts) && sts != INI__FILE)
    errh_LogError(&cp->log, "ini_SetAttributeAfterPlc, %m", sts);
         
  ini_SetSystemStatus( cp, PWR__RUNNING);
  errh_SetStatus( PWR__SRUN);

  return sts;
}
Esempio n. 17
0
main()
{
  tree_sTable* tp;
  sNode* np;
  int key;
  int i;
  char s[256];
  char* cp;
  char c;

  tp = tree_CreateTable(sizeof(int), offsetof(sNode, key), sizeof(sNode), 100,
      tree_eComp_int32, NULL);

  for (i = 0; i < 1000; i += 10) {
    tree_Insert(tp, &i);
  }

  for (;;) {
    printf("Command: ");
    cp = gets(s);
    c = s[0];
    if (cp == NULL || c == '\0') {
      printf("\nGoodbye\n");
      return;
    }
    switch (c) {
    case 'i':
    case 'I':
      printf("Insert, Key: ");
      gets(s);
      key = atoi(s);
      if (tree_Find(tp, &key) == NULL) {
        tree_Insert(tp, &key);
      } else
        printf("\nKey allready exists!\n");
      break;
    case 'd':
    case 'D':
      printf("Delete, Key: ");
      gets(s);
      key = atoi(s);
      if ((np = tree_Find(tp, &key)) != NULL) {
        tree_Remove(tp, &key);
      } else
        printf("\nKey does not exist!\n");
      break;
    case 'f':
    case 'F':
      printf("Find, Key: ");
      gets(s);
      key = atoi(s);
      if ((np = tree_Find(tp, &key)) == NULL) {
        printf("\nKey does not exist!\n");
      } else
        printf("\nKey exists! %d\n", np->key);
      break;
    case 's':
    case 'S':
      printf("Find successor, Key: ");
      gets(s);
      key = atoi(s);
      if ((np = tree_FindSuccessor(tp, &key)) == NULL) {
        printf("\nKey does not exist!\n");
      } else
        printf("\nKey exists! %d\n", np->key);
      break;
    case 'p':
    case 'P':
      printf("Find predecessor, Key: ");
      gets(s);
      key = atoi(s);
      if ((np = tree_FindPredecessor(tp, &key)) == NULL) {
        printf("\nKey does not exist!\n");
      } else
        printf("\nKey exists! %d\n", np->key);
      break;
    case 'q':
    case 'Q':
      printf("\nGoodbye\n");
      return;
      break;
    default:
      printf("Illegal command!\n");

      break;
    }
  }
}