3 |
|
|
4 |
#include "rdesktop.h" |
#include "rdesktop.h" |
5 |
|
|
6 |
/* mppc-like??? decompression */ |
/* mppc decompression */ |
7 |
/* http://www.faqs.org/rfcs/rfc2118.html */ |
/* http://www.faqs.org/rfcs/rfc2118.html */ |
8 |
|
|
9 |
/* TODO: research the below statements */ |
/* TODO: research the below statements */ |
18 |
/* already paying royalties */ |
/* already paying royalties */ |
19 |
/* through the CAL licenses? */ |
/* through the CAL licenses? */ |
20 |
|
|
21 |
/* the dictionary is empty when init. like */ |
/* as the rfc states the algorithm seems to */ |
22 |
/* LZ78, which is not patented */ |
/* be LZ77 with a sliding buffer */ |
23 |
|
/* that is empty at init. */ |
24 |
|
|
25 |
|
/* as of my limited knowledge these patents */ |
26 |
|
/* has expired. */ |
27 |
|
|
28 |
RDPCOMP mppc_dict; |
|
29 |
|
RDPCOMP g_mppc_dict; |
30 |
|
|
31 |
int |
int |
32 |
mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen) |
mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen) |
37 |
int match_len; |
int match_len; |
38 |
int old_offset, match_bits; |
int old_offset, match_bits; |
39 |
|
|
40 |
signed char *dict = &(mppc_dict.hist); |
signed char *dict = &(g_mppc_dict.hist); |
41 |
|
|
42 |
if ((ctype & RDP_MPPC_COMPRESSED) == 0) |
if ((ctype & RDP_MPPC_COMPRESSED) == 0) |
43 |
{ |
{ |
48 |
|
|
49 |
if ((ctype & RDP_MPPC_RESET) != 0) |
if ((ctype & RDP_MPPC_RESET) != 0) |
50 |
{ |
{ |
51 |
mppc_dict.roff = 0; |
g_mppc_dict.roff = 0; |
52 |
} |
} |
53 |
|
|
54 |
if ((ctype & RDP_MPPC_FLUSH) != 0) |
if ((ctype & RDP_MPPC_FLUSH) != 0) |
55 |
{ |
{ |
56 |
memset(dict, 0, RDP_MPPC_DICT_SIZE); |
memset(dict, 0, RDP_MPPC_DICT_SIZE); |
57 |
mppc_dict.roff = 0; |
g_mppc_dict.roff = 0; |
58 |
} |
} |
59 |
|
|
60 |
*roff = 0; |
*roff = 0; |
61 |
*rlen = 0; |
*rlen = 0; |
62 |
|
|
63 |
walker = mppc_dict.roff; |
walker = g_mppc_dict.roff; |
64 |
|
|
65 |
next_offset = walker; |
next_offset = walker; |
66 |
old_offset = next_offset; |
old_offset = next_offset; |
271 |
while (1); |
while (1); |
272 |
|
|
273 |
/* store history offset */ |
/* store history offset */ |
274 |
mppc_dict.roff = next_offset; |
g_mppc_dict.roff = next_offset; |
275 |
|
|
276 |
*roff = old_offset; |
*roff = old_offset; |
277 |
*rlen = next_offset - old_offset; |
*rlen = next_offset - old_offset; |