Example #1
0
        public unsafe static byte Strmake_StrGetcanshu(byte *buf, PosLaction *poscode, PosLaction *cancode, byte canshuqyt)
        {
            ushort     num = poscode->star;
            PosLaction posLaction;

            posLaction.end = poscode->end;
            byte result;

            if (canshuqyt == 0)
            {
                if (poscode->star > poscode->end)
                {
                    result = 1;
                }
                else
                {
                    result = 0;
                }
            }
            else
            {
                ushort num2 = 0;
                while (num2 < (ushort)canshuqyt)
                {
                    if (num > poscode->end)
                    {
                        result = 0;
                        return(result);
                    }
                    posLaction.star    = num;
                    cancode[num2].star = num;
                    num = Strmake.Findfenge(buf, &posLaction);
                    if (num == 65535)
                    {
                        if (num2 != (ushort)(canshuqyt - 1))
                        {
                            result = 0;
                            return(result);
                        }
                        cancode[num2].end = poscode->end;
                        result            = 1;
                        return(result);
                    }
                    else
                    {
                        if (num == cancode[num2].star)
                        {
                            result = 0;
                            return(result);
                        }
                        cancode[num2].end = (ushort)(num - 1);
                        num  += 1;
                        num2 += 1;
                    }
                }
                result = 0;
            }
            return(result);
        }
Example #2
0
 public unsafe static byte Strmake_Makestr(byte *v1, string str, byte lenth)
 {
     byte[] array = str.GetbytesssASCII();
     array = Kuozhan.Gethebingbytes(array, "".GetbytesssASCII(1));
     fixed(byte *ptr = array)
     {
         return(Strmake.Strmake_Makestr(v1, ptr, lenth));
     }
 }
Example #3
0
        public unsafe static byte Strmake_StrGetcanshu(byte *buf, ref PosLaction poscode, ref PosLaction[] cancode, byte canshuqyt)
        {
            byte result;

            fixed(PosLaction *ptr = &poscode)
            {
                fixed(PosLaction *ptr2 = cancode)
                {
                    result = Strmake.Strmake_StrGetcanshu(buf, ptr, ptr2, canshuqyt);
                }
            }

            return(result);
        }
Example #4
0
        public unsafe static ushort Strmake_StrSubstring(byte *buf, ref PosLaction bufpos, string val, byte starmod)
        {
            byte[] array = Kuozhan.Gethebingbytes(val.GetbytesssASCII(), "".GetbytesssASCII(1));
            ushort result;

            fixed(PosLaction *ptr = &bufpos)
            {
                fixed(byte *ptr2 = array)
                {
                    result = Strmake.Strmake_StrSubstring(buf, ptr, ptr2, starmod);
                }
            }

            return(result);
        }
Example #5
0
        private unsafe static int Lstrbyteaddstring(byte[] b, bool biaoji)
        {
            strxinxi item = default(strxinxi);

            if (dataput.bianyi == 1 && biaoji)
            {
                fixed(byte *ptr = b)
                {
                    if (b.Length > 5)
                    {
                        if (Strmake.Strmake_Makestr(ptr, "LcCL ", 5) == 1)
                        {
                            string[] array = b.Getstring(datasize.Myencoding).Split(new char[]
                            {
                                ' '
                            });
                            if (array.Length == 3)
                            {
                                if (array[1] == "L")
                                {
                                    dataput.LcCL_L.Add(new LcCL_type
                                    {
                                        strbytesid = dataput.strbytes.Count,
                                        biaoji     = array[2]
                                    });
                                    b = (array[1] + "   ").GetbytesssASCII();
                                }
                                else if (array[1] == "S")
                                {
                                    dataput.LcCL_S.Add(new LcCL_type
                                    {
                                        strbytesid = dataput.strbytes.Count,
                                        biaoji     = array[2]
                                    });
                                    b = (array[1] + " " + array[2]).GetbytesssASCII();
                                }
                            }
                        }
                    }
                }
            }
            item.size   = (ushort)b.Length;
            item.addbeg = (uint)dataput.strdatasize;
            dataput.strxinxis.Add(item);
            dataput.strbytes.Add(b);
            dataput.strdatasize += b.Length;
            return(dataput.strxinxis.Count - 1);
        }
Example #6
0
        public unsafe static string Strmake_BytesToStr16(byte[] bytes)
        {
            byte[] array = new byte[bytes.Length * 2];
            string @string;

            fixed(byte *ptr = bytes)
            {
                fixed(byte *ptr2 = array)
                {
                    Strmake.Strmake_BytesToStr16(ptr, ptr2, (byte)bytes.Length);
                    @string = Encoding.ASCII.GetString(array);
                }
            }

            return(@string);
        }
Example #7
0
        public static string GetMyID()
        {
            string result;

            try
            {
                string text  = Win32.GetMotherBoardSerialNumber();
                string text2 = Win32.GetDiskID();
                string text3 = Win32.GetMacAddress();
                if (text != "0000")
                {
                    text = Strmake.Strmake_BytesToStr16(Encoding.ASCII.GetBytes(text).getcrc(0).structToBytes());
                }
                if (text2 != "0000")
                {
                    text2 = Strmake.Strmake_BytesToStr16(Encoding.ASCII.GetBytes(text2).getcrc(0).structToBytes());
                }
                if (text3 != "0000")
                {
                    text3 = Strmake.Strmake_BytesToStr16(Encoding.ASCII.GetBytes(text3).getcrc(0).structToBytes());
                }
                result = string.Concat(new string[]
                {
                    text,
                    "-",
                    text2,
                    "-",
                    text3
                });
            }
            catch
            {
                result = "error";
            }
            return(result);
        }
Example #8
0
        public unsafe static void Strmake_S32ToStr(int num, byte *buf, byte lenth, byte isend)
        {
            byte b = Strmake.Strmake_GetS32strlen(num);

            if (lenth == 0)
            {
                lenth = b;
            }
            if (num == -2147483648)
            {
                *buf = 45;
                buf++;
                byte[] array = "2147483648".GetbytesssASCII();
                fixed(byte *ptr = array)
                {
                    Kuozhan.memcpy(buf, ptr, (int)lenth);
                }

                if (isend == 1)
                {
                    buf[lenth] = 0;
                }
            }
            else
            {
                if (num < 0)
                {
                    num *= -1;
                    *buf = 45;
                    buf++;
                }
                byte b2;
                if (b > lenth)
                {
                    b2 = (byte)(b - lenth);
                    for (int i = 1; i <= (int)b2; i++)
                    {
                        num /= 10;
                    }
                    b2 += 1;
                }
                else
                {
                    b  = lenth;
                    b2 = 1;
                }
                for (int i = (int)b2; i <= (int)b; i++)
                {
                    if (num == 0)
                    {
                        buf[(int)b - i] = Strmake.u8tables[0];
                    }
                    else
                    {
                        buf[(int)b - i] = Strmake.u8tables[num % 10];
                    }
                    num /= 10;
                }
                if (isend == 1)
                {
                    buf[lenth] = 0;
                }
            }
        }
Example #9
0
        private string getkeywordofoffset(int offset, byte state, ref int thisline, ref bool isnewline)
        {
            string text = "";
            string result;

            try
            {
                isnewline = false;
                if (offset >= this.textBox1.Text.Length || !this.isoffsettrue(offset))
                {
                    result = "";
                    return(result);
                }
                char charAt = this.textBox1.Document.GetCharAt(offset);
                if (charAt == '\r' || charAt == '\n')
                {
                    result = "";
                    return(result);
                }
                thisline = this.textBox1.Document.GetLineNumberForOffset(offset);
                int num;
                if (state == 0 || state == 2)
                {
                    if (Strmake.Strmake_IsAttendbyte((byte)charAt) == 1 || this.Keywordstr.Contains(charAt))
                    {
                        result = "";
                        return(result);
                    }
                    num = offset;
                    while (Strmake.Strmake_IsAttendbyte((byte)charAt) != 1 && !this.Keywordstr.Contains(charAt))
                    {
                        num--;
                        if (num < 0)
                        {
                            break;
                        }
                        charAt = this.textBox1.Document.GetCharAt(num);
                    }
                    num++;
                    int offset2 = this.textBox1.Document.GetLineSegment(thisline).Offset;
                    if (num == offset2 || this.textBox1.Document.GetText(offset2, num - offset2).Trim() == "")
                    {
                        isnewline = true;
                    }
                }
                else
                {
                    isnewline = true;
                    num       = this.textBox1.Document.GetLineSegment(thisline).Offset;
                }
                int num2;
                if (state == 0 || state == 1)
                {
                    num2 = offset;
                    if (state == 0)
                    {
                        int num3 = num2 + 1;
                        if (num3 < this.textBox1.Text.Length)
                        {
                            charAt = this.textBox1.Document.GetCharAt(num3);
                            if (Strmake.Strmake_IsAttendbyte((byte)charAt) != 1 && !this.Keywordstr.Contains(charAt))
                            {
                                result = "";
                                return(result);
                            }
                        }
                    }
                }
                else
                {
                    charAt = this.textBox1.Document.GetCharAt(offset);
                    num2   = offset;
                    while (Strmake.Strmake_IsAttendbyte((byte)charAt) != 1 && !this.Keywordstr.Contains(charAt))
                    {
                        num2++;
                        if (num2 >= this.textBox1.Text.Length)
                        {
                            break;
                        }
                        charAt = this.textBox1.Document.GetCharAt(num2);
                    }
                    num2--;
                }
                if (num2 < num)
                {
                    result = "";
                    return(result);
                }
                if (num2 - num > 99)
                {
                    result = "";
                    return(result);
                }
                if (text.Contains("\r") || text.Contains("\n"))
                {
                    text = "";
                }
                text = this.textBox1.Document.GetText(num, num2 - num + 1).TrimStart(new char[]
                {
                    ' '
                });
                this.KeyTextoffset = num;
                this.KeyTextlenth  = num2 - num + 1;
            }
            catch (Exception ex)
            {
                MessageOpen.Show(ex.Message);
            }
            result = text;
            return(result);
        }