// public static void Print(sizebuf_t buf, string data) { Com.dprintln("SZ.print():<" + data + ">"); var length = data.Length; var str = Lib.stringToBytes(data); if (buf.cursize != 0) { if (buf.data[buf.cursize - 1] != 0) { //memcpy( SZ_GetSpace(buf, len), data, len); // no trailing 0 Array.Copy(str, 0, buf.data, SZ.GetSpace(buf, length + 1), length); } else { Array.Copy(str, 0, buf.data, SZ.GetSpace(buf, length) - 1, length); //memcpy(SZ_GetSpace(buf, len - 1) - 1, data, len); // write over trailing 0 } } else { // first print. Array.Copy(str, 0, buf.data, SZ.GetSpace(buf, length), length); } //memcpy(SZ_GetSpace(buf, len), data, len); buf.data[buf.cursize - 1] = 0; }
public static void Write(sizebuf_t buf, byte[] data) { var length = data.Length; //memcpy(SZ_GetSpace(buf, length), data, length); Array.Copy(data, 0, buf.data, SZ.GetSpace(buf, length), length); }
public static void WriteShort(sizebuf_t sb, int c) { var i = SZ.GetSpace(sb, 2); sb.data[i++] = (byte)(c & 0xff); sb.data[i] = (byte)(((uint)c >> 8) & 0xFF); }
//ok. public static void WriteInt(sizebuf_t sb, int c) { var i = SZ.GetSpace(sb, 4); sb.data[i++] = (byte)(c & 0xff); sb.data[i++] = (byte)(((uint)c >> 8) & 0xff); sb.data[i++] = (byte)(((uint)c >> 16) & 0xff); sb.data[i++] = (byte)(((uint)c >> 24) & 0xff); }
public static void Write(sizebuf_t buf, byte[] data, int offset, int length) { Array.Copy(data, offset, buf.data, SZ.GetSpace(buf, length), length); }
//ok. public static void WriteByte(sizebuf_t sb, int c) { sb.data[SZ.GetSpace(sb, 1)] = (byte)(c & 0xFF); }