public Engine(ICreateBlobFactory blob, IBlobData data, IInputReader reader, IOutputWriter writer)
 {
     this.createBlob = blob;
     this.data = data;
     this.reader = reader;
     this.writer = writer;
 }
Exemplo n.º 2
0
 public Engine(IBlobFactory blobFactory, IBlobData data, IInputReader reader, IOutputWriter writer)
 {
     this.blobFactory = blobFactory;
     this.data = data;
     this.reader = reader;
     this.writer = writer;
 }
Exemplo n.º 3
0
 public Engine(IBlobFactory blobFactory, IBlobData data, IInputReader reader, IOutputWriter writer)
 {
     this.blobFactory = blobFactory;
     this.data        = data;
     this.reader      = reader;
     this.writer      = writer;
 }
Exemplo n.º 4
0
 public int Compare(IBlobData a, IBlobData b)
 {
     lock (this)
     {
         if (a.GetId() == b.GetId())
         {
             return(0);
         }
         object[] lobHeader = this.GetLobHeader(a.GetId());
         if (lobHeader == null)
         {
             return(1);
         }
         long num2 = (long)lobHeader[1];
         lobHeader = this.GetLobHeader(b.GetId());
         if (lobHeader == null)
         {
             return(-1);
         }
         long num3 = (long)lobHeader[1];
         if (num2 > num3)
         {
             return(1);
         }
         if (num2 < num3)
         {
             return(-1);
         }
         return(this.CompareBytes(a.GetId(), b.GetId()));
     }
 }
Exemplo n.º 5
0
        public override object ConvertToType(ISessionInterface session, object a, SqlType othType)
        {
            if (a == null)
            {
                return(null);
            }
            if (othType.TypeCode == 30)
            {
                return(a);
            }
            if ((othType.TypeCode == 60) || (othType.TypeCode == 0x3d))
            {
                IBlobData  data = (IBlobData)a;
                BlobDataId id1  = session.CreateBlob(data.Length(session));
                id1.SetBytes(session, 0L, data.GetBytes());
                return(id1);
            }
            if ((othType.TypeCode != 12) && (othType.TypeCode != 1))
            {
                throw Error.GetError(0x15b9);
            }
            IBlobData  data2 = session.GetScanner().ConvertToBinary((string)a);
            BlobDataId id2   = session.CreateBlob(data2.Length(session));

            id2.SetBytes(session, 0L, data2.GetBytes());
            return(id2);
        }
Exemplo n.º 6
0
        public virtual IBlobData Overlay(Session session, IBlobData data, IBlobData overlay, long offset, long length, bool hasLength)
        {
            if ((data == null) || (overlay == null))
            {
                return(null);
            }
            if (!hasLength)
            {
                length = overlay.Length(session);
            }
            int typeCode = base.TypeCode;

            if (typeCode == 30)
            {
                byte[]    bytes = this.Substring(session, data, 0L, offset, false).GetBytes();
                long      num2  = (data.Length(session) + overlay.Length(session)) - length;
                IBlobData data3 = session.CreateBlob(num2);
                data3.SetBytes(session, 0L, bytes);
                data3.SetBytes(session, data3.Length(session), overlay.GetBytes());
                bytes = this.Substring(session, data, offset + length, 0L, false).GetBytes();
                data3.SetBytes(session, data3.Length(session), bytes);
                return(data3);
            }
            if ((typeCode - 60) > 1)
            {
                throw Error.RuntimeError(0xc9, "BinaryType");
            }
            return(new BinaryData(session, new BinaryData(session, this.Substring(session, data, 0L, offset, true), overlay), this.Substring(session, data, offset + length, 0L, false)));
        }
Exemplo n.º 7
0
        public override object ConvertSQLToCSharp(ISessionInterface session, object a)
        {
            IBlobData data1  = (IBlobData)a;
            int       length = (int)data1.Length(session);

            return(data1.GetBytes(session, 0L, length));
        }
Exemplo n.º 8
0
        public virtual IBlobData Substring(ISessionInterface session, IBlobData data, long offset, long length, bool hasLength)
        {
            long num2;
            long num = data.Length(session);

            if (hasLength)
            {
                num2 = offset + length;
            }
            else
            {
                num2 = (num > offset) ? num : offset;
            }
            if (offset > num2)
            {
                throw Error.GetError(0xd67);
            }
            if ((offset > num2) || (num2 < 0L))
            {
                offset = 0L;
                num2   = 0L;
            }
            if (offset < 0L)
            {
                offset = 0L;
            }
            if (num2 > num)
            {
                num2 = num;
            }
            length = num2 - offset;
            return(new BinaryData(data.GetBytes(session, offset, (int)length), false));
        }
Exemplo n.º 9
0
 public long Position(ISessionInterface session, IBlobData pattern, long start)
 {
     if (pattern.Length(session) > this._data.Length)
     {
         return(-1L);
     }
     byte[] bytes = pattern.GetBytes();
     return(this.Position(session, bytes, start));
 }
Exemplo n.º 10
0
        public Engine(IBlobFactory blobFactory, IAttackFactory attackFactory, IBehaviorFactory behaviorFactory,
                      IInputReader reader, IOutputWriter writer, IBlobData blobData)
        {
            this.blobFactory     = blobFactory;
            this.attackFactory   = attackFactory;
            this.behaviorFactory = behaviorFactory;
            this.reader          = reader;
            this.writer          = writer;
            this.blobData        = blobData;

            this.shouldReportEvents = false;
        }
Exemplo n.º 11
0
        public Engine(IBlobFactory blobFactory, IAttackFactory attackFactory, IBehaviorFactory behaviorFactory,
            IInputReader reader, IOutputWriter writer, IBlobData blobData)
        {
            this.blobFactory = blobFactory;
            this.attackFactory = attackFactory;
            this.behaviorFactory = behaviorFactory;
            this.reader = reader;
            this.writer = writer;
            this.blobData = blobData;

            this.shouldReportEvents = false;
        }
Exemplo n.º 12
0
        public BinaryData(ISessionInterface session, IBlobData b1, IBlobData b2)
        {
            long num = b1.Length(session) + b2.Length(session);

            if (num > 0x7fffffffL)
            {
                throw Error.GetError(0xd49);
            }
            this._data = new byte[(int)num];
            Array.Copy(b1.GetBytes(), 0, this._data, 0, (int)b1.Length(session));
            Array.Copy(b2.GetBytes(), 0, this._data, (int)b1.Length(session), (int)b2.Length(session));
            this._bitLength = (b1.Length(session) + b2.Length(session)) * 8L;
        }
Exemplo n.º 13
0
        public static long Position(ISessionInterface session, IBlobData data, IBlobData otherData, SqlType otherType, long offset)
        {
            if ((data == null) || (otherData == null))
            {
                return(-1L);
            }
            long num2 = data.Length(session);

            if ((offset + num2) > data.Length(session))
            {
                return(-1L);
            }
            return(data.Position(session, otherData, offset));
        }
Exemplo n.º 14
0
        internal async Task <IBlobData> GetBlob()
        {
            if (blobFetched)
            {
                return(blob);
            }
            var blobResult = GetBlobResult();

            if (blobResult != null)
            {
                blob = await blobResult.Value.GetBlob();
            }
            blobFetched = true;
            return(blob);
        }
Exemplo n.º 15
0
        public int Compare(IBlobData a, byte[] b)
        {
            int num;

            lock (this)
            {
                long    num2     = (long)this.GetLobHeader(a.GetId())[1];
                int[][] numArray = this.GetBlockAddresses(a.GetId(), 0, 0x7fffffff);
                int     index    = 0;
                int     num4     = 0;
                int     num5     = 0;
                do
                {
                    int    blockAddress = numArray[index][0] + num5;
                    byte[] blockBytes   = this._lobStore.GetBlockBytes(blockAddress, 1);
                    for (int i = 0; i < blockBytes.Length; i++)
                    {
                        if ((num4 + i) >= b.Length)
                        {
                            goto Label_00A3;
                        }
                        if (blockBytes[i] != b[num4 + i])
                        {
                            return(((blockBytes[i] & 0xff) > (b[num4 + i] & 0xff)) ? 1 : -1);
                        }
                    }
                    num5++;
                    num4 += this._lobBlockSize;
                    if (num5 == numArray[index][1])
                    {
                        num5 = 0;
                        index++;
                    }
                }while (index != numArray.Length);
                goto Label_00DC;
Label_00A3:
                if (num2 == b.Length)
                {
                    return(0);
                }
                return(1);

Label_00DC:
                num = -1;
            }
            return(num);
        }
Exemplo n.º 16
0
        public IBlobData Trim(Session session, IBlobData data, int trim, bool leading, bool trailing)
        {
            if (data == null)
            {
                return(null);
            }
            byte[] bytes  = data.GetBytes();
            int    length = bytes.Length;

            if (trailing)
            {
                length--;
                while ((length >= 0) && (bytes[length] == trim))
                {
                    length--;
                }
                length++;
            }
            int index = 0;

            if (leading)
            {
                while ((index < length) && (bytes[index] == trim))
                {
                    index++;
                }
            }
            byte[] destinationArray = bytes;
            if ((index != 0) || (length != bytes.Length))
            {
                destinationArray = new byte[length - index];
                Array.Copy(bytes, index, destinationArray, 0, length - index);
            }
            if (base.TypeCode == 30)
            {
                BlobDataId id1 = session.CreateBlob((long)destinationArray.Length);
                id1.SetBytes(session, 0L, destinationArray);
                return(id1);
            }
            return(new BinaryData(destinationArray, destinationArray == bytes));
        }
Exemplo n.º 17
0
 protected override void WriteBlob(IBlobData o, SqlType type)
 {
     this.WriteLong(o.GetId());
 }
Exemplo n.º 18
0
 public long Position(ISessionInterface session, IBlobData pattern, long start)
 {
     return(0L);
 }
Exemplo n.º 19
0
 protected abstract void WriteBlob(IBlobData o, SqlType type);
Exemplo n.º 20
0
        private object CastOrConvertToType(ISessionInterface session, object a, SqlType otherType, bool cast)
        {
            if (a == null)
            {
                return(null);
            }
            int typeCode = otherType.TypeCode;

            if (typeCode > 12)
            {
                if ((typeCode != 30) && ((typeCode - 60) > 1))
                {
                    goto Label_005A;
                }
                IBlobData data1 = (IBlobData)a;
                goto Label_0065;
            }
            switch (typeCode)
            {
            case 1:
            case 12:
            {
                IBlobData data = session.GetScanner().ConvertToBinary((string)a);
                otherType = GetBinaryType(0x3d, data.Length(session));
                goto Label_0065;
            }
            }
Label_005A:
            throw Error.GetError(0xd8f);
Label_0065:
            if (base.Precision == 0)
            {
                return(null);
            }
            IBlobData data2 = null;

            if ((data2.Length(session) > base.Precision) && (data2.NonZeroLength(session) > base.Precision))
            {
                if (!cast)
                {
                    throw Error.GetError(0xd49);
                }
                session.AddWarning(Error.GetError(0x3ec));
            }
            if (otherType.TypeCode == 30)
            {
                long num2 = data2.Length(session);
                if (num2 > base.Precision)
                {
                    throw Error.GetError(0xd8f);
                }
                data2 = new BinaryData(data2.GetBytes(session, 0L, (int)num2), false);
            }
            int num3 = base.TypeCode;

            if (num3 == 60)
            {
                if (data2.Length(session) > base.Precision)
                {
                    return(new BinaryData(data2.GetBytes(session, 0L, (int)base.Precision), false));
                }
                if (data2.Length(session) < base.Precision)
                {
                    data2 = new BinaryData(ArrayUtil.ResizeArray <byte>(data2.GetBytes(), (int)base.Precision), false);
                }
                return(data2);
            }
            if (num3 != 0x3d)
            {
                throw Error.GetError(0xd8f);
            }
            if (data2.Length(session) > base.Precision)
            {
                data2 = new BinaryData(data2.GetBytes(session, 0L, (int)base.Precision), false);
            }
            return(data2);
        }