コード例 #1
0
    virtual void bytesReady( size_t offset, const dp::Data& data, bool eof )
    {
        if( !data.isNull() )
        {
            size_t buflen;
            const unsigned char * buf = data.data(&buflen);

            if (offset != data_bytes_read_) 
            {
                reportError("Stream received non-sequentially");
                return;
            }

            if (data_capacity_ < data_bytes_read_ + buflen) 
            {

                data_capacity_ = data_bytes_read_ + buflen;
                unsigned char * tmp = new unsigned char[data_capacity_];
                if (data_read_)
                {
                    ::memcpy(tmp, data_read_, data_bytes_read_);
                    delete[] data_read_;
                }
                data_read_ = tmp;
            }

            memcpy(data_read_ + data_bytes_read_, buf, buflen);
            data_bytes_read_ += buflen;
        }
    }
コード例 #2
0
ファイル: curlnetprovider.cpp プロジェクト: bq/cervantes
	virtual void bytesReady( size_t offset, const dp::Data& data, bool eof )
	{
		if( !data.isNull() )
		{
			size_t buflen;
			const unsigned char * buf = data.data(&buflen);

			if (offset != m_DataBytesRead) 
			{
				reportError("Stream received non-sequentially");
				return;
			}

			if (m_DataCapacity < m_DataBytesRead + buflen) 
			{

				m_DataCapacity = m_DataBytesRead + buflen;
				unsigned char * tmp = new unsigned char[m_DataCapacity];
				if (m_pDataRead)
				{
					::memcpy(tmp, m_pDataRead, m_DataBytesRead);
					delete[] m_pDataRead;
				}
				m_pDataRead = tmp;
			}

			if( m_verbose )
				reportData( "out", offset, data );

			memcpy(m_pDataRead + m_DataBytesRead, buf, buflen);
			m_DataBytesRead += buflen;
		}
	}
コード例 #3
0
ファイル: curlnetprovider.cpp プロジェクト: bq/cervantes
	void reportData( const char * dir, size_t offset, const dp::Data& data )
	{
		printf("Stream %08x %s offset=%d\n", this, dir, offset );
		size_t len;
		size_t i;
		const unsigned char * p = data.data(&len);
		for( i = 0 ; i < len && i < 4096 ; i++ )
		{
			if( p[i] == '\n' || p[i] == '\t' || (' ' <= p[i] && p[i] < 0x7F) )
					putchar( p[i] );
			else
					putchar( '.' );
		}
		if( i < len )
			printf("...[%d bytes]...", (len-i));
		printf("\n");
	}