コード例 #1
0
void UnixDirectoryReader::OpenPath(const char *path)
{
	if (this->dirfp != nullptr) this->ClosePath();

	SafeStrncpy(this->dpath, path, MAX_PATH);
	this->dirfp = opendir(this->dpath);
}
コード例 #2
0
ファイル: JEvent.cpp プロジェクト: weiganyi/jphone
JUINT32 JEvent::DeSerialize(JCHAR* pBuf)
{
    JUINT32 uiBufLen = 0;
    JCHAR* pTmpBuf = JNULL;

    JEVT_TYPE* pEvtType = JNULL;
    JUINT32* pLen = JNULL;
    JCHAR strName[JMAX_BUFFER_LEN] = {0};
    JUINT32* pBodyLen = JNULL;

    JLogAutoPtr clsLogAutoPtr(JSingleton<JLog>::instance(), 
        JLOG_MOD_EVENT, "JEvent::DeSerialize");

    uiBufLen = SafeStrlen(pBuf);
    if (uiBufLen)
    {
        pTmpBuf = pBuf;

        //get the event type from the buffer
        pEvtType = reinterpret_cast<JEVT_TYPE*>(pTmpBuf);
        m_eType = *pEvtType;
        pTmpBuf += sizeof(JEVT_TYPE);

        //first get the from process length from buffer
        pLen = reinterpret_cast<JUINT32*>(pTmpBuf);
        pTmpBuf += sizeof(JUINT32);
        //then get the from process from buffer
        if (*pLen)
        {
            SafeStrncpy(strName, pTmpBuf, *pLen, JMAX_BUFFER_LEN);
        	m_strFromProc = strName;
            pTmpBuf += *pLen;
        }

        //first get the from thread length from buffer
        pLen = reinterpret_cast<JUINT32*>(pTmpBuf);
        pTmpBuf += sizeof(JUINT32);
        //then get the from thread from buffer
        if (*pLen)
        {
            SafeStrncpy(strName, pTmpBuf, *pLen, JMAX_BUFFER_LEN);
        	m_strFromThrd = strName;
            pTmpBuf += *pLen;
        }

        //first get the from module length from buffer
        pLen = reinterpret_cast<JUINT32*>(pTmpBuf);
        pTmpBuf += sizeof(JUINT32);
        //then get the from module from buffer
        if (*pLen)
        {
            SafeStrncpy(strName, pTmpBuf, *pLen, JMAX_BUFFER_LEN);
        	m_strFromMod = strName;
            pTmpBuf += *pLen;
        }

        //first get the to process length from buffer
        pLen = reinterpret_cast<JUINT32*>(pTmpBuf);
        pTmpBuf += sizeof(JUINT32);
        //then get the to process from buffer
        if (*pLen)
        {
            SafeStrncpy(strName, pTmpBuf, *pLen, JMAX_BUFFER_LEN);
        	m_strToProc = strName;
            pTmpBuf += *pLen;
        }

        //first get the to thread length from buffer
        pLen = reinterpret_cast<JUINT32*>(pTmpBuf);
        pTmpBuf += sizeof(JUINT32);
        //then get the to thread from buffer
        if (*pLen)
        {
            SafeStrncpy(strName, pTmpBuf, *pLen, JMAX_BUFFER_LEN);
        	m_strToThrd = strName;
            pTmpBuf += *pLen;
        }

        //first get the to module length from buffer
        pLen = reinterpret_cast<JUINT32*>(pTmpBuf);
        pTmpBuf += sizeof(JUINT32);
        //then get the to module from buffer
        if (*pLen)
        {
            SafeStrncpy(strName, pTmpBuf, *pLen, JMAX_BUFFER_LEN);
        	m_strToMod = strName;
            pTmpBuf += *pLen;
        }

        //first get the body length from buffer
        pBodyLen = reinterpret_cast<JUINT32*>(pTmpBuf);
        pTmpBuf += sizeof(JUINT32);
        //then get the body from buffer
        if (*pBodyLen)
        {
    		if (m_pBody)
    		{
    			delete m_pBody;
    			m_pBody = JNULL;
    		}

            //construct a event body
			m_pBody = JSingleton<JThreadManager>::instance()->MakeEventBody(m_strToThrd.c_str(), 
			    m_strToMod.c_str(), m_eType);
			if (m_pBody)
			{
			    //deserialize body from buffer
    			m_pBody->DeSerialize(pTmpBuf);
			}
        }

    	return JSUCCESS;
    }

	return JFAILURE;
}