20 |
|
|
21 |
#include "rdesktop.h" |
#include "rdesktop.h" |
22 |
|
|
23 |
#define MAX_CELL_SIZE 0x1000 /* pixels */ |
#define MAX_CELL_SIZE 0x1000 /* pixels */ |
24 |
|
|
25 |
#define IS_PERSISTENT(id) (g_pstcache_fd[id] > 0) |
#define IS_PERSISTENT(id) (g_pstcache_fd[id] > 0) |
26 |
|
|
33 |
int g_pstcache_fd[8]; |
int g_pstcache_fd[8]; |
34 |
int g_pstcache_Bpp; |
int g_pstcache_Bpp; |
35 |
BOOL g_pstcache_enumerated = False; |
BOOL g_pstcache_enumerated = False; |
36 |
uint8 zero_id[] = {0, 0, 0, 0, 0, 0, 0, 0}; |
uint8 zero_id[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
37 |
|
|
38 |
|
|
39 |
/* Update usage info for a bitmap */ |
/* Update usage info for a bitmap */ |
65 |
fd = g_pstcache_fd[cache_id]; |
fd = g_pstcache_fd[cache_id]; |
66 |
rd_lseek_file(fd, cache_idx * (g_pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER))); |
rd_lseek_file(fd, cache_idx * (g_pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER))); |
67 |
rd_read_file(fd, &cellhdr, sizeof(CELLHEADER)); |
rd_read_file(fd, &cellhdr, sizeof(CELLHEADER)); |
68 |
celldata = (uint8 *)xmalloc(cellhdr.length); |
celldata = (uint8 *) xmalloc(cellhdr.length); |
69 |
rd_read_file(fd, celldata, cellhdr.length); |
rd_read_file(fd, celldata, cellhdr.length); |
70 |
|
|
71 |
DEBUG(("Loading bitmap from disk (%d:%d)\n", cache_id, cache_idx)); |
DEBUG(("Loading bitmap from disk (%d:%d)\n", cache_id, cache_idx)); |
79 |
|
|
80 |
/* Store a bitmap in the persistent cache */ |
/* Store a bitmap in the persistent cache */ |
81 |
BOOL |
BOOL |
82 |
pstcache_put_bitmap(uint8 cache_id, uint16 cache_idx, uint8 *bitmap_id, |
pstcache_put_bitmap(uint8 cache_id, uint16 cache_idx, uint8 * bitmap_id, |
83 |
uint16 width, uint16 height, uint16 length, uint8 *data) |
uint16 width, uint16 height, uint16 length, uint8 * data) |
84 |
{ |
{ |
85 |
int fd; |
int fd; |
86 |
CELLHEADER cellhdr; |
CELLHEADER cellhdr; |
104 |
|
|
105 |
/* list the bitmaps from the persistent cache file */ |
/* list the bitmaps from the persistent cache file */ |
106 |
int |
int |
107 |
pstcache_enumerate(uint8 cache_id, uint8 *idlist) |
pstcache_enumerate(uint8 cache_id, uint8 * idlist) |
108 |
{ |
{ |
109 |
int fd, n, c = 0; |
int fd, n, c = 0; |
110 |
CELLHEADER cellhdr; |
CELLHEADER cellhdr; |
127 |
if (memcmp(cellhdr.bitmap_id, zero_id, sizeof(BITMAP_ID)) != 0) |
if (memcmp(cellhdr.bitmap_id, zero_id, sizeof(BITMAP_ID)) != 0) |
128 |
{ |
{ |
129 |
memcpy(idlist + n * sizeof(BITMAP_ID), cellhdr.bitmap_id, |
memcpy(idlist + n * sizeof(BITMAP_ID), cellhdr.bitmap_id, |
130 |
sizeof(BITMAP_ID)); |
sizeof(BITMAP_ID)); |
131 |
|
|
132 |
if (cellhdr.stamp) |
if (cellhdr.stamp) |
133 |
{ |
{ |