Пример #1
0
bool XMLElement::SetBuffer(const String& name, const PODVector<unsigned char>& value)
{
    if (!value.Size())
        return SetAttribute(name, String::EMPTY);
    else
        return SetBuffer(name, &value[0], value.Size());
}
Пример #2
0
bool XMLElement::SetBuffer(const ea::string& name, const ea::vector<unsigned char>& value)
{
    if (!value.size())
        return SetAttribute(name, EMPTY_STRING);
    else
        return SetBuffer(name, &value[0], value.size());
}
Пример #3
0
String::String(const String& other) :
m_Buffer(NULL),
m_BufferSize(NULL),
m_Length(NULL)
{
	SetBuffer(other.GetBuffer());
}
Пример #4
0
	/// <summary>Read the full method from the supplied buffer.</summary>
	void Method::ReadMethod(IMAGE_COR_ILMETHOD* pMethod)
	{
		BYTE* pCode;
		auto fatImage = static_cast<COR_ILMETHOD_FAT*>(&pMethod->Fat);
		if (!fatImage->IsFat())
		{
			#ifdef TRACE_ENABLED
			ATLTRACE(_T("TINY"));
			#endif
			auto tinyImage = static_cast<COR_ILMETHOD_TINY*>(&pMethod->Tiny);
			m_header.CodeSize = tinyImage->GetCodeSize();
			pCode = tinyImage->GetCode();
			#ifdef TRACE_ENABLED
			ATLTRACE(_T("TINY(%X) => (%d + 1) : %d"), m_header.CodeSize, m_header.CodeSize, m_header.MaxStack);
			#endif		
		}
		else
		{
			memcpy(&m_header, pMethod, fatImage->Size * sizeof(DWORD));
			pCode = fatImage->GetCode();
			#ifdef TRACE_ENABLED
			ATLTRACE(_T("FAT(%X) => (%d + 12) : %d"), m_header.CodeSize, m_header.CodeSize, m_header.MaxStack);
			#endif
		}
		SetBuffer(pCode);
		ReadBody();
	}
Пример #5
0
String::String(void) :
m_Buffer(NULL),
m_BufferSize(NULL),
m_Length(NULL)
{
	SetBuffer(L"");
}
Пример #6
0
Sound& Sound::operator =(const Sound& right)
{
    // Here we don't use the copy-and-swap idiom, because it would mess up
    // the list of sound instances contained in the buffers

    // Detach the sound instance from the previous buffer (if any)
    if (myBuffer)
    {
        Stop();
        myBuffer->DetachSound(this);
        myBuffer = NULL;
    }

    // Copy the sound attributes
    if (right.myBuffer)
        SetBuffer(*right.myBuffer);
    SetLoop(right.GetLoop());
    SetPitch(right.GetPitch());
    SetVolume(right.GetVolume());
    SetPosition(right.GetPosition());
    SetRelativeToListener(right.IsRelativeToListener());
    SetMinDistance(right.GetMinDistance());
    SetAttenuation(right.GetAttenuation());

    return *this;
}
Пример #7
0
String::String(const wchar_t* buffer) :
m_Buffer(NULL),
m_BufferSize(NULL),
m_Length(NULL)
{
	SetBuffer(buffer);
}
Пример #8
0
//===========================================================================
int CSerialThread::m_InitSerialThread( ){

  int iRet;

  if( m_hSerialThread ) {
    CP_printf("Error in m_InitSerialThread()! Thread is already running.\n");
    return 1;
  }

  // Init sliding buffer
  SetBuffer(sizeof(IScanData), ISCAN_BUFFER_SIZE);
  CP_printf("Connecting to %s port\n", x_aszComNames[ m_iComPortIdx-1]);
  iRet = m_Serial.connect(x_aszComNames[ m_iComPortIdx-1], m_iBaudRate, m_iSerialParity);
  if(iRet) {
    CP_printf("Error in m_InitSerialThread, m_Serial.connect() failed\n");
    return 1;
  }

  ResetTimeAndBuffer();
  m_hSerialThread = CreateThread( NULL,  // pointer to security attributes
                                        0,  // initial thread stack size
                                        m_SerialThread, // pointer to thread function
                                        (LPVOID) this,  // argument for new thread
                                        0,  // no specific creation flags
                                        &m_dwThreadId ); // pointer to receive thread ID

  if( !m_hSerialThread ) {
    CP_printf("Error in m_InitSerialThread()! CreateThread() failed.\n");
    return 1;
  }
  return 0;
}
Пример #9
0
HRESULT StringBuffer::Concat(__deref_in const WCHAR* pszString, __in_z const UINT &length)
{
    if (!m_pszString)
    {
        return SetBuffer(pszString, length);
    }
        
    if (length > 0)
    {
        size_t actualLen = wcslen(m_pszString);
        size_t newSize = (actualLen + length + 1) * sizeof(WCHAR);

        WCHAR* temp = (WCHAR*)realloc(m_pszString, newSize);

        if (!temp)
        {
            return E_OUTOFMEMORY;
        }

        m_pszString = temp;
        memcpy(m_pszString + actualLen, pszString, (length + 1) * sizeof(WCHAR));
    }

    return S_OK;
}
Пример #10
0
 CMediaBufferDecode(const BYTE *pData, DWORD dwLength) 
   : CMediaBuffer(NULL, 0, false)
 {
   m_pBuffer = (BYTE *)av_malloc(dwLength + FF_INPUT_BUFFER_PADDING_SIZE);
   memcpy(m_pBuffer, pData, dwLength);
   SetBuffer(m_pBuffer, dwLength);
 }
Пример #11
0
void JSONValue::SetBuffer(const String& name, const PODVector<unsigned char>& value)
{
    if (!value.Size())
        SetString(name, String::EMPTY);
    else
        SetBuffer(name, &value[0], value.Size());
}
Пример #12
0
Sound::Sound(const Sound& copy) :
SoundSource(copy),
myBuffer   (NULL)
{
    if (copy.myBuffer)
        SetBuffer(*copy.myBuffer);
    SetLoop(copy.GetLoop());
}
Пример #13
0
////////////////////////////////////////////////////////////
/// Bind a sound buffer to a sound
////////////////////////////////////////////////////////////
void sfSound_SetBuffer(sfSound* Sound, sfSoundBuffer* Buffer)
{
    if (Buffer)
    {
        CSFML_CALL(Sound, SetBuffer(Buffer->This))
        Sound->Buffer = Buffer;
    }
}
Пример #14
0
	void Source::SetBuffer(Buffer* value)
	{
	    #ifdef HAS_AUDIO_SOURCE
		impl->SetBuffer(value);
		#else
        (void)value;
		throw System::PunkException(L"Audio source is not available");
		#endif
	}
Пример #15
0
Sound::Sound(const SoundBuffer& buffer, bool loop, float pitch, float volume, const Vector3f& position) :
myBuffer(NULL)
{
    SetBuffer(buffer);
    SetLoop(loop);
    SetPitch(pitch);
    SetVolume(volume);
    SetPosition(position);
}
Пример #16
0
KaxBlockVirtual::KaxBlockVirtual(const KaxBlockVirtual & ElementToClone)
 :EbmlBinary(ElementToClone)
 ,Timecode(ElementToClone.Timecode)
 ,TrackNumber(ElementToClone.TrackNumber)
 ,ParentCluster(ElementToClone.ParentCluster) ///< \todo not exactly
{
    SetBuffer(DataBlock,sizeof(DataBlock));
    SetValueIsSet(false);
}
Пример #17
0
CTokenBufferInfo::CTokenBufferInfo(CTokenParser* Parser, char* pTxt)
  {
  bUseLineEnd = 0;
  pParser = Parser;
  pBigBuff = NULL;
  bMyBigBuff = 0;
  SetParameters();
  SetBuffer(pTxt);
  }
Пример #18
0
static void TXT_SpinControlDrawer(TXT_UNCAST_ARG(spincontrol), int selected)
{
    TXT_CAST_ARG(txt_spincontrol_t, spincontrol);
    unsigned int i;
    unsigned int padding;

    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
    TXT_BGColor(TXT_COLOR_BLUE, 0);

    TXT_DrawString("\x1b ");

    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    // Choose background color

    if (selected && spincontrol->editing)
    {
        TXT_BGColor(TXT_COLOR_BLACK, 0);
    }
    else if (selected)
    {
        TXT_BGColor(TXT_COLOR_GREY, 0);
    }
    else
    {
        TXT_BGColor(TXT_COLOR_BLUE, 0);
    }

    if (!spincontrol->editing)
    {
        SetBuffer(spincontrol);
    }

    i = 0;

    padding = spincontrol->widget.w - strlen(spincontrol->buffer) - 4;

    while (i < padding)
    {
        TXT_DrawString(" ");
        ++i;
    }

    TXT_DrawString(spincontrol->buffer);
    i += strlen(spincontrol->buffer);

    while (i < spincontrol->widget.w - 4)
    {
        TXT_DrawString(" ");
        ++i;
    }

    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
    TXT_BGColor(TXT_COLOR_BLUE, 0);
    TXT_DrawString(" \x1a");
}
Пример #19
0
  /**
   * Swap in the old "virtual buffer" (see above) attributes in aNew*
   * and return the old ones in aOld*.
   *
   * Swap() must only be called when the buffer is in its "unmapped"
   * state, that is the underlying gfxASurface is not available.  It
   * is expected that the owner of this buffer holds an unmapped
   * SurfaceDescriptor as the backing storage for this buffer.  That's
   * why no gfxASurface or SurfaceDescriptor parameters appear here.
   */
  void Swap(const nsIntRect& aNewRect, const nsIntPoint& aNewRotation,
            nsIntRect* aOldRect, nsIntPoint* aOldRotation)
  {
    *aOldRect = BufferRect();
    *aOldRotation = BufferRotation();

    nsRefPtr<gfxASurface> oldBuffer;
    oldBuffer = SetBuffer(nullptr, aNewRect, aNewRotation);
    MOZ_ASSERT(!oldBuffer);
  }
Пример #20
0
CStream::CStream()
{
	m_BufferReadPoint = 0;
	m_BufferWritePoint = 0;
	SetBuffer(BUF_SIZE);
	ClearRecvBuffer();
	ClearSendBuffer();
	ResetRecvPoint();
	ResetSendPoint();
}
Пример #21
0
void DoBuffer(struct Buffer *b, int x, int y, int dx, int w, int xn,
	      int yn)
{
	SetBuffer(x + xn, y + yn, b, w);
	if (fLOS) {
		LineOfSight(x, y, b, IS_SHADOW);
		FixBuffer(b, IS_SHADOW);
	}
	DrawBuffer(b, dx);
}
Пример #22
0
static void TXT_SpinControlDrawer(TXT_UNCAST_ARG(spincontrol))
{
    TXT_CAST_ARG(txt_spincontrol_t, spincontrol);
    unsigned int i;
    unsigned int padding;
    int focused;

    focused = spincontrol->widget.focused;

    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
    TXT_BGColor(TXT_WINDOW_BACKGROUND, 0);

    TXT_DrawString("\x1b ");
    
    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    // Choose background color

    if (focused && spincontrol->editing)
    {
        TXT_BGColor(TXT_COLOR_BLACK, 0);
    }
    else
    {
        TXT_SetWidgetBG(spincontrol);
    }

    if (!spincontrol->editing)
    {
        SetBuffer(spincontrol);
    }
    
    i = 0;

    padding = spincontrol->widget.w - strlen(spincontrol->buffer) - 4;

    while (i < padding)
    {
        TXT_DrawString(" ");
        ++i;
    }

    TXT_DrawString(spincontrol->buffer);
    i += strlen(spincontrol->buffer);

    while (i < spincontrol->widget.w - 4)
    {
        TXT_DrawString(" ");
        ++i;
    }

    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
    TXT_BGColor(TXT_WINDOW_BACKGROUND, 0);
    TXT_DrawString(" \x1a");
}
Пример #23
0
	/*!
	* \brief Loads the sound from file
	* \return true if loading is successful
	*
	* \param filePath Path to the file
	* \param params Parameters for the sound
	*
	* \remark Produces a NazaraError if loading failed
	*/
	bool Sound::LoadFromFile(const String& filePath, const SoundBufferParams& params)
	{
		SoundBufferRef buffer = SoundBuffer::New();
		if (!buffer->LoadFromFile(filePath, params))
		{
			NazaraError("Failed to load buffer from file (" + filePath + ')');
			return false;
		}

		SetBuffer(buffer);
		return true;
	}
Пример #24
0
	/*!
	* \brief Loads the sound from memory
	* \return true if loading is successful
	*
	* \param data Raw memory
	* \param size Size of the memory
	* \param params Parameters for the sound
	*
	* \remark Produces a NazaraError if loading failed
	*/
	bool Sound::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params)
	{
		SoundBufferRef buffer = SoundBuffer::New();
		if (!buffer->LoadFromMemory(data, size, params))
		{
			NazaraError("Failed to load buffer from memory (" + String::Pointer(data) + ')');
			return false;
		}

		SetBuffer(buffer);
		return true;
	}
Пример #25
0
	/*!
	* \brief Loads the sound from stream
	* \return true if loading is successful
	*
	* \param stream Stream to the sound
	* \param params Parameters for the sound
	*
	* \remark Produces a NazaraError if loading failed
	*/
	bool Sound::LoadFromStream(Stream& stream, const SoundBufferParams& params)
	{
		SoundBufferRef buffer = SoundBuffer::New();
		if (!buffer->LoadFromStream(stream, params))
		{
			NazaraError("Failed to load buffer from stream");
			return false;
		}

		SetBuffer(buffer);
		return true;
	}
Пример #26
0
static void sync_audio(SNDBUF hbuff, int buffsize)
{
    SND_EVENT   evnt;
    uint32_t    offset;
    double      time_stamp;

#ifdef BLACK_MAGIC_SOUND

    while( player_state != CLOSED)
    {
        GetNotify(&evnt);

        if(evnt.code != 0xFF000001)
        {
            printf("invalid event code %d\n\r", evnt.code);
            continue;
        }

        if(evnt.stream != hbuff)
        {
            printf("invalid stream %x hBuff= %x\n\r",
                    evnt.stream, hbuff);
            continue;
        }

        GetTimeStamp(hbuff, &time_stamp);
        audio_delta = time_stamp - last_time_stamp;

        offset = evnt.offset;

        mutex_lock(&astream.lock);
        {
            if(astream.count < buffsize)
            {
                memset(astream.buffer+astream.count,
                       0, buffsize-astream.count);
                astream.count = buffsize;
            };

            SetBuffer(hbuff, astream.buffer, offset, buffsize);
            samples_written+= buffsize/4;

            astream.count -= buffsize;
            if(astream.count)
                memcpy(astream.buffer, astream.buffer+buffsize, astream.count);
            mutex_unlock(&astream.lock);
        };
        break;
    };
#endif

};
Пример #27
0
 /*!
  * Change the size of the register value, truncating or zero-extending the value
  * as necessary.
  *
  *  @param[in] size     New size (bits).
  */
 void Resize(unsigned size)
 {
     if (_size <= 8*sizeof(FUND::PTRINT))
     {
         Set64(_value, size);
     }
     else
     {
         UTIL::DATA *d = _bigValue;
         SetBuffer(d->GetBuf<void>(), d->GetSize(), size);
         delete d;
     }
 }
Пример #28
0
void
ContentClientRemote::SetBackingBuffer(gfxASurface* aBuffer,
                                      const nsIntRect& aRect,
                                      const nsIntPoint& aRotation)
{
#ifdef DEBUG
  gfxIntSize prevSize = gfxIntSize(BufferRect().width, BufferRect().height);
  gfxIntSize newSize = aBuffer->GetSize();
  NS_ABORT_IF_FALSE(newSize == prevSize,
                    "Swapped-in buffer size doesn't match old buffer's!");
#endif
  nsRefPtr<gfxASurface> oldBuffer;
  oldBuffer = SetBuffer(aBuffer, aRect, aRotation);
}
Пример #29
0
static bool SetREPARSE_DATA_BUFFER(const string& Object, REPARSE_DATA_BUFFER* rdb)
{
	if (!IsReparseTagValid(rdb->ReparseTag))
		return false;

	SCOPED_ACTION(os::security::privilege){ SE_CREATE_SYMBOLIC_LINK_NAME };

	const auto Attributes = os::fs::get_file_attributes(Object);
	if(Attributes&FILE_ATTRIBUTE_READONLY)
	{
		os::fs::set_file_attributes(Object, Attributes&~FILE_ATTRIBUTE_READONLY);
	}

	SCOPE_EXIT
	{
		if (Attributes&FILE_ATTRIBUTE_READONLY)
			os::fs::set_file_attributes(Object, Attributes);
	};

	const auto& SetBuffer = [&](bool ForceElevation)
	{
		const os::fs::file fObject(Object, GetDesiredAccessForReparsePointChange(), 0, nullptr, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT, nullptr, ForceElevation);
		DWORD dwBytesReturned;
		return fObject && fObject.IoControl(FSCTL_SET_REPARSE_POINT, rdb, rdb->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE, nullptr, 0, &dwBytesReturned);
	};

	if (SetBuffer(false))
		return true;

	if (ElevationRequired(ELEVATION_MODIFY_REQUEST))
	{
		// Open() succeeded, but IoControl() failed. We can't handle this automatically :(
		return SetBuffer(true);
	}

	return false;
}
Пример #30
0
//==============================================================================
int CEyeTrack::ConnectISCAN(  ){
  int iRet;

  if( IsRunning() ) {
    CP_printf("Error in m_InitSerialThread()! Thread is already running.\n");
    return 1;
  }
  iRet = g_SysGrantIO( LPT_BASE );
  if( iRet ) {
    iPortIO_Granted = 0;
    printf("Error: Cannot grant I/O access, error: %d\n", iRet );
    return 1;
  }
 
  iPortIO_Granted = 1;
  PortOutput( LPT_CONTROL, RESET_ON);
  Sleep(1);
  PortOutput( LPT_CONTROL, GATE_OFF);
  Sleep(1);
  PortOutput( LPT_CONTROL, GATE_ON);


  CP_printf("Connecting to %s port\n", x_aszComNames[ m_iComPortIdx-1]);
  iRet = m_Serial.connect(x_aszComNames[ m_iComPortIdx-1], m_iBaudRate, m_iSerialParity);
  if(iRet) {
    CP_printf("Error in m_InitSerialThread, m_Serial.connect() failed\n");
    return 1;
  }

  m_ReadCount = 0;
  m_iMissCount = 0;
  m_nMissedFrames = 0;
  m_iPrevFrame = 0;
  m_iReportSync = 1;  // report next sync
  // Init sliding buffer
  SetBuffer(sizeof(IScanFrameStruct), ISCAN_BUFFER_SIZE);
  ResetBuffer();
  ResetTime();
  m_StartReadingThread( ); 
  if( !IsRunning() ) {
    CP_printf("Error in m_InitSerialThread()! CreateThread() failed.\n");
    PortOutput( LPT_CONTROL, GATE_OFF);
    RemoveBuffer();
    return 1;
  }
  CP_printf("Connected ISCAN\n");
  CP_printf("Expected number of parameters: %d\n", N_DATA_ITEMS);
  return 0;
}