Ejemplo n.º 1
0
// Message retrieved from Payload
bool OTPayload::GetMessage(OTMessage & theMessage) const
{
	// validate checksum
	uint32_t lSize	= GetSize();
	uint32_t lIndex	= lSize-2; // the index to where the NULL terminator SHOULD be if they
						  // sent us a string like they were supposed to. (A contract.)
						  // (nSize-1 would be the location of the checksum at the end.)
	if (0 == lSize)
		return false;
	
	if (IsChecksumValid((OT_BYTE*)GetPointer(), (uint32_t)lSize))
	{
		// We add the null-terminator ourselves at this point, for security reasons,
		// since we will process the data, after this point, as a string.
		((OT_BYTE *)GetPointer())[lIndex] = 0;
		
		theMessage.Release();
		
		// Why is this safe, where I cast the Payload data pointer as
		// a char * and tell the string to set itself from that?
		// Because (1) I just validated the checksum, and
		// (2) There place where the NULL should be, I set to 0, by hand,
		// just above 2 lines. So when this set operation occurs, the
		// farthest it will go is to that 0.
		theMessage.m_strRawFile.Set((const char *)GetPointer());
		return true;
	}
	else {
		OTLog::Error("Invalid Checksum in OTPayload::GetMessage\n");
		return false;
	}
}
  void GetImageStatisticsInvalid()
  {
    CreateNodeRelationImage(m_statisticsContainer.GetPointer(), m_image.GetPointer());

    CPPUNIT_ASSERT_THROW(mitk::ImageStatisticsContainerManager::GetImageStatistics(nullptr, m_image.GetPointer()), mitk::Exception);

    auto standaloneDataStorage = mitk::StandaloneDataStorage::New();

    CPPUNIT_ASSERT_THROW(mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), nullptr), mitk::Exception);
    CPPUNIT_ASSERT_THROW(mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), nullptr, m_mask.GetPointer()), mitk::Exception);
    CPPUNIT_ASSERT_THROW(mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), nullptr, m_planarFigure.GetPointer()), mitk::Exception);
  }
Ejemplo n.º 3
0
HRESULT CMfxBufferFactory::CreateCopy( MFX_HBUFFER hbufOld, DWORD dwLength, MFX_HBUFFER* phbufNew )
{
	void*	pvSrc;
	void* pvDst;
	DWORD	cbSrc, cbDst;

	CHECK( GetPointer( hbufOld, &pvSrc, &cbSrc ) );
	CHECK( Create( dwLength, phbufNew ) );
	CHECK( GetPointer( *phbufNew, &pvDst, &cbDst ) );

	memcpy( pvDst, pvSrc, min( cbSrc, cbDst ) );

	return S_OK;
}
Ejemplo n.º 4
0
bool OTPayload::SetMessage(const OTMessage & theMessage)
{
	uint32_t lSize = theMessage.m_strRawFile.GetLength()+1; //+1 for the null terminater
	
	if (theMessage.m_strRawFile.GetLength())
	{
		SetPayloadSize(lSize + 1); // +1 for the checksum byte.
		memcpy((void *)GetPointer(), theMessage.m_strRawFile.Get(), lSize);
		
		// Add the checksum
		AppendChecksum( (OT_BYTE*)GetPointer(), lSize );
		return true;
	}
	return false;
}
Ejemplo n.º 5
0
void DoState(PointerWrap &p)
{
	auto s = p.Section("Memory", 1, 2);
	if (!s)
		return;

	if (s < 2) {
		if (!g_RemasterMode)
			g_MemorySize = RAM_NORMAL_SIZE;
		g_PSPModel = PSP_MODEL_FAT;
	} else {
		u32 oldMemorySize = g_MemorySize;
		p.Do(g_PSPModel);
		p.DoMarker("PSPModel");
		if (!g_RemasterMode) {
			g_MemorySize = g_PSPModel == PSP_MODEL_FAT ? RAM_NORMAL_SIZE : RAM_DOUBLE_SIZE;
			if (oldMemorySize < g_MemorySize) {
				Shutdown();
				Init();
			}
		}
	}

	p.DoArray(GetPointer(PSP_GetKernelMemoryBase()), g_MemorySize);
	p.DoMarker("RAM");

	p.DoArray(m_pVRAM, VRAM_SIZE);
	p.DoMarker("VRAM");
	p.DoArray(m_pScratchPad, SCRATCHPAD_SIZE);
	p.DoMarker("ScratchPad");
}
Ejemplo n.º 6
0
JNIEXPORT void JNICALL Java_com_aio4c_Connection_close(JNIEnv* jvm, jobject connection, jboolean force) {
    void* myConnection = NULL;

    GetPointer(jvm, connection, &myConnection);

    ConnectionClose(myConnection, force);
}
Ejemplo n.º 7
0
/**
 * Contiguous Fetch.
 * The simple API is blocking, which is perfect for tracter.  Fab.
 */
Tracter::SizeType
Tracter::PulseAudioSource::ContiguousFetch(
    IndexType iIndex, SizeType iLength, SizeType iOffset
)
{
    if (mMaxIndex)
        if (iIndex > mMaxIndex)
            return 0;

    /* I'm assuming that it reads a whole buffer-full here */
    int error;
    int ret = pa_simple_read(
        mHandle,
        GetPointer(iOffset),
        iLength * sizeof(float),
        &error
    );
    if (ret < 0)
        throw Exception("%s: Failed to read %d samples. %s",
                        mObjectName, iLength, pa_strerror(error));

    if (mMaxIndex)
        if (iIndex + iLength > mMaxIndex)
            return mMaxIndex - iIndex;
    return iLength;
}
Ejemplo n.º 8
0
bool Entity::IsValid()
{
	if( !GetPointer() )
		return false;

	if( !GetBoneMatrix() )
		return false;

	if( !GetTeamNum() )
		return false;

	if( IsDead() )
		return false;

	if( IsDormant() )
		return false;

	if( GetOrigin().IsZero() )
		return false;

	if( GetHealth() < 1 )
		return false;

	return true;
}
Ejemplo n.º 9
0
void OTIdentifier::CopyTo(uint8_t * szNewLocation) const
{
	if (GetSize())
	{
		memcpy((void*)GetPointer(), szNewLocation, GetSize()); // todo cast
	}
}
Ejemplo n.º 10
0
JNIEXPORT void JNICALL Java_com_aio4c_Connection_enableWriteInterest(JNIEnv* jvm, jobject connection) {
    void* myConnection = NULL;

    GetPointer(jvm, connection, &myConnection);

    EnableWriteInterest(myConnection);
}
Ejemplo n.º 11
0
void CBotVar::SetInit(int bInit)
{
    m_binit = bInit;
    if ( bInit == 2 ) m_binit = IS_DEF;                    // cas spécial

    if ( m_type.Eq(CBotTypPointer) && bInit == 2 )
    {
        CBotVarClass* instance = GetPointer();
        if ( instance == NULL )
        {
            instance = new CBotVarClass(NULL, m_type);
//            instance->SetClass((static_cast<CBotVarPointer*>(this))->m_pClass);
            SetPointer(instance);
        }
        instance->SetInit(1);
    }

    if ( m_type.Eq(CBotTypClass) || m_type.Eq(CBotTypIntrinsic) )
    {
        CBotVar*    p = (static_cast<CBotVarClass*>(this))->m_pVar;
        while( p != NULL )
        {
            p->SetInit( bInit );
            p->m_pMyThis = static_cast<CBotVarClass*>(this);
            p = p->GetNext();
        }
    }
}
Ejemplo n.º 12
0
void CKConfig::Commit() const
{
    if ( rc_t rc = KConfigCommit(const_cast<KConfig*>(GetPointer())) ) {
        NCBI_THROW2(CSraException, eOtherError,
                    "CKConfig: Cannot commit config changes", rc);
    }
}
Ejemplo n.º 13
0
void CBotVar::SetInit(CBotVar::InitType initType)
{
    m_binit = initType;
    if (initType == CBotVar::InitType::IS_POINTER ) m_binit = CBotVar::InitType::DEF;                    // cas spécial

    if ( m_type.Eq(CBotTypPointer) && initType == CBotVar::InitType::IS_POINTER )
    {
        CBotVarClass* instance = GetPointer();
        if ( instance == nullptr )
        {
            instance = new CBotVarClass(CBotToken(), m_type);
//            instance->SetClass((static_cast<CBotVarPointer*>(this))->m_classes);
            SetPointer(instance);
        }
        instance->SetInit(CBotVar::InitType::DEF);
    }

    if ( m_type.Eq(CBotTypClass) || m_type.Eq(CBotTypIntrinsic) )
    {
        CBotVar*    p = (static_cast<CBotVarClass*>(this))->m_pVar;
        while( p != nullptr )
        {
            p->SetInit(initType);
            p->m_pMyThis = static_cast<CBotVarClass*>(this);
            p = p->GetNext();
        }
    }
}
Ejemplo n.º 14
0
AudioSamplePtr ETHAudioResourceManager::GetPointer(AudioPtr audio,
										  const str_type::string &fileRelativePath, const str_type::string &programPath,
										  const str_type::string &searchPath, const GS_SAMPLE_TYPE type)
{
	if (fileRelativePath == GS_L(""))
		return AudioSamplePtr();

	if (!m_resource.empty())
	{
		str_type::string fileName = ETHGlobal::GetFileName(fileRelativePath);
		std::map<str_type::string, AudioSamplePtr>::iterator iter = m_resource.find(fileName);
		if (iter != m_resource.end())
			return iter->second;
	}

	// we can set a search path to search the file in case
	// it hasn't been loaded yet
	if (searchPath != GS_L(""))
	{
		str_type::string fileName = ETHGlobal::GetFileName(fileRelativePath);

		str_type::string path = programPath;
		path += searchPath;
		path += fileName;
		AddFile(audio, path, type);
		return GetPointer(audio, fileName, programPath, GS_L(""), type);
	}
	return AudioSamplePtr();
}
Ejemplo n.º 15
0
static Buffer* _GetBuffer(JNIEnv* jvm, jobject buffer) {
    void* _buffer = NULL;

    GetPointer(jvm, buffer, &_buffer);

    return (Buffer*)_buffer;
}
Ejemplo n.º 16
0
/**
 * Fetch speaker ID.  This is done by sending a timestamp to the
 * server.  It should respond immediately with a speaker ID, otherwise
 * everything will grind to a halt.
 */
bool Tracter::SpeakerIDSocketSource::UnaryFetch(IndexType iIndex, int iOffset)
{
    assert(mFrame.size == 1);

    Verbose(2, "Fetching SpeakerID for index %ld\n", iIndex);
    char* cache = (char*)GetPointer(iOffset);

    // Send time stamp to the socket: converting from nanoseconds
    // to milliseconds
    //TimeType timestamp = ( TimeStamp(0)+TimeOffset(iIndex) ) / 1000000;
    //TimeType timestamp = TimeStamp(iIndex) / 1000000;  ///<--- This doesn't seem to work!
    // PNG: Incoming index is absoute time in seconds
    TimeType timestamp = (TimeType)iIndex * ONEe3 + mTimeOffset;
    Verbose(2, "Sending time %lld ms\n", timestamp);
#if 1
    mSocket.Send(sizeof(TimeType), (char*)&timestamp);

    // Read the data from the socket
    Verbose(2, "Waiting for response\n");
    int nGet = sizeof(float);
    int nGot = mSocket.Receive(nGet, cache);
    Verbose(2, "Got %d bytes\n", (int)nGot);
    if (nGot < nGet)
        return false;
#else
    arraySize += 1; //dummy
    cache[0] = 'a';
    cache[1] = 'b';
    cache[2] = 'c';
    cache[3] = 0;
#endif

    return true;
}
Ejemplo n.º 17
0
MCmdParamBlob* CommandToBlob(MCommand& Command)
{
	size_t BlobSize = Command.GetSize();
	auto Param = new MCmdParamBlob(BlobSize);
	Command.GetData(static_cast<char*>(Param->GetPointer()), BlobSize);
	return Param;
}
Ejemplo n.º 18
0
static
PyObject* getPointer(PyObject* self, PyObject* args) {
    PyObject* obj;
    if (!PyArg_ParseTuple(args, "O", &obj)){
        return NULL;
    }
    return GetPointer(obj);
}
Ejemplo n.º 19
0
void CopyFromEmu(void* data, u32 address, size_t size)
{
    if (!ValidCopyRange(address, size))
    {
        PanicAlert("Invalid range in CopyFromEmu. %lx bytes from 0x%08x", (unsigned long)size, address);
        return;
    }
    memcpy(data, GetPointer(address), size);
}
Ejemplo n.º 20
0
// This method implements the (ripemd160 . sha256) hash,
// so the result is 20 bytes long.
bool Identifier::CalculateDigest(const unsigned char* data, size_t len)
{
    // The Hash160 function comes from the Bitcoin reference client, where
    // it is implemented as RIPEMD160 ( SHA256 ( x ) ) => 20 byte hash
    auto hash160 = Hash160(data, data + len);
    SetSize(20);
    memcpy(const_cast<void*>(GetPointer()), hash160, 20);
    return true;
}
Ejemplo n.º 21
0
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT iMessage, WPARAM wParam,
											LPARAM lParam )
{
	// Pointer to the (C++ object that is the) window.
	Window *pWindow = GetPointer( hWnd );
	TMSG Msg={iMessage,wParam,lParam,0};
	if (pWindow->WndProc(Msg)) return Msg.RetVal;
	return pWindow->DefProc( hWnd, iMessage, wParam, lParam );
}
Ejemplo n.º 22
0
void CopyToEmu(u32 address, const void* data, size_t size)
{
    if (!ValidCopyRange(address, size))
    {
        PanicAlert("Invalid range in CopyToEmu. %lx bytes to 0x%08x", (unsigned long)size, address);
        return;
    }
    memcpy(GetPointer(address), data, size);
}
Ejemplo n.º 23
0
void __fastcall TInputGroupBox::TInputGroupBoxConvertToDecNumMenuItemOnClick(TObject*)
{
    //TODO: Add your source code here
unsigned long num;
num=0;
num=GetPointer();
TypeBox->ItemIndex=DEC_NUM;
TextBox->Text=AnsiString(ulongToAnsi(num).c_str());
}
Ejemplo n.º 24
0
JNIEXPORT jboolean JNICALL Java_com_aio4c_Connection_closing(JNIEnv* jvm, jobject connection) {
    void* pConnection = NULL;
    Connection* myConnection = NULL;

    GetPointer(jvm, connection, &pConnection);
    myConnection = (Connection*)pConnection;

    return (jboolean)(myConnection->state == AIO4C_CONNECTION_STATE_PENDING_CLOSE);
}
Ejemplo n.º 25
0
void CVDBCursor::SetParam(const char* name, const CTempString& value) const
{
    if ( rc_t rc = VCursorParamsSet
         ((struct VCursorParams *)GetPointer(),
          name, "%.*s", value.size(), value.data()) ) {
        NCBI_THROW2_FMT(CSraException, eNotFound,
                        "Cannot set VDB cursor param: "<<*this<<": "<<name,
                        rc);
    }
}
Ejemplo n.º 26
0
	CGparameter	IOGLBaseShader::GetParameter(const CString& strName) const{
		auto szName = String::ToANSI(strName);

		auto uParam = cgGetNamedParameter(this->m_uProgram, reinterpret_cast<const char*>(szName.GetPointer()));
		if(uParam == 0 || !cgIsParameter(uParam)){
			CR_THROW(L"Failed to find parameter: " + strName);
		}

		return uParam;
	}
Ejemplo n.º 27
0
// Envelope retrieved from payload.
bool OTPayload::GetEnvelope(OTEnvelope & theEnvelope) const
{
	// validate checksum
	uint32_t lSize = GetSize();
	uint32_t lIndex = lSize-2; // the index to where the NULL terminator SHOULD be if they
						  // sent us a base64-encoded string, containing an encrypted message. (which we expect...)

	// (lSize-1 would be the location of the checksum at the end.)
	if (0 == lSize)
		return false;

	if (IsChecksumValid((OT_BYTE*)GetPointer(), (uint32_t)lSize))
	{
		// We add the null-terminator ourselves at this point, for security reasons,
		// since we will process the data, soon after this function, as a string.
		((OT_BYTE *)GetPointer())[lIndex] = 0;

		theEnvelope.m_dataContents.Release();

		OTASCIIArmor theArmor;
		// Why is this safe, where I cast the Payload data pointer as
		// a char * and tell the data object to set itself from that?
		// Because (1) I just validated the checksum, and
		// (2) There place where the NULL should be, I set to 0, by hand,
		// just above 2 lines. So when this set operation occurs, the
		// farthest it will go is to that 0.
		theArmor.Set((const char *)GetPointer());

		// Todo NOTE: If I ever want to process bookends here instead of assuming they aren't there,
		// IT'S VERY EASY!! All I have to do is call theArmor.LoadFromString instead of theArmor.Set.

		// Now the ascii-armored string that was sent across is decoded back to binary into the
		// Envelope object.
		theEnvelope.SetAsciiArmoredData(theArmor);
		return true;
	}
	else
    {
		OTLog::Error("Invalid Checksum in OTPayload::GetEnvelope\n");
		return false;
	}
}
Ejemplo n.º 28
0
Tracter::SizeType
Tracter::Normalise::Fetch(IndexType iIndex, CacheArea& iOutputArea)
{
    assert(iIndex >= 0);
    assert(mFrame.size);
    CacheArea inputArea;
    SizeType lenGot = mInput->Read(inputArea, iIndex, iOutputArea.Length());
    short* input = mInput->GetPointer(inputArea.offset);
    float* output = GetPointer(iOutputArea.offset);

    SizeType rOffset = 0;
    SizeType wOffset = 0;
    for (SizeType i=0; i<lenGot; i++)
    {
        if (i == inputArea.len[0])
        {
            input = mInput->GetPointer(0);
            rOffset = 0;
        }
        if (i == iOutputArea.len[0])
        {
            output = GetPointer(0);
            wOffset = 0;
        }

        if (mByteOrder.WrongEndian())
            for (int j=0; j<mFrame.size; j++)
            {
                // Inefficient!
                short s = input[rOffset++];
                mByteOrder.Swap(&s, 2, 1);
                output[wOffset++] = (float)s / 32768.0f;
            }
        else
            for (int j=0; j<mFrame.size; j++)
            {
                output[wOffset++] = (float)input[rOffset++] / 32768.0f;
            }
    }

    return lenGot;
}
Ejemplo n.º 29
0
unsigned        DIGENTRY DIPImpModName( imp_image_handle *ii,
                        imp_mod_handle im, char *buff, unsigned max )
{
    ji_ptr      name;
    unsigned    len;

    name = GetPointer( ii->cc + offsetof( ClassClass, name ) );
    len = GetString( name, NameBuff, sizeof( NameBuff ) );
    NormalizeClassName( NameBuff, len );
    return( NameCopy( buff, NameBuff, max, len ) );
}
Ejemplo n.º 30
0
/*************
 * DESCRIPTION:   Gets the paramters from the argument list.
 *    Parses the arguments with a argument description.
 * INPUT:         list     argument list
 * OUTPUT:        TRUE if failed else FALSE
 *************/
BOOL GetParams(va_list *list, PARAM *para)
{
	BOOL done = FALSE, identified = FALSE;
	PARAM *curpara;
	int type;
	int ret = FALSE;

	while(!done)
	{
		// Watcom seems to have a bug
#ifdef __WATCOMC__
		type = *((ULONG*)(**list));
#else
		type = *((ULONG*)(*list));
#endif
		if(type == rsiTDone)
		{
			done = TRUE;
			continue;
		}
		va_arg(*list,int);
		if(type == rsiTMore)
		{
			*list = *((va_list*)(*list));
			continue;
		}

		curpara = para;
		while(curpara->tag_id != rsiTDone)
		{
			if(curpara->tag_id == type)
			{
				identified = TRUE;
				switch(curpara->type)
				{
					case rsiTypeInt:
						*((int*)curpara->data) = GetInt(list);
						break;
					case rsiTypeFloat:
						*((float*)curpara->data) = GetFloat(list);
						break;
					case rsiTypePointer:
						*((void**)curpara->data) = GetPointer(list);
						break;
				}
			}
			curpara++;
		}
		if(!identified)
			return TRUE;
	}
	va_end(*list);
	return ret;
}