Exemple #1
0
/*!
    start the client program.
*/
int TEPty::run(const char *_pgm, QStrList &_args, const char *_term, ulong winid, bool _addutmp, const char *_konsole_dcop,
               const char *_konsole_dcop_session)
{
    clearArguments();

    setBinaryExecutable(_pgm);

    QStrListIterator it(_args);
    for(; it.current(); ++it)
        arguments.append(it.current());

    if(_term && _term[0])
        setEnvironment("TERM", _term);
    if(_konsole_dcop && _konsole_dcop[0])
        setEnvironment("KONSOLE_DCOP", _konsole_dcop);
    if(_konsole_dcop_session && _konsole_dcop_session[0])
        setEnvironment("KONSOLE_DCOP_SESSION", _konsole_dcop_session);
    setEnvironment("WINDOWID", QString::number(winid));

    setUsePty(All, _addutmp);

    if(start(NotifyOnExit, (Communication)(Stdin | Stdout)) == false)
        return -1;

    resume(); // Start...
    return 0;
}
Exemple #2
0
STDMETHODIMP GuestSessionWrap::COMSETTER(Environment)(ComSafeArrayIn(IN_BSTR, aEnvironment))
{
    LogRelFlow(("{%p} %s: enter aEnvironment=%zu\n", this, "GuestSession::setEnvironment", ComSafeArraySize(aEnvironment)));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = setEnvironment(ArrayBSTRInConverter(ComSafeArrayInArg(aEnvironment)).array());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, "GuestSession::setEnvironment", hrc));
    return hrc;
}
BCSPImplementation::BCSPImplementation ( UARTPtr aFile )
:
    mFile ( aFile ),
    mLockCS ( 0 ),
    mXMITBusy ( false ),
    mRCVBusy ( false ),
    mXMITBytesAvailable ( 0 ),
    mRCVBytesAvailable ( 0 ),
    mStackMustDie ( false ),
    mStackDead ( mSignals ),
    userOnLinkFailSync ( 0 ),
    userOnLinkFailRetries ( 0 )
{
    memset(Packets,0,sizeof(Packets)) ;
    //create the initial stack state
    createBCSPStack() ;
    mBCSPenv.allocMem = allocMem;
    mBCSPenv.freeMem = freeMem;
    mBCSPenv.enterCS = enterCS;
    mBCSPenv.leaveCS = leaveCS;
    mBCSPenv.signal = signal;
    mBCSPenv.onLinkFailureSync = onLinkFailSync;
    mBCSPenv.onLinkFailureRetries = onLinkFailRetries;
    mBCSPenv.clockMask = 0xFFFFFFFF;
    // call back to reverse BCSPaddPacket below
    mBCSPenv.releasePacket = releasePacket; 
    mBCSPenv.envState = this;
    setEnvironment(mStack,&mBCSPenv) ;
}
Exemple #4
0
int main(void) {
	setEnvironment();
	setOutput();
	setScoreboard();

	while(1) {
		setRaceMode();
		PLAYER ppp[numOfPlayers];
		setPlayer(&ppp, 0, STARTING_POSITION_X, 18, '1', 65, 66, 67, 68);
		setPlayer(&ppp, 1, STARTING_POSITION_X, 20, '2', 119, 115, 100, 97);
		players = &ppp;

		redrawScreen();
		splashScreen();
		countdown();

		setStartTime(&ppp); 
		char c;
		while (!weHaveAWinner(&ppp)) { 
			c = getc(stdin);
			checkMove(c, &ppp);
		}
		printWins();
		checkeredFlag();
		waitForEnter();
	}

	return EXIT_SUCCESS;
}	
Exemple #5
0
// Structure of this code influenced by naev
void Console::processCommand(const char *cmdline)
{
#ifndef BF_NO_CONSOLE

    if(consoleCommand == "" && strcmp(cmdline, "") == 0)
        return;

    setEnvironment();

    // If we are not on the first line of our command, we need to append the command to our existing line
    if(consoleCommand == "")
        consoleCommand = cmdline;
    else
        consoleCommand += "\n" + string(cmdline);

    S32 status = luaL_loadbuffer(L, consoleCommand.c_str(), consoleCommand.length(), "ConsoleInput");

    if(status == LUA_ERRSYNTAX)      // cmd is not a complete Lua statement yet -- need to add more input
    {
        std::size_t lmsg;
        const char *msg = lua_tolstring(L, -1, &lmsg);
        const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1);

        if(strstr(msg, LUA_QL("<eof>")) == tp)
            lua_pop(L, 1);
        else
        {
            // Error -- print to console
            output("%s\n", lua_tostring(L, -1));
            consoleCommand = "";       // Reset command
        }
    }

    // Success -- print results to console
    else if(status == 0)
    {
        if(lua_pcall(L, 0, LUA_MULTRET, 0))
        {
            output("%s\n", lua_tostring(L, -1));
            lua_pop(L, 1);
        }

        if(lua_gettop(L) > 0)
        {
            lua_getglobal(L, "print");
            lua_insert(L, 1);
            if(lua_pcall(L, lua_gettop(L) - 1, 0, 0) != 0)
                output("Error printing results.");
        }

        consoleCommand = "";    // Reset command
    }

    clearStack(L);

    // Don't call LuaObject::eraseAllPotentiallyUntrackedObjects() here; we might create an object
    // in one command and want to use it in another... better to wait until we close the console.

#endif
}
Command* CommandPacker::packCommand(InputTokens* tokens) {
	assert(tokens);

	setEnvironment(tokens);
	branchToNode(START_INDEX);

	return _command;
}
void TaskPacker::packStandardTask(InputTokens* tokens, int index) {
	assert(tokens);
	assert(!tokens->isOutOfBounds(index));

	setEnvironment(tokens);
	findTaskDetails(index);
	_task = new Task(_name, _date1, _date2, _time1, _time2, _location, _doneStatus);
	
	return;
}
//
// bool init(dx, dy, dz, theta, colorIndex)
// Last modified: 06Nov2009
//
// Initializes the object to the parameterized values,
// returning true if successful, false otherwise.
//
// Returns:     true if successful, false otherwise
// Parameters:
//      dx          in      the initial x-coordinate of the object (default 0)
//      dy          in      the initial y-coordinate of the object (default 0)
//      dz          in      the initial z-coordinate of the object (default 0)
//      colorIndex  in      the initial array index of the color of the object
//
bool Object::init(const GLfloat dx,    const GLfloat dy, const GLfloat dz,
                 const GLfloat theta, const Color   colorIndex)
{
    Circle::init(dx, dy, dz, DEFAULT_OBJECT_RADIUS, colorIndex);
    setHeading(theta);
    behavior         = DEFAULT_OBJECT_BEHAVIOR;
    behavior.setMaxSpeed(maxSpeed());
    showFilled       = DEFAULT_OBJECT_SHOW_FILLED;
    setEnvironment(NULL);
    return true;
}   // init(const GLfloat..<4>, const Color)
Exemple #9
0
void KProcess::setEnv(const QString &name, const QString &value, bool overwrite)
{
    QStringList env = environment();
    if (env.isEmpty()) {
        env = systemEnvironment();
        env.removeAll(QString::fromLatin1(DUMMYENV));
    }
    QString fname(name);
    fname.append(QLatin1Char('='));
    for (QStringList::Iterator it = env.begin(); it != env.end(); ++it)
        if ((*it).startsWith(fname)) {
            if (overwrite) {
                *it = fname.append(value);
                setEnvironment(env);
            }
            return;
        }
    env.append(fname.append(value));
    setEnvironment(env);
}
Exemple #10
0
	void Device::checkEnvironment() {
		libnutcommon::SelectResult user_res;
		if (m_userEnv >= 0) user_res = m_envs[m_userEnv]->getSelectResult();
		if ((m_userEnv >= 0) && (m_envs[m_userEnv]->selectionDone())) {
			if (user_res == libnutcommon::SelectResult::True || user_res == libnutcommon::SelectResult::User) {
				setEnvironment(m_userEnv);
				return;
			}
		}
		if (m_waitForEnvSelects != 0) return;
		// every environment has now selectionDone() == true
		// => m_userEnv is either -1 or m_userEnv cannot be selected.
		if ((m_activeEnv >= 0) && (m_envs[m_activeEnv]->getSelectResult() == libnutcommon::SelectResult::True)) return;
		// => select first with SelectResult::True
		foreach (Environment* env, m_envs) {
			if (env->getSelectResult() == libnutcommon::SelectResult::True) {
				setEnvironment(env->m_id);
				return;
			}
		}
		setEnvironment(0);
	}
void ExternalCommand::setup()
{
	setEnvironment(QStringList() << QStringLiteral("LC_ALL=C") << QStringLiteral("PATH=") + QString::fromUtf8(getenv("PATH")));
	setProcessChannelMode(MergedChannels);

	processes = new QProcess[command().size()];
	connect(&processes[command().size()-1], SIGNAL(readyReadStandardOutput()), SLOT(onReadOutput()));
	connect(&processes[command().size()-1], SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(onFinished(int)));

	for (unsigned int i = 0; i < command().size() - 1; i++)
	{
		processes[i].setStandardOutputProcess(&processes[i+1]);
	}
}
//
// bool init(dx, dy, dz, theta, colorIndex)
// Last modified: 06Nov2009
//
// Initializes the robot to the parameterized values,
// returning true if successful, false otherwise.
//
// Returns:     true if successful, false otherwise
// Parameters:
//      dx          in      the initial x-coordinate of the robot (default 0)
//      dy          in      the initial y-coordinate of the robot (default 0)
//      dz          in      the initial z-coordinate of the robot (default 0)
//      theta       in      the initial heading of the robot (default 0)
//      colorIndex  in      the initial array index of the color of the robot
//
bool Robot::init(const GLfloat dx,    const GLfloat dy, const GLfloat dz,
                 const GLfloat theta, const Color   colorIndex)
{
    Circle::init(dx, dy, dz, DEFAULT_ROBOT_RADIUS, colorIndex);
    setHeading(theta);
    behavior         = DEFAULT_ROBOT_BEHAVIOR;
    behavior.setMaxSpeed(maxSpeed());
    showHeading      = DEFAULT_ROBOT_SHOW_HEADING;
    heading.showLine = DEFAULT_ROBOT_SHOW_LINE;
    heading.showHead = DEFAULT_ROBOT_SHOW_HEAD;
    showFilled       = DEFAULT_ROBOT_SHOW_FILLED;
    setEnvironment(NULL);
    return true;
}   // init(const GLfloat..<4>, const Color)
Exemple #13
0
/****** Interactive/qrsh/--qrsh_starter ***************************************
*
*  NAME
*     qrsh_starter -- start a command special correct environment
*
*  SYNOPSIS
*     qrsh_starter <environment file> <noshell>
*     int main(int argc, char **argv[])
*
*  FUNCTION
*     qrsh_starter is used to start a command, optionally with additional
*     arguments, in a special environment.
*     The environment is read from the given <environment file>.
*     The command to be executed is read from the environment variable
*     QRSH_COMMAND and executed either standalone, passed to a wrapper
*     script (environment  variable QRSH_WRAPPER) or (default) in a users login
*     shell (<shell> -c <command>).
*     On exit of the command, or if an error occurs, an exit code is written
*     to the file $TMPDIR/qrsh_exit_code.
*
*     qrsh_starter is called from qrsh to start the remote processes in 
*     the correct environment.
*
*  INPUTS
*     environment file - file with environment information, each line 
*                        contains a tuple <name>=<value>
*     noshell          - if this parameter is passed, the command will be
*                        executed standalone
*
*  RESULT
*     EXIT_SUCCESS, if all actions could be performed,
*     EXIT_FAILURE, if an error occured
*
*  EXAMPLE
*     setenv QRSH_COMMAND "echo test"
*     env > ~/myenvironment
*     rsh <hostname> qrsh_starter ~/myenvironment 
*
*  SEE ALSO
*     Interactive/qsh/--Interactive
*
****************************************************************************
*/
int main(int argc, char *argv[])
{
   int   exitCode = 0;
   char *command  = NULL;
   char *wrapper = NULL;
   int  noshell  = 0;

   /* check for correct usage */
   if(argc < 2) {
      fprintf(stderr, "usage: %s <job spooldir> [noshell]\n", argv[0]);
      exit(EXIT_FAILURE);        
   }

   /* check for noshell */
   if(argc > 2) {
      if(strcmp(argv[2], "noshell") == 0) {
         noshell = 1;
      }
   }

   if(!readConfig(argv[1])) {
      writeExitCode(EXIT_FAILURE, 0);
      exit(EXIT_FAILURE);
   }

   /* setup environment */
   command = setEnvironment(argv[1], &wrapper);
   if(command == NULL) {
      writeExitCode(EXIT_FAILURE, 0);
      exit(EXIT_FAILURE);
   }   

   if(!changeDirectory()) {
      writeExitCode(EXIT_FAILURE, 0);
      exit(EXIT_FAILURE);
   }

   /* start job */
   exitCode = startJob(command, wrapper, noshell);

   /* JG: TODO: At this time, we could already pass the exitCode to qrsh.
    *           Currently, this is done by shepherd, but only after 
    *           qrsh_starter and rshd exited.
    *           If we pass exitCode to qrsh, we also have to implement the
    *           shepherd_about_to_exit mechanism here.
    */

   /* write exit code and exit */
   return writeExitCode(EXIT_SUCCESS, exitCode);
}
Exemple #14
0
UpdateProcess::UpdateProcess(QObject *parent)
  : QProcess(parent)
{
  _currentCommand = NoCommand;
  _socksPort = 0;

  connect(this, SIGNAL(readyReadStandardError()),
          this, SLOT(readStandardError()));
  connect(this, SIGNAL(readyReadStandardOutput()),
          this, SLOT(readStandardOutput()));
  connect(this, SIGNAL(finished(int, QProcess::ExitStatus)),
          this, SLOT(onFinished(int, QProcess::ExitStatus)));

  setEnvironment(systemEnvironment());
}
    foreach (const ExternalToolValidation& validation, validations) {
        if (externalToolProcess != NULL) {
            delete externalToolProcess;
            externalToolProcess = NULL;
        }

        checkArchitecture(validation.executableFile);
        CHECK_OP(stateInfo, );

        externalToolProcess = new QProcess();
        setEnvironment(tool);

        externalToolProcess->start(validation.executableFile, validation.arguments);
        bool started = externalToolProcess->waitForStarted(3000);

        if (!started) {
            errorMsg = validation.possibleErrorsDescr.value(ExternalToolValidation::DEFAULT_DESCR_KEY, "");
            if (!errorMsg.isEmpty()) {
                stateInfo.setError(errorMsg);
            } else {
                stateInfo.setError(tr("Tool does not start.<br>"
                                      "It is possible that the specified executable file "
                                      "<i>%1</i> for %2 tool is invalid. You can change "
                                      "the path to the executable file in the external "
                                      "tool settings in the global preferences.")
                                   .arg(toolPath)
                                   .arg(toolName));
            }
            isValid = false;
            return;
        }

        int elapsedTime = 0;
        while (!externalToolProcess->waitForFinished(CHECK_PERIOD_MS)) {
            elapsedTime += CHECK_PERIOD_MS;
            if (isCanceled() || elapsedTime >= TIMEOUT_MS) {
                cancelProcess();
            }
        }

        if (!parseLog(validation)) {
            return;
        }

        if (!isValid) {
            return;
        }
    }
SynchronizedWeatherGenerator::SynchronizedWeatherGenerator(int updateInterval) :
		m_updateInterval(updateInterval),
		m_weather(),
		m_nextUpdate(0),
		m_minTemp(0),
		m_maxTemp(0),
		m_minWind(0),
		m_maxWind(0),
		m_randomGenerator(new RandomGenerator)
{
	// Until we can integrate with environment blocks:
	// the weather is standardized to a mild climate, with
	// a wind speed of 0-10 m/s (roughly equal to 0-20 miles per hour), temperature 0-35 degrees
	// (32 - 95 degrees Fahrenheit.)
	// TODO:  Integrate with environment blocks
	setEnvironment(0,35,0,10);
}
Exemple #17
0
PathChooser::PathChooser(QWidget *parent) :
    QWidget(parent),
    m_d(new PathChooserPrivate(this))
{
    m_d->m_hLayout->setContentsMargins(0, 0, 0, 0);

    connect(m_d->m_lineEdit, SIGNAL(validReturnPressed()), this, SIGNAL(returnPressed()));
    connect(m_d->m_lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(changed(QString)));
    connect(m_d->m_lineEdit, SIGNAL(validChanged()), this, SIGNAL(validChanged()));
    connect(m_d->m_lineEdit, SIGNAL(validChanged(bool)), this, SIGNAL(validChanged(bool)));
    connect(m_d->m_lineEdit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));

    m_d->m_lineEdit->setMinimumWidth(200);
    m_d->m_hLayout->addWidget(m_d->m_lineEdit);
    m_d->m_hLayout->setSizeConstraint(QLayout::SetMinimumSize);

    addButton(tr(browseButtonLabel), this, SLOT(slotBrowse()));

    setLayout(m_d->m_hLayout);
    setFocusProxy(m_d->m_lineEdit);
    setEnvironment(Environment::systemEnvironment());
}
void SetCommand::execute(const Arguments& args, NSDebuggingContext::Context& ctx)
{
    mili::assert_throw<NSCommon::InvalidArgumentNumbers>(args.size() == 1u || args.size() == 2u);

    auto instanceId = ctx.getCurrentInstance();
    const auto instance = ctx.getInstance(instanceId).lock();
    mili::assert_throw<NSCommon::InstanceNoLongerAlive>(bool(instance));

    if (args.size() == 1u)
    {
        const auto& assignation = args[0u];
        auto pos = assignation.find('=');
        if (pos == std::string::npos)
        {
            throw NSCommon::InvalidArgument(assignation);
        }
        instance->setVariable(assignation.substr(0u, pos), assignation.substr(pos + 1u));
    }
    else // args.size() == 2u
    {
        instance->setEnvironment(args[0u], args[1u]);
    }
}
Exemple #19
0
void KProcess::clearEnvironment()
{
    setEnvironment(QStringList() << QString::fromLatin1(DUMMYENV));
}
QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent)
    : SshDeviceProcess(device, parent)
{
    setEnvironment(Environment(OsTypeLinux));
    m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter);
}