Go to the documentation of this file.
29#define LZFU_COMPRESSED 0x75465a4c
30#define LZFU_UNCOMPRESSED 0x414c454d
32#define LZFU_INITDICT \
33 "{\\rtf1\\ansi\\mac\\deff0\\deftab720{\\fonttbl;}" \
34 "{\\f0\\fnil \\froman \\fswiss \\fmodern \\fscrip" \
35 "t \\fdecor MS Sans SerifSymbolArialTimes Ne" \
36 "w RomanCourier{\\colortbl\\red0\\green0\\blue0" \
37 "\r\n\\par \\pard\\plain\\f0\\fs20\\b\\i\\u\\tab" \
39#define LZFU_INITLENGTH 207
43using lzfuheader =
struct _lzfuheader {
52#define FLAG(f, n) (f >> n) & 0x1
59#define OFFSET(b) (b >> 4) & 0xFFF
60#define LENGTH(b) ((b & 0xF) + 2)
65 unsigned char window[4096];
66 unsigned int wlength = 0;
67 unsigned int cursor = 0;
68 unsigned int ocursor = 0;
75 memcpy(window, LZFU_INITDICT, LZFU_INITLENGTH);
76 wlength = LZFU_INITLENGTH;
77 if (input->
read((
char *)&lzfuhdr,
sizeof(lzfuhdr)) !=
sizeof(lzfuhdr)) {
78 fprintf(stderr,
"unexpected eof, cannot read LZFU header\n");
81 cursor +=
sizeof(lzfuhdr);
83 fprintf(stdout,
"total size : %d\n", lzfuhdr.cbSize + 4);
84 fprintf(stdout,
"raw size : %d\n", lzfuhdr.cbRawSize);
85 fprintf(stdout,
"compressed : %s\n", (lzfuhdr.dwMagic == LZFU_COMPRESSED ?
"yes" :
"no"));
86 fprintf(stdout,
"CRC : %x\n", lzfuhdr.dwCRC);
87 fprintf(stdout,
"\n");
90 while (cursor < lzfuhdr.cbSize + 4 && ocursor < lzfuhdr.cbRawSize && !input->atEnd()) {
91 if (input->
read(&bFlags, 1) != 1) {
92 fprintf(stderr,
"unexpected eof, cannot read chunk flag\n");
98 fprintf(stdout,
"Flags : ");
99 for (
int i = nFlags - 1; i >= 0; i--) {
100 fprintf(stdout,
"%d", FLAG(bFlags, i));
102 fprintf(stdout,
"\n");
104 for (
int i = 0; i < nFlags && ocursor < lzfuhdr.cbRawSize && cursor < lzfuhdr.cbSize + 4; i++) {
105 if (FLAG(bFlags, i)) {
109 if (input->
read(&c1, 1) != 1 || input->
read(&c2, 1) != 1) {
110 fprintf(stderr,
"unexpected eof, cannot read block header\n");
115 blkhdr |= (0xFF & c2);
116 unsigned int offset = OFFSET(blkhdr);
117 unsigned int length = LENGTH(blkhdr);
120 fprintf(stdout,
"block : offset=%.4d [%d], length=%.2d (0x%04X)\n", OFFSET(blkhdr), wlength, LENGTH(blkhdr), blkhdr);
126 fprintf(stdout,
"block : ");
128 for (
unsigned int i = 0; i < length; i++) {
129 c1 = window[(offset + i) % 4096];
131 window[wlength] = c1;
132 wlength = (wlength + 1) % 4096;
136 fprintf(stdout,
"\nblock : ");
138 fprintf(stdout,
"%c", c1);
145 fprintf(stdout,
"\n");
151 if (!input->
atEnd()) {
152 fprintf(stderr,
"unexpected eof, cannot read character\n");
158 fprintf(stdout,
"char : %c\n", c);
163 wlength = (wlength + 1) % 4096;
This file is part of the API for handling TNEF data and provides the LZFU decompression functionality...
int lzfu_decompress(QIODevice *input, QIODevice *output)
LZFU decompress data in compressed Rich Text Format (RTF).
virtual bool atEnd() const const
QByteArray read(qint64 maxSize)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:13:25 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.