Exemplo n.º 1
0
        public byteinfo GetTextChapter(BookInfo bookinfo, int chapterstart, int chapterblock, int key)
        {
            string             text       = bookinfo.Text;
            List <chapterlist> list       = new List <chapterlist>();
            Model               model     = new Model();
            byteinfo            byteinfo  = new byteinfo();
            ChapterListModel    infomodel = new ChapterListModel();
            GetChapterListArray array     = new GetChapterListArray();
            int    num    = 0;
            int    lenth  = 0;
            int    offset = 0;
            string str2   = text.Replace("\r\n", "\n");

            for (int i = 0; i < bookinfo.ChaterList.Count; i++)
            {
                int index  = bookinfo.ChaterList[i].Index;
                int length = 0;
                if (i != (bookinfo.ChaterList.Count - 1))
                {
                    length = bookinfo.ChaterList[i + 1].Index;
                }
                else
                {
                    length = str2.Length;
                }
                string s = str2.Substring(index, length - index).Replace("\n", "\r\n");
                lenth = s.Length * 2;
                string      chaptername = bookinfo.ChaterList[i].Name.Replace("\n", "");
                chapterlist chapterlist = new chapterlist(offset, lenth, chaptername);
                list.Add(chapterlist);
                num    += Encoding.UTF8.GetBytes(s).Length;
                offset += lenth;
            }
            int num7 = offset;
            int num8 = num7 / model.CATHY_LZ77_WINDOW_SIZE;

            if ((num7 % model.CATHY_LZ77_WINDOW_SIZE) != 0)
            {
                num8++;
            }
            uint num9  = 0;
            uint num10 = 0;

            byte[] buffer = new byte[0xa00000];
            byte[] bytes  = Encoding.Unicode.GetBytes(text);
            while (num7 >= model.CATHY_LZ77_WINDOW_SIZE)
            {
                byte[] inputBytes = new byte[0x10000];
                Array.Copy(bytes, num10 * model.CATHY_LZ77_WINDOW_SIZE, inputBytes, 0, inputBytes.Length);
                byte[] buffer4 = this.encodeingtext(DeCompress.Compress(inputBytes), key);
                Array.Copy(buffer4, 0, buffer, (int)num9, buffer4.Length);
                int            num11 = (int)num9;
                int            num12 = buffer4.Length;
                m_compressList list2 = new m_compressList(num11, num12);
                byteinfo.compressblocksizelist.Add(list2);
                num10++;
                num9 += (uint)(buffer4.Length);
                num7 -= model.CATHY_LZ77_WINDOW_SIZE;
            }
            if (num7 > 0)
            {
                byte[] buffer5 = new byte[num7];
                Array.Copy(bytes, bytes.Length - num7, buffer5, 0, buffer5.Length);
                byte[] buffer6 = this.encodeingtext(DeCompress.Compress(buffer5), key);
                Array.Copy(buffer6, 0, buffer, (int)num9, buffer6.Length);
                int num13 = (int)num9;
                int num14 = buffer6.Length;
                num10++;
                m_compressList list3 = new m_compressList(num13, num14);
                byteinfo.compressblocksizelist.Add(list3);
                num9 += (uint)buffer6.Length;
            }
            byte[] buffer7 = new byte[0x100000];
            int    num15   = 0;

            for (int j = 0; j < bookinfo.ChaterList.Count; j++)
            {
                chapterlist chapterlist2 = list[j];
                infomodel.chapter_index1                      = (uint)(chapterstart + j);
                infomodel.chapter_level2                      = 1;
                infomodel.chapter_data_type3                  = 1;
                infomodel.chapter_data_block_offset4          = (uint)chapterblock;
                infomodel.chapter_content_decompresss_offset5 = (uint)chapterlist2._offset;
                infomodel.chapter_content_decompress_length6  = (uint)chapterlist2._lenth;
                infomodel.chapter_name_length7                = (uint)Encoding.Unicode.GetBytes(chapterlist2._chaptername).Length;
                infomodel.chapter_name_data8                  = chapterlist2._chaptername;
                byte[] buffer8 = array.infomodelarray(infomodel, key);
                Array.Copy(buffer8, 0, buffer7, num15, buffer8.Length);
                num15 += buffer8.Length;
            }
            byte[] buffer9  = new byte[num9];
            byte[] buffer10 = new byte[num15];
            Array.Copy(buffer7, 0, buffer10, 0, buffer10.Length);
            Array.Copy(buffer, 0, buffer9, 0, buffer9.Length);
            byteinfo.compressysdate       = buffer9;
            byteinfo.chaptertxtbyteresult = buffer10;
            return(byteinfo);
        }
Exemplo n.º 2
0
        public BookInfo Open(byte[] buffer)
        {
            EBK3HeadStruct         headStruct             = new EBK3HeadStruct();
            EBK3HeadInfoModel      recodeModel            = new EBK3HeadInfoModel();
            ChapterHeadModelStruct chapterHeadModelStruct = new ChapterHeadModelStruct();

            new blockinfoModel();
            new ChapterListModel();
            DynDataStruct dynDataStruct = new DynDataStruct();

            headStruct = new ByteToStructEbk3().GetHeadStruct(buffer);
            int key = (int)headStruct.decode_key;

            byte[] buffer2 = new byte[headStruct.header_length];
            Array.Copy(buffer, 0, buffer2, 0, buffer2.Length);
            byte[] data = new byte[buffer2.Length - 0x10];
            Array.Copy(buffer, 0x10, data, 0, data.Length);
            recodeModel = GetRecodeModel(this.ebk3_data.pbk_sys_data_decode(data, key), (int)recodeModel.modellenth);
            byte[] buffs = new byte[0x10];
            Array.Copy(buffer, (int)recodeModel.chapter_dyn_info_offset5, buffs, 0, buffs.Length);
            dynDataStruct = new ByteToStructEbk3().GetDynDataStruct(buffs);
            byte[] buffer5 = new byte[dynDataStruct.chapter_list_length];
            Array.Copy(buffer, (int)dynDataStruct.chapter_list_offset, buffer5, 0, buffer5.Length);
            chapterHeadModelStruct = new ByteToStructEbk3().GetChapterHeadModelStruct(buffer5);
            byte[] buff = new byte[buffer5.Length - 8];
            Array.Copy(buffer5, 8, buff, 0, buff.Length);
            this.mChapterList = this.GetChapterList((int)chapterHeadModelStruct.chapter_count, (int)chapterHeadModelStruct.chapter_name_header_length, buff, key);
            this.mChapterList = this.SortChapterList(this.mChapterList);
            BookInfo info = new BookInfo();

            info.BookName = recodeModel.name;
            info.Author   = recodeModel.author;
            for (int i = 0; i < this.mChapterList.Count; i++)
            {
                ChapterListModel model2 = this.mChapterList[i];
                if ((model2.chapter_data_type3 != 0) && (info.Text == ""))
                {
                    byte[] blockdata = new byte[buffer.Length - model2.chapter_data_block_offset4];
                    Array.Copy(buffer, (int)model2.chapter_data_block_offset4, blockdata, 0, blockdata.Length);
                    string chapter = this.Getchapter(blockdata, 1);
                    info.Text = chapter;
                }
            }
            byte[] bytes   = Encoding.Unicode.GetBytes(info.Text);
            int    num3    = 0;
            int    myindex = 0;

            for (int j = 0; j < this.mChapterList.Count; j++)
            {
                ChapterListModel model3 = this.mChapterList[j];
                if (model3.chapter_data_type3 == 1)
                {
                    if (num3 == 0)
                    {
                        BookItems items = new BookItems(model3.chapter_name_data8, 0, model3.chapter_name_data8.Length);
                        info.ChaterList.Add(items);
                    }
                    else
                    {
                        ChapterListModel model4 = this.mChapterList[j - 1];
                        int    num6             = (int)model4.chapter_content_decompresss_offset5;
                        int    num7             = (int)model4.chapter_content_decompress_length6;
                        byte[] buffer9          = new byte[num7];
                        Array.Copy(bytes, num6, buffer9, 0, num7);
                        string str2 = Encoding.Unicode.GetString(buffer9, 0, buffer9.Length);
                        myindex += str2.Replace("\r\n", "\n").Length;
                        BookItems items2 = new BookItems(model3.chapter_name_data8, myindex, model3.chapter_name_data8.Length);
                        info.ChaterList.Add(items2);
                    }
                    num3++;
                }
            }
            return(info);
        }
Exemplo n.º 3
0
 public int ebk2makes(BookInfo bookinfo, byte[] txtData, int txtLenth, string fileFullName, int chpterstartindex, int chpterendindex, int flag)
 {
     return(1);
 }