public int addByteArray(int aiType, byte[] aoVal, int size) { if (0 > this.ensureSpace(aiType, size)) { return(-2); } if (this.m_eDefaultMode == 0) { Buffer.BlockCopy(TLVUtil.int2byte(aiType, 4, true), 0, this.m_pcBuf, this.m_iUsedSize, 4); this.m_iUsedSize += 4; Buffer.BlockCopy(TLVUtil.int2byte(size, 4, true), 0, this.m_pcBuf, this.m_iUsedSize, 4); this.m_iUsedSize += 4; } else if (this.m_eDefaultMode == 1) { int num = TLVUtil.EncodeVByte32(aiType, this.m_pcBuf, this.m_iUsedSize); this.m_iUsedSize += num; int num2 = TLVUtil.EncodeVByte32(size, this.m_pcBuf, this.m_iUsedSize); this.m_iUsedSize += num2; } else { return(-8); } Buffer.BlockCopy(aoVal, 0, this.m_pcBuf, this.m_iUsedSize, size); this.m_iUsedSize += size; return(0); }
public static int mmpkg_mini_head_hton(MMPKG_mini_header header, out byte[] outbuff) { outbuff = null; if (header == null) { return(-1); } int num = _mmpkg_validate(header); if (num != 0) { return(num); } byte[] dst = new byte[header.getMaxSize()]; int dstOffset = 0; byte[] src = header.getHeaderBits(); Buffer.BlockCopy(src, 0, dst, dstOffset, src.Length); dstOffset += src.Length; byte[] buffer3 = TLVUtil.int2byte(header.ret, 4, true); Buffer.BlockCopy(buffer3, 0, dst, dstOffset, buffer3.Length); dstOffset += buffer3.Length; buffer3 = TLVUtil.int2byte((int)header.uin, 4, true); Buffer.BlockCopy(buffer3, 0, dst, dstOffset, buffer3.Length); dstOffset += buffer3.Length; Buffer.BlockCopy(header.server_id, 0, dst, dstOffset, header.server_id.Length); dstOffset += header.server_id.Length; appendIntTobuf(dst, ref dstOffset, header.cmd_id); appendIntTobuf(dst, ref dstOffset, (int)header.compress_len); appendIntTobuf(dst, ref dstOffset, (int)header.compressed_len); appendIntTobuf(dst, ref dstOffset, header.cert_version); appendIntTobuf(dst, ref dstOffset, header.device_type); int count = dstOffset; outbuff = new byte[count]; Buffer.BlockCopy(dst, 0, outbuff, 0, count); header.len = (byte)count; Buffer.BlockCopy(header.getHeaderBits(), 0, outbuff, 0, 1); return(0); }
public int addNestedTLV(int aiType, TLVPack apoVal) { if (0 > this.ensureSpace(aiType, apoVal.m_iUsedSize)) { return(-2); } int iUsedSize = this.m_iUsedSize; if (this.m_eDefaultMode == 0) { Buffer.BlockCopy(TLVUtil.int2byte(aiType, 4, true), 0, this.m_pcBuf, this.m_iUsedSize, 4); this.m_iUsedSize += 4; Buffer.BlockCopy(TLVUtil.int2byte(apoVal.m_iUsedSize, 4, true), 0, this.m_pcBuf, this.m_iUsedSize, 4); this.m_iUsedSize += 4; } else if (this.m_eDefaultMode == 1) { int num2 = TLVUtil.EncodeVByte32(aiType, this.m_pcBuf, this.m_iUsedSize); this.m_iUsedSize += num2; int num3 = TLVUtil.EncodeVByte32(apoVal.m_iUsedSize, this.m_pcBuf, this.m_iUsedSize); this.m_iUsedSize += num3; } else { return(-8); } if (apoVal.m_iUsedSize > 0) { int apiSize = 0; apiSize = this.m_iAllocSize - this.m_iUsedSize; int num5 = apoVal.CopyTo(this.m_pcBuf, this.m_iUsedSize, ref apiSize); if (num5 != 0) { this.m_iUsedSize = iUsedSize; return(num5); } } this.m_iUsedSize += apoVal.m_iUsedSize; return(0); }
public int AddInt(int aiType, int aiVal) { return(this.addByteArray(aiType, TLVUtil.int2byte(aiVal, 4, this.m_eDefaultMode == 0), 4)); }