psection() { Section *sec; Prop *p, *p1; sec = chk_access(); p = sec->prop; Printf("%s {", secname(sec)); Printf(" nseg=%d L=%g Ra=%g", sec->nnode - 1, section_length(sec), nrn_ra(sec)); if (p->dparam[4].val != 1) { Printf(" rallbranch=%g", p->dparam[4].val); } Printf("\n"); if (sec->parentsec) { Printf(" %s ",secname(sec->parentsec)); Printf("connect %s (%g), %g\n", secname(sec), p->dparam[3].val, p->dparam[1].val); } else { v_setup_vectors(); /*SUPPRESS 440*/ Printf(" /*location %g attached to cell %d*/\n", p->dparam[3].val, sec->parentnode->v_node_index); } if (sec->nnode) { /*SUPPRESS 440*/ Printf(" /* First segment only */\n"); p1 = sec->pnode[0]->prop; pnode(p1); } Printf("}\n"); ret(1.); }
static void plist(shm_node_t *head) { shm_node_t *c; FUN("plist"); LOGS(L_SHM,L_ERROR,("=== list starts at 0x%x ===\n", (uint32_t)head)); c = head; while (NULL != c) { pnode(c); c = c->x.next; } }
bool patcher_dynamic::add_node (node0* obj) { if (m_nodes.insert(pair<int, pnode>(obj->get_id(), pnode(obj))).second) { map<int, pnode>::iterator i; int this_type = obj->get_type (); int other_type; for (i = m_nodes.begin(); i != m_nodes.end(); ++i) { if (i->first == obj->get_id ()) continue; other_type = i->second.obj->get_type (); if (PATCHER_TABLE[this_type][other_type].socket_type != node0::LINK_NONE) { m_links.insert(new link(obj, (*i).second.obj, obj->sqr_distance_to(*i->second.obj), i->second.obj->sqr_distance_to_center (), PATCHER_TABLE[this_type][other_type].socket_type, PATCHER_TABLE[this_type][other_type].src_socket, PATCHER_TABLE[this_type][other_type].dest_socket)); } if (PATCHER_TABLE[other_type][this_type].socket_type != node0::LINK_NONE) { m_links.insert(new link(i->second.obj, obj, i->second.obj->sqr_distance_to(*obj), obj->sqr_distance_to_center(), PATCHER_TABLE[other_type][this_type].socket_type, PATCHER_TABLE[other_type][this_type].src_socket, PATCHER_TABLE[other_type][this_type].dest_socket)); } } m_changed = true; return true; } return false; }
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"); } }
int main(int argc, char* argv[]) { queue_root_t root; queue_init(&root, 10); void* p = malloc(sizeof(int)); *(int*)p = 10; printf("result: %d\n", queue_push(&root, p)); queue_node_t* node = queue_pop(&root); pnode(node); void* pp = malloc(sizeof(int)); *(int*)pp = 100; printf("result: %d\n", queue_push(&root, pp)); node = queue_pop(&root); pnode(node); free(p); free(pp); for (int i = 0; i < 10; i++) { void* ppp = malloc(sizeof(int)); *(int*)ppp = i; printf("result: %d\n", queue_push(&root, ppp)); printf("size: %u\n", queue_count(&root)); } for (int i = 0; i < 10; i++) { queue_node_t* node = queue_pop(&root); pnode(node); free(node->data); } /* 验证循环插入的正确性 */ for (int i = 0; i < 10; i++) { void* ppp = malloc(sizeof(int)); *(int*)ppp = i; printf("result: %d\n", queue_push(&root, ppp)); printf("size: %u\n", queue_count(&root)); } for (int i = 0; i < 5; i++) { queue_node_t* node = queue_pop(&root); pnode(node); free(node->data); } for (int i = 10; i < 15; i++) { void* ppp = malloc(sizeof(int)); *(int*)ppp = i; printf("result: %d\n", queue_push(&root, ppp)); printf("size: %u\n", queue_count(&root)); } return 0; }