Air::U1 Buffer11::Read( U32 uiOffset,U32 uiSize,void* pData ) { DxContext* pContext = (DxContext*)(pDevice->GetContext()); ID3D11Resource* pResource = (ID3D11Resource*)GetBuffer(); D3D11_MAPPED_SUBRESOURCE res; HRESULT hr = pContext->Map(pResource,0,D3D11_MAP_READ,0,&res); if(SUCCEEDED(hr)){ U8* pDst = (U8*)res.pData; memcpy(pData,&pDst[uiOffset],uiSize); pContext->Unmap(pResource,0); } return true; }
// Delete - Deletes a segment of the string and resizes it // Returns - Reference to the same string object // pos - Position of the string segment to remove // len - Number of characters to remove CStringEx& CStringEx::Delete(int pos, int len) { int strLen = GetLength(); if( pos >= strLen) return *this; if(len < 0 ||len > strLen - pos) len = strLen - pos; LPTSTR str = GetBuffer( strLen ); memmove(str+pos, str+pos+len, sizeof(_T(' ')) *(strLen-pos)); ReleaseBuffer( strLen - len ); return *this; }
// TODO: this code require full information about editabel register in dialog // TODO: to make editable all registers which is output void RegRichTextCtrl::OnLeftDClick(wxMouseEvent& event) { wxClientDC dc(this); PrepareDC(dc); dc.SetFont(GetFont()); long position = 0; GetBuffer().HitTest(dc, event.GetLogicalPosition(dc), position); long linePos = GetBuffer().GetVisibleLineNumber(position, true, true); wxString line = GetLineText(linePos); const size_t szRegNames = 15; for (size_t i = 0; i < szRegNames; ++i) if (line.Find(RegistersName[i]) != wxNOT_FOUND) { wxString str = GetStringSelection(); bool bShowEditBox = true; for (size_t k = 0; k < szRegNames; ++k) { if ( 0 == str.Cmp(RegistersName[k]) ) { bShowEditBox = false; break; } } if (bShowEditBox) { EditRegister(RegistersName[i], str); break; } } }
static ParseStatus ReadHeader(MemBuffer* const mem) { const size_t min_size = RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE; uint32_t riff_size; // Basic file level validation. if (MemDataSize(mem) < min_size) return PARSE_NEED_MORE_DATA; if (memcmp(GetBuffer(mem), "RIFF", CHUNK_SIZE_BYTES) || memcmp(GetBuffer(mem) + CHUNK_HEADER_SIZE, "WEBP", CHUNK_SIZE_BYTES)) { return PARSE_ERROR; } riff_size = GetLE32(GetBuffer(mem) + TAG_SIZE); if (riff_size < CHUNK_HEADER_SIZE) return PARSE_ERROR; if (riff_size > MAX_CHUNK_PAYLOAD) return PARSE_ERROR; // There's no point in reading past the end of the RIFF chunk mem->riff_end_ = riff_size + CHUNK_HEADER_SIZE; if (mem->buf_size_ > mem->riff_end_) { mem->buf_size_ = mem->end_ = mem->riff_end_; } Skip(mem, RIFF_HEADER_SIZE); return PARSE_OK; }
size_t GarlicRoutingSession::CreateDeliveryStatusClove (uint8_t * buf, uint32_t msgID) { size_t size = 0; if (m_Owner) { auto inboundTunnel = m_Owner->GetTunnelPool ()->GetNextInboundTunnel (); if (inboundTunnel) { buf[size] = eGarlicDeliveryTypeTunnel << 5; // delivery instructions flag tunnel size++; // hash and tunnelID sequence is reversed for Garlic memcpy (buf + size, inboundTunnel->GetNextIdentHash (), 32); // To Hash size += 32; htobe32buf (buf + size, inboundTunnel->GetNextTunnelID ()); // tunnelID size += 4; // create msg auto msg = CreateDeliveryStatusMsg (msgID); if (m_Owner) { //encrypt uint8_t key[32], tag[32]; RAND_bytes (key, 32); // random session key RAND_bytes (tag, 32); // random session tag m_Owner->SubmitSessionKey (key, tag); GarlicRoutingSession garlic (key, tag); msg = garlic.WrapSingleMessage (msg); } memcpy (buf + size, msg->GetBuffer (), msg->GetLength ()); size += msg->GetLength (); // fill clove uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 8000; // 8 sec uint32_t cloveID; RAND_bytes ((uint8_t *)&cloveID, 4); htobe32buf (buf + size, cloveID); // CloveID size += 4; htobe64buf (buf + size, ts); // Expiration of clove size += 8; memset (buf + size, 0, 3); // certificate of clove size += 3; } else LogPrint (eLogError, "Garlic: No inbound tunnels in the pool for DeliveryStatus"); } else LogPrint (eLogWarning, "Garlic: Missing local LeaseSet"); return size; }
void RenderLine(uint8 *pStart, float xOff, float vLineTop, float vLineBottom, int nCursor, int nSelStart, int nSelEnd, View *pcView, bool bSelected) { Color32_s sCursCol(40,40,40); Color32_s sCursLineCol(255,235,186); if( ! bSelected ) { sCursCol = lighten_color(sCursCol); sCursLineCol = lighten_color(sCursLineCol); } float vCharWidth = GetCharWidth(); float vCharHeight = GetCharHeight(); uint8 *pEnd = GetBuffer() + GetBufferLength(); static char zLine[(BYTES_PER_LINE) + 1]; for( int x = 0; x < BYTES_PER_LINE; x++ ) { uint8 *p = pStart + x; zLine[x] = p >= pEnd || *p < 32 || *p > 126?'.':*p; } Rect cRect(xOff + GetX() + 2, vLineTop, xOff + GetX() + GetWidth() - 2, vLineBottom); pcView->SetFgColor(Color32_s(0,0,0)); if( nSelStart < 0 ) { if( nCursor >= 0 ) pcView->FillRect(cRect, sCursLineCol); pcView->DrawText(cRect, zLine); if( nCursor >= 0 ) { float vCursorX = cRect.left + (vCharWidth * nCursor); pcView->SetFgColor(sCursCol); pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom)); vCursorX++; pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom)); } } else { IPoint cSel1((int)(nSelStart * vCharWidth), (int)vCharHeight); IPoint cSel2((int)((nSelEnd * vCharWidth) + 1), (int)vCharHeight); pcView->DrawSelectedText(cRect, zLine, cSel1, cSel2, SEL_CHAR); } }
HRESULT CLR_RT_HeapBlock_XmlReader::Read() { TINYCLR_HEADER(); CLR_RT_XmlState* state = GetState(); state->State.bufferStart = GetBuffer(); state->State.buffer = state->State.bufferStart + GetOffset(); state->State.bufferEnd = state->State.buffer + GetLength(); state->State.reader = this; if(state->State.initFn) { state->State.initFn( state ); } while(true) { TINYCLR_CHECK_HRESULT(state->State.stateFn( state )); } TINYCLR_CLEANUP(); if(hr == XML_E_NEED_MORE_DATA) { if(state->State.cleanUpFn) { state->State.cleanUpFn( state ); } else { state->State.ShiftBuffer( state->State.buffer ); } // if after buffer adjustment, there's no room for new data, then we know that // we've exceeded one of the system constraints (either the length of name or // attribute value is over buffer size) if(state->State.bufferEnd - state->State.bufferStart == XmlBufferSize) { hr = XML_E_LIMIT_EXCEEDED; } } SetOffset( state->State.buffer - state->State.bufferStart ); SetLength( state->State.bufferEnd - state->State.buffer ); TINYCLR_CLEANUP_END(); }
bool BufferTextureClient::AllocateForSurface(gfx::IntSize aSize) { MOZ_ASSERT(IsValid()); MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This textureClient cannot use YCbCr data"); int bufSize = ImageDataSerializer::ComputeMinBufferSize(aSize, mFormat); if (!Allocate(bufSize)) { return false; } ImageDataSerializer serializer(GetBuffer()); serializer.InitializeBufferInfo(aSize, mFormat); mSize = aSize; return true; }
void Binarization::HMT(unsigned char *buffer_in, unsigned char *buffer_out, bool inverse) { set_structure_element(mixture_structure_element_2_); unsigned char *buffer = GetBuffer(BUFFER_INTERMEDIATE - 1); Invert(buffer_in, buffer); Erode(buffer, buffer, inverse); set_structure_element(mixture_structure_element_1_); Erode(buffer_in, buffer_out, inverse); for(int i = 1; i < height_ - 1; i++) for(int j = 1; j < width_ - 1; j++) { buffer_out[(i * width_ + j) * 3 + 2] = inverse ? buffer_out[(i * width_ + j) * 3 + 2] | buffer[(i * width_ + j) * 3 + 2] : buffer_out[(i * width_ + j) * 3 + 2] & buffer[(i * width_ + j) * 3 + 2]; buffer_out[(i * width_ + j) * 3 + 1] = inverse ? buffer_out[(i * width_ + j) * 3 + 1] | buffer[(i * width_ + j) * 3 + 1] : buffer_out[(i * width_ + j) * 3 + 1] & buffer[(i * width_ + j) * 3 + 1]; buffer_out[(i * width_ + j) * 3 + 0] = inverse ? buffer_out[(i * width_ + j) * 3 + 0] | buffer[(i * width_ + j) * 3 + 0] : buffer_out[(i * width_ + j) * 3 + 0] & buffer[(i * width_ + j) * 3 + 0]; } }
bool BufferTextureData::BorrowMappedData(MappedTextureData& aData) { if (GetFormat() == gfx::SurfaceFormat::YUV) { return false; } gfx::IntSize size = GetSize(); aData.data = GetBuffer(); aData.size = size; aData.format = GetFormat(); aData.stride = ImageDataSerializer::ComputeRGBStride(aData.format, size.width); return true; }
LPSTR IUrlDownloader::CreateCharCopy() const { ASSERT(GetStatus() == S_Success); LPSTR ret = NULL; if (GetStatus() == S_Success) { UINT bfLen = GetBufferSize(); if (bfLen > 0) { ret = new CHAR[bfLen + 1]; strncpy(ret, (LPCSTR)GetBuffer(), bfLen); ret[bfLen] = 0; } } return ret; }
/// ctor; parses event data CameraEventData(prVoid* pEventData) :m_uiEventCode(0) { BYTE* pbData = reinterpret_cast<BYTE*>(pEventData); std::vector<BYTE>& vecBuffer = GetBuffer(); vecBuffer.assign(pbData, pbData + 12);// at least 12 bytes // read length of event data prUInt32 uiLength = ReadUint32(); vecBuffer.assign(pbData, pbData + uiLength); unsigned int uiNumParams = (uiLength - 12) / 4; Parse(uiNumParams); }
void ImageProcessing::Output(const char *output, int buffer_num) { std::ofstream ofs(output, std::ifstream::binary); ofs.write((char *)head_, head_size_); unsigned char *canvas = GetBuffer(buffer_num); for(int i = 0; i < height_; i++) for(int j = 0; j < width_; j++) { image_[image_size_ / height_ * i + j * 3 + 2] = canvas[(i * width_ + j) * 3 + 2]; image_[image_size_ / height_ * i + j * 3 + 1] = canvas[(i * width_ + j) * 3 + 1]; image_[image_size_ / height_ * i + j * 3 + 0] = canvas[(i * width_ + j) * 3 + 0]; } ofs.write((char *)image_, image_size_); ofs.close(); }
void CComplexBinary::Append (CDatum dDatum) // Append // // Appends data { const CString &sNewData = dDatum; if (sNewData.GetLength() == 0) return; // Compute the new length int iOldLen = GetLength(); int iNewLen = iOldLen + sNewData.GetLength(); // Allocate a new buffer char *pNewBuffer = new char [sizeof(DWORD) + iNewLen + 1]; char *pPos = pNewBuffer; *(DWORD *)pPos = iNewLen; pPos += sizeof(DWORD); // Copy the original data if (iOldLen) { utlMemCopy(m_pData, pPos, iOldLen); pPos += iOldLen; } // Copy the new data utlMemCopy(sNewData.GetParsePointer(), pPos, sNewData.GetLength()); pPos += sNewData.GetLength(); // NULL-terminator *pPos++ = '\0'; // Free our original buffer and swap if (m_pData) delete [] GetBuffer(); m_pData = pNewBuffer + sizeof(DWORD); }
DWORD CStreamBuffer::Get( void *pOut,DWORD bytesToRead ) { if (m_pBuf==NULL || pOut==NULL || bytesToRead==0) { return 0; } if (bytesToRead+m_readPos >= m_writePos) { bytesToRead = m_writePos-m_readPos; } if (bytesToRead) { ::memcpy(pOut,GetBuffer() + m_readPos,bytesToRead); m_readPos += bytesToRead; } return bytesToRead; }
void CFileName::ReplaceExtension(LPCTSTR pszNewExt) { ASSERT(pszNewExt); if(_TCHAR('.')==*pszNewExt){ // Be tolerant of whether '.' is included in what we are passed: pszNewExt++; } LPTSTR pch=GetBuffer(2+GetLength()+_tcslen(pszNewExt)); LPTSTR pcExt=_tcsrchr(pch,_TCHAR('.')); if(NULL==pcExt || _tcschr(pcExt,cSep)){ // No existing extension pcExt=pch+GetLength(); *pcExt++=_TCHAR('.'); } _tcscpy(pcExt+1,pszNewExt); ReleaseBuffer(); }
void ContentClientSingleBuffered::SyncFrontBufferToBackBuffer() { if (!mFrontAndBackBufferDiffer) { return; } if (SupportsAzureContent()) { DrawTarget* backBuffer = GetDTBuffer(); if (!backBuffer && mDeprecatedTextureClient) { backBuffer = mDeprecatedTextureClient->LockDrawTarget(); } RefPtr<DrawTarget> oldBuffer; oldBuffer = SetDTBuffer(backBuffer, mBufferRect, mBufferRotation); backBuffer = GetDTBufferOnWhite(); if (!backBuffer && mDeprecatedTextureClientOnWhite) { backBuffer = mDeprecatedTextureClientOnWhite->LockDrawTarget(); } oldBuffer = SetDTBufferOnWhite(backBuffer); } else { gfxASurface* backBuffer = GetBuffer(); if (!backBuffer && mDeprecatedTextureClient) { backBuffer = mDeprecatedTextureClient->LockSurface(); } nsRefPtr<gfxASurface> oldBuffer; oldBuffer = SetBuffer(backBuffer, mBufferRect, mBufferRotation); backBuffer = GetBufferOnWhite(); if (!backBuffer && mDeprecatedTextureClientOnWhite) { backBuffer = mDeprecatedTextureClientOnWhite->LockSurface(); } oldBuffer = SetBufferOnWhite(backBuffer); } mIsNewBuffer = false; mFrontAndBackBufferDiffer = false; }
static void parseBreakpointWatchpointCommandArguments(BreakpointWatchpointArguments* pArguments) { Buffer* pBuffer = GetBuffer(); __try { __throwing_func( pArguments->type = Buffer_ReadChar(pBuffer) ); __throwing_func( ThrowIfNextCharIsNotEqualTo(pBuffer, ',') ); __throwing_func( pArguments->address = ReadUIntegerArgument(pBuffer) ); __throwing_func( ThrowIfNextCharIsNotEqualTo(pBuffer, ',') ); __throwing_func( pArguments->kind = ReadUIntegerArgument(pBuffer) ); } __catch { __rethrow; } }
BOOL IUrlDownloader::SaveToFile(LPCTSTR path) const { ASSERT(GetStatus() == S_Success); BOOL bRet = FALSE; if (GetStatus() == S_Success) { HANDLE f = CreateFile(path, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (f != INVALID_HANDLE_VALUE) { DWORD bytesWritten = 0; if (WriteFile(f, (LPCSTR)GetBuffer(), GetBufferSize(), &bytesWritten, 0) && bytesWritten) bRet = TRUE; CloseHandle(f); } } return bRet; }
WrappedIDXGISwapChain2::WrappedIDXGISwapChain2(IDXGISwapChain* real, HWND wnd, WrappedID3D11Device *device) : RefCountDXGIObject(real), m_pReal(real), m_pDevice(device), m_iRefcount(1), m_Wnd(wnd) { DXGI_SWAP_CHAIN_DESC desc; real->GetDesc(&desc); #if defined(INCLUDE_DXGI_1_2) m_pReal1 = NULL; real->QueryInterface(__uuidof(IDXGISwapChain1), (void **)&m_pReal1); m_pReal2 = NULL; real->QueryInterface(__uuidof(IDXGISwapChain2), (void **)&m_pReal2); #endif int bufCount = desc.BufferCount; if(desc.SwapEffect == DXGI_SWAP_EFFECT_DISCARD) bufCount = 1; RDCASSERT(bufCount < MAX_NUM_BACKBUFFERS); for(int i=0; i < MAX_NUM_BACKBUFFERS; i++) { m_pBackBuffers[i] = NULL; if(i < bufCount) { GetBuffer(i, __uuidof(ID3D11Texture2D), (void **)&m_pBackBuffers[i]); WrappedID3D11Texture2D *wrapped = (WrappedID3D11Texture2D *)m_pBackBuffers[i]; if(wrapped) { // keep ref as a 'view' (invisible to user) wrapped->ViewAddRef(); wrapped->Release(); } } } SAFE_ADDREF(m_pDevice); // we do a 'fake' present right at the start, so that we can capture frame 1, by // going from this fake present to the first present. m_pDevice->FirstFrame(this); }
int CxString :: GetPrivateProfileString( const char *sec, const char *ent, const char *def, int size, const char *file ) { if (NULL == file || 0 == strlen(file)) // ohne ini-Dateiname kein Resultat return 0; int result = size; char *text; ASSERT( def ); ASSERT( file ); if ( result <= 10 ) result = 10; text = GetBuffer( result ); result = ::GetPrivateProfileString( sec, ent, def, text, result, file ); ReleaseBuffer(); return result; } // GetPrivateProfileString
void prefix::CRenderableVideo::Update( float fSeconds ) { // decode next frame from the stream. SeekNextFrameFromStream(static_cast<int>(fSeconds*1000.0f)); //UpdateBuffer(); // prepare frame buffer for rendering m_Renderer.CommitFrameBufferSingle(*m_pFrameBufferObj, 0); // flip image vertically glRasterPos2i( 0, 240); glPixelZoom(1,-1); //glRasterPos2i(0,0); // put pixels into buffer glDrawPixels(GetWidth(),GetHeight(), GL_RGB, GL_UNSIGNED_BYTE, GetBuffer()); // restore things back to normal glPixelZoom(1,1); m_Renderer.RollbackFrameBuffer( *m_pFrameBufferObj ); }
bool MemBuffer::Compare(const vector<uint8_t> &compTo) { if (compTo.size() != GetBufSize()) { throw FrmwkEx(HERE, "Compare buffers not same size: %d != %d", compTo.size(), GetBufSize()); } vector<uint8_t>::const_iterator iterCompTo = compTo.begin(); uint8_t *iterThis = GetBuffer(); for (size_t i = 0; i < GetBufSize(); i++, iterCompTo++, iterThis++) { if (*iterCompTo != *iterThis) { LOG_ERR("Detected data miscompare @ index = %ld(0x%08lX)", i, i); return false; } } return true; }
CHistogram3D CHistogram3D::operator -(const CHistogram3D &histo) const { if (histo.iNbBins!=iNbBins || histo.iPadding!=iPadding) { cerr<<"ERROR in CHistogram3D::operator -(...): histograms have different sizes"<<endl; return *this; } if (histo.fRangeMin!=fRangeMin || histo.fRangeMax!=fRangeMax) { cerr<<"ERROR in CHistogram3D::operator -(...): histograms have different ranges"<<endl; return *this; } CHistogram3D histoRes; int i, iSize; const float *pValue, *pValue2; float *pValueRes; histoRes.iNbBins = iNbBins; histoRes.iPadding = iPadding; histoRes.fGaussianStdDeviation = fGaussianStdDeviation; histoRes.arrayGaussian = arrayGaussian; histoRes.fRangeMin = fRangeMin; histoRes.fRangeMax = fRangeMax; histoRes.fSumWeights = fSumWeights - histo.fSumWeights; histoRes.Init(iNbBins + CTriplet<int>(iPadding, iPadding, iPadding)*2); iSize = CArray1D<float>::GetSize(); pValue = GetBuffer(); pValue2 = histo.GetBuffer(); pValueRes = histoRes.GetBuffer(); for (i=0; i<iSize; i++) { *pValueRes = *pValue - *pValue2; pValue++; pValue2++; pValueRes++; } return histoRes; }
bool Source::Play(bool bRestart) { // Is a buffer loaded? Buffer *pBuffer = static_cast<Buffer*>(GetBuffer()); if (!pBuffer) return false; // Error! // Paused? if (IsPaused() && !bRestart) { FSOUND_SetPaused(m_nChannel, 0); } else { // Play if (IsPlaying()) { if (!bRestart) return true; // Done Stop(); } m_nChannel = pBuffer->Play(); // Add source to sound manager static_cast<SoundManager&>(GetSoundManager()).AddActiveSource(*this); // Get frequency and setup pitch m_nFrequency = FSOUND_GetFrequency(m_nChannel); float fPitch = m_fPitch; m_fPitch = -1.0f; SetPitch(fPitch); // Set volume pBuffer->SetVolume(m_nChannel, m_fVolume); // [HACK] HW sound: We have to pause the playback if we want to change the looping mode... // FSOUND_SetPaused(m_nChannel, 1); pBuffer->SetLooping(m_nChannel, m_bLooping); // FSOUND_SetPaused(m_nChannel, 0); // Set attributes SetAttribute(Position, m_vAttributes[Position]); SetAttribute(Velocity, m_vAttributes[Velocity]); } // Done return true; }
//Levanta del buffer de su TTY un scancode int GetKey() { int key; char* video= (char*)0xB8000; BUFFERTYPE* mibuffer; mibuffer=GetBuffer(); if((mibuffer->tail)==(mibuffer->head)) { return -1; } else { key=mibuffer->buffer[mibuffer->head]&0xFF; mibuffer->head=(mibuffer->head+1)%10; } return key; }
CHistogram1D CHistogram1D::operator +(const CHistogram1D &histo) const { if (histo.iNbBins!=iNbBins || histo.iPadding!=iPadding) { cerr<<"ERROR in CHistogram1D::operator +(...): histograms have different sizes"<<endl; return *this; } if (histo.fRangeMin!=fRangeMin || histo.fRangeMax!=fRangeMax) { cerr<<"ERROR in CHistogram1D::operator +(...): histograms have different ranges"<<endl; return *this; } CHistogram1D histoRes; int i; const float *pValue, *pValue2; float *pValueRes; histoRes.iNbBins = iNbBins; histoRes.iPadding = iPadding; histoRes.fGaussianStdDeviation = fGaussianStdDeviation; histoRes.arrayGaussian = arrayGaussian; histoRes.fRangeMin = fRangeMin; histoRes.fRangeMax = fRangeMax; histoRes.fSumWeights = fSumWeights + histo.fSumWeights; histoRes.Init(iNbBins + 2*iPadding); pValue = GetBuffer(); pValue2 = histo.GetBuffer(); pValueRes = histoRes.GetBuffer(); for (i=0; i<iSize; i++) { *pValueRes = *pValue + *pValue2; pValue++; pValue2++; pValueRes++; } return histoRes; }
bool BufferTextureClient::AllocateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize, StereoMode aStereoMode) { MOZ_ASSERT(IsValid()); size_t bufSize = YCbCrImageDataSerializer::ComputeMinBufferSize(aYSize, aCbCrSize); if (!Allocate(bufSize)) { return false; } YCbCrImageDataSerializer serializer(GetBuffer()); serializer.InitializeBufferInfo(aYSize, aCbCrSize, aStereoMode); mSize = aYSize; return true; }
int _Unpack(lua_State* L) { size_t sz = 0; void * buffer = GetBuffer(L, 1, &sz); void * output = lua_touserdata(L, lua_upvalueindex(1)); int osz = lua_tointeger(L, lua_upvalueindex(2)); int r = Zerounpack(buffer, sz, output, &osz); if (r < 0) return luaL_error(L, "Invalid unpack stream"); if (r > osz) { output = ExpandBuffer(L, osz, r); r = Zerounpack(buffer, sz, output, &r); if (r < 0) return luaL_error(L, "Invalid unpack stream"); } lua_pushlstring(L, (const char*)output, r); return 1; }
void COXString::Format(LPCTSTR pszFormat, LPCTSTR* rgpsz, int nString) { // NOTE: will not work for strings > 255 characters int nTotalLen = PtrToInt(_tcslen(pszFormat)); int i = 0; for (i = 0; i < nString; i++) { if (rgpsz[i] != NULL) nTotalLen += PtrToInt(_tcslen(rgpsz[i])); } LPCTSTR pchSrc = pszFormat; LPTSTR pchDestBegin = GetBuffer(nTotalLen+1); LPTSTR pchDest = pchDestBegin; while (*pchSrc != '\0') { if (pchSrc[0] == _T('%') && (pchSrc[1] >= _T('1') && pchSrc[1] <= _T('9'))) { i = pchSrc[1] - _T('1'); pchSrc += 2; if (i >= nString) { TRACE1("COXString::Format : Illegal string index requested %d\n", i); *pchDest++ = _T('?'); } else if (rgpsz[i] != NULL) { UTBStr::tcscpy(pchDest, nTotalLen, rgpsz[i]); pchDest += _tcslen(pchDest); } } else { *pchDest++ = *pchSrc++; } } ReleaseBuffer((int)((LPCTSTR)pchDest - (LPCTSTR)pchDestBegin)); // Release will assert if we went too far }