Example #1
0
        public void Process()
        {
            RandomAccess ra = RandomAccess.GetInstance();

            addr                 = ra.leLong();
            pageSize             = ra.leShort();
            pageSizeUncompressed = ra.leShort();
            pageSizeUncompressedWithoutHeader = ra.leShort();
            recordCount = ra.leShort();
            flags       = (int)ra.leByte();

            ra.jumpRelative(pageSize - 13);               //burn these bytes. This will leave the RandomAccess at the very end of the page
        }
Example #2
0
        public void Process()
        {
            RandomAccess ra = RandomAccess.GetInstance();

            ra.position = 0;

            Addr = ra.leLong();
            if (Addr != 0)
            {
                throw new Exception("File doesn't start with 0x00000000 - it's not a TPS databse");
            }

            HeaderSize        = ra.leShort();
            FileLength1       = ra.leLong();
            FileLength2       = ra.leLong();
            TopSpeed          = ra.fixedLengthString(4);
            Zeros             = ra.leShort();
            LastIssuedRow     = ra.beLong();
            Changes           = ra.leLong();
            ManagementPageRef = ra.toFileOffset(ra.leLong());

            PageStart = ra.toFileOffset(ra.leLongArray((0x110 - 0x20) / 4));
            PageEnd   = ra.toFileOffset(ra.leLongArray((0x200 - 0x110) / 4));
        }
Example #3
0
        /// <summary>
        /// Will return a list of all pages in the block
        /// </summary>
        /// <returns></returns>
        public List <TPSPage> getPages()
        {
            RandomAccess   ra    = RandomAccess.GetInstance();
            List <TPSPage> pages = new List <TPSPage>();

            ra.jumpAbs(_start);             //jump to the start of the block

            try{
                while (ra.position < _end)                    //while we have not fallen off the end of the file

                {
                    TPSPage page = new TPSPage();
                    page.Process();
                    pages.Add(page);

                    //pages always start on the position % 100 = 0
                    //So let's jump forward to find the next start
                    if ((ra.position & 0xFF) != 0x00)
                    {
                        ra.jumpAbs((ra.position & 0xFFFFFF00L) + 0x0100);
                    }

                    //we can find the next page because the address of the page will be in the data
                    int addr = 0;
                    if (!ra.isAtEnd())
                    {
                        do
                        {
                            addr = ra.leLong();
                            ra.jumpRelative(-4);                             //backup 4 bytes

                            if (addr != ra.position)
                            {
                                ra.jumpRelative(0x0100);
                            }
                        }while ((addr != ra.position) && !ra.isAtEnd());
                    }
                }
            }catch (Exception ex) {
                ;
            }

            return(pages);
        }
Example #4
0
        public object parseField(int type, int ofs, int len, TableField field, RandomAccess ra)
        {
            ra.jumpAbs(ofs);
            switch (type)
            {
            case 1:
                // byte
                assertEqual(1, len);
                return(ra.leByte());

            case 2:
                // short
                assertEqual(2, len);
                return(ra.leShort());

            case 3:
                // unsigned short
                assertEqual(2, len);
                return(ra.leUShort());

            case 4:
                // Date, mask encoded.
                long date = ra.leULong();
                if (date != 0)
                {
                    long years  = (date & 0xFFFF0000) >> 16;
                    long months = (date & 0x0000FF00) >> 8;
                    long days   = (date & 0x000000FF);
                    return(new DateTime((int)years, (int)months, (int)days));
                }
                else
                {
                    return(null);
                }

            case 5:
                //
                // Time, mask encoded.
                // So far i've only had values with hours and minutes
                // but no seconds or milliseconds so I've no way of
                // knowing how to decode these.
                //
                //TODO: Fix the time here based on decaseconds
                int time  = ra.leLong();
                int mins  = (time & 0x00FF0000) >> 16;
                int hours = (time & 0x7F000000) >> 24;
                //
                return(hours + " " + mins);            //

            case 6:
                // Long
                assertEqual(4, len);
                return(ra.leLong());

            case 7:
                // Unsigned Long
                assertEqual(4, len);
                return(ra.leULong());

            case 8:
                // Float
                assertEqual(4, len);
                return(ra.leFloat());

            case 9:
                // Double
                assertEqual(8, len);
                return(ra.leDouble());

            case 0x0A:
                // BCD encoded.
                return(ra.binaryCodedDecimal(len, field.BcdLengthOfElement, field.BcdDigitsAfterDecimalPoint));

            case 0x12:
                // Fixed Length String
                return(ra.fixedLengthString(len));

            case 0x13:
                return(ra.zeroTerminatedString());

            case 0x14:
                return(ra.pascalString());

            case 0x16:
                // Group (an overlay on top of existing data, can be anything).
                return(ra.leBytes(len));

            default:
                throw new Exception("Unsupported type " + type + " (" + len + ")");
            }
        }