Beispiel #1
0
void ControlSocket::HandleString(std::string s)
{
    if(_instance->GetConf()->rmcontrolpass.size())
    {
        if(_authed)
        {
            _Execute(s);
        }
        else
        {
            if(s.size() > 3 && !memicmp(s.c_str(),"pw ",3)) // string format: "pw secret12345"
            {
                if(_instance->GetConf()->rmcontrolpass == s.c_str() + 3)
                {
                    logdetail("ControlSocket: Authenticated successfully with: \"%s\"",s.c_str());
                    SendTelnetText("+accepted");
                    _authed = true;
                }
                else
                {
                    SendTelnetText("+wrong password");
                    SetCloseAndDelete(true);
                }
            }
        }
    }
    else
    {
        _Execute(s);
    }
}
Beispiel #2
0
SQLRETURN SQLExecDirect(  SQLHSTMT    hDrvStmt,
						  SQLCHAR     *szSqlStr,
						  SQLINTEGER  nSqlStr )
{
    HDRVSTMT hStmt	= (HDRVSTMT)hDrvStmt;
	RETCODE         rc;
					
	/* SANITY CHECKS */
    if( NULL == hStmt )
        return SQL_INVALID_HANDLE;

	sprintf( hStmt->szSqlMsg, "hStmt = $%08lX", hStmt );
    logPushMsg( hStmt->hLog, __FILE__, __FILE__, __LINE__, LOG_WARNING, LOG_WARNING, hStmt->szSqlMsg );

	/* prepare command */
	rc = _Prepare( hDrvStmt, szSqlStr, nSqlStr );
	if ( SQL_SUCCESS != rc )
	{
		logPushMsg( hStmt->hLog, __FILE__, __FILE__, __LINE__, LOG_WARNING, LOG_WARNING, "Could not prepare statement" );
		return rc;
	}

	/* execute command */
	rc = _Execute( hDrvStmt );
	if ( SQL_SUCCESS != rc )
	{
		logPushMsg( hStmt->hLog, __FILE__, __FILE__, __LINE__, LOG_WARNING, LOG_WARNING, "Problem calling SQLEXecute" );
		return rc;
	}

	logPushMsg( hStmt->hLog, __FILE__, __FILE__, __LINE__, LOG_INFO, LOG_INFO, "SQL_SUCCESS" );
	return SQL_SUCCESS;
}
Beispiel #3
0
Datei: task.cpp Projekt: JT-a/USD
void
HdTask::Execute(HdTaskContext* ctx)
{
    _Execute(ctx);
    TF_FOR_ALL(task, _children) {
        (*task)->Execute(ctx);
    }
Beispiel #4
0
int InsBobine(LISTE *tags,TMxMsg *msg5,TMxMsg *msg6)
{	int i,nbre_vars=0;
	char tagn[500];
	char values[500];
	char *str,*name;
	char tagname[30];
	//char *name;
	if (TEST) return(0);

	Log(LOG_DEBUG,"Entering InsBobine\n");
	if ((msg5==NULL)&&(msg6==NULL)) return(-1);

	memset(tagn,0,sizeof(tagn));
	memset(values,0,sizeof(values));

	sprintf(tagn,"TEMPS,MACHINE,");
	sprintf(values,"now(),'%s',",MXNAME);

	for (i=0;i<10;i++)
	{
		if ((msg5!=NULL)&&(GetTagName(tags,msg5->Variables[i].Repere,tagname)))
		{ name=strchr(tagname,'_');
			if (name!=NULL)
			{
				name++;
				if (nbre_vars++) {sprintf(tagn+strlen(tagn),",");sprintf(values+strlen(values),",");}
				sprintf(tagn+strlen(tagn),"%s",name);
				str=msg5->Variables[i].Value;
				sprintf(values+strlen(values),"'%s'",str);
			}
		}
		if ((msg6!=NULL)&&(GetTagName(tags,msg6->Variables[i].Repere,tagname)))
		{ name=strchr(tagname,'_');
			if (name!=NULL)
			{
				name++;
				if (nbre_vars++) {sprintf(tagn+strlen(tagn),",");sprintf(values+strlen(values),",");}
				sprintf(tagn+strlen(tagn),"%s",name);
				str=msg6->Variables[i].Value;
				sprintf(values+strlen(values),"'%s'",str);
			}
		}
	}
	readwritedata(plc,&variables);
	for (i=0;i<AB_VARCOUNT;i++)
	{
		TAG *atag=variables.Data[i];
		sprintf(tagn+strlen(tagn),",");sprintf(values+strlen(values),",");
		sprintf(tagn+strlen(tagn),"%s",atag->TagName);
		sprintf(values+strlen(values),"'%f'",atag->Value);
	}
	Log(LOG_DEBUG,"InsBobine : %s \n %s \n length : (%d , %d)\n",tagn,values,strlen(tagn),strlen(values));
	i=_Execute(&Default_Db,"insert into BOBINE (%s) values (%s)",tagn,values);

	Log(LOG_NOTICE,"insert into BOBINE (%s) values (%s)\n",tagn,values);
	Log(LOG_NOTICE,"InsBobine : %s (%d)\n",MysqlErrorMsg,i);
	return(i);
}
Beispiel #5
0
unsigned CMssqlConnection::ExecuteAndReturnIdentity(const char *string, ...)
{
	cvs::string str;
	va_list va;

	va_start(va,string);
	cvs::vsprintf(str,64,string,va);
	va_end(va);

	_Execute(str.c_str());
	if(Error())
		return 0;

	CSqlRecordsetPtr rs = _Execute("select @@IDENTITY");

	if(Error() || rs->Closed() || rs->Eof())
		return 0;
	return *rs[0];
}
Beispiel #6
0
CSqlRecordsetPtr CMssqlConnection::Execute(const char *string, ...)
{
	cvs::string str;
	va_list va;

	va_start(va,string);
	cvs::vsprintf(str,64,string,va);
	va_end(va);

	return _Execute(str.c_str());
}
Beispiel #7
0
unsigned CDb2Connection::ExecuteAndReturnIdentity(const char *string, ...)
{
	cvs::string str;
	va_list va;

	va_start(va,string);
	cvs::vsprintf(str,64,string,va);
	va_end(va);

	str = "begin atomic;" + str;
	str += " select identity_val_local(); end";

	CSqlRecordsetPtr rs = _Execute(str.c_str());

	if(Error() || rs->Closed() || rs->Eof())
		return 0;
	return *rs[0];
}
Beispiel #8
0
/**
 * The run method is used internally to actually run the commands.
 * @return whether or not the command should stay within the {@link Scheduler}.
 */
bool Command::Run()
{
	if (!m_runWhenDisabled && m_parent == NULL && DriverStation::GetInstance()->IsDisabled())
		Cancel();

	if (IsCanceled())
		return false;

	if (!m_initialized)
	{
		m_initialized = true;
		StartTiming();
		_Initialize();
		Initialize();
	}
	_Execute();
	Execute();
	return !IsFinished();
}
Beispiel #9
0
SQLRETURN SQLExecute( SQLHSTMT  hDrvStmt )
{
    return _Execute( hDrvStmt );
}
Beispiel #10
0
HX_RESULT HXScheduler::ExecuteCurrentFunctions(HXBOOL bAtInterrupt)
{
    HXBOOL bShouldServiceSystem	= FALSE;
    HXBOOL bShouldServiceInterrupt = FALSE;
    HXBOOL bShouldServiceInterruptOnly = FALSE;
    HXBOOL bImmediatesPending = FALSE;
    HXBOOL bInterruptImmediatesPending = FALSE;
    HXBOOL bInterruptOnlyImmediatesPending = FALSE;

    HXBOOL bUpdateRet = UpdateCurrentTime(bAtInterrupt, 
					  bShouldServiceSystem, 
					  bShouldServiceInterrupt,
					  bShouldServiceInterruptOnly);
    if (!bUpdateRet)
    {
        return HXR_OK;
    }

    /* if not at interrupt time, execute interrupt safe & 
     * non-interrupt safe tasks 
     */
    if (bShouldServiceInterrupt)
    {
	_Execute(m_pInterruptTimeScheduler, bInterruptImmediatesPending);
    }

    if (bShouldServiceInterruptOnly)
    {
	_Execute(m_pInterruptTimeOnlyScheduler, bInterruptOnlyImmediatesPending);
    }

    if (bShouldServiceSystem)
    {
	UINT32 ulElemsExecuted = _Execute(m_pScheduler, bImmediatesPending);
	
#if defined(_WIN32) || defined(THREADS_SUPPORTED)
	if (ulElemsExecuted != 0)
	{
	    HXBOOL bChange = FALSE;
	    if (m_pScheduler->empty())
	    {
		if (m_ulCurrentGranularity < MINIMUM_GRANULARITY &&
		    (MINIMUM_GRANULARITY - m_ulCurrentGranularity >= 
		     MINIMUM_DIFFERENCE))
		{
		    bChange = TRUE;
		    m_ulCurrentGranularity = MINIMUM_GRANULARITY;
		}
	    }
	    else if (m_ulCurrentGranularity > MINIMUM_DIFFERENCE)
	    {
		Timeval timeout	  = m_pScheduler->head_time() - m_CurrentTimeVal;
		INT32  lTimeoutInMs;

		if (timeout.tv_sec >= 0)
		{
		    lTimeoutInMs = timeout.tv_sec * 1000 + 
			timeout.tv_usec / 1000;
		}
		else
		{
		    lTimeoutInMs = 0;
		}

		if (lTimeoutInMs > 0 &&
		    ((UINT32) lTimeoutInMs) < m_ulCurrentGranularity &&
		    (m_ulCurrentGranularity - (UINT32) lTimeoutInMs >= 
		     MINIMUM_DIFFERENCE))
		{
		    bChange = TRUE;
		    m_ulCurrentGranularity = (UINT32) ((lTimeoutInMs >= MINIMUM_DIFFERENCE ? lTimeoutInMs: MINIMUM_DIFFERENCE));
		}
	    }

	    if (bChange)
	    {
		m_pTimeline->Pause();
		/* Reset the granularity */
		m_pTimeline->SetGranularity(m_ulCurrentGranularity);
		/* Resume */
		m_pTimeline->Resume();
	    }
	}
#endif /*_WIN32*/
    }

    m_bImmediatesPending = (bImmediatesPending || 
			    bInterruptImmediatesPending || 
			    bInterruptOnlyImmediatesPending);

    m_ulSystemNextDueTime = _GetNextDueTimeInMs(m_pScheduler);
    m_ulInterruptNextDueTime = _GetNextDueTimeInMs(m_pInterruptTimeScheduler);
    m_ulInterruptOnlyNextDueTime = _GetNextDueTimeInMs(m_pInterruptTimeOnlyScheduler);

    return HXR_OK;
}
Beispiel #11
0
Datei: task.cpp Projekt: MWDD/USD
void
HdTask::Execute(HdTaskContext* ctx)
{
    _Execute(ctx);
    _ExecuteChildren(ctx);
}