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); } }
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); }
static void printohead(pwr_tOid oid, db_sObject *op) { count_ohead++; sOentry *oep; pwr_tStatus sts; if (cdh_ObjidIsNull(oid)) printf("** Error: object is null!\n"); if (cdh_ObjidIsNotEqual(oid, op->oid)) printf("Ohead: oid not equal %s oid: %d.%d != %d.%d\n", op->name, oid.vid, oid.oix, op->oid.vid, op->oid.oix); // printf("O [%10.10d.%10.10d] [%10.10d.%10.10d] P [%10.10d.%10.10d] %d:%s\n B [%10.10d.%10.10d] A [%10.10d.%10.10d] F [%10.10d.%10.10d] L [%10.10d.%10.10d] \n", oid.vid, oid.oix, op->oid.vid, op->oid.oix, op->poid.vid, op->poid.oix, strlen(op->name), op->name, op->boid.vid, op->boid.oix, op->aoid.vid, op->aoid.oix, op->foid.vid, op->foid.oix, op->loid.vid, op->loid.oix); if (cdh_ObjidIsNull(op->poid) || op->poid.oix == 0) { printf("P [%6.6d] B [%6.6d] O [%6.6d] A [%6.6d] F [%6.6d] L [%6.6d]\n", op->poid.oix, op->boid.oix, op->oid.oix, op->aoid.oix, op->foid.oix, op->loid.oix); } oep = (sOentry *)tree_Insert(&sts, oid_th, &oid); if (sts == TREE__INSERTED) { oep->flags.b.inOhead = 1; oep->o = *op; } else if (!oep->flags.b.inOhead) { oep->flags.b.inOhead = 1; oep->o = *op; } if (cdh_ObjidIsNotNull(op->poid)) { oep->poep = (sOentry *)tree_Insert(&sts, oid_th, &op->poid); if (sts == TREE__FOUND && oep->poep->flags.b.inOhead) { oep->flags.b.pOk = 1; if (oep == oep->poep->foep) { oep->poep->flags.b.fOk = 1; } if (oep == oep->poep->loep) { oep->poep->flags.b.lOk = 1; } } else { } } else { oep->flags.b.pOk = 1; printf("This should be the volume object: %s, [%d.%d]\n", oep->o.name, oep->o.oid.vid, oep->o.oid.oix); } if (cdh_ObjidIsNotNull(op->boid)) { oep->boep = (sOentry *)tree_Insert(&sts, oid_th, &op->boid); if (sts == TREE__FOUND && oep->boep->flags.b.inOhead) { oep->flags.b.bOk = 1; if (oep->boep->flags.b.aOk) { printf("Flags: %s [%d] b-object [%d] allready connected to a-object\n", oep->o.name, oep->o.oid.oix, oep->boep->o.oid.oix); } if (oep->boep->aoep != NULL && oep->boep->aoep != oep) { printf("aoep: %s [%d] b-object [%d] allready connected to a-object [%d]\n", oep->o.name, oep->o.oid.oix, oep->boep->o.oid.oix, oep->boep->aoep->o.oid.oix); } else { oep->boep->aoep = oep; oep->boep->flags.b.aOk = 1; } } } else { oep->flags.b.bOk = 1; // todo! check I am first child } if (cdh_ObjidIsNotNull(op->aoid)) { oep->aoep = (sOentry *)tree_Insert(&sts, oid_th, &op->aoid); if (sts == TREE__FOUND && oep->aoep->flags.b.inOhead) { oep->flags.b.aOk = 1; if (oep->aoep->flags.b.bOk) { printf("Flags: %s [%d] a-object [%d] allready connected to b-object\n", oep->o.name, oep->o.oid.oix, oep->aoep->o.oid.oix); } if (oep->aoep->boep != NULL && oep->aoep->boep != oep) { printf("boep: %s [%d] a-object [%d] allready connected to b-object [%d]\n", oep->o.name, oep->o.oid.oix, oep->aoep->o.oid.oix, oep->aoep->boep->o.oid.oix); } else { oep->aoep->boep = oep; oep->aoep->flags.b.bOk = 1; } } } else { oep->flags.b.aOk = 1; // todo! check I am last child } if (cdh_ObjidIsNotNull(op->foid)) { oep->foep = (sOentry *)tree_Insert(&sts, oid_th, &op->foid); if (sts == TREE__FOUND && oep->foep->flags.b.inOhead) { oep->flags.b.fOk = 1; if (oep->foep->flags.b.pOk) { printf("Flags: %s [%d] f-object [%d] allready connected to p-object\n", oep->o.name, oep->o.oid.oix, oep->foep->o.oid.oix); } if (oep->foep->poep != NULL && oep->foep->poep != oep) { printf("foep: %s [%d] f-object [%d] allready connected to p-object [%d]\n", oep->o.name, oep->o.oid.oix, oep->foep->o.oid.oix, oep->foep->poep->o.oid.oix); } else { oep->foep->poep = oep; oep->foep->flags.b.pOk = 1; } } } else { oep->flags.b.fOk = 1; } if (cdh_ObjidIsNotNull(op->loid)) { oep->loep = (sOentry *)tree_Insert(&sts, oid_th, &op->loid); if (sts == TREE__FOUND && oep->loep->flags.b.inOhead) { oep->flags.b.lOk = 1; if (oep->loep->flags.b.pOk) { if (oep->foep == oep->loep) { if (cdh_ObjidIsNotEqual(oep->foep->o.oid, oep->loep->o.oid)) printf("Object: %s [%d] has only one child %d == %d\n", oep->o.name, oep->o.oid.oix, oep->foep->o.oid.oix, oep->loep->o.oid.oix); } else { printf("Flags: %s [%d] l-object [%d] allready connected to p-object\n", oep->o.name, oep->o.oid.oix, oep->loep->o.oid.oix); } } if (oep->loep->poep != NULL && oep->loep->poep != oep) { printf("loep: %s [%d] l-object [%d] allready connected to p-object [%d]\n", oep->o.name, oep->o.oid.oix, oep->loep->o.oid.oix, oep->loep->poep->o.oid.oix); } else { oep->loep->poep = oep; oep->loep->flags.b.pOk = 1; } } } else { oep->flags.b.lOk = 1; } }
void wb_crrgen::load(pwr_tStatus* rsts, int sim, int graph) { pwr_tStatus sts; for (int i = 0; i < int(sizeof(reflist) / sizeof(reflist[0])); i++) { if (!sim && reflist[i].table == crrgen_eTable_SimSignal) continue; for (wb_object o = m_sp->object(reflist[i].cid); o; o = o.next()) { pwr_tAttrRef aref; // Skip if in LibHier bool in_libhier = false; for (wb_object p = o.parent(); p; p = p.parent()) { if (p.cid() == pwr_eClass_LibHier) { in_libhier = true; break; } } if (in_libhier) continue; wb_attribute a = m_sp->attribute(o.oid(), reflist[i].body, reflist[i].attr); if (reflist[i].is_oid) { // Objid reference pwr_tOid oid; a.value(&oid); aref = cdh_ObjidToAref(oid); } else // AttrRef reference a.value(&aref); if (cdh_ObjidIsNotNull(aref.Objid)) { sCrrKey key; wb_utl::utl_replace_symbol((ldh_tSesContext)m_sp, o.oid(), &aref); key.target = aref; key.reference = cdh_ObjidToAref(o.oid()); key.type = reflist[i].type; switch (reflist[i].table) { case crrgen_eTable_Signal: case crrgen_eTable_SimSignal: tree_Insert(&sts, m_signal_th, &key); break; case crrgen_eTable_Object: tree_Insert(&sts, m_object_th, &key); break; default:; } } } } if (graph) { // Ge references for (wb_object o = m_sp->object(pwr_cClass_XttGraph); o; o = o.next()) { pwr_tString80 action; pwr_tFileName fname; char line[512]; char linep[2][512]; int tag; int nr; char* s; wb_attribute a = m_sp->attribute(o.oid(), "RtBody", "Action"); a.value(action); if (strstr(action, ".pwg")) { sprintf(fname, "$pwrp_exe/%s", cdh_Low(action)); dcli_translate_filename(fname, fname); std::ifstream fpg(fname); if (!fpg) continue; while (fpg.getline(line, sizeof(line))) { nr = dcli_parse(line, " ", "", (char*)linep, sizeof(linep) / sizeof(linep[0]), sizeof(linep[0]), 0); if (nr != 2) continue; nr = sscanf(linep[0], "%d", &tag); if (nr != 1) continue; switch (tag) { case ge_eSave_DigLowColor_attribute: case ge_eSave_DigColor_attribute: case ge_eSave_DigError_attribute: case ge_eSave_DigWarning_attribute: case ge_eSave_Invisible_attribute: case ge_eSave_DigBorder_attribute: case ge_eSave_DigText_attribute: case ge_eSave_Value_decimals_attr: case ge_eSave_ValueInput_minvalue_attr: case ge_eSave_ValueInput_maxvalue_attr: case ge_eSave_Rotate_attribute: case ge_eSave_Move_move_x_attribute: case ge_eSave_Move_move_y_attribute: case ge_eSave_Move_scale_x_attribute: case ge_eSave_Move_scale_y_attribute: case ge_eSave_AnalogShift_attribute: case ge_eSave_DigShift_attribute: case ge_eSave_Animation_attribute: case ge_eSave_Bar_attribute: case ge_eSave_Bar_minvalue_attr: case ge_eSave_Bar_maxvalue_attr: case ge_eSave_Trend_attribute1: case ge_eSave_Trend_attribute2: case ge_eSave_Trend_minvalue_attr1: case ge_eSave_Trend_maxvalue_attr1: case ge_eSave_Trend_minvalue_attr2: case ge_eSave_Trend_maxvalue_attr2: case ge_eSave_Trend_mark1_attr: case ge_eSave_Trend_mark2_attr: case ge_eSave_DigFlash_attribute: case ge_eSave_FillLevel_attribute: case ge_eSave_FillLevel_minvalue_attr: case ge_eSave_FillLevel_maxvalue_attr: case ge_eSave_Table_attribute1: case ge_eSave_Table_sel_attribute1: case ge_eSave_StatusColor_attribute: case ge_eSave_DigSound_attribute: case ge_eSave_XY_Curve_x_attr: case ge_eSave_XY_Curve_y_attr: case ge_eSave_XY_Curve_y_minvalue_attr: case ge_eSave_XY_Curve_y_maxvalue_attr: case ge_eSave_XY_Curve_x_minvalue_attr: case ge_eSave_XY_Curve_x_maxvalue_attr: case ge_eSave_XY_Curve_x_mark1_attr: case ge_eSave_XY_Curve_x_mark2_attr: case ge_eSave_XY_Curve_y_mark1_attr: case ge_eSave_XY_Curve_y_mark2_attr: case ge_eSave_Pie_attribute1: case ge_eSave_Pie_attribute2: case ge_eSave_Pie_attribute3: case ge_eSave_Pie_attribute4: case ge_eSave_Pie_attribute5: case ge_eSave_Pie_attribute6: case ge_eSave_Pie_attribute7: case ge_eSave_Pie_attribute8: case ge_eSave_Pie_attribute9: case ge_eSave_Pie_attribute10: case ge_eSave_Pie_attribute11: case ge_eSave_Pie_attribute12: case ge_eSave_BarChart_attribute1: case ge_eSave_BarChart_attribute2: case ge_eSave_BarChart_attribute3: case ge_eSave_BarChart_attribute4: case ge_eSave_BarChart_attribute5: case ge_eSave_BarChart_attribute6: case ge_eSave_BarChart_attribute7: case ge_eSave_BarChart_attribute8: case ge_eSave_BarChart_attribute9: case ge_eSave_BarChart_attribute10: case ge_eSave_BarChart_attribute11: case ge_eSave_BarChart_attribute12: case ge_eSave_Axis_minvalue_attr: case ge_eSave_Axis_maxvalue_attr: case ge_eSave_DigFourShift_attribute1: case ge_eSave_DigFourShift_attribute2: case ge_eSave_DigFourShift_attribute3: case ge_eSave_ScrollingText_attribute: case ge_eSave_DigBackgroundColor_attribute: case ge_eSave_DigSwap_attribute: case ge_eSave_DigScript_attribute: case ge_eSave_DigCommand_attribute: case ge_eSave_Slider_minvalue_attr: case ge_eSave_Slider_maxvalue_attr: case ge_eSave_Slider_insensitive_attr: case ge_eSave_AnalogColor_attribute: case ge_eSave_DigSound_soundobject: case ge_eSave_PopupMenu_ref_object: { if ((s = strchr(linep[1], '#'))) *s = 0; if (linep[1][0] == '!') strcpy(&linep[1][0], &linep[1][1]); wb_attribute al = m_sp->attribute(linep[1]); if (!al) break; int len = strlen(linep[1]); if (len > 12 && str_NoCaseStrcmp(&linep[1][len - 12], ".ActualValue") == 0) { linep[1][len - 12] = 0; al = m_sp->attribute(linep[1]); if (!al) break; } switch (al.tid()) { case pwr_cClass_Di: case pwr_cClass_Do: case pwr_cClass_Dv: case pwr_cClass_Ai: case pwr_cClass_Ao: case pwr_cClass_Av: case pwr_cClass_Co: case pwr_cClass_Ii: case pwr_cClass_Io: case pwr_cClass_Iv: case pwr_cClass_Sv: case pwr_cClass_ATv: case pwr_cClass_DTv: { sCrrKey key; key.target = al.aref(); key.reference = cdh_ObjidToAref(o.oid()); key.type = crrgen_eType_Read; tree_Insert(&sts, m_signal_th, &key); break; } default: { sCrrKey key; key.target = al.aref(); key.reference = cdh_ObjidToAref(o.oid()); key.type = crrgen_eType_Read; tree_Insert(&sts, m_object_th, &key); } } break; } case ge_eSave_Value_attribute: case ge_eSave_SetDig_attribute: case ge_eSave_ResetDig_attribute: case ge_eSave_ToggleDig_attribute: case ge_eSave_StoDig_attribute: case ge_eSave_IncrAnalog_attribute: case ge_eSave_RadioButton_attribute: case ge_eSave_Slider_attribute: case ge_eSave_OptionMenu_attribute: case ge_eSave_SetValue_attribute: { if ((s = strchr(linep[1], '#'))) *s = 0; if (linep[1][0] == '!') strcpy(&linep[1][0], &linep[1][1]); wb_attribute al = m_sp->attribute(linep[1]); if (!al) break; int len = strlen(linep[1]); if (len > 12 && str_NoCaseStrcmp(&linep[1][len - 12], ".ActualValue") == 0) { linep[1][len - 12] = 0; al = m_sp->attribute(linep[1]); if (!al) break; } switch (al.tid()) { case pwr_cClass_Di: case pwr_cClass_Do: case pwr_cClass_Dv: case pwr_cClass_Ai: case pwr_cClass_Ao: case pwr_cClass_Av: case pwr_cClass_Co: case pwr_cClass_Ii: case pwr_cClass_Io: case pwr_cClass_Iv: case pwr_cClass_Sv: case pwr_cClass_ATv: case pwr_cClass_DTv: { sCrrKey key; key.target = al.aref(); key.reference = cdh_ObjidToAref(o.oid()); key.type = crrgen_eType_Write; tree_Insert(&sts, m_signal_th, &key); break; } default: { sCrrKey key; key.target = al.aref(); key.reference = cdh_ObjidToAref(o.oid()); key.type = crrgen_eType_Write; tree_Insert(&sts, m_object_th, &key); } } break; } default:; } } fpg.close(); } } } *rsts = 1; }
void subc_ActivateList ( pool_sQlink *lh, pwr_tObjid oid ) { pwr_tStatus sts; tree_sTable *add; #if 0 tree_sTable *remove; sRemove *rep; #endif net_sSubSpec *specp; qcom_sQid tgt; pool_sQlink *my_lh; pwr_tUInt32 my_subc_lc; gdb_sNode *np; gdb_sNode *old_np; sub_sClient *cp; pool_sQlink *cl; sAdd *aep; /* Test each client. If existing object, fill in nid field and move the client to the appropriate nodes's subc_lh list. Turn on timeouts. Put request in subadd message buffer. We must do it all in one pass, since a user can come in during a cache query for a later subcli and cancel the subscription for an earlier subcli. */ add = tree_CreateTable(&sts, sizeof(pwr_tNodeId), offsetof(sAdd, nid), sizeof(sAdd), 10, tree_Comp_nid); #if 0 remove = tree_CreateTable(&sts, sizeof(pwr_tNodeId), offsetof(sRemove, nid), sizeof(sRemove), 10, tree_eComp_nid); #endif /* Move all objects to a new, temporary root */ my_lh = pool_Qalloc(NULL, gdbroot->pool); my_subc_lc = 0; for (cl = pool_Qsucc(NULL, gdbroot->pool, lh); cl != lh;) { cp = pool_Qitem(cl, sub_sClient, subc_ll); cl = pool_Qsucc(NULL, gdbroot->pool, cl); if (cdh_ObjidIsNull(oid) || cdh_ObjidIsEqual(oid, cp->aref.Objid)) { pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll); pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, my_lh); my_subc_lc++; } } /* Now start testing clients from 'my_lh', and move them to other lists Make sure the clients are still there after the test. */ for (cl = pool_Qsucc(NULL, gdbroot->pool, my_lh); cl != my_lh; ) { cp = pool_Qitem(cl, sub_sClient, subc_ll); cl = pool_Qsucc(NULL, gdbroot->pool, cl); np = testClient(&sts, cp); /* If an error is returned the client doesn't exist anymore. Some other user removed it while TestSubcli had the database unlocked. Just go on with the next client... */ if (np == NULL) continue; /* Move the client to the list for the node where the object resides. nid = pwr_cNNodeId is used for all objects we don't know. */ old_np = hash_Search(&sts, gdbroot->nid_ht, &cp->nid); if (old_np == NULL) errh_Bugcheck(GDH__WEIRD, ""); pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll); old_np->subc_lc--; pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, &np->subc_lh); np->subc_lc++; cp->nid = np->nid; /* If the object's nid changed, then take the appropriate actions. */ if (np != old_np) { if (np->nid != pwr_cNNodeId) { /* Object is known. */ activateTimeoutWatch(cp); aep = tree_Insert(&sts, add, &np->nid); if (aep == NULL) errh_Bugcheck(GDH__WEIRD, ""); if (aep->msg == NULL) { aep->cnt = MIN(my_subc_lc, net_cSubMaxAdd); aep->msg = malloc(sizeof(net_sSubAdd) + sizeof(net_sSubSpec) * aep->cnt); aep->msg->count = 0; } /* If there was no message allocated */ specp = &aep->msg->spec[aep->msg->count]; specp->sid = cp->sid; specp->dt = cp->dt; specp->sub_by_name = cp->sub_by_name; specp->aref = cp->cclass != pool_cNRef ? cp->raref : cp->aref; if (++aep->msg->count >= aep->cnt) { /* The message buffer is full and must be sent. */ tgt = np->handler; pwr_Assert(tgt.nid != pwr_cNNodeId); gdb_Unlock; net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0); gdb_Lock; aep->msg->count = 0; } } else { /* The object became unknown... */ cancelTimeoutWatch(cp); subc_SetOld(cp); /* Data gets old immediately */ #if 0 /** @todo Maybe we should unlock the cached class? */ if (cp->cclass != pwr_cNRefId) { ccp = pool_Address(NULL, gdbroot->pool, cp->cclass); if (ccp == NULL) errh_Bugcheck(GDH__WEIRD, "Cached class address"); cmvolc_UnlockClass(NULL, ccp); cp->cclass = pwr_cNRefId; } #endif #if 0 if (old_np->nid != pwr_cNNodeId) { rep = tree_Insert(&sts, remove, &old_np->nid); if (rep == NULL) errh_Bugcheck(GDH__WEIRD, ""); if (rep->msg == NULL) { rep->nid = old_np->nid; rep->cnt = MIN(my_subc_lc, net_cSubMaxRemove); rep->msg = malloc(sizeof(net_sSubRemove) + sizeof(rep->msg->sid[0]) * rep->cnt); rep->msg->count = 0; } rep->msg->sid[rep->msg->count++] = cp->sid; if (rep->msg->count >= net_cSubMaxRemove) { np = hash_Search(&sts, gdbroot->nid_ht, &old_np->nid); if (np == NULL) errh_Bugcheck(sts, ""); tgt.nid = rep->nid; pwr_Assert(tgt.nid != pwr_cNNodeId); gdb_Unlock; net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0); gdb_Lock; rep->msg->count = 0; } } #endif } } } pool_Free(NULL, gdbroot->pool, my_lh); /* Now walk through the addmsg & remmsg and send all unsent messages. */ gdb_Unlock; #if 0 for (rep = tree_Minimum(remove); rep != NULL; rep = tree_Successor(remove, rep)) { if (rep->msg != NULL) { if (rep->msg->count > 0) { tgt.nid = rep->nid; pwr_Assert(tgt.nid != pwr_cNNodeId); net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0); } free(rep->msg); } } #endif for (aep = tree_Minimum(&sts, add); aep != NULL; aep = tree_Successor(&sts, add, aep)) { if (aep->msg != NULL) { if (aep->msg->count > 0) { np = hash_Search(&sts, gdbroot->nid_ht, &aep->nid); if (np == NULL) errh_Bugcheck(GDH__WEIRD, ""); tgt = np->handler; pwr_Assert(tgt.nid != pwr_cNNodeId); net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0); } free(aep->msg); } } gdb_Lock; tree_DeleteTable(&sts, add); #if 0 tree_DeleteTable(remove); #endif }
void subc_CancelList ( pool_sQlink *lh ) { qcom_sQid tgt; #if 0 tree_sTable *remove; sRemove *rep; gdb_sNode *np; #endif pwr_tNodeId nid; pwr_tSubid sid; sub_sClient *cp; pool_sQlink *cl; gdb_AssumeLocked; tgt.qix = net_cProcHandler; #if 0 remove = tree_CreateTable(sizeof(pwr_tNodeId), offsetof(sRemove, nid), sizeof(sRemove), 10, tree_eComp_nid, NULL); #endif for (cl = pool_Qsucc(NULL, gdbroot->pool, lh); cl != lh;) { cp = pool_Qitem(cl, sub_sClient, subc_ll); cl = pool_Qsucc(NULL, gdbroot->pool, cl); cancelTimeoutWatch(cp); /* Get rid of the client, make it invalid for other references that might happen when we are unlocked But first: save nid and sid which we need further down. */ nid = cp->nid; sid = cp->sid; deleteClient(cp); #if 0 if (nid != pwr_cNNodeId) { rep = tree_Insert(remove, &nid); if (rep == NULL) errh_Bugcheck(GDH__WEIRD, ""); if (rep->msg == NULL) { np = hash_Search(NULL, gdbroot->nid_ht, &nid); if (np == NULL) errh_Bugcheck(GDH__WEIRD, ""); rep->cnt = net_cSubMaxRemove; rep->msg = malloc(sizeof(net_sSubRemove) + sizeof(rep->msg->sid[0]) * rep->cnt); rep->msg->count = 0; } rep->msg->sid[rep->msg->count++] = sid; if (rep->msg->count >= net_cSubMaxRemove) { tgt.nid = rep->nid; gdb_Unlock; net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0); gdb_Lock; rep->msg->count = 0; } } /* Remote */ #endif } /* For all clients in list */ #if 0 /* Now send all unsent messages. */ gdb_Unlock; for (rep = tree_Minimum(remove); rep != NULL; rep = tree_Successor(remove, rep)) { if (rep->msg != NULL) { if (rep->msg->count > 0) { tgt.nid = rep->nid; net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0); } free(rep->msg); } } gdb_Lock; tree_DeleteTable(remove); #endif }
bool Lng::read_files( char *fname1, char *fname2, bool global, pwr_tStatus *sts) { pwr_tFileName filename1, filename2; sprintf( filename2, fname2, get_language_str()); dcli_translate_filename( filename1, fname1); dcli_translate_filename( filename2, filename2); ifstream fp1( filename1); if ( !fp1 && strcmp( fname1, "$pwr_exe/en_us/xtt_lng.dat") == 0) { // Try $pwr_eexe strcpy( fname1, "$pwr_eexe/en_us/xtt_lng.dat"); dcli_translate_filename( filename1, fname1); fp1.open( filename1); if ( !fp1) { *sts = LNG__FILE; return false; } } else if ( !fp1) { *sts = LNG__FILE; return global ? false : true; } ifstream fp2( filename2); if ( !fp2 && strcmp( fname2, "$pwr_exe/%s/xtt_lng.dat") == 0) { // Try $pwr_eexe strcpy( fname2, "$pwr_eexe/%s/xtt_lng.dat"); sprintf( filename2, fname2, get_language_str()); dcli_translate_filename( filename2, filename2); fp2.open( filename2); if ( !fp2) { *sts = LNG__FILE; return false; } } else if ( !fp2) { *sts = LNG__FILE; return global ? false : true; } Row r1( fp1, filename1); Row r2( fp2, filename2); read_metadata( fp1, global, sts); read_metadata( fp2, global, sts); read_include( fp1, fp2, global, sts); bool hit = true; for (;;) { if ( hit) { if ( !read_line( r1)) break; if ( !read_line( r2)) break; } else if ( r1.lt( r2)) { if ( !read_line( r1)) break; } else { if ( !read_line( r2)) break; } hit = false; if ( r1.eq( r2)) hit = true; if ( hit) { lang_sKey key; lang_sRecord *record; strncpy( key.text, r1.text, sizeof(key.text)); key.type = r1.type; record = (lang_sRecord *) tree_Insert( sts, tree, &key); strcpy( record->transl, r2.text); // printf ( "%c %d.%d.%d '%s' '%s'\n", r1.type, r1.n1, r1.n2, r1.n3, r1.text,r2.text); } } *sts = LNG__SUCCESS; return true; }
ini_sProc *ini_ProcInsert ( pwr_tStatus *status, ini_sContext *cp, char *id, char *name, int load, int run, char *file, int prio, int debug, char *arg ) { ini_sProc *pp; char buf[255]; char *s; int ret; struct stat f_stat; pwr_dStatus(sts, status, INI__SUCCESS); pp = tree_Insert(sts, cp->proc_t, id); if (pp == NULL) return NULL; if (name != NULL && name[0] != '\0' && strcmp(name, "\"\"")) { if (pp->proc.name != NULL) free(pp->proc.name); sprintf(buf, name, cp->busid); pp->proc.name = strsav(buf); } if (load != -1) pp->proc.flags.b.load = load != 0; if (run != -1) pp->flags.b.run = run != 0; if (file != NULL && file[0] != '\0' && strcmp(file, "\"\"")) { if (pp->proc.file != NULL) free(pp->proc.file); pp->proc.file = strsav(file); #if defined(OS_LINUX) s = getenv("pwr_exe"); sprintf(buf, "%s/%s", s, file); ret = stat(buf, &f_stat); if (ret == -1) { s = getenv("pwrp_exe"); sprintf(buf, "%s/%s", s, file); ret = stat(buf, &f_stat); if (ret == -1) { pp->flags.b.run = 0; pp->proc.flags.b.load = 0; } } #endif } if (arg != NULL && arg[0] != '\0' && strcmp(arg, "\"\"")) { if (pp->proc.arg != NULL) free(pp->proc.arg); pp->proc.arg = strsav(arg); } if (prio != -1) pp->proc.p_prio = prio; if (debug != -1) pp->proc.flags.b.debug = debug != 0; if (!lst_IsLinked(NULL, &pp->proc_ll)) { lst_InsertPred(NULL, &cp->proc_lh, &pp->proc_ll, pp); } return pp; }
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(<p, i, Compare, &lnp); if (!(sts & 1)) { lib$insert_tree(<p, 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(<p, 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; } } }
pwr_tStatus wb_dbs::prepareSectVolref() { char v[dbs_dAlign(sizeof(dbs_sVolRef))]; dbs_sVolRef *vp = (dbs_sVolRef*)v; cdh_uTid cid; sCentry *cep; pwr_tStatus sts; pwr_tUInt32 dvVersion; if (fseek(m_fp, m_sect[dbs_eSect_volref].offset, SEEK_SET) != 0) return LDH__FILEPOS; memset(v, 0, sizeof(v)); cid.pwr = pwr_cNCid; cep = (sCentry*)tree_FindSuccessor(&sts, m_class_th, &cid.pwr); while (cep) { cdh_uVid vid; vid.pwr = pwr_cNVid; cid.pwr = cep->c.cid; vid.v.vid_0 = cid.c.vid_0; vid.v.vid_1 = cid.c.vid_1; if (vid.pwr != m_volume.vid) { wb_mvrep *mvrep = m_v->merep()->volume(&sts, vid.pwr); if ( EVEN(sts)) throw wb_error_str("Metavolume not found"); dvVersion = getDvVersion( mvrep); sVentry *vep; vep = (sVentry*)tree_Insert(&sts, m_vol_th, &vid.pwr); if (sts == TREE__INSERTED) { /* was inserted now */ dbs_Open(&sts, &vep->env, mvrep->fileName()); strcpy(vep->v.name, mvrep->name()); vep->v.cid = mvrep->cid(); if ( m_volume.cid == pwr_eClass_DetachedClassVolume) { vep->v.time.tv_sec = dvVersion; vep->v.time.tv_nsec = 0; } else vep->v.time = vep->env.file.time; vep->v.size = vep->env.file.size; vep->v.offset = 0; int i = 0; while ((vp = dbs_VolRef(&sts, i, (dbs_sVolRef *)v, &vep->env)) != NULL) { sVentry *nvep; i++; nvep = (sVentry*)tree_Insert(&sts, m_vol_th, &vp->vid); if (sts == TREE__INSERTED) { wb_mvrep *nmvrep = m_v->merep()->volume(&sts, vp->vid); if ( EVEN(sts)) { printf( "** Classvolume %s referenced but not loaded\n", vp->name); throw wb_error_str("Metavolume not loaded"); } dvVersion = getDvVersion( mvrep); dbs_Open(&sts, &nvep->env, nmvrep->fileName()); strcpy(nvep->v.name, vp->name); nvep->v.cid = vp->cid; if ( m_volume.cid == pwr_eClass_DetachedClassVolume) { nvep->v.time.tv_sec = dvVersion; nvep->v.time.tv_nsec = 0; } else nvep->v.time = vp->time; // nvep->v.dvVersion = vp->dvVersion; nvep->v.size = vp->size; nvep->v.offset = 0; } } } } vid.pwr++; cid.pwr = pwr_cNCid; cid.c.vid_0 = vid.v.vid_0; cid.c.vid_1 = vid.v.vid_1; cep = (sCentry*)tree_FindSuccessor(&sts, m_class_th, &cid.pwr); } // Search trhough all found volumes and get their volrefs int nVolume = 0; sVentry *vep; vep = (sVentry*)tree_Minimum(&sts, m_vol_th); while (vep) { if (vep->env.file.cookie == 0) { printf(" volume not found: %d\n", vep->v.vid); } else { nVolume++; m_sect[dbs_eSect_volref].size += sizeof(v); } vep = (sVentry*)tree_Successor(&sts, m_vol_th, vep); } return LDH__SUCCESS; }
bool wb_dbs::importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid, pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid, pwr_tOid loid, const char *name, const char *normname, pwr_mClassDef flags, pwr_tTime time, pwr_tTime rbTime, pwr_tTime dbTime, size_t rbSize, size_t dbSize) { sNentry *nep; sOentry *oep; pwr_tStatus sts; if (cdh_ObjidIsNull(oid)) printf("** Error: object is null!\n"); oep = (sOentry *)tree_Insert(&sts, m_oid_th, &oid); if (sts == TREE__INSERTED) { } else if (oep->flags.b.exist) { printf("** Error: object is already inserted!\n"); } if (oid.oix == pwr_cNOix) { // this is the volume object m_oep = oep; } oep->flags.b.exist = 1; // Link objects to its relatives if (cdh_ObjidIsNotNull(poid)) oep->poep = (sOentry *)tree_Insert(&sts, m_oid_th, &poid); if (cdh_ObjidIsNotNull(boid)) oep->boep = (sOentry *)tree_Insert(&sts, m_oid_th, &boid); if (cdh_ObjidIsNotNull(aoid)) oep->aoep = (sOentry *)tree_Insert(&sts, m_oid_th, &aoid); if (cdh_ObjidIsNotNull(foid)) oep->foep = (sOentry *)tree_Insert(&sts, m_oid_th, &foid); if (cdh_ObjidIsNotNull(loid)) oep->loep = (sOentry *)tree_Insert(&sts, m_oid_th, &loid); m_nObjects++; m_volume.cardinality++; if (flags.b.DevOnly) oep->o.flags.b.devOnly = 1; if (flags.b.RtReadOnly) oep->o.flags.b.readOnly = 1; oep->o.oid = oid; oep->o.cid = cid; oep->o.poid = poid; oep->o.boid = boid; oep->o.aoid = aoid; oep->o.foid = foid; oep->o.loid = loid; strcpy(oep->o.name, name); strcpy(oep->o.normname, normname); oep->o.time = time; if (cdh_ObjidIsNotNull(poid)) { dbs_sName n; /* insert into name table */ memset(&n, 0, sizeof(n)); n.poix = poid.oix; strcpy(n.normname, normname); nep = (sNentry*)tree_Insert(&sts, m_name_th, &n); nep->oep = oep; } oep->o.ohFlags.m = flags.m; // classInsert(oep); oep->o.rbody.time = rbTime; oep->o.rbody.size = rbSize; if (rbSize > 0) { oep->rbody.oid = oid; oep->rbody.size = dbs_dAlign(rbSize); m_volume.rbodySize += oep->rbody.size; } oep->o.dbody.time = dbTime; oep->o.dbody.size = dbSize; if (oep->o.dbody.size > 0) { oep->dbody.oid = oid; oep->dbody.size = dbs_dAlign(oep->o.dbody.size); } if ( cid == pwr_eClass_ClassDef) { // Version is dependent of attribute objects // m_v->merep()->classVersion(&sts, cdh_ClassObjidToId(oid), &oep->o.time); } return true; }
void wb_dbs::cidInsert(pwr_tStatus *sts, pwr_tCid cid, pwr_sAttrRef *arp, sCentry **cep) { *cep = (sCentry*)tree_Insert(sts, m_class_th, &cid); if ( !arp) return; if (*sts == TREE__INSERTED) { // Insert depending classes pwr_tCid *lst; pwr_sAttrRef *arlst; sCentry *entry; int cnt; pwr_tStatus lsts; pwr_sAttrRef aref; pwr_sAttrRef cast_aref; pwr_tCid cast_cid; m_v->merep()->classDependency( &lsts, cid, &lst, &arlst, &cnt); for ( int i = 0; i < cnt; i++) { aref = cdh_ArefAdd( arp, &arlst[i]); cidInsert(&lsts, lst[i], &aref, &entry); if ( aref.Flags.b.CastAttr) { cast_aref = cdh_ArefToCastAref( &aref); wb_volume v(m_v); wb_attribute a = v.attribute( &cast_aref); if ( a) { a.value( &cast_cid); if ( cast_cid != pwr_cNCid) { wb_cdef cd = v.cdef( cast_cid); if ( cd) cidInsert(&lsts, cast_cid, 0, &entry); else printf("** Invalid cast class %s\n", cdh_ObjidToString( 0, aref.Objid, 1)); } } } } free(lst); free(arlst); } else if ( !(cdh_CidToVid(cid) == 1 && cdh_CidToVid(cid) == 2)) { // Check class of casted attribute for every instance pwr_tCid *lst; pwr_sAttrRef *arlst; sCentry *entry; int cnt; pwr_tStatus lsts; pwr_sAttrRef aref; pwr_sAttrRef cast_aref; pwr_tCid cast_cid; m_v->merep()->classDependency( &lsts, cid, &lst, &arlst, &cnt); for ( int i = 0; i < cnt; i++) { aref = cdh_ArefAdd( arp, &arlst[i]); if ( aref.Flags.b.CastAttr) { cast_aref = cdh_ArefToCastAref( &aref); wb_volume v(m_v); wb_attribute a = v.attribute( &cast_aref); if ( a) { a.value( &cast_cid); if ( cast_cid != pwr_cNCid) { wb_cdef cd = v.cdef( cast_cid); if ( cd) cidInsert(&lsts, cast_cid, 0, &entry); else printf("** Invalid cast class %s\n", cdh_ObjidToString( 0, aref.Objid, 1)); } } } } free(lst); free(arlst); } }
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; } } }