void wb_pvd_gvl::load( pwr_tStatus *rsts) { char line[200]; char line_item[6][80]; int num; ifstream is; pwr_tFileName fname; int line_cnt = 0; pwr_tStatus sts; int menu_stack[100]; int menu_cnt = 0; char description[80]; *rsts = LDH__SUCCESS; // Create Root object procom_obj rootitem; strcpy( rootitem.name, "GlobalVolumeList"); rootitem.cid = pwr_eClass_Hier; rootitem.oix = 0; m_list.push_back(rootitem); menu_stack[menu_cnt] = rootitem.oix; menu_cnt++; dcli_translate_filename( fname, "$pwra_db/pwr_volumelist.dat"); is.open( fname); if ( !is) { *rsts = LDH__NEWFILE; return; } while ( is.getline( line, sizeof(line))) { line_cnt++; if ( line[0] == '!') { if ( strncmp( line, "!**Menu", 7) == 0) { // Add Hier char *s = strstr( line, "// "); if ( s) { strncpy( description, s+3, sizeof(description)); description[sizeof(description)-1] = 0; } else strcpy( description, ""); num = dcli_parse( line, " ", "", (char *)line_item, sizeof(line_item)/sizeof(line_item[0]), sizeof(line_item[0]), 0); if ( num < 3) { cout << "Syntax error " << fname << " row " << line_cnt << endl; continue; } procom_obj plantitem; strcpy( plantitem.name, line_item[1]); plantitem.cid = pwr_eClass_Hier; plantitem.oix = next_oix++; plantitem.fthoix = menu_stack[menu_cnt - 1]; plantitem.bwsoix = m_list[plantitem.fthoix].lchoix; plantitem.fwsoix = 0; plantitem.body_size = sizeof(pwr_sHier); pwr_sHier *plantbody = (pwr_sHier *) calloc( 1, plantitem.body_size); plantitem.body = plantbody; strcpy( plantbody->Description, description); m_list.push_back(plantitem); if ( plantitem.bwsoix != 0) m_list[plantitem.bwsoix].fwsoix = plantitem.oix; m_list[plantitem.fthoix].lchoix = plantitem.oix; if ( m_list[plantitem.fthoix].fchoix == 0) m_list[plantitem.fthoix].fchoix = plantitem.oix; menu_stack[menu_cnt] = plantitem.oix; menu_cnt++; } else if ( strncmp( line, "!**}", 4) == 0) { if ( menu_cnt == 0) { cout << "Syntax error " << fname << " row " << line_cnt << endl; continue; } menu_cnt--; } continue; } dcli_trim( line, line); num = dcli_parse( line, " ", "", (char *)line_item, sizeof(line_item)/sizeof(line_item[0]), sizeof(line_item[0]), 0); if ( num != 3) { cout << "Syntax error " << fname << " row " << line_cnt << endl; continue; } procom_obj volitem; strcpy( volitem.name, line_item[0]); volitem.body_size = sizeof(pwr_sClass_VolumeReg); pwr_sClass_VolumeReg *volbody = (pwr_sClass_VolumeReg *) calloc( 1, volitem.body_size); volitem.body = volbody; strcpy( volbody->Project, line_item[2]); sts = cdh_StringToVolumeId( line_item[1], &volbody->VolumeId); if ( EVEN(sts)) { cout << "Syntax error " << fname << " row " << line_cnt << endl; continue; } volitem.cid = pwr_cClass_VolumeReg; volitem.oix = next_oix++; volitem.fthoix = menu_stack[menu_cnt - 1]; volitem.bwsoix = m_list[volitem.fthoix].lchoix; volitem.fwsoix = 0; strcpy( volbody->Description, line_item[1]); for ( int i = strlen(volbody->Description); i < 18; i++) strcat( volbody->Description, " "); strcat( volbody->Description, line_item[2]); m_list.push_back(volitem); if ( volitem.bwsoix != 0) m_list[volitem.bwsoix].fwsoix = volitem.oix; m_list[volitem.fthoix].lchoix = volitem.oix; if ( m_list[volitem.fthoix].fchoix == 0) m_list[volitem.fthoix].fchoix = volitem.oix; } }
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); }
int main(int argc, char *argv[]) { pwr_tStatus sts; char remote_address[40]; char remote_host_name[40]; char remote_vid[40]; char remote_volume_name[40]; int udp_port; int server_id; /* Read arguments */ if ( argc < 5) { usage(); exit(0); } strcpy( remote_address, argv[1]); strcpy( remote_host_name, argv[2]); strcpy( remote_vid, argv[3]); strcpy( remote_volume_name, argv[4]); if ( argc >= 6) { sts = sscanf( argv[5], "%d", &server_id); if ( sts != 1) { usage(); exit(0); } } else server_id = 200; if ( argc >= 7) { sts = sscanf( argv[6], "%d", &udp_port); if ( sts != 1) { usage(); exit(0); } } else udp_port = 3051; if ( argc >= 8) { sts = sscanf( argv[7], "%d", &rpvd_opsys); if ( sts != 1) { usage(); exit(0); } } else rpvd_opsys = 0; cdh_StringToVolumeId( remote_vid, &rpvd_vid); strcpy( rpvd_vname, remote_volume_name); sts = udp_Init( remote_address, remote_host_name, udp_port); if ( EVEN(sts)) { exit(0); } remote_pvd_pwrcli provider( pvd_eEnv_Rt); rt_procom procom( &provider, errh_eAnix_appl20, // Application index "remote_pvd_pwrcli", // Process name server_id, // Sid rpvd_vid, // Vid rpvd_vname, // Volume name 0); // Global procom.init(); provider.nodeUp(); procom.mainLoop(); }