Пример #1
0
        public byte[] OnlyChapter(string html, int allheadenth, string htmlname, int index, int encodeing, int key)
        {
            GetChapterListArray array     = new GetChapterListArray();
            ChapterListModel    infomodel = new ChapterListModel
            {
                chapter_index1                      = (uint)index,
                chapter_level2                      = 1,
                chapter_data_type3                  = 0,
                chapter_data_block_offset4          = (uint)allheadenth,
                chapter_content_decompresss_offset5 = 0
            };

            if (encodeing == 3)
            {
                infomodel.chapter_content_decompress_length6 = (uint)(Encoding.UTF8.GetBytes(html).Length);
            }
            if (encodeing == 1)
            {
                infomodel.chapter_content_decompress_length6 = (uint)(Encoding.Unicode.GetBytes(html).Length);
            }
            infomodel.chapter_name_length7 = (uint)(Encoding.Unicode.GetBytes(htmlname).Length);
            infomodel.chapter_name_data8   = htmlname;
            return(array.infomodelarray(infomodel, key));
        }
Пример #2
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);
        }