void gtBaseOpts::processOption_Log () { if (m_vm.count (OPT_LOGGING)) { std::string logArgument = m_vm[OPT_LOGGING].as<std::string>(); strTokenize strToken (logArgument, ":", strTokenize::MERGE_CONSECUTIVE_SEPARATORS); std::string level; #ifdef __CYGWIN__ if (std::count(logArgument.begin(), logArgument.end(), ':') > 1) { m_logDestination = strToken.getToken(1) + ":" + strToken.getToken(2); level = strToken.getToken(3); } else { m_logDestination = strToken.getToken(1); level = strToken.getToken(2); } #else m_logDestination = strToken.getToken(1); level = strToken.getToken(2); #endif if ("verbose" == level) { m_logMask = LOGMASK_VERBOSE; } else if ("full" == level) { m_logMask = LOGMASK_FULL; } else if ("standard" == level || level.size() == 0) // default to standard { m_logMask = LOGMASK_STANDARD; } else { m_logMask = strtoul (level.c_str(), NULL, 0); if (0 == m_logMask) { commandLineError ("Unexpected logging level encountered."); } } } m_logToStdErr = gtLogger::create_globallog (m_progName, m_logDestination); }
v8::Local<v8::Value> DotExpressions::AddWorker(const v8::FunctionCallbackInfo<v8::Value>& args) { LOG("@%p", this); if (args.Length() != 2) { ThrowSyntaxError("expected add(name, function)\r\n"); } if (!args[0]->IsString()) { std::stringstream ss; ss << "first parameter has to be string\r\n"; auto s = args[0]->ToString(); String::Utf8Value str(s); ss << (*str); ThrowSyntaxError(ss.str().c_str()); } if (!args[1]->IsFunction()) { std::stringstream ss; ss << "second parameter has to be a function\r\n"; ss << *String::Utf8Value(args[1]->ToString()); ThrowSyntaxError(ss.str().c_str()); } auto token = args[0]->ToString(); String::Utf8Value strToken(token); _Expressions.emplace(std::string(*strToken, strToken.length()), UniquePersistent<Function>(Isolate::GetCurrent(), args[1].As<Function>())); return v8::Local<v8::Value>(); }
bool CHUD::UpdateWeaponAccessoriesScreen() { bool bWeaponHasAttachments = false; m_animWeaponAccessories.Invoke("clearAllSlotButtons"); CWeapon *pCurrentWeapon = GetCurrentWeapon(); if(pCurrentWeapon) { const CItem::THelperVector& helpers = pCurrentWeapon->GetAttachmentHelpers(); for(int iHelper=0; iHelper<helpers.size(); iHelper++) { CItem::SAttachmentHelper helper = helpers[iHelper]; if (helper.slot != CItem::eIGS_FirstPerson) continue; if(pCurrentWeapon->HasAttachmentAtHelper(helper.name)) { // marcok: make sure the vars are correctly mapped SFlashVarValue args[3] = {helper.name.c_str(), "", ""}; m_animWeaponAccessories.Invoke("addSlotButton", args, 3); //should really do not use dynamic strings here string strControl("Root.slot_"); strControl += helper.name.c_str(); string strToken("hud.WS"); strToken += helper.name.c_str(); string strTokenX = strToken + "X"; string strTokenY = strToken + "Y"; m_animWeaponAccessories.AddVariable(strControl.c_str(),"_x",strTokenX.c_str(),1.0f,0.0f); m_animWeaponAccessories.AddVariable(strControl.c_str(),"_y",strTokenY.c_str(),1.0f,0.0f); string curAttach; { const char* szCurAttach = pCurrentWeapon->CurrentAttachment(helper.name); curAttach = (szCurAttach ? szCurAttach : ""); } std::vector<string> attachments; pCurrentWeapon->GetAttachmentsAtHelper(helper.name, attachments); int iSelectedIndex = 0; int iCount = 0; if(attachments.size() > 0) { if(strcmp(helper.name,"magazine") && strcmp(helper.name,"attachment_front") && strcmp(helper.name,"energy_source_helper") && strcmp(helper.name,"shell_grenade")) { if(!strcmp(helper.name,"attachment_top")) { SFlashVarValue args[3] = {helper.name.c_str(), "@IronSight", "NoAttachment"}; m_animWeaponAccessories.Invoke("addSlotButton", args, 3); ++iCount; } else { SFlashVarValue args[3] = {helper.name.c_str(), "@NoAttachment", "NoAttachment"}; m_animWeaponAccessories.Invoke("addSlotButton", args, 3); ++iCount; } } for(int iAttachment=0; iAttachment<attachments.size(); iAttachment++) { // Ignore this item: it's a very special one! if(attachments[iAttachment] != "GrenadeShell") { string sName("@"); sName.append(attachments[iAttachment]); SFlashVarValue args[3] = {helper.name.c_str(), sName.c_str(), attachments[iAttachment].c_str()}; m_animWeaponAccessories.Invoke("addSlotButton", args, 3); if(curAttach == attachments[iAttachment]) { iSelectedIndex = iCount; } bWeaponHasAttachments = bWeaponHasAttachments || iCount>0; ++iCount; } } } if(curAttach) { SFlashVarValue args[2] = {helper.name.c_str(), iSelectedIndex}; m_animWeaponAccessories.Invoke("selectSlotButton", args, 2); } } else ; // no attachment found for this helper } m_animWeaponAccessories.GetFlashPlayer()->Advance(0.25f); } return bWeaponHasAttachments; }
extern "C" BOOL PASCAL EXPORT StartSimulation(char* strInputFilePath,char* strBestPopRun) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // normal function body here int nReturn = TRUE; CString str1, str2, strFilePath; str1 = strInputFilePath; str1.TrimLeft(); str1.TrimRight(); str2 = strBestPopRun; str2.TrimLeft(); str2.TrimRight(); // initialize progress bar CProgressWnd wndProgress(NULL, "SUSTAIN_MODEL", TRUE); if(str1.GetLength() < 2) return true; ////////////////////////////////////////////////////////////////////// //SWMM5 initialize conduit parameters initPointers(); setDefaults(); // --- create hash tables for fast retrieval of objects by ID names createHashTables(); ////////////////////////////////////////////////////////////////////// strFilePath = str1; CBMPData bmpData; CBMPRunner bmpRunner(&bmpData); if (!bmpData.ReadInputFile(strFilePath)) { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } //optional weather data if (bmpData.nWeatherFile == 1) { if (!bmpData.ReadWeatherFile(bmpData.strInputDir + "weather.inp")) return FALSE; if (!bmpData.MarkWetIntervals(bmpData.startDate,bmpData.endDate)) return FALSE; } if (!bmpData.PrepareDataForModel()) { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } // disabled for the first release (under testing) // run PreDeveloped scenario for bufferstrip simulation if necessary // if (!bmpData.RunVFSMOD(RUN_PREDEV)) // { // AfxMessageBox(bmpData.strError); // nReturn = FALSE; // goto L001; // } // run PostDeveloped scenario for bufferstrip simulation if necessary // if (!bmpData.RunVFSMOD(RUN_POSTDEV)) // { // AfxMessageBox(bmpData.strError); // nReturn = FALSE; // goto L001; // } if (!bmpData.OpenOutputFiles("Init"))// open file for time series { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } if (!bmpRunner.OpenOutputFiles("Init", bmpData.nRunOption, RUN_INIT))// open file for evaluation factor { nReturn = FALSE; goto L001; } bmpRunner.pWndProgress = &wndProgress; bmpRunner.RunModel(RUN_INIT); if (!bmpData.CloseOutputFiles()) // close file for time series { nReturn = FALSE; goto L001; } if (!bmpRunner.CloseOutputFiles()) // close file for evaluation factor { nReturn = FALSE; goto L001; } if (bmpRunner.pWndProgress->Cancelled()) { bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation is cancelled"); goto L001; } if (!bmpData.OpenOutputFiles("PreDev")) // open file for time series { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } if (!bmpRunner.OpenOutputFiles("PreDev", bmpData.nRunOption, RUN_PREDEV)) // open file for evaluation factor { nReturn = FALSE; goto L001; } bmpRunner.RunModel(RUN_PREDEV); if (!bmpData.CloseOutputFiles()) // close file for time series { nReturn = FALSE; goto L001; } if (!bmpRunner.CloseOutputFiles()) // close file for evaluation factor { nReturn = FALSE; goto L001; } if (bmpRunner.pWndProgress->Cancelled()) { bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation is cancelled"); goto L001; } if (!bmpData.OpenOutputFiles("PostDev"))// open file for time series { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } if (!bmpRunner.OpenOutputFiles("PostDev", bmpData.nRunOption, RUN_POSTDEV))// open file for evaluation factor { nReturn = FALSE; goto L001; } bmpRunner.RunModel(RUN_POSTDEV); if (!bmpData.CloseOutputFiles()) // close file for time series { nReturn = FALSE; goto L001; } if (!bmpRunner.CloseOutputFiles()) // close file for evaluation factor { nReturn = FALSE; goto L001; } if (bmpRunner.pWndProgress->Cancelled()) { bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation is cancelled"); goto L001; } srand((unsigned)time(NULL)); // initialize seed for random number generator if (bmpData.nRunOption != OPTION_NO_OPTIMIZATION) { if (bmpData.nStrategy == STRATEGY_SCATTER_SEARCH) { // run option MinimizeCost or MaximizeControl CBMPOptimizer bmpOptimizer(&bmpRunner); if (bmpData.nAdjVariable < 5) { bmpOptimizer.problem.b1 = 5; bmpOptimizer.problem.b2 = 5; } else { bmpOptimizer.problem.b1 = bmpData.nAdjVariable; bmpOptimizer.problem.b2 = bmpData.nAdjVariable; } bmpOptimizer.problem.PSize = 3*(bmpOptimizer.problem.b1+bmpOptimizer.problem.b2); bmpOptimizer.problem.LS = FALSE; if (bmpRunner.lInitRunTime != 0) bmpOptimizer.nMaxRun = int((bmpData.lfMaxRunTime*3600000)/bmpRunner.lInitRunTime)+1; else bmpOptimizer.nMaxRun = 1000; if (bmpOptimizer.nMaxRun < 2*bmpOptimizer.problem.PSize) bmpOptimizer.nMaxRun = 2*bmpOptimizer.problem.PSize; bmpOptimizer.nMaxIter = int(bmpOptimizer.nMaxRun / (2*bmpOptimizer.problem.PSize)) + 1; bmpRunner.nMaxRun = bmpOptimizer.nMaxRun; // run optimization for Minimum Cost or MaximumControl options if (bmpData.nRunOption == OPTION_MIMIMIZE_COST || bmpData.nRunOption == OPTION_MAXIMIZE_CONTROL) { CString strOutPath = bmpData.strOutputDir + "\\AllSolutions.out"; bmpOptimizer.m_pAllSolutions = fopen(LPCSTR(strOutPath), "wt"); if (bmpOptimizer.m_pAllSolutions == NULL) { nReturn = FALSE; goto L001; } bmpOptimizer.OutputFileHeader("SS - All solutions", bmpOptimizer.m_pAllSolutions); bmpOptimizer.nRunCounter = 0; bmpOptimizer.InitProblem(bmpData.nAdjVariable, bmpOptimizer.problem.b1, bmpOptimizer.problem.b2, bmpOptimizer.problem.PSize, bmpOptimizer.problem.LS); bmpOptimizer.InitRefSet(); bmpOptimizer.PerformSearch(); fclose(bmpOptimizer.m_pAllSolutions); bmpOptimizer.OutputBestSolutions(); if (bmpRunner.pWndProgress->Cancelled()) { bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation is cancelled"); goto L001; } else { bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation completed successfully", MB_ICONINFORMATION); goto L001; } } // run optimization for TradeOff Curve options else if (bmpData.nRunOption == OPTION_TRADE_OFF_CURVE) { CString strOutPath = bmpData.strOutputDir + "\\AllSolutions.out"; bmpOptimizer.m_pAllSolutions = fopen(LPCSTR(strOutPath), "wt"); if (bmpOptimizer.m_pAllSolutions == NULL) { nReturn = FALSE; goto L001; } bmpOptimizer.OutputFileHeader("SS - All solutions", bmpOptimizer.m_pAllSolutions); // prepare output file for TradeOff Curve optimization strFilePath = bmpRunner.pBMPData->strOutputDir + "\\CECurve_Solutions.out"; FILE* fp = fopen(LPCSTR(strFilePath), "wt"); if(fp == NULL) { AfxMessageBox("Failed in creating output file "+strFilePath, MB_ICONEXCLAMATION); nReturn = FALSE; goto L001; } bmpOptimizer.OutputFileHeaderForTradeOffCurve(fp); // initialize problem only once bmpOptimizer.InitProblem(bmpData.nAdjVariable, bmpOptimizer.problem.b1, bmpOptimizer.problem.b2, bmpOptimizer.problem.PSize, bmpOptimizer.problem.LS); //update the max. runs bmpRunner.nMaxRun *= (bmpData.nTargetBreak + 1); // run optimization for the target range for (int i=0; i<=bmpData.nTargetBreak; i++) { POSITION pos, pos1; pos = bmpData.routeList.GetHeadPosition(); while (pos != NULL) { CBMPSite* pBMPSite = (CBMPSite*) bmpData.routeList.GetNext(pos); pos1 = pBMPSite->m_factorList.GetHeadPosition(); while (pos1 != NULL) { EVALUATION_FACTOR* pEF = (EVALUATION_FACTOR*) pBMPSite->m_factorList.GetNext(pos1); pEF->m_lfTarget = pEF->m_lfUpperTarget - i*(pEF->m_lfUpperTarget-pEF->m_lfLowerTarget)/bmpData.nTargetBreak; pEF->m_lfNextTarget = pEF->m_lfTarget - (pEF->m_lfUpperTarget-pEF->m_lfLowerTarget)/bmpData.nTargetBreak; } } bmpOptimizer.nRunCounter = 0; if (i == 0) bmpOptimizer.InitRefSet(); else bmpOptimizer.ResetRefSet(); bmpOptimizer.PerformSearch(); bmpOptimizer.OutputBestSolutionsForTradeOffCurve(i, fp); if (bmpRunner.pWndProgress->Cancelled()) { bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation is cancelled"); fclose(bmpOptimizer.m_pAllSolutions); fclose(fp); goto L001; } } fclose(bmpOptimizer.m_pAllSolutions); fclose(fp); } } else if (bmpData.nStrategy == STRATEGY_GENETIC_ALGORITHM) { //run the best population scenarios (call from the post-processor spreadsheet) if(str2.GetLength() > 0) { CString strLine, strValue; POSITION pos, pos1; CBMPSite* pBMPSite; EVALUATION_FACTOR* pEF; ADJUSTABLE_PARAM* pAP; CStringToken strToken(str2); int nBestPops = 0; while (strToken.HasMoreTokens()) { str1 = strToken.NextToken(); nBestPops++; } bmpData.nSolution = nBestPops; // prepare output file for TradeOff Curve optimization strFilePath = bmpData.strOutputDir + "\\CECurve_Solutions.out"; FILE* fp = fopen(LPCSTR(strFilePath), "wt"); if(fp == NULL) { AfxMessageBox("Failed in creating output file "+strFilePath, MB_ICONEXCLAMATION); nReturn = FALSE; goto L001; } bmpData.OutputFileHeaderForTradeOffCurve(fp); CStringToken strToken1(str2); for (int i=0; i<nBestPops; i++) { //read best population file int nBestPopId = atoi((LPCSTR)strToken1.NextToken()); if (!bmpData.ReadBestPopFile(nBestPopId)) { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } //output time series for the best pop solution strValue.Format("BestPop%d", nBestPopId); if (!bmpData.OpenOutputFiles(strValue)) { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } //run model bmpRunner.RunModel(RUN_OUTPUT); //close time series for the best pop solution if (!bmpData.CloseOutputFiles()) { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } //output CECurve_Solutions double totalCost = 0.0; double output1 = 0.0; pos = bmpData.routeList.GetHeadPosition(); while (pos != NULL) { pBMPSite = (CBMPSite*) bmpData.routeList.GetNext(pos); totalCost += pBMPSite->m_lfCost; } strLine.Format("%d\t%d", i+1, 1); strValue.Format("\t%lf", totalCost); strLine += strValue; //evaluation factors pos = bmpData.routeList.GetHeadPosition(); while (pos != NULL) { pBMPSite = (CBMPSite*) bmpData.routeList.GetNext(pos); pos1 = pBMPSite->m_factorList.GetHeadPosition(); while (pos1 != NULL) { pEF = (EVALUATION_FACTOR*) pBMPSite->m_factorList.GetNext(pos1); if (pEF->m_nCalcMode == CALC_PERCENT) // if the calculation mode is percentage { if (pEF->m_lfPostDev == 0.0) output1 = pEF->m_lfCurrent; else output1 = pEF->m_lfCurrent/pEF->m_lfPostDev*100; } else if (pEF->m_nCalcMode == CALC_VALUE) // if the calculation mode is value { output1 = pEF->m_lfCurrent; } else // if the calculation mode is scale { if (pEF->m_lfPostDev - pEF->m_lfPreDev > 0) output1 = (pEF->m_lfCurrent - pEF->m_lfPreDev) / (pEF->m_lfPostDev-pEF->m_lfPreDev); else output1 = pEF->m_lfCurrent; } strValue.Format("\t%lf", output1); strLine += strValue; } } //adjust parameters pos = bmpData.routeList.GetHeadPosition(); while (pos != NULL) { pBMPSite = (CBMPSite*) bmpData.routeList.GetNext(pos); pos1 = pBMPSite->m_adjustList.GetHeadPosition(); while (pos1 != NULL) { pAP = (ADJUSTABLE_PARAM*) pBMPSite->m_adjustList.GetNext(pos1); double* pVariable = pBMPSite->GetVariablePointer(pAP->m_strVariable); strValue.Format("\t%lf", *pVariable); strLine += strValue; } } strLine += "\n"; fputs(strLine, fp); if (bmpRunner.pWndProgress->Cancelled()) { bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation is cancelled"); fclose(fp); nReturn = FALSE; goto L001; } } bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation is completed", MB_ICONINFORMATION); fclose(fp); nReturn = TRUE; goto L001; } else { CBMPOptimizerGA bmpOptimizerGA(&bmpRunner); if (!bmpOptimizerGA.OpenOutputFiles()) { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } if (!bmpOptimizerGA.LoadData()) { nReturn = FALSE; goto L001; } if (!bmpOptimizerGA.ValidateParams()) { AfxMessageBox(bmpData.strError); nReturn = FALSE; goto L001; } bmpOptimizerGA.nMaxRun = bmpOptimizerGA.problem.popsize * bmpOptimizerGA.problem.ngen; bmpRunner.nMaxRun = bmpOptimizerGA.nMaxRun; if (!bmpOptimizerGA.InitProblem()) { nReturn = FALSE; goto L001; } bmpOptimizerGA.PerformSearch(); bmpOptimizerGA.OutputBestPopulation(); bmpOptimizerGA.CloseOutputFiles(); if (bmpRunner.pWndProgress->Cancelled()) { bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation is cancelled"); nReturn = FALSE; goto L001; } } } } bmpRunner.pWndProgress->DestroyWindow(); AfxMessageBox("BMP simulation is completed", MB_ICONINFORMATION); L001: //SWMM5 release memory deleteHashTables(); transect_delete(); for (int j=0; j<bmpData.nBMPC; j++) { FREE(Link[j].oldQual); FREE(Link[j].newQual); } FREE(Link); FREE(Conduit); FREE(GAInfil); return nReturn; }
int Response::ParseHttpHEAD( SSL* inSSL ) { string buf; bool isGET = false; bool isProtocolVersion_1_1 = false; bool isWebSocket = false; bool isWebSocketVersion_13 = false; string FileName; string FileType; string WebSocketKey; try { // We are getting string with HTTTP HEAD MyCover mySendRecv; mySendRecv.my_recv(inSSL, buf); cout << buf; WSLexer mLexer; const char* buff_s = buf.c_str(); mLexer.Put_HttpRequest( buff_s, buff_s + buf.size() ); bool ContinueToCycle = false; WSLexer::Token currToken; WSLexer::Token prevToken; ContinueToCycle = mLexer.GetNextToken(&currToken, true); while(ContinueToCycle) { string strToken(currToken.ps, currToken.mLen); // Find type of request if( currToken.mPosition == 0 && currToken.mLine == 1 && strToken == "GET" ) isGET = true; // Find FileName if( currToken.mLine == 1 && prevToken.mType == wsDefaultType && strToken == "." ) { ContinueToCycle = mLexer.GetNextToken(&currToken, true); strToken = string(currToken.ps, currToken.mLen); if( currToken.mType == wsDefaultType && currToken.mLine == 1 ) { FileType = string(currToken.ps, currToken.mLen); FileName = string(prevToken.ps, prevToken.mLen); } else { continue; // we have to go to the next iteration of the loop without using function GetNextToken } } // Check version of HTTP if( currToken.mLine == 1 && strToken == "HTTP") { ContinueToCycle = mLexer.GetNextToken(&currToken, true); if(currToken.mLine == 1 && currToken.mType == wsSymbolType && *(currToken.ps) == '/' ) { ContinueToCycle = mLexer.GetNextToken(&currToken, true); strToken = string(currToken.ps, currToken.mLen); if( strToken != "2") { ContinueToCycle = mLexer.GetNextToken(&currToken, true); strToken += string(currToken.ps, currToken.mLen); ContinueToCycle = mLexer.GetNextToken(&currToken, true); strToken += string(currToken.ps, currToken.mLen); if( strToken == "1.1") { isProtocolVersion_1_1 = true; } } } else { continue; // we have to go to the next iteration of the loop without using function GetNextToken } } // This is WebSocket? If not we stop parcing if( strToken == "Upgrade" ) { ContinueToCycle = mLexer.GetNextToken(&currToken, true); if( string(currToken.ps, currToken.mLen) == ":" ) { ContinueToCycle = mLexer.GetNextToken(&currToken, true); strToken = string(currToken.ps, currToken.mLen); if( strToken == "websocket" || strToken == "WebSocket" ) isWebSocket = true; else break; } else { continue; // we have to go to the next iteration of the loop without using function GetNextToken } } // Find WebSocket Key if( strToken == "Sec-WebSocket-Key" ) { ContinueToCycle = mLexer.GetNextToken(&currToken, true); if( string(currToken.ps, currToken.mLen) == ":" ) { string PartOfKey; do { WebSocketKey += PartOfKey; ContinueToCycle = mLexer.GetNextToken(&currToken, true); PartOfKey = string(currToken.ps, currToken.mLen); } while(PartOfKey != "\n" && PartOfKey != "\r"); } else { continue; // we have to go to the next iteration of the loop without using function GetNextToken } } // Check version of WebSocket? we work only with version 13 if( strToken == "Sec-WebSocket-Version" ) { ContinueToCycle = mLexer.GetNextToken(&currToken, true); if( string(currToken.ps, currToken.mLen) == ":" ) { ContinueToCycle = mLexer.GetNextToken(&currToken, true); if(string(currToken.ps, currToken.mLen) == "13") isWebSocketVersion_13 = true; } else { continue; // we have to go to the next iteration of the loop without using function GetNextToken } } prevToken = currToken; ContinueToCycle = mLexer.GetNextToken(&currToken, true); } GenerateResponse( inSSL, isGET, isProtocolVersion_1_1, isWebSocket, isWebSocketVersion_13, FileName, FileType, WebSocketKey); } catch(exception& e) { LogFile log; log.write(e.what()); } return 0; }
void gtBaseOpts::processOption_InternalPort () { std::string portList; if (m_vm.count (OPT_INTERNAL_PORT) == 1) { portList = m_vm[OPT_INTERNAL_PORT].as<std::string>(); } else // Option not present { return; } strTokenize strToken (portList, ":", strTokenize::MERGE_CONSECUTIVE_SEPARATORS); int lowPort = strtol (strToken.getToken (1).c_str (), NULL, 10); if (lowPort < 1024 || lowPort > 65535) { commandLineError ("-i (--internal-port) " + strToken.getToken (1) + " out of range (1024-65535)"); } int highPort; bool highPortSet = false; if (strToken.size () > 1) { highPort = strtol (strToken.getToken (2).c_str (), NULL, 10); highPortSet = true; } if (highPortSet) { if (highPort < 1024 || highPort > 65535) { commandLineError ("-i (--internal-port) " + strToken.getToken (2) + " out of range (1024-65535)"); } if (lowPort <= highPort) { m_portStart = lowPort; m_portEnd = highPort; } else { commandLineError ("when using -i (--internal-port) " + strToken.getToken (1) + " must be smaller than " + strToken.getToken (2)); } } else { m_portStart = lowPort; if (m_portStart + 8 > 65535) { commandLineError ("-i (--internal-port) implicit (add 8 ports)" " end value exceeds 65535"); } m_portEnd = m_portStart + 8; // default 8 ports } }