Exemplo n.º 1
0
  bool start(const char* working_dir, NdbProcess::Args& args)
  {
    g_info << "Starting " << name() << " ";
    for (unsigned i = 0; i < args.args().size(); i++)
      g_info << args.args()[i].c_str() << " ";
    g_info << endl;

    if (exe_valgrind == 0)
    {
      m_proc = NdbProcess::create(name(),
                                  exe(),
                                  working_dir,
                                  args);
    }
    else
    {
      NdbProcess::Args copy;
      if (arg_valgrind)
      {
        copy.add(arg_valgrind);
      }
      copy.add(exe());
      copy.add(args);
      m_proc = NdbProcess::create(name(),
                                  BaseString(exe_valgrind),
                                  working_dir,
                                  copy);
    }
    return (m_proc != NULL);
  }
Exemplo n.º 2
0
UserDB::UserDB(std::string database): errMsg(0), rc(0), dbOpen(false) 
{
	rc = sqlite3_open(database.c_str(), &db);
	if( rc ) {
		LOG4CXX_ERROR(logger, "Failed to open database" << database);
		sqlite3_close(db);
		exit(0);
	}
	
	LOG4CXX_INFO(logger, "Checking if table users is present")	
	if(exe(std::string("select * from users limit 1;")) != SQLITE_OK) {
		exe("create table users (user text primarykey, key text, secret text);");
		LOG4CXX_INFO(logger, "Created table users in the database");
	}
	dbOpen = true;
}
Exemplo n.º 3
0
/*-----------------------------------------------------------------------------
  Install/update the flash player if the executable is local
  (delivered as part of an update)
-----------------------------------------------------------------------------*/
void CurlBlastDlg::InstallFlash()
{
    // try launching the current version of the installer from the same directory we are in
    TCHAR path[MAX_PATH];
    if( GetModuleFileName(NULL, path, _countof(path)) )
    {
        lstrcpy(PathFindFileName(path), _T("flash.exe"));
        CString exe(path);
        CString cmd = CString(_T("\"")) + exe + _T("\" -install");

        PROCESS_INFORMATION pi;
        STARTUPINFO si;
        memset( &si, 0, sizeof(si) );
        si.cb = sizeof(si);
        si.dwFlags = STARTF_USESHOWWINDOW;
        si.wShowWindow = SW_HIDE;
        if( CreateProcess((LPCTSTR)exe, (LPTSTR)(LPCTSTR)cmd, 0, 0, FALSE, IDLE_PRIORITY_CLASS , 0, NULL, &si, &pi) )
        {
            WaitForSingleObject(pi.hProcess, 60 * 60 * 1000);
            CloseHandle(pi.hThread);
            CloseHandle(pi.hProcess);
            DeleteFile(path);
            log.Trace(_T("Updated/installed flash"), (LPCTSTR)cmd);
        }
    }
}
Exemplo n.º 4
0
///////////////////////////////////////////////////////////////////////////////
// function allowing to deploy the current executable to the remote machine, 
// where it is supposed to be launched. return the directory name the job got 
// deployed
std::string deploy_me(std::string path, std::string target_host)
{
    // construct unique target directory
    std::string targetdir("/tmp/saga_tutorial/");
    targetdir += boost::lexical_cast<std::string>(getuid());
    targetdir += "/";
    targetdir += boost::lexical_cast<std::string>(getpid());
    targetdir += "/";

    // copy the executable to the remote directory
    fs::path exe(path);

    // Create remote directory
    saga::url target_dir(targetdir);
    target_dir.set_scheme("any");         // we rely on adaptor selection
    target_dir.set_host(get_host(target_host));
    saga::filesystem::directory d(target_dir, saga::filesystem::Create|saga::filesystem::CreateParents);

    // copy the executable
    saga::url source(exe.filename());
    saga::filesystem::file f(source);

    saga::url target(targetdir + "/" + exe.filename());
    target.set_scheme("any");            // we rely on adaptor selection
    target.set_host(get_host(target_host));
    f.copy(target);

    return targetdir;
}
Exemplo n.º 5
0
int main(int argc, char* argv[])
{
    
    args::Executable exe("Cuts the specified type of data from Fourier space of the input map/mrc ", ' ', "1.0" );
    
    TCLAP::ValueArg<int> XY_PLANE("", "xyplane", "Cut the specified XY plane from Fourier space", false, 0, "INT");
    TCLAP::ValueArg<double> CONE("", "cone", "Cut the cone with specified angle (in degrees) from Fourier space", false, 30.0, "FLOAT");
    
    
    TCLAP::ValueArg<std::string> CUT_OUT("", "cutout", "Base name for writing output files (mrc/hkl) for what's been cut", false, "", "STRING");
    TCLAP::ValueArg<std::string> VOLUME_OUT("", "volout", "Base name for writing output files (mrc/hkl) for volume with cut", false, "","STRING");
    
    //Select required arguments
    args::templates::MRCIN.forceRequired();
    
    //Parse the arguments
    exe.add(CUT_OUT);
    exe.add(VOLUME_OUT);
    exe.add(args::templates::MRCIN);
    
    std::vector<args::Arg*> optionArgs = {&XY_PLANE, &CONE};
    exe.xorAdd(optionArgs);
    
    exe.parse(argc, argv); 
    
    //Check for arguments
    if(!(XY_PLANE.isSet()) && !(CONE.isSet()))
    {
        std::cerr << "\n\nERROR: Please specify what needs to be cut from Fourier space with --xyplane or --cone\n";
        std::cerr << "\nFor full details type:\n\t" << exe.getProgramName() << " --help \n\n\n";
        exit(1);
    }
    
    //Prepare the input
    Volume2DX input;
    input.read_volume(args::templates::MRCIN.getValue());
    
    Volume2DX cutout;
    Volume2DX after_cut;
    
    if(XY_PLANE.isSet()) input.cut_xy_plane(cutout, after_cut, XY_PLANE.getValue());
    if(CONE.isSet()) input.cut_cone(cutout, after_cut, CONE.getValue());
    
    //Write output
    if(CUT_OUT.isSet())
    {
        std::string out_name = CUT_OUT.getValue();
        cutout.write_volume(out_name + ".hkl", "hkl");
        cutout.write_volume(out_name + ".mrc", "mrc");
    }
    
    if(VOLUME_OUT.isSet())
    {
        std::string out_name = VOLUME_OUT.getValue();
        after_cut.write_volume(out_name + ".hkl", "hkl");
        after_cut.write_volume(out_name + ".mrc", "mrc");
    }
    
    return 0;
}
Exemplo n.º 6
0
bool DBUpdaterUtil::CheckExecutable()
{
    boost::filesystem::path exe(GetCorrectedMySQLExecutable());
    if (!exists(exe))
    {
        exe.clear();

        if (auto path = Trinity::SearchExecutableInPath("mysql"))
        {
            exe = std::move(*path);

            if (!exe.empty() && exists(exe))
            {
                // Correct the path to the cli
                corrected_path() = absolute(exe).generic_string();
                return true;
            }
        }

        TC_LOG_FATAL("sql.updates", "Didn't find any executable MySQL binary at \'%s\' or in path, correct the path in the *.conf (\"MySQLExecutable\").",
            absolute(exe).generic_string().c_str());

        return false;
    }
    return true;
}
Exemplo n.º 7
0
int main(int argc, char** arg){
  if(argc!=2){
    cerr << "USAGE: "<<arg[0] << " <wash file>" <<endl;
    return 1;
  }
  
  ifstream in(arg[1]);
  if( !in.is_open () ){
    cerr<<"could not open file: "<<arg[1]<<endl;
    return 1;
  }
  
  Parser parser(in);
  
  if( parser.parse() ){

    TreeNode* root=parser.getTree();
    //root->showTree(root); //show parsetree
    
    Executer exe(root); //execute this tree
    exe.run();

  }
  else{
    cerr<<"Parsing failed!"<<endl;
    cerr<<parser.getErrors()<<endl;
  }
  
  return 0;
}
Exemplo n.º 8
0
int wmain(int argc, WCHAR* argv[])
{
	if (argc < 3) {
		std::wcout << argv[0] << " dll command_line\n";
		return 1;
	}
	std::wstring dllToInject (argv[1]);
  std::wstring exe (argv[2]);
  exe = exe.substr (0, exe.find (' '));
  std::wstring command_line (argv[2]);
  command_line = command_line.substr (command_line.find (' ') + 1);
        
  ULONG pid;
	NTSTATUS nt = RhCreateAndInject
    ( const_cast<WCHAR*> (exe.c_str())
    , const_cast<WCHAR*> (command_line.c_str())
    , 0
		, EASYHOOK_INJECT_DEFAULT
		, const_cast<WCHAR*> (dllToInject.c_str())
		, nullptr
		, nullptr
		, 0
    , &pid
	  );

	if (nt != 0)
	{
		std::wcout << "RhCreateAndInject failed with error code = " << nt << "\n  " << RtlGetLastErrorString() << "\n";
		return 1;
	}
  	
	return 0;
}
Exemplo n.º 9
0
int	exec_d_red_left(t_manage *man, char *cmd, int pipefd[2],
			int *p, int flag)
{
  int	pid;

  if ((pid = fork()) == -1)
    return (-1);
  else if (pid == 0)
    {
      if (flag == 0)
	{
	  if (dup2(p[1], 1) == -1)
	    return (-1);
	  if (close(p[0]) == -1)
	    return (-1);
	}
      if ((close(pipefd[1])) == -1)
	return (-1);
      if (dup2(pipefd[0], 0) == -1)
	return (-1);
      if (exe(man, cmd) == MASTER_ERROR)
	return (MASTER_ERROR);
    }
  return (pid);
}
Exemplo n.º 10
0
void UserDB::insert(UserData info)
{
	std::string q = "insert into users (user,key,secret) values ('" + info.user + "','" + info.accessTokenKey + "','" + info.accessTokenSecret + "');";
	if(exe(q) !=  SQLITE_OK) {
		LOG4CXX_ERROR(logger, "Failed to insert into database!");
		exit(0);	
	}
}
Exemplo n.º 11
0
static void print_task_info(struct task *t)
{
	if (want_ms)
		printf("# task NAME=%s PID=%d COST=%.2f PERIOD=%.2f CPU=%d\n",
		       tsk_name(t),
		       t->pid,
		       nano_to_ms(exe(t)),
		       nano_to_ms(per(t)),
		       tsk_cpu(t));
	else
		printf("# task NAME=%s PID=%d COST=%lu PERIOD=%lu CPU=%d\n",
		       tsk_name(t),
		       t->pid,
		       (unsigned long) exe(t),
		       (unsigned long) per(t),
		       tsk_cpu(t));
}
Exemplo n.º 12
0
void UserDB::fetch(std::string user, std::vector<std::string> &row)
{
	std::string q =  "select key,secret from users where user='******'";
	if(exe(q) !=  SQLITE_OK) {
		LOG4CXX_ERROR(logger, "Failed to fetch data from database!");
		exit(0);
	}
	row = data[0];
}
Exemplo n.º 13
0
void exec_thread(unsigned char *path, int p)
{
#if defined(HAVE_SETPGID) && !defined(BEOS) && !defined(HAVE_BEGINTHREAD)
    if (path[0] == 2) setpgid(0, 0);
#endif
    exe(path + 1);
    /*close(p);*/
    if (path[1 + strlen(path + 1) + 1]) unlink(path + 1 + strlen(path + 1) + 1);
}
Exemplo n.º 14
0
void DisplayFileInformation( PMODULE_FILE_INFO pModInfo, BOOL bQuiet )
{
    LPCTSTR base = getModuleBase(pModInfo,bQuiet);
    if ( !base ) return ;
    printf( "%-14s", base) ; // ->GetBaseName() );

    PSTR pszFullName = pModInfo->GetFullName();

    if ( g_fShowDateTime )
    {
        HFILE hFile = _lopen( pszFullName, OF_READ );
        if ( HFILE_ERROR != hFile )
        {
            FILETIME ft;

            if ( GetFileTime( (HANDLE)hFile, 0, 0, &ft ) )
            {
                char szFileDate[32] = { 0 };
                char szFileTime[32] = { 0 };

                GetFileDateAsString(&ft, szFileDate, sizeof(szFileDate) );
                GetFileTimeAsString(&ft, szFileTime, sizeof(szFileTime),
                                    TRUE);

                printf( "%s %s  ", szFileDate, szFileTime );
            }

            _lclose( hFile );
        }
    }

    if ( g_fShowLinkDateTime )
    {
        FILETIME ft;
        char szFileDate[32] = { 0 };
        char szFileTime[32] = { 0 };

        PE_EXE exe( pszFullName );

        TimeDateStampToFileTime( exe.GetTimeDateStamp(), &ft );

        GetFileDateAsString(&ft, szFileDate, sizeof(szFileDate) );
        GetFileTimeAsString(&ft, szFileTime, sizeof(szFileTime),
                            TRUE);

        printf( "%s %s  ", szFileDate, szFileTime );
    }

    if ( g_fShowFullPath )
        printf( "(%s)", pszFullName );

    printf( "\n" );

    if ( g_fShowVersion )
        ShowVersionInfo( pszFullName );
}
Exemplo n.º 15
0
void omii_gridsam_job_service::sync_run_job(saga::job::job& ret, 
                                            std::string commandline,
                                            std::string host, 
                                            saga::job::ostream& in, 
                                            saga::job::istream& out, 
                                            saga::job::istream& err)
{
    std::vector<std::string> cmdline = saga::adaptors::utils::split_commandline (commandline);
    std::string executable = cmdline[0];
    
    saga::job::description jd;

    std::vector <std::string> chosts;
    chosts.push_back (host);
    jd.set_vector_attribute(saga::job::attributes::description_candidate_hosts, chosts);

    jd.set_attribute(saga::job::attributes::description_executable, executable);
    if (cmdline.size() > 1)
    {
        cmdline.erase(cmdline.begin());   // get rid of argv[0]
        jd.set_vector_attribute(saga::job::attributes::description_arguments, 
                                cmdline);
    }
// the following is not (yet) supported by Gridsam
//     jd.set_attribute(saga::job::attributes::description_interactive, 
//         saga::attributes::common_true);

    // set working directory
    namespace fs = boost::filesystem;
    fs::path exe(executable);     // not fs::native!
    std::string branch(exe.branch_path().string());
    if (branch.empty())
        branch = ".";
    jd.set_attribute(saga::job::attributes::description_working_directory,
                     branch);
    
    // create a new job instance
    saga::job::job job = saga::adaptors::job(endpoint_, jd, proxy_->get_session());

    // set the created attribute 
    saga::adaptors::attribute attr (job);
    std::time_t current = 0;
    std::time(&current);
    attr.set_attribute(saga::job::attributes::created, ctime(&current));
    
    job.run();    // start this job

    in = job.get_stdin();
    out = job.get_stdout();
    err = job.get_stderr();

    ret = job;
}
Exemplo n.º 16
0
void CefIPCPipeClient::startService()
{
#ifdef DEBUG
	const char* exeName = "desura_browserhost-d.exe";
#else
	const char* exeName = "desura_browserhost.exe";
#endif


	UserAgentFN userAgent = (UserAgentFN)WebCore::FactoryBuilder(WEBCORE_USERAGENT);
		
	gcString ua = userAgent();

	gcString exe(exeName);
	gcString params("{3} {0} {1} {2}", m_szPipeId, m_szHostName, UTIL::STRING::base64_encode(ua.c_str(), ua.size()), exeName);
	


	DWORD dwExitCode = 0; 

	
	STARTUPINFOA siStartupInfo; 
	PROCESS_INFORMATION piProcessInfo; 

	memset(&siStartupInfo, 0, sizeof(siStartupInfo)); 
	memset(&piProcessInfo, 0, sizeof(piProcessInfo)); 
	siStartupInfo.cb = sizeof(siStartupInfo); 

	gcString workingDir(UTIL::OS::getCurrentDir());

	UINT oldErrMode = SetErrorMode(0);

	BOOL res = CreateProcessA(const_cast<char*>(exe.c_str()), const_cast<char*>(params.c_str()), 0, 0, false,  CREATE_DEFAULT_ERROR_MODE, 0, workingDir.c_str(),  &siStartupInfo, &piProcessInfo);
	DWORD lastError = GetLastError();

	SetErrorMode(oldErrMode);
	CloseHandle( piProcessInfo.hThread );

	if (res == false)
	{
		CloseHandle( piProcessInfo.hProcess );
		throw gcException(ERR_LAUNCH, lastError, "Failed to start render helper");
	}
	else
	{
#ifdef DEBUG
		WaitForInputIdle(piProcessInfo.hProcess, INFINITE); 
#else
		WaitForInputIdle(piProcessInfo.hProcess, 5000); 
#endif
		CloseHandle( piProcessInfo.hProcess );
	}
}
Exemplo n.º 17
0
bool SerzFile::RunSerz(const QString op, QString inPath, QString outPath)
{
	bool ok = false;
	int retCode;
	int tries = 0;
	QString in(QDir::toNativeSeparators(inPath));
	QString out(QDir::toNativeSeparators(outPath));
	
	QStringList args = QStringList() << in << op + out;
	QString exe(serzExePath());
	QString wd = QFileInfo(exe).absolutePath();

retry:
	{
		QProcess p;
		QByteArray output;
		tries++;
		p.setProcessChannelMode(QProcess::MergedChannels);
		p.setWorkingDirectory(wd);
		p.start(exe, args, QIODevice::ReadWrite);

		// TODO: make async
		QApplication::processEvents();
		p.waitForFinished(10000);
		output = p.readAllStandardOutput();
		if (output.contains("Conversion complete"))
		{
			setResult(SerzFile::Ok);
			ok = true;
		}
		else if (output.contains("Could not open input file"))
		{
			setResult(SerzFile::DecodeBadInputFile);
			ok = false;
		}
		else if (output.contains("Could not open output file"))
		{
			setResult(SerzFile::DecodeBadOutputFile);
			ok = false;
		}
		else
		{
			if (tries < 2)
				goto retry;
			setResult(SerzFile::UnknownError);
			QString e = p.errorString();
			ok = false;
		}
		retCode = p.exitCode(); // sadly it's always 0...
	}

	return ok;
}
Exemplo n.º 18
0
std::set<std::string> UserDB::getRegisteredUsers()
{
	std::string q = "select user from users";
	if(exe(q) != SQLITE_OK) {
		LOG4CXX_ERROR(logger, "Failed to registered users from database!");
		exit(0);
	}
	
	std::set<std::string> users;
	for(int i=0 ; i<data.size() ; i++)
		users.insert(data[i][0]);
	return users;
}
Exemplo n.º 19
0
/*
主函数基于课本151页的测试循环小程序进行编写
*/
int main()
{
    init();//初始化
    int i;
    FILE* program;
    program=fopen("input.txt","r+");//设置输入文件
  //设置R1和R2
    myRegister[1]=0x00008000;
    myRegister[2]=0x00007F00;
    double* test=myFloatReg+2;
    *test=1.5;//设置F2
    printf("/****************** 执行前*******************/\n从0(R1)到8(R2)的值向量(使用双精度浮点数型读):\n");
    for(i=0;i<=31;i++)
    {
        unsigned long long tmp=0;
        double* p=&tmp;
        unsigned short addr=addrToMyAddr(32768-8*i);
        unsigned char* tmp_char=&tmp;
        int j;
        for(j=0;j<8;j++)
        {
           readMymemory(addr+j,tmp_char+j);
        }
        printf("%lf\n",*p);

    }
    printf("寄存器状态:\n");
    printMygister();  //显示通用寄存器
    printFloatReg();  //显示浮点数寄存器
    exe(program);//开始执行
    //显示存储器中的值向量
    printf("/****************** 执行后*******************/\n从0(R1)到8(R2)的值向量(使用双精度浮点数型读):\n");
    for(i=0;i<=31;i++)
    {
        unsigned long long tmp=0;
        double* p=&tmp;
        unsigned short addr=addrToMyAddr(32768-8*i);
        unsigned char* tmp_char=&tmp;
        int j;
        for(j=0;j<8;j++)
        {
           readMymemory(addr+j,tmp_char+j);
        }
        printf("%lf\n",*p);

    }
    printf("寄存器状态:\n");
    printMygister();  //显示通用寄存器
    printFloatReg();  //显示浮点数寄存器
    return 0;
}
Exemplo n.º 20
0
int main ()
{
    gethostname(hostname2,51);
    int f1=0;
    sprintf(uname,"%s",getenv("USER"));
    sprintf(homepath,"%s",getenv("PWD"));
    signal(SIGCHLD,SIG_IGN);//all signals that are to be handled
    signal(SIGCHLD,handler2);
    signal(SIGINT,SIG_IGN);
    signal(SIGINT,handler);
    signal(SIGTSTP,SIG_IGN);
    signal(SIGTSTP,handler);
    signal(SIGQUIT,SIG_IGN);
    signal(SIGQUIT,handler);
    int i2,i1=0,i3=0;
    char cur_dir[101];
    p5=0;
    while(1)
    {
	getcwd(cur_dir,101);//get path of current working directory
	back=0;
	p1=0;
	in1[0]='\0';
	if(!ch)
	{
	    findit(cur_dir);
	    scanf("%[^\n]",in1);
	    getchar();
	    if(in1[0]=='\0') 
		continue;
	}
	i2=0;
	argvals=0;
	while(i2<argvals)
	{
	    command[i2][0]='\0';
	    i2++;
	    i3++;
	}
	redir_in=0;
	redir_out=0;
	fun();//call function
	if(p1)
            exe();
	else
	    execute();
	i1++;
    }
    return 0;
}
Exemplo n.º 21
0
bool SunJVMLauncher::runProc(ResourceManager& resource, bool useConsole, const string& origin)
{
    std::string classname = resource.getProperty(string(ResourceManager::KEY_MAINCLASSNAME));

    if (VmVersion.isValid() == false)
    {
        DEBUG("No version identified for " + toString());
        SunJVMExe exe(this->JavaHome);
        VmVersion = exe.guessVersion();
        DEBUG("Version found: " + VmVersion.toString());
    }

    if (VmVersion.isValid() == false)
        return false;

    if (origin != "bundled") {

        Version max(resource.getProperty(ResourceManager:: KEY_MAXVERSION));
        Version min(resource.getProperty(ResourceManager:: KEY_MINVERSION));

        if (min.isValid() && (VmVersion < min))
            return false;

        if (max.isValid() && (max < VmVersion))
            return false;
    }

    SunJVMExe exe(this->JavaHome, VmVersion);
    setupVM(resource, &exe);
    if (exe.run(classname, useConsole))
    {
        m_exitCode = exe.getExitCode();
        return true;
    }
    return false;
}
Exemplo n.º 22
0
/*
 * A Universal volume processor. 
 */
int main(int argc, char* argv[]) 
{
    args::Executable exe("A universal 2D crystallography stack processor.", ' ', "1.0" );
    
    //Custom arguments
    TCLAP::ValueArg<int> START("", "start", "Starting frame number for consideration (starting from 0,1,2,3..)", false, -1, "INT");
    TCLAP::ValueArg<int> END("", "end", "Last frame number for consideration (starting from 0,1,2,3..) if end=start only one frame will be considered", false, -1, "INT");
    
    args::templates::MRCIN.forceRequired();
    args::templates::MRCOUT.forceRequired();
    
    //Add arguments
    exe.add(args::templates::MRCOUT);
    exe.add(args::templates::ZERO_PHASES);
    exe.add(END);
    exe.add(START);
    exe.add(args::templates::MRCIN);
    
    //Parse the arguments
    exe.parse(argc, argv);
    
    //Prepare the input
    tdx::data::VolumeStack input_stack(args::templates::MRCIN.getValue(), START.getValue(), END.getValue());
    
    std::cout << "\nNumber of frames being considered in the movie: " << input_stack.number_of_frames() << "\n\n";
    
    if(args::templates::ZERO_PHASES.getValue())
    {
        tdx::data::VolumeHeader header = input_stack.header();
        std::cout << "Setting all phases to zero..\n";
        for(int frame=0; frame<input_stack.number_of_frames(); frame++)
        {
            std::cout << "Processing frame: " << frame << " ..\n";
            Volume2DX frame_vol(header.rows(), header.columns(), 1);
            frame_vol.set_real(input_stack.get_frame(frame));
            frame_vol.zero_phases();
            input_stack.set_frame(frame, frame_vol.get_real());
        }
    }
    
    if(args::templates::MRCOUT.isSet())
    {
        Volume2DX output = input_stack.to_3D_volume();
        output.write_volume(args::templates::MRCOUT.getValue());;
    }
    
    return 0;
}
Exemplo n.º 23
0
/* FIXME: Qt manuals is saying this is the wrong way to create thread since version 4.x
   we better use QThreadPool or similar but for now...
 */
void SlimIncomingHandler::run()
{
    QString received;
    QTcpSocket tcpSocket;
    if (!tcpSocket.setSocketDescriptor(client))
    {
        qDebug() << "tcpSocket rip?";
        emit error();
        return ;
    }

    bExit = false;
    tcpSocket.write("Slim -- V0.3\r\n");
    while (!bExit) // todo mutex to make possible for server to force exit
    {
        if (tcpSocket.waitForReadyRead(FITNESSE_TIMEOUT))
        {
            received.append(QString(tcpSocket.readAll()));
            qDebug() << received;
            if (received.size() > 6)
            {
                SlimDeserializer dser(received);
                dser.getLength();

                CommandExecuter exe(dser.deserialize());
                QString result = exe.executeAll();
                qDebug() << "resultsend" << result.toUtf8();
                tcpSocket.write(result.toUtf8());
                // fixme failcheck
                received ="";
            }
            // FIXME... parser
            if (received.endsWith("bye")) // the later variant(\r\n) used when debugging since telnet adds \r\n
                break;
        }
        else // timeout waitForDataTimeout
        {
            // tell client to die since there were no data from fitnesse server to process
            qDebug() << "socket timeout";
            bExit = true;
        }
    }
    qDebug() << "die";
    tcpSocket.close();
    emit exited(this);
}
Exemplo n.º 24
0
int	exec_d_red_left_spe(t_manage *man, char *cmd, int pipefd[2], int fd)
{
  int	pid;

  if ((pid = fork()) == -1)
    return (-1);
  else if (pid == 0)
    {
      dup2(fd, 1);
      if ((close(pipefd[1])) == -1)
	return (-1);
      if (dup2(pipefd[0], 0) == -1)
	return (-1);
      if (exe(man, cmd) == MASTER_ERROR)
	return (MASTER_ERROR);
    }
 return (pid);
}
Exemplo n.º 25
0
void
set_clipboard_text(unsigned char *data)
{
	/* GNU Screen's clipboard */
	if (is_gnuscreen()) {
		struct string str;

		if (!init_string(&str)) return;

		add_to_string(&str, "screen -X register . ");
		add_shell_quoted_to_string(&str, data, strlen(data));

		if (str.length) exe(str.source);
		if (str.source) done_string(&str);
	}

	/* TODO: internal clipboard */
}
Exemplo n.º 26
0
int main(int argc, const char ** argv)
{
  bool ok = true;
  std::function<std::size_t(std::size_t, std::size_t)> exe;
  std::size_t nrows = 0;
  std::size_t ncols = 0;
  if(argc < 4) 
    {
      ok = false;
    }
  else 
    {
      if(argv[1] == std::string("std")) 
        {
          exe = readFromIstream;
        }
      else if(argv[1] == std::string("csv"))
        {
          exe = readFromCsvReader;
        }
      else
        {
          ok = false;
        }
      try 
        {
          nrows = std::stoi(argv[2]);
          ncols = std::stoi(argv[3]);
        }
      catch(std::exception ex)
        {
          std::cerr << ex.what() << std::endl;
          ok = false;
        }
    }
  if(!ok) 
    {
      std::cerr << "run test as " << argv[0] << " std|csv nrows ncols" << std::endl;
      return 8;
    }
  std::size_t n = exe(nrows, ncols);
  std::cout << n << " values read with method " << argv[1] << std::endl;
  return 0;
}
Exemplo n.º 27
0
Arquivo: lab6.c Projeto: chad831/315
/*************************************** MAIN ******************************/
int main()
{

   MIPS_SIM* sim = malloc(sizeof(MIPS_SIM)); /* init sim structure */
   FDB* fdBasket = malloc(sizeof(FDB)); /* init Baskets */
   DEB* deBasket = malloc(sizeof(DEB));
   EMB* emBasket = malloc(sizeof(EMB));
   MWB* mwBasket = malloc(sizeof(MWB));
   simDefault(sim); /* set default values */
   basketDefault(fdBasket, deBasket, emBasket, mwBasket); /* default values for baskets */
   initProgram(); /* prompt user for file and read in mips program to buffer */

   /* Multi Cycle Loop */
   do
   {
      printf("Count: %d\n", count);
      wb(sim, fdBasket, deBasket, emBasket, mwBasket);  /* write back */
      m(sim, emBasket, mwBasket); /* memory write */
      exe(sim, fdBasket, deBasket, emBasket, mwBasket); /* execute */
      if(sim->regs[2] == 10 && mem[(sim->pcValue-4)/4] == 0xC) /* program finished */
         break;
      d(sim, fdBasket, deBasket); /* instruction decode */
      f(sim, fdBasket);  /* instruction fetch */
      sim->numClock++;

      count++;
      printf("Enter to continue...\n");
      getc(stdin);

   } while(sim->regs[2] != 10);  /* run until user quits or $v0 is 10 */

   printf("\n Total instunctions: %d\n", sim->numOfInstr);
   printf(" Total read-write instructions: %d\n", sim->numOfRWs);
   printf(" Total clock cycles: %d\n\n", sim->numClock);

   printf("\n count: %d\n", count);
   free(sim);
   free(fdBasket);
   free(deBasket);
   free(emBasket);
   free(mwBasket);
   return 0;

}  /* End Main */
Exemplo n.º 28
0
void ofApp::exit(){

    cout << "Start termination." << endl;

    
    cout << "EXIT: KILL ALL NODE(closing the process of git-hub)" << endl;
    exe("killall node");

    
    int flg = 1;
    GismoManager& gismo = GismoManager::getInstance();
    gismo.bang("/yaritori/save", &flg);
    cout << ": : :" << endl;
    cout << "Auto save finished." << endl;
    cout << "waiting the file writing..." << endl;
    ofSleepMillis(1000);
    cout << "yaritori all finished." << endl;

}
Exemplo n.º 29
0
void UpdateShortCuts()
{
	char curDir[255];
	GetCurrentDirectory(255, curDir);

	gcString exe(curDir);
	gcString wd(curDir);

#ifdef DEBUG
	exe += "\\desura-d.exe";
#else
	exe += "\\desura.exe";
#endif

	gcWString folder = UTIL::OS::getConfigValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Desura\\DesuraApp\\StartMenuFolder");

	if (folder == L"")
		folder == L"Desura";

	gcString startFolder = UTIL::OS::getStartMenuProgramsPath(folder);

	gcString spOne = startFolder + "\\Desura.lnk";
	gcString spTwo = startFolder + "\\Desura (force update).lnk";

	OS_VERSION ver = UTIL::WIN::getOSId();

	bool force = ((ver == WINDOWS_XP || ver == WINDOWS_XP64) && UTIL::FS::isValidFolder(startFolder));

	if (UTIL::FS::isValidFile(spOne) || force)
	{
		UTIL::FS::delFile(spOne);
		UTIL::WIN::createShortCut(gcWString(spOne).c_str(), exe.c_str(), wd.c_str(), "", false);
	}

#ifdef DESURA_NONGPL_BUILD
	if (UTIL::FS::isValidFile(spTwo) || force)
	{
		UTIL::FS::delFile(spTwo);
		UTIL::WIN::createShortCut(gcWString(spTwo).c_str(), exe.c_str(), wd.c_str(), "-forceupdate", true);
	}
#endif
}
Exemplo n.º 30
0
int Response::response()
{
	sprintf(file,"%s%s",pwd,req.path);
	if(strstr(file,"/../")!=0) return -1;
	File f(file);
	if(f.fok)
	{
		if(f.isfile)
		{
			if(f.xok)
			{
				return exe();
			}else if(f.rok)
			{
				return sendfile(f);
			}else	return notfound();
		}else	return notfound();
	}else	return notfound();
	return -1;
}