Пример #1
0
bool
CryptoKey::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const
{
  nsNSSShutDownPreventionLock locker;
  if (isAlreadyShutDown()) {
    return false;
  }

  // Write in five pieces
  // 1. Attributes
  // 2. Symmetric key as raw (if present)
  // 3. Private key as pkcs8 (if present)
  // 4. Public key as spki (if present)
  // 5. Algorithm in whatever form it chooses
  CryptoBuffer priv, pub;

  if (mPrivateKey) {
    CryptoKey::PrivateKeyToPkcs8(mPrivateKey, priv, locker);
  }

  if (mPublicKey) {
    CryptoKey::PublicKeyToSpki(mPublicKey, pub, locker);
  }

  return JS_WriteUint32Pair(aWriter, mAttributes, CRYPTOKEY_SC_VERSION) &&
         WriteBuffer(aWriter, mSymKey) &&
         WriteBuffer(aWriter, priv) &&
         WriteBuffer(aWriter, pub) &&
         mAlgorithm.WriteStructuredClone(aWriter);
}
Пример #2
0
int WriteToken (int         inSocket, 
                const char *inTokenValue, 
                size_t      inTokenLength)
{
    int err = 0;
    u_int32_t tokenLength = htonl (inTokenLength);

    if (!inTokenValue) { err = EINVAL; }
    
    if (!err) {
	err = WriteBuffer (inSocket, (char *) &tokenLength, 4);
    }
        
    if (!err) { 
        err = WriteBuffer (inSocket, inTokenValue, inTokenLength);
    }
    
    if (!err) {
        printf ("Wrote token:\n");
        PrintBuffer (inTokenValue, inTokenLength);
    } else { 
        printError (err, "WriteToken failed");
    }
   
    return err;
}
Пример #3
0
int gsscon_write_token (int         inSocket, 
                const char *inTokenValue, 
                size_t      inTokenLength)
{
    int err = 0;
    u_int32_t tokenLength = htonl (inTokenLength);

    if (!inTokenValue) { err = EINVAL; }
    
    if (!err) {
	err = WriteBuffer (inSocket, (char *) &tokenLength, 4);
    }
        
    if (!err) { 
        err = WriteBuffer (inSocket, inTokenValue, inTokenLength);
    }
    
    if (!err) {
    //    printf ("Wrote token:\n");
    //    PrintBuffer (inTokenValue, inTokenLength);

    } else { 
        gsscon_print_error (err, "gsscon_write_token() failed");
    }
   
    return err;
}
Пример #4
0
void SndSysDriverJackasyn::Run()
{
  csTicks last_write, current_ticks, tick_difference;

  // Write at about 20 times per second
  tick_difference=1000/20;

  last_write=csGetTicks();
  // Clear the buffer and write one section ahead
  ClearBuffer();
  WriteBuffer(oss_buffer_bytes);
  

  while (running)
  {
    current_ticks=csGetTicks();
    if (last_write + tick_difference <= current_ticks)
    {
      uint32 bytes_used=attached_renderer->FillDriverBuffer(oss_buffer, oss_buffer_bytes, 0, 0);
      if (bytes_used > 0)
      {
        WriteBuffer(bytes_used);
      }
      last_write=current_ticks;
    }
    csSleep(0);
  }
}
Пример #5
0
bool User::SendPacket(NetPacket * pack)
{
    if (!IsValid())
        return false;

	PkOStream stream;
	
	pack->Out(stream);

    char buffer[MAX_PACK_SIZE];

    NetPacketHead head;

    head.id = pack->GetPacketId();
    head.size = (short)stream.Size();
    head.tick = 0;

    int offset = 0;
    WriteBuffer(buffer, MAX_PACK_SIZE, 0, PACK_COMPACK, PACK_COMPACK_SIZE);
    offset += PACK_COMPACK_SIZE;
    WriteBuffer(buffer, MAX_PACK_SIZE, offset, &head, NetPacketHead::SIZE);
    offset += NetPacketHead::SIZE;

    WriteBuffer(buffer, MAX_PACK_SIZE, offset, stream.Data(), head.size);
    offset += head.size;

    // 加密消息头
    NET_ENCRYPT(buffer + PACK_COMPACK_SIZE, NetPacketHead::SIZE, PACK_HEAD_KEY, PACK_HEAD_SPACER);
    // 加密消息体
    NET_ENCRYPT(buffer + PACK_COMPACK_SIZE + NetPacketHead::SIZE, head.size, PACK_BODY_KEY, PACK_BODY_SPACER);

    mOStream->Write(buffer, offset);

    return true;
}
Пример #6
0
void lds_uart_receive(USART_TypeDef* USARTx)
{
	uint8_t dat;
	dat = USART_ReceiveData(USARTx);
	if(sm_lds_485== lds_idle)
	{
		if((dat == 0xfa)
				||(dat == 0xfc)
				||(dat == 0xf5)
				||(dat == 0xfe))
		{
			sm_lds_485 = lds_receiving;
			//写入环形缓冲区
//			ENTER_CRITICAL_SECTION();
			WriteBuffer(&lds_uart_buffer,dat);
			RcvNum = 7;
			UartTimer_CMD_Expire_Enable();
//			EXIT_CRITICAL_SECTION();
		}
	}
	else 
		if(sm_lds_485 == lds_receiving)
		{
			//写入环形缓冲区
			WriteBuffer(&lds_uart_buffer,dat);
//			RcvNum--;
//			if(RcvNum == 0)
//			{
//				sm_lds_485 = lds_idle;
////				UartTimer_Expire_Disable();
//			}
//			else
				UartTimer_CMD_Expire_Enable();
		}
}
Пример #7
0
void CRequestResourcePacket::DoPack()
{
    CFinderPacket::DoPack();
    WriteString(strRef);
    WriteString(strUrl);
    WriteBuffer(&nFileLength, sizeof(int64));
    WriteBuffer(&nTaskId, sizeof(int));
};
Пример #8
0
void CUdpBizPacket::WriteIntegerArray(const IntegerArray& Array)
{
    int nCount;

    nCount = Array.size();
    WriteBuffer(&nCount, sizeof(int));
    if (nCount > 0)
        WriteBuffer((void*)&Array[0], sizeof(int) * nCount);
}
Пример #9
0
void CUploadFileListPacket::DoPack()
{
    CFinderPacket::DoPack();
    WriteBuffer(&wFileCount, sizeof(word));
    for(int i=0; i<wFileCount; i++)
    {
        WriteBuffer(&FileList.at(i).nFileLength, sizeof(int64));
        WriteString(FileList.at(i).strHashValue);
    }
};
Пример #10
0
	void HttpProtocol::WriteHeader( const char* name,const char* value )
	{
		char buf[4096] = "";
		char* targetValue = NULL;
		WriteBuffer(name);
		WriteBuffer(": ");
		targetValue = &m_pBuf[m_nLenUsed];
		WriteBuffer(value);
		WriteBuffer(HttpConsts::LF);

		OnHeaderSet(name,targetValue);
	}
Пример #11
0
		bool PipeClient::WriteLengthEncodedBuffer(pGina::Memory::Buffer *buffer)
		{
			pGina::Memory::Buffer lengthBuffer(4);
			pGina::Memory::BinaryWriter writer(lengthBuffer);
			writer.Write(buffer->Length());

			if(WriteBuffer(&lengthBuffer))
			{
				return WriteBuffer(buffer);
			}

			return false;
		}
Пример #12
0
/////////////////////////////////////////////////////////////////////////////////
// CReGetUserIpPacket - 回给客户端一批IP
void CReGetUserIpPacket::DoPack()
{
    CReFinderPacket::DoPack();
    //打一批用户IP
    int Number = UserList.size();
    WriteBuffer(&Number, sizeof(int));
    for(int i=0; i<Number; i++)
    {
        WriteBuffer(&UserList.at(i).nUserIp, sizeof(uint));
        WriteBuffer(&UserList.at(i).wTcpPort, sizeof(word));

    }
    WriteString(strHashValue);
    WriteBuffer(&nTaskId, sizeof(int));
};
Пример #13
0
bool CDeviceSPI::WriteOutput()
{
  //get the channel values from the clientshandler
  int64_t now = GetTimeUs();
  m_clients.FillChannels(m_channels, now, this);
  counter=4;
  
  
  
   for (int i = 0; i < (m_channels.size()-2); i+=3) {
      r=(uint16_t) ((m_channels[i].GetValue(now) * m_max)+0.5);
	  // r=Clamp(r,0,(uint16_t)(m_max));
	  g=(uint16_t) ((m_channels[i+1].GetValue(now) * m_max)+0.5);
	  // g=Clamp(g,0,(uint16_t)(m_max));
	  b=(uint16_t) ((m_channels[i+2].GetValue(now) * m_max)+0.5);
	  // b=Clamp(b,0,(uint16_t)(m_max));
	  d = (r*1024) + (g*32) + b + 32768;
	  m_buff[counter] =d >> 8;
      counter++;
      m_buff[counter] =d & 0x00FF;
      counter++;

  }
  if (!WriteBuffer())
    return false;

  m_timer.Wait();
  
  return true;
}
Пример #14
0
void Encoder::WriteDofNode(DXDof *pNode)
{
	DxDofType dxDOFNode;
	// Reset structure
	memset((void*)&dxDOFNode, 0, sizeof(dxDOFNode));
	// Set common data
	dxDOFNode.h.dwNodeSize = sizeof(DxDofType);
	dxDOFNode.h.Type       = DX_DOF;
	// Set fields
	dxDOFNode.dofNumber = pNode->dof.dofNumber;
	dxDOFNode.flags = pNode->dof.flags;
	dxDOFNode.future = pNode->dof.future;
	dxDOFNode.max = pNode->dof.max;
	dxDOFNode.min = pNode->dof.min;
	dxDOFNode.multiplier = pNode->dof.multiplier;
	dxDOFNode.rotation = pNode->dof.rotation;
	dxDOFNode.scale= pNode->dof.scale;
	dxDOFNode.translation = pNode->dof.translation;
	dxDOFNode.Type = pNode->dof.Type;
	dxDOFNode.SwitchBranch = pNode->dof.SwitchBranch;
	dxDOFNode.SwitchNumber = pNode->dof.SwitchNumber;
	// Save DOF pointer
	m_arDOFPointers.Add((DxDofType*)(m_pBuffer+m_dwBufferOffset));
	m_dwDOF++;
	// Write data to buffer
	WriteBuffer((void*)&dxDOFNode, sizeof(dxDOFNode));
	// Increment total node counter
	m_dwTotalNodeCount++;
}
Пример #15
0
bool StorageChunkWriter::WriteDataPages()
{
    unsigned            i;
    StorageDataPage*    dataPage;

    for (i = 0; i < file->numDataPages; i++)
    {
        if (env->shuttingDown)
            return false;
        
        while (env->yieldThreads)
        {
            Log_Trace("Yielding...");
            MSleep(YIELD_TIME);
        }
        
        dataPage = file->dataPages[i];
        writeBuffer.Clear();
        dataPage->Write(writeBuffer);
        //ASSERT(writeBuffer.GetLength() == dataPage->GetSize());

        if (!WriteBuffer())
            return false;
    }
    
    return true;
}
Пример #16
0
static void DirectSoundThread(void* Arg)
{
	DRV_DSND* drv = (DRV_DSND*)Arg;
	UINT32 wrtBytes;
	UINT32 didBuffers;	// number of processed buffers
	
	OSSignal_Wait(drv->hSignal);	// wait until the initialization is done
	
	while(drv->devState == 1)
	{
		didBuffers = 0;
		
		OSMutex_Lock(drv->hMutex);
		while(GetFreeBytes(drv) >= drv->bufSegSize && drv->FillBuffer != NULL)
		{
			wrtBytes = drv->FillBuffer(drv->audDrvPtr, drv->userParam, drv->bufSegSize, drv->bufSpace);
			WriteBuffer(drv, wrtBytes, drv->bufSpace);
			didBuffers ++;
		}
		OSMutex_Unlock(drv->hMutex);
		if (! didBuffers)
			Sleep(1);
		
		while(drv->FillBuffer == NULL && drv->devState == 1)
			Sleep(1);
		//while(drv->PauseThread && drv->devState == 1)
		//	Sleep(1);
	}
	
	return;
}
Пример #17
0
void Encoder::WriteDofEndNode()
{
	DxDofEndType dxDofEndNode;
	// Reset structure
	memset((void*)&dxDofEndNode, 0, sizeof(dxDofEndNode));
	//Set the ID
	dxDofEndNode.h.dwNodeID=m_dwNodeID;
	// Set common data
	dxDofEndNode.h.dwNodeSize = sizeof(DxDofEndType);
	dxDofEndNode.h.Type       = DX_ENDDOF;

	// Assign the DOF the size of this before closing it
	if(DofStackLevel){
		DofStackLevel--;
		DOFsStack[DofStackLevel]->dwDOFTotalSize=m_pBuffer+m_dwBufferOffset-(byte*)DOFsStack[DofStackLevel];
	}

	//Write data to buffer
	WriteBuffer((void*)&dxDofEndNode, sizeof(dxDofEndNode));
	// Decrement DOF counter
	m_arDOFPointers.RemoveAt(m_dwDOF-1);
	m_dwDOF--;
	// Increment total node counter
	m_dwTotalNodeCount++;
}
Пример #18
0
/*
 * Retail deletion of a single tuple.
 *
 * NB: this is no longer called externally, but is still needed by
 * gistlayerinsert().  That dependency will have to be fixed if GIST
 * is ever going to allow concurrent insertions.
 */
static void
gistdelete(Relation r, ItemPointer tid)
{
	BlockNumber blkno;
	OffsetNumber offnum;
	Buffer		buf;
	Page		page;

	/*
	 * Since GIST is not marked "amconcurrent" in pg_am, caller should
	 * have acquired exclusive lock on index relation.	We need no locking
	 * here.
	 */

	blkno = ItemPointerGetBlockNumber(tid);
	offnum = ItemPointerGetOffsetNumber(tid);

	/* adjust any scans that will be affected by this deletion */
	/* NB: this works only for scans in *this* backend! */
	gistadjscans(r, GISTOP_DEL, blkno, offnum);

	/* delete the index tuple */
	buf = ReadBuffer(r, blkno);
	page = BufferGetPage(buf);

	PageIndexTupleDelete(page, offnum);

	WriteBuffer(buf);
}
Пример #19
0
void CDownloadFileCompletePacket::DoPack()
{
    CFinderPacket::DoPack();
    WriteString(strUrl);
    WriteBuffer(&nFileLength, sizeof(int64));
    WriteString(strHashValue);
};
Пример #20
0
void Encoder::WriteSurfaceNode(DXNode *pNode)
{
	if(m_pLastSurfaceNode)
	{
		// Set node total size (Node + Data (total indexes size))
		DWORD dwTotalNodeSize = (m_dwTotalSurfaceVertexes*sizeof(Int16) + sizeof(DxSurfaceType));
		memcpy((void*)m_pLastSurfaceNode, (const void*)&dwTotalNodeSize, sizeof(dwTotalNodeSize));
		// Set previous SURFACE node vertex counter and reset it (12 is the offset of dwVCount field)
		memcpy((void*)(m_pLastSurfaceNode + 12), (const void*)&m_dwTotalSurfaceVertexes, sizeof(m_dwTotalSurfaceVertexes));
	}
	m_dwTotalSurfaceVertexes = 0;
	// Define new node to insert
	DxSurfaceType dxSurfaceNode;
	// Reset structure
	memset((void*)&dxSurfaceNode, 0, sizeof(dxSurfaceNode));
	// Set common data
	dxSurfaceNode.h.dwNodeSize = sizeof(DxSurfaceType);
	dxSurfaceNode.h.Type       = DX_SURFACE;
	// Set Flags
	dxSurfaceNode.dwFlags = pNode->Flags;
	// Based on node type, set DX primitive type
	switch(pNode->Type)
	{
		case TRIANGLE:
			dxSurfaceNode.dwPrimType = D3DPT_TRIANGLELIST;
		break;

		case LINE:
			dxSurfaceNode.dwPrimType = D3DPT_LINELIST;
		break;

		case DOT:
			dxSurfaceNode.dwPrimType = D3DPT_POINTLIST;
		break;
	}
	
	// Set vertex format using DX Flexible Vertex Format flags
	dxSurfaceNode.dwVFormat = D3DFVF_XYZ|D3DFVF_NORMAL;

	// Set dimension of each vertex item
	if(pNode->Flags.b.Texture)
	{
		dxSurfaceNode.dwVFormat |= D3DFVF_TEX1;
		//dxSurfaceNode.dwStride = 32;   // 32 bytes if Texture Node (tu and tv texture coordinate)
	}
	else if(pNode->Flags.b.Solid || pNode->Flags.b.VColor)
	{
		dxSurfaceNode.dwVFormat |= D3DFVF_DIFFUSE;
		//dxSurfaceNode.dwStride = 28;            // else 28 bytes (only VColour component)
	}

	// Set vertex dimension
	dxSurfaceNode.dwStride = sizeof(D3DVERTEXEX);
	// Save pointer to this SURFACE node
	m_pLastSurfaceNode = m_pBuffer + m_dwBufferOffset;
	WriteBuffer((void*)&dxSurfaceNode, sizeof(dxSurfaceNode));
	// Increment total node counter
	m_dwTotalNodeCount++;
}
Пример #21
0
void
FetchStreamReader::ResolvedCallback(JSContext* aCx,
                                    JS::Handle<JS::Value> aValue)
{
  if (mStreamClosed) {
    return;
  }

  // This promise should be resolved with { done: boolean, value: something },
  // "value" is interesting only if done is false.

  // We don't want to play with JS api, let's WebIDL bindings doing it for us.
  // FetchReadableStreamReadDataDone is a dictionary with just a boolean, if the
  // parsing succeeded, we can proceed with the parsing of the "value", which it
  // must be a Uint8Array.
  FetchReadableStreamReadDataDone valueDone;
  if (!valueDone.Init(aCx, aValue)) {
    JS_ClearPendingException(aCx);
    CloseAndRelease(aCx, NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }

  if (valueDone.mDone) {
    // Stream is completed.
    CloseAndRelease(aCx, NS_BASE_STREAM_CLOSED);
    return;
  }

  UniquePtr<FetchReadableStreamReadDataArray> value(
    new FetchReadableStreamReadDataArray);
  if (!value->Init(aCx, aValue) || !value->mValue.WasPassed()) {
    JS_ClearPendingException(aCx);
    CloseAndRelease(aCx, NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }

  Uint8Array& array = value->mValue.Value();
  array.ComputeLengthAndData();
  uint32_t len = array.Length();

  if (len == 0) {
    // If there is nothing to read, let's do another reading.
    OnOutputStreamReady(mPipeOut);
    return;
  }

  MOZ_DIAGNOSTIC_ASSERT(!mBuffer);
  mBuffer = Move(value);

  mBufferOffset = 0;
  mBufferRemaining = len;

  nsresult rv = WriteBuffer();
  if (NS_FAILED(rv)) {
    // DOMException only understands errors from domerr.msg, so we normalize to
    // identifying an abort if the write fails.
    CloseAndRelease(aCx, NS_ERROR_DOM_ABORT_ERR);
  }
}
Пример #22
0
void WriteCciDataToOutput(cci_settings *set)
{
	// NCSD Header
	WriteBuffer(set->headers.ccihdr.buffer, set->headers.ccihdr.size, 0, set->out);
	// Card Info Header
	WriteBuffer(set->headers.cardinfohdr.buffer, set->headers.cardinfohdr.size, set->headers.ccihdr.size, set->out);
	
	// Dummy data between header and first NCCH
	u64 len = set->content.cOffset[0] - (set->headers.ccihdr.size + set->headers.cardinfohdr.size);
	u8 *dummy_data = malloc(len);
	if(set->headers.cardinfohdr.size > sizeof(cardinfo_hdr)) // additional debug header data exists
		memset(dummy_data, 0x00, len);
	else // normal production cci image
		memset(dummy_data, 0xff, len);
	WriteBuffer(dummy_data, len, (set->headers.ccihdr.size + set->headers.cardinfohdr.size),set->out);	
	free(dummy_data);
	
	// NCCH Partitions
	u8 *ncch;
	for(int i = 0; i < CCI_MAX_CONTENT; i++){
		if(set->content.active[i]){
			ncch = set->content.data + set->content.dOffset[i];
			WriteBuffer(ncch, set->content.dSize[i], set->content.cOffset[i], set->out);
		}
	}	
	
	// Cci Padding
	if(set->options.padCci){
		fseek_64(set->out,set->romInfo.usedSize);

		// Determining Size of Padding
		u64 len = set->romInfo.mediaSize - set->romInfo.usedSize;
		
		// Create Padding chunk
		u8 *pad = malloc(set->romInfo.blockSize);
		memset(pad,0xff,set->romInfo.blockSize);
		
		// Writing Dummy Bytes to file
		for(u64 i = 0; i < len; i += set->romInfo.blockSize)
			fwrite(pad,set->romInfo.blockSize,1,set->out);
			
		free(pad);
	}
	
	return;
}
Пример #23
0
NS_IMETHODIMP nsCacheEntryDescriptor::
nsCompressOutputStreamWrapper::Write(const char * buf,
                                     uint32_t     count,
                                     uint32_t *   result)
{
    int zerr = Z_OK;
    nsresult rv = NS_OK;

    if (!mStreamInitialized) {
        rv = InitZstream();
        if (NS_FAILED(rv)) {
            return rv;
        }
    }

    if (!mWriteBuffer) {
        // Once allocated, this buffer is referenced by the zlib stream and
        // cannot be grown. We use 2x(initial write request) to approximate
        // a stream buffer size proportional to request buffers.
        mWriteBufferLen = NS_MAX(count*2, (uint32_t)kMinCompressWriteBufLen);
        mWriteBuffer = (unsigned char*)nsMemory::Alloc(mWriteBufferLen);
        if (!mWriteBuffer) {
            mWriteBufferLen = 0;
            return NS_ERROR_OUT_OF_MEMORY;
        }
        mZstream.next_out = mWriteBuffer;
        mZstream.avail_out = mWriteBufferLen;
    }

    // Compress (deflate) the requested buffer. Keep going
    // until the entire buffer has been deflated.
    mZstream.avail_in = count;
    mZstream.next_in = (Bytef*)buf;
    while (mZstream.avail_in > 0) {
        zerr = deflate(&mZstream, Z_NO_FLUSH);
        if (zerr == Z_STREAM_ERROR) {
            deflateEnd(&mZstream);
            mStreamInitialized = false;
            return NS_ERROR_FAILURE;
        }
        // Note: Z_BUF_ERROR is non-fatal and sometimes expected here.

        // If the compression stream output buffer is filled, write
        // it out to the underlying stream wrapper.
        if (mZstream.avail_out == 0) {
            rv = WriteBuffer();
            if (NS_FAILED(rv)) {
                deflateEnd(&mZstream);
                mStreamInitialized = false;
                return rv;
            }
        }
    }
    *result = count;
    mUncompressedCount += *result;
    return NS_OK;
}
Пример #24
0
void BioloidBus::BufferByte( uint8_t data )
{
    m_data[ m_dataBytes++ ] = data;

    if ( m_dataBytes >= sizeof( m_data ))
    {
        WriteBuffer();
    }
}
Пример #25
0
void CReGetUrlPacket::DoPack()
{
    CReFinderPacket::DoPack();
    //打一个URL
    WriteString(strReference);
    WriteString(strUrl);
    WriteString(strHashValue);
    WriteBuffer(&nTaskId, sizeof(int));
};
Пример #26
0
int main(int argc, char* argv[])
{

	ProcessInput(argc,argv);
	CompileBuffer();
	WriteBuffer();

	return 0;
}
NS_IMETHODIMP nsCacheEntryDescriptor::
nsCompressOutputStreamWrapper::Close()
{
    mozilla::MutexAutoLock lock(mLock);

    if (!mDescriptor)
        return NS_ERROR_NOT_AVAILABLE;

    nsresult retval = NS_OK;
    nsresult rv;
    int zerr = 0;

    if (mStreamInitialized) {
        // complete compression of any data remaining in the zlib stream
        do {
            zerr = deflate(&mZstream, Z_FINISH);
            rv = WriteBuffer();
            if (NS_FAILED(rv))
                retval = rv;
        } while (zerr == Z_OK && rv == NS_OK);
        deflateEnd(&mZstream);
        mStreamInitialized = false;
    }
    // Do not allow to initialize stream after calling Close().
    mStreamEnded = true;

    if (mDescriptor->CacheEntry()) {
        nsAutoCString uncompressedLenStr;
        rv = mDescriptor->GetMetaDataElement("uncompressed-len",
                                             getter_Copies(uncompressedLenStr));
        if (NS_SUCCEEDED(rv)) {
            int32_t oldCount = uncompressedLenStr.ToInteger(&rv);
            if (NS_SUCCEEDED(rv)) {
                mUncompressedCount += oldCount;
            }
        }
        uncompressedLenStr.Adopt(0);
        uncompressedLenStr.AppendInt(mUncompressedCount);
        rv = mDescriptor->SetMetaDataElement("uncompressed-len",
            uncompressedLenStr.get());
        if (NS_FAILED(rv))
            retval = rv;
    }

    if (mWriteBuffer) {
        nsMemory::Free(mWriteBuffer);
        mWriteBuffer = 0;
        mWriteBufferLen = 0;
    }

    rv = nsOutputStreamWrapper::Close_Locked();
    if (NS_FAILED(rv))
        retval = rv;

    return retval;
}
Пример #28
0
int textfile_c::WriteTextLine(char * aText) {
  char * text = new char[strlen(aText)+3];
  memcpy(text,aText,strlen(aText));
  text[strlen(aText)] = 13;
  text[strlen(aText)+1] = 10;
  text[strlen(aText)+2] = 0;
  WriteBuffer(text,strlen(text));
  delete text;
  return 0;
}
Пример #29
0
// Fill the buffer with a rgb color
void fill_full(unsigned char r,unsigned char g,unsigned char b,unsigned char *buffer, int show) {
	int i;
	
	for (i=0;i<MAXBUFFER_PER_PANEL;i+=3) {
		buffer[i+0]=(r<<LEFT_SHIFT);
		buffer[i+1]=(g<<LEFT_SHIFT);
		buffer[i+2]=(b<<LEFT_SHIFT);
	}
	if (show) WriteBuffer(buffer);
}
Пример #30
0
void FileStore::Close()
{
  if(writing)
	  WriteBuffer();
  f_close(&file);
  platform->ReturnFileStore(this);
  inUse = false;
  writing = false;
  lastBufferEntry = 0;
}