pkg_node& wb_pkg::getNode( char *name) { for ( int i = 0; i < (int) m_nodelist.size(); i++) { if ( strcmp( m_nodelist[i].name(), cdh_Low(name)) == 0) return m_nodelist[i]; } throw wb_error_str("No such node"); }
// Convert language enum to lower case string char *Lng::lang_to_str( lng_eLanguage language) { static char result[20]; if ( language >= lng_eLanguage__ || language <= 0) strcpy( result, ""); else strcpy( result, cdh_Low( lng_cLanguageStr[language])); return result; }
int sev_db::get_systemname(char* name) { FILE* file; pwr_tFileName fname; char nodename[40]; char* bus_str; int bus; char line[200]; pwr_tStatus sts; static char system_name[80] = ""; if (streq(system_name, "")) { syi_NodeName(&sts, nodename, sizeof(nodename)); if (EVEN(sts)) return 0; bus_str = getenv("PWR_BUS_ID"); if (!bus_str) return 0; if (sscanf(bus_str, "%d", &bus) != 1) return 0; sprintf(fname, pwr_cNameBoot, load_cDirectory, cdh_Low(nodename), bus); dcli_translate_filename(fname, fname); file = fopen(fname, "r"); if (file == 0) { printf("In %s row %d:\n", __FILE__, __LINE__); printf("** Warning, systemname not found\n"); return 0; } if (!dcli_read_line(line, sizeof(line), file)) return 0; if (!dcli_read_line(line, sizeof(line), file)) return 0; strcpy(system_name, line); } strcpy(name, system_name); return 1; }
wb_dbs::wb_dbs(wb_vrep *v) : m_oid(pwr_cNOid), m_rtonly(0), m_warnings(0), m_errors(0), m_nObjects(0), m_nTreeObjects(0), m_nClassObjects(0), m_nNameObjects(0), m_nRbodyObjects(0), m_nDbodyObjects(0), m_oep(0) { pwr_tStatus sts; memset(m_fileName, 0, sizeof(m_fileName)); memset(&m_volume, 0, sizeof(m_volume)); memset(m_sect, 0, sizeof(m_sect)); time_GetTime(&m_volume.time); m_v = v; m_volume.vid = m_v->vid(); strcpy(m_volume.name, m_v->name()); m_volume.cid = m_v->cid(); //@todo strcpy(m_volume.className, m_ohp->chp->db.name.data); m_volume.dvVersion = getDvVersion( m_v); sprintf(m_fileName, dbs_cNameVolume, dbs_cDirectory, cdh_Low(m_v->name())); dcli_translate_filename(m_fileName, m_fileName); m_oid_th = tree_CreateTable(&sts, sizeof(pwr_tOid), offsetof(sOentry, o.oid), sizeof(sOentry), 1000, tree_Comp_oid); m_name_th = tree_CreateTable(&sts, sizeof(dbs_sName), offsetof(sNentry, n), sizeof(sNentry), 1000, comp_dbs_name); m_class_th = tree_CreateTable(&sts, sizeof(pwr_tCid), offsetof(sCentry, c), sizeof(sCentry), 1000, tree_Comp_cid); m_vol_th = tree_CreateTable(&sts, sizeof(pwr_tVid), offsetof(sVentry, v.vid), sizeof(sVentry), 10, tree_Comp_vid); }
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 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; } }
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; }
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; }
void wb_pkg::readConfig() { char fname[200]; char line[200]; char line_item[7][80]; int num; int sts; dcli_translate_filename( fname, load_cNameDistribute); ifstream is( fname); while ( is.getline( line, sizeof(line))) { dcli_trim( line, line); if ( line[0] == '#' || line[0] == '!') continue; num = dcli_parse( line, " ", "", (char *)line_item, sizeof(line_item)/sizeof(line_item[0]), sizeof(line_item[0]), 0); if ( !num) continue; if ( strcmp( cdh_Low(line_item[0]), "node") == 0) { pwr_mOpSys opsys; int bus; pwr_tMask dstatus; char bootnode[80]; pwr_tString80 custom_platform; if ( num != 7) throw wb_error_str("File corrupt " load_cNameDistribute); sts = sscanf( line_item[2], "%d", (int *)&opsys); if ( sts != 1) throw wb_error_str("File corrupt " load_cNameDistribute); sts = sscanf( line_item[3], "%d", &bus); if ( sts != 1) throw wb_error_str("File corrupt " load_cNameDistribute); sts = sscanf( line_item[4], "%d", (int *)&dstatus); if ( sts != 1) throw wb_error_str("File corrupt " load_cNameDistribute); strcpy( bootnode, line_item[5]); strcpy( custom_platform, line_item[6]); if ( m_allnodes) { pkg_node node( line_item[1], opsys, bus, dstatus, bootnode, custom_platform); m_nodelist.push_back( node); } else { bool found = false; for ( int i = 0; i < (int) m_nodelist.size(); i++) { if ( strcmp( m_nodelist[i].name(), cdh_Low(line_item[1])) == 0) { found = true; m_nodelist[i].setOpsys( opsys); m_nodelist[i].setBus( bus); m_nodelist[i].setDStatus( dstatus); m_nodelist[i].setBootnode( bootnode); m_nodelist[i].setCustomPlatform( custom_platform); m_nodelist[i].setValid(); break; } } } } else if ( strcmp( cdh_Low(line_item[0]), "appl") == 0) { if ( !(num == 4 || num == 5)) throw wb_error_str("File corrupt " load_cNameDistribute); char severity = line_item[2][0]; try { pkg_node& n = getNode( line_item[1]); if ( num == 4) { pkg_pattern p( line_item[3], "", severity); n.push_back( p); } else { pkg_pattern p( line_item[3], line_item[4], severity); n.push_back( p); } } catch ( wb_error &e) { continue; } } else if ( strcmp( cdh_Low(line_item[0]), "load") == 0) { pwr_tVolumeId *vollist; pwr_tString40 *volnamelist; int volcount; pwr_tString80 *plclist; int plccount; char systemname[80]; char systemgroup[80]; pwr_tTime date; if ( !(num == 2)) throw wb_error_str("File corrupt " load_cNameDistribute); try { pkg_node &n = getNode( line_item[1]); // Add ld_node file sprintf( fname, load_cNameNode, load_cDirectory, n.name(), n.bus()); pkg_pattern pnode( fname, "", 'E'); n.push_back( pnode); // Add bootfile sprintf( fname, load_cNameBoot, load_cDirectory, n.name(), n.bus()); pkg_pattern pboot( fname, "", 'E'); n.push_back( pboot); // Read bootfile, get plc and volumes sts = lfu_ReadBootFile( fname, &date, systemname, systemgroup, &vollist, &volnamelist, &volcount, &plclist, &plccount); if ( EVEN(sts)) throw wb_error_str("Bootfile is corrupt"); // Add plc for ( int j = 0; j < plccount; j++) { pwr_tFileName dir; if ( n.opsys() == pwr_mOpSys_CustomBuild && strcmp( n.customPlatform(), "-") != 0) sprintf( dir, "$pwrp_root/bld/%s/exe/", n.customPlatform()); else sprintf( dir, "$pwrp_root/bld/%s/exe/", cdh_OpSysToStr( n.opsys())); sprintf( fname, "%s%s", dir, plclist[j]); sprintf( dir, "$pwrp_exe/"); pkg_pattern pplc( fname, dir, 'W'); n.push_back( pplc); } // Add volumes for ( int j = 0; j < volcount; j++) { char dir[80]; if ( (vollist[j] >= cdh_cManufactClassVolMin && vollist[j] <= cdh_cManufactClassVolMax) || (vollist[j] >= cdh_cSystemClassVolMin && vollist[j] <= cdh_cSystemClassVolMax)) { // Base volume, skip continue; } strcpy( dir, "$pwrp_load/"); sprintf( fname, "%s%s.dbs", dir, cdh_Low( (char *)(volnamelist + j))); n.checkVolume( fname); // Check if there are any rtt-files for Root or Sub Volumes if ( vollist[j] >= cdh_cUserVolMin && vollist[j] <= cdh_cUserVolMax) { cdh_uVolumeId vid; vid.pwr = vollist[j]; // RttCrr-file strcpy( dir, "$pwrp_load/"); sprintf( fname, "%s" load_cNameRttCrr, dir, vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0); pkg_pattern rttcrr( fname); n.push_back( rttcrr); // RttCrrObj-file strcpy( dir, "$pwrp_load/"); sprintf( fname, "%s" load_cNameRttCrrObj, dir, vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0); pkg_pattern rttcrrobj( fname); n.push_back( rttcrrobj); // RttCrrCode-file strcpy( dir, "$pwrp_load/"); sprintf( fname, "%s" load_cNameRttCrrCode, dir, vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0); pkg_pattern rttcrrcode( fname); n.push_back( rttcrrcode); // RttSignals strcpy( dir, "$pwrp_load/"); sprintf( fname, "%s" load_cNameRttSignals, dir, vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0); pkg_pattern rttsignals( fname); n.push_back( rttsignals); } } free( volnamelist); free( vollist); } catch ( wb_error &e) { if ( e.what() == string("No such node")) continue; throw wb_error_str(e.what()); } } else if ( strcmp( cdh_Low(line_item[0]), "boot") == 0) { // A Sev node, only node and bootfile try { if ( !(num == 2)) throw wb_error_str("File corrupt " load_cNameDistribute); pkg_node &n = getNode( line_item[1]); // Add ld_node file sprintf( fname, load_cNameNode, load_cDirectory, n.name(), n.bus()); pkg_pattern pnode( fname, "", 'E'); n.push_back( pnode); // Add bootfile sprintf( fname, load_cNameBoot, load_cDirectory, n.name(), n.bus()); pkg_pattern pboot( fname, "", 'E'); n.push_back( pboot); } catch ( wb_error &e) { if ( e.what() == string("No such node")) continue; throw wb_error_str(e.what()); } } } is.close(); // Check that all nodes are valid for ( int i = 0; i < (int) m_nodelist.size(); i++) { if ( !m_nodelist[i].valid()) throw wb_error_str( "Unknown node name"); } }