From: Daniel M. <tub...@us...> - 2003-06-03 15:03:31
|
Update of /cvsroot/epp-rtk/epp-rtk/c++/src In directory sc8-pr-cvs1:/tmp/cvs-serv6694 Modified Files: main_hostupdate.cc Log Message: updated host update example with new param stuff Index: main_hostupdate.cc =================================================================== RCS file: /cvsroot/epp-rtk/epp-rtk/c++/src/main_hostupdate.cc,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** main_hostupdate.cc 2 Jun 2003 21:24:25 -0000 1.15 --- main_hostupdate.cc 3 Jun 2003 15:03:27 -0000 1.16 *************** *** 63,77 **** string username, password; ! if(!handleArgs(test, argc, argv, username, password)) return 1; ! map<unsigned int,string> testDataMap; if(argc > 1) { for(int parm = 1; parm < argc; parm++) { ! if (!strncmp(argv[parm], "-testdata=", 10)) { ! string td = &argv[parm][10]; ! testDataMap = getTestDataMap(td); } } --- 63,107 ---- string username, password; ! vector<string> extra_usage; ! extra_usage.push_back("[-extradata=trid=xxx:name=ns1.host.tld"); ! extra_usage.push_back(" -add=status1=aaa{~...}~ip1=v4/1.2.3.4~ip2=v6/1080:0:0:0:8:800:200C:417A{~...}"); ! extra_usage.push_back(" -remove=status1=ccc{~...}~ip1=v4/1.2.3.4~ip2=v6/1080:0:0:0:8:800:200C:417A{~...}"); ! extra_usage.push_back(" -change=name=new.host.tld]"); ! if(!handleArgs(test, argc, argv, username, password, extra_usage)) return 1; ! map<string,string> extraDataMap; ! map<string,string> addDataMap; ! map<string,string> changeDataMap; ! map<string,string> removeDataMap; if(argc > 1) { for(int parm = 1; parm < argc; parm++) { ! if (!strncmp(argv[parm], "-extradata=", 11)) { ! cout << "Found extra data param..." << endl; ! string td = &argv[parm][11]; ! extraDataMap = getExtraDataMap(td); ! } ! ! if (!strncmp(argv[parm], "-add=", 5)) { ! cout << "Found 'add' data param..." << endl; ! string td = &argv[parm][5]; ! addDataMap = getExtraDataMap(td); ! if ( addDataMap.empty() ) addDataMap[""] = "dummy"; ! } ! ! if (!strncmp(argv[parm], "-change=", 8)) { ! cout << "Found 'change' data param..." << endl; ! string td = &argv[parm][8]; ! changeDataMap = getExtraDataMap(td); ! if ( changeDataMap.empty() ) changeDataMap[""] = "dummy"; ! } ! ! if (!strncmp(argv[parm], "-remove=", 8)) { ! cout << "Found 'remove' data param..." << endl; ! string td = &argv[parm][8]; ! removeDataMap = getExtraDataMap(td); ! if ( removeDataMap.empty() ) removeDataMap[""] = "dummy"; } } *************** *** 85,90 **** string trID; ! if(testDataMap.empty()) trID = "ABC-12345"; ! else trID = testDataMap[1]; l_req->m_cmd.ref(new epp_Command(NULL, --- 115,120 ---- string trID; ! if(extraDataMap.find("trid") == extraDataMap.end()) trID = "ABC-12345"; ! else trID = extraDataMap["trid"]; l_req->m_cmd.ref(new epp_Command(NULL, *************** *** 92,96 **** epp_trid(trID))); ! if(testDataMap.empty()) { // Data to add: epp_HostAddress host1(IPV4, epp_string("192.1.2.3")); --- 122,133 ---- epp_trid(trID))); ! ! if ( extraDataMap.find("name") == extraDataMap.end() ) l_req->m_name.ref(new epp_string("ns1.example.com")); ! else l_req->m_name.ref(new epp_string(extraDataMap["name"])); ! ! if( addDataMap.empty() && ! removeDataMap.empty() && ! changeDataMap.empty() ) { ! // Data to add: epp_HostAddress host1(IPV4, epp_string("192.1.2.3")); *************** *** 119,233 **** torem->m_addresses = hosts2; - l_req->m_name.ref(new epp_string("ns1.example.com")); l_req->m_add = toadd; l_req->m_remove = torem; l_req->m_change.ref(new epp_HostUpdateChange()); l_req->m_change->m_name.ref(new epp_string("ns2.example.com")); ! } ! else { ! if(testDataMap[2] != "-1") l_req->m_name.ref(new epp_string(testDataMap[2])); ! ! if(testDataMap[3] == "chg") { ! ! l_req->m_change.ref(new epp_HostUpdateChange()); ! ! if(testDataMap[4] != "-1") l_req->m_change->m_name.ref(new epp_string(testDataMap[4])); ! } ! ! unsigned int thisEl = 6; ! unsigned int remEl = 1; ! unsigned int mapSize = testDataMap.size(); ! ! while(remEl <= mapSize) { ! if(testDataMap[remEl] == "rem") break; ! remEl++; ! } ! ! if(testDataMap[5] == "add") { ! ! epp_HostUpdateAddRemove_ref toadd(new epp_HostUpdateAddRemove()); ! if(testDataMap[6] != "-1") { ! string statuses = testDataMap[6]; ! toadd->m_status.ref(new epp_host_status_seq()); ! ! int begin = 0; ! int end = 0; ! while(end != string::npos) { ! end = statuses.find(' ', begin); ! string tmp = statuses.substr(begin,end-begin); epp_HostStatus status; status.m_type.ref(new epp_HostStatusType(returnStatusEnumType(tmp))); ! toadd->m_status->push_back(status); ! ! begin = end+1; } } - - while(thisEl <= mapSize && testDataMap[++thisEl] != "rem") { ! if(toadd->m_addresses == NULL) toadd->m_addresses.ref(new epp_host_address_seq); ! ! string::size_type space = testDataMap[thisEl].find(" "); ! if(space != string::npos) { ! string ip = testDataMap[thisEl].substr(0,space); ! string iptype = testDataMap[thisEl].substr(space+1, testDataMap[thisEl].length()); ! ! epp_HostAddress host(returnIPTypeEnum(epp_string(iptype)), epp_string(ip)); ! toadd->m_addresses->push_back(host); } } ! ! l_req->m_add = toadd; ! } ! thisEl = remEl; ! ! if(testDataMap[thisEl] == "rem") { ! ! epp_HostUpdateAddRemove_ref torem(new epp_HostUpdateAddRemove()); ! if(testDataMap[++thisEl] != "-1") { ! string statuses = testDataMap[thisEl]; ! torem->m_status.ref(new epp_host_status_seq()); ! ! int begin = 0; ! int end = 0; ! while(end != string::npos) { ! end = statuses.find(' ', begin); ! string tmp = statuses.substr(begin,end-begin); epp_HostStatus status; status.m_type.ref(new epp_HostStatusType(returnStatusEnumType(tmp))); ! torem->m_status->push_back(status); ! ! begin = end+1; } } ! ! while(thisEl++ <= mapSize) { ! ! if(torem->m_addresses == NULL) torem->m_addresses.ref(new epp_host_address_seq); ! ! string::size_type space = testDataMap[thisEl].find(" "); ! if(space != string::npos) { ! string ip = testDataMap[thisEl].substr(0,space); ! string iptype = testDataMap[thisEl].substr(space+1, testDataMap[thisEl].length()); ! ! epp_HostAddress host(returnIPTypeEnum(epp_string(iptype)), epp_string(ip)); ! torem->m_addresses->push_back(host); } ! } ! ! l_req->m_remove = torem; ! } ! } --- 156,275 ---- torem->m_addresses = hosts2; l_req->m_add = toadd; l_req->m_remove = torem; l_req->m_change.ref(new epp_HostUpdateChange()); l_req->m_change->m_name.ref(new epp_string("ns2.example.com")); ! ! } else { ! ! ! if( ! addDataMap.empty() ) { ! l_req->m_add.ref(new epp_HostUpdateAddRemove()); ! if( ! addDataMap["status1"].empty() ) { ! char status_name[10]; ! int status_number = 1; ! sprintf(status_name, "status%d", status_number); ! ! l_req->m_add->m_status.ref(new epp_host_status_seq()); ! while( ! addDataMap[status_name].empty() ) { ! string tmp = addDataMap[status_name]; epp_HostStatus status; status.m_type.ref(new epp_HostStatusType(returnStatusEnumType(tmp))); ! l_req->m_add->m_status->push_back(status); ! ! status_number++; ! sprintf(status_name, "status%d", status_number); } } ! if( ! addDataMap["ip1"].empty() ) { ! ! char ip_name[5]; ! int ip_number = 1; ! sprintf(ip_name, "ip%d", ip_number); ! ! l_req->m_add->m_addresses.ref(new epp_host_address_seq()); ! while( ! addDataMap[ip_name].empty() ) { ! string ipstring = addDataMap[ip_name]; ! ! unsigned int sep = ipstring.find("/"); ! if(sep != string::npos) { ! string iptype = ipstring.substr(0,sep); ! string ip = ipstring.substr(sep+1); ! epp_HostAddress host(returnIPTypeEnum(epp_string(iptype)), epp_string(ip)); ! l_req->m_add->m_addresses->push_back(host); ! } ! ip_number++; ! sprintf(ip_name, "ip%d", ip_number); } + } ! } + ! ! if( ! removeDataMap.empty() ) { ! l_req->m_remove.ref(new epp_HostUpdateAddRemove()); ! if( ! removeDataMap["status1"].empty() ) { ! char status_name[10]; ! int status_number = 1; ! sprintf(status_name, "status%d", status_number); ! ! l_req->m_remove->m_status.ref(new epp_host_status_seq()); ! while( ! removeDataMap[status_name].empty() ) { ! string tmp = removeDataMap[status_name]; epp_HostStatus status; status.m_type.ref(new epp_HostStatusType(returnStatusEnumType(tmp))); ! l_req->m_remove->m_status->push_back(status); ! ! status_number++; ! sprintf(status_name, "status%d", status_number); } } ! ! if( ! removeDataMap["ip1"].empty() ) { ! ! char ip_name[5]; ! int ip_number = 1; ! sprintf(ip_name, "ip%d", ip_number); ! ! l_req->m_remove->m_addresses.ref(new epp_host_address_seq()); ! while( ! removeDataMap[ip_name].empty() ) { ! string ipstring = removeDataMap[ip_name]; ! ! unsigned int sep = ipstring.find("/"); ! if(sep != string::npos) { ! string iptype = ipstring.substr(0,sep); ! string ip = ipstring.substr(sep+1); ! epp_HostAddress host(returnIPTypeEnum(epp_string(iptype)), epp_string(ip)); ! l_req->m_remove->m_addresses->push_back(host); ! } ! ip_number++; ! sprintf(ip_name, "ip%d", ip_number); } ! ! } ! } ! ! if( ! changeDataMap.empty() ) { ! ! l_req->m_change.ref(new epp_HostUpdateChange()); ! ! if(changeDataMap.find("name") != changeDataMap.end()) { ! l_req->m_change->m_name.ref(new epp_string(changeDataMap["name"])); ! } ! ! } ! } |