Example #1
0
        //
        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;
        }
Example #2
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);
        }
Example #3
0
        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);
        }
Example #4
0
        //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);
        }
Example #5
0
 public static void Write(sizebuf_t buf, byte[] data, int offset, int length)
 {
     Array.Copy(data, offset, buf.data, SZ.GetSpace(buf, length), length);
 }
Example #6
0
 //ok.
 public static void WriteByte(sizebuf_t sb, int c)
 {
     sb.data[SZ.GetSpace(sb, 1)] = (byte)(c & 0xFF);
 }