/[rdesktop]/sourceforge.net/trunk/rdesktop/pstcache.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/pstcache.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 725 by jsorg71, Sun Jun 27 17:51:54 2004 UTC revision 808 by jdmeijer, Sat Dec 25 13:37:08 2004 UTC
# Line 20  Line 20 
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) (id < 8 && g_pstcache_fd[id] > 0)
26    
27  extern int g_server_bpp;  extern int g_server_bpp;
28  extern uint32 g_stamp;  extern uint32 g_stamp;
# Line 33  extern BOOL g_bitmap_cache_precache; Line 33  extern BOOL g_bitmap_cache_precache;
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 */
# Line 42  pstcache_touch_bitmap(uint8 cache_id, ui Line 42  pstcache_touch_bitmap(uint8 cache_id, ui
42  {  {
43          int fd;          int fd;
44    
45          if (!IS_PERSISTENT(cache_id))          if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
46                  return;                  return;
47    
48          fd = g_pstcache_fd[cache_id];          fd = g_pstcache_fd[cache_id];
# Line 59  pstcache_load_bitmap(uint8 cache_id, uin Line 59  pstcache_load_bitmap(uint8 cache_id, uin
59          CELLHEADER cellhdr;          CELLHEADER cellhdr;
60          HBITMAP bitmap;          HBITMAP bitmap;
61    
62          if (!(g_bitmap_cache_persist_enable && IS_PERSISTENT(cache_id)))          if (!g_bitmap_cache_persist_enable)
63                    return False;
64    
65            if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
66                  return False;                  return False;
67    
68          fd = g_pstcache_fd[cache_id];          fd = g_pstcache_fd[cache_id];
69          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)));
70          rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));          rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));
71          celldata = (uint8 *)xmalloc(cellhdr.length);          celldata = (uint8 *) xmalloc(cellhdr.length);
72          rd_read_file(fd, celldata, cellhdr.length);          rd_read_file(fd, celldata, cellhdr.length);
73    
74          DEBUG(("Loading bitmap from disk (%d:%d)\n", cache_id, cache_idx));          DEBUG(("Loading bitmap from disk (%d:%d)\n", cache_id, cache_idx));
# Line 79  pstcache_load_bitmap(uint8 cache_id, uin Line 82  pstcache_load_bitmap(uint8 cache_id, uin
82    
83  /* Store a bitmap in the persistent cache */  /* Store a bitmap in the persistent cache */
84  BOOL  BOOL
85  pstcache_put_bitmap(uint8 cache_id, uint16 cache_idx, uint8 *bitmap_id,  pstcache_put_bitmap(uint8 cache_id, uint16 cache_idx, uint8 * bitmap_id,
86                  uint16 width, uint16 height, uint16 length, uint8 *data)                      uint16 width, uint16 height, uint16 length, uint8 * data)
87  {  {
88          int fd;          int fd;
89          CELLHEADER cellhdr;          CELLHEADER cellhdr;
90    
91          if (!IS_PERSISTENT(cache_id))          if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
92                  return False;                  return False;
93    
94          memcpy(cellhdr.bitmap_id, bitmap_id, sizeof(BITMAP_ID));          memcpy(cellhdr.bitmap_id, bitmap_id, sizeof(BITMAP_ID));
# Line 104  pstcache_put_bitmap(uint8 cache_id, uint Line 107  pstcache_put_bitmap(uint8 cache_id, uint
107    
108  /* list the bitmaps from the persistent cache file */  /* list the bitmaps from the persistent cache file */
109  int  int
110  pstcache_enumerate(uint8 cache_id, uint8 *idlist)  pstcache_enumerate(uint8 cache_id, uint8 * idlist)
111  {  {
112          int fd, n, c = 0;          int fd, n, c = 0;
113          CELLHEADER cellhdr;          CELLHEADER cellhdr;
# Line 127  pstcache_enumerate(uint8 cache_id, uint8 Line 130  pstcache_enumerate(uint8 cache_id, uint8
130                  if (memcmp(cellhdr.bitmap_id, zero_id, sizeof(BITMAP_ID)) != 0)                  if (memcmp(cellhdr.bitmap_id, zero_id, sizeof(BITMAP_ID)) != 0)
131                  {                  {
132                          memcpy(idlist + n * sizeof(BITMAP_ID), cellhdr.bitmap_id,                          memcpy(idlist + n * sizeof(BITMAP_ID), cellhdr.bitmap_id,
133                                          sizeof(BITMAP_ID));                                 sizeof(BITMAP_ID));
134    
135                          if (cellhdr.stamp)                          if (cellhdr.stamp)
136                          {                          {

Legend:
Removed from v.725  
changed lines
  Added in v.808

  ViewVC Help
Powered by ViewVC 1.1.26