Example #1
0
/* List the bitmap keys from the persistent cache file */
int
pstcache_enumerate(rdpPcache * pcache, uint8 id, HASH_KEY * keylist)
{
	int fd, n;
	uint16 idx;
	sint16 mru_idx[0xa00];
	uint32 mru_stamp[0xa00];
	CELLHEADER cellhdr;

	if (!(pcache->rdp->settings->bitmap_cache &&
	      pcache->rdp->settings->bitmap_cache_persist_enable &&
	      IS_PERSISTENT(id)))
		return 0;

	/* The server disconnects if the bitmap cache content is sent more than once */
	if (pcache->pstcache_enumerated)
		return 0;

	DEBUG_RDP5("Persistent bitmap cache enumeration... ");
	for (idx = 0; idx < BMPCACHE2_NUM_PSTCELLS; idx++)
	{
		fd = pcache->pstcache_fd[id];
		rd_lseek_file(fd, idx *
			(pcache->pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
		if (rd_read_file(fd, &cellhdr, sizeof(CELLHEADER)) <= 0)
			break;

		if (memcmp(cellhdr.key, pcache->zero_key, sizeof(HASH_KEY)) != 0)
		{
			memcpy(keylist[idx], cellhdr.key, sizeof(HASH_KEY));

			/* Pre-cache (not possible for 8 bit color depth cause it needs a colormap) */
			if (pcache->rdp->settings->bitmap_cache_precache && cellhdr.stamp &&
			    pcache->rdp->settings->server_depth > 8)
				pstcache_load_bitmap(pcache, id, idx);

			/* Sort by stamp */
			for (n = idx; n > 0 && cellhdr.stamp < mru_stamp[n - 1]; n--)
			{
				mru_idx[n] = mru_idx[n - 1];
				mru_stamp[n] = mru_stamp[n - 1];
			}

			mru_idx[n] = idx;
			mru_stamp[n] = cellhdr.stamp;
		}
		else
		{
			break;
		}
	}

	DEBUG_RDP5("%d cached bitmaps.\n", idx);

	cache_rebuild_bmpcache_linked_list(pcache->rdp->cache, id, mru_idx, idx);
	pcache->pstcache_enumerated = True;
	return idx;
}
Example #2
0
/* List the bitmap keys from the persistent cache file */
int
pstcache_enumerate(uint8 id, HASH_KEY * keylist)
{
	int fd, n;
	uint16 idx;
	sint16 mru_idx[0xa00];
	uint32 mru_stamp[0xa00];
	CELLHEADER cellhdr;

	if (!(g_bitmap_cache && g_bitmap_cache_persist_enable && IS_PERSISTENT(id)))
		return 0;

	/* The server disconnects if the bitmap cache content is sent more than once */
	if (g_pstcache_enumerated)
		return 0;

	logger(Core, Debug, "pstcache_enumerate(), start enumeration");
	for (idx = 0; idx < BMPCACHE2_NUM_PSTCELLS; idx++)
	{
		fd = g_pstcache_fd[id];
		rd_lseek_file(fd, idx * (g_pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
		if (rd_read_file(fd, &cellhdr, sizeof(CELLHEADER)) <= 0)
			break;

		if (memcmp(cellhdr.key, zero_key, sizeof(HASH_KEY)) != 0)
		{
			memcpy(keylist[idx], cellhdr.key, sizeof(HASH_KEY));

			/* Pre-cache (not possible for 8-bit colour depth cause it needs a colourmap) */
			if (g_bitmap_cache_precache && cellhdr.stamp && g_server_depth > 8)
				pstcache_load_bitmap(id, idx);

			/* Sort by stamp */
			for (n = idx; n > 0 && cellhdr.stamp < mru_stamp[n - 1]; n--)
			{
				mru_idx[n] = mru_idx[n - 1];
				mru_stamp[n] = mru_stamp[n - 1];
			}

			mru_idx[n] = idx;
			mru_stamp[n] = cellhdr.stamp;
		}
		else
		{
			break;
		}
	}

	logger(Core, Debug, "pstcache_enumerate(), %d cached bitmaps", idx);

	cache_rebuild_bmpcache_linked_list(id, mru_idx, idx);
	g_pstcache_enumerated = True;
	return idx;
}
Example #3
0
/* List the bitmap keys from the persistent cache file */
int
pstcache_enumerate(rdcConnection conn, uint8 id, HASH_KEY * keylist)
{
	int fd, idx, n;
	sint16 mru_idx[0xa00];
	uint32 mru_stamp[0xa00];
	CELLHEADER cellhdr;

	if (!(conn->bitmapCache && conn->bitmapCachePersist && IS_PERSISTENT(id)))
		return 0;

	/* The server disconnects if the bitmap cache content is sent more than once */
	if (conn->pstcacheEnumerated)
		return 0;

	DEBUG_RDP5(("Persistent bitmap cache enumeration... "));
	for (idx = 0; idx < BMPCACHE2_NUM_PSTCELLS; idx++)
	{
		fd = conn->pstcacheFd[id];
		rd_lseek_file(fd, idx * (conn->pstcacheBpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
		if (rd_read_file(fd, &cellhdr, sizeof(CELLHEADER)) <= 0)
			break;

		if (memcmp(cellhdr.key, zero_key, sizeof(HASH_KEY)) != 0)
		{
			memcpy(keylist[idx], cellhdr.key, sizeof(HASH_KEY));

			/* Pre-cache (not possible for 8bpp because 8bpp needs a colourmap) */
			if (conn->bitmapCachePrecache && cellhdr.stamp && conn->serverBpp > 8)
				pstcache_load_bitmap(conn, id, idx);

			/* Sort by stamp */
			for (n = idx; n > 0 && cellhdr.stamp < mru_stamp[n - 1]; n--)
			{
				mru_idx[n] = mru_idx[n - 1];
				mru_stamp[n] = mru_stamp[n - 1];
			}

			mru_idx[n] = idx;
			mru_stamp[n] = cellhdr.stamp;
		}
		else
		{
			break;
		}
	}

	DEBUG_RDP5(("%d cached bitmaps.\n", idx));

	cache_rebuild_bmpcache_linked_list(conn, id, mru_idx, idx);
	conn->pstcacheEnumerated = True;
	return idx;
}
Example #4
0
/* Retrieve a bitmap from the cache */
RD_HBITMAP
cache_get_bitmap(uint8 id, uint16 idx)
{
	if ((id < NUM_ELEMENTS(g_bmpcache)) && (idx < NUM_ELEMENTS(g_bmpcache[0])))
	{
		if (g_bmpcache[id][idx].bitmap || pstcache_load_bitmap(id, idx))
		{
			if (IS_PERSISTENT(id))
				cache_bump_bitmap(id, idx, BUMP_COUNT);

			return g_bmpcache[id][idx].bitmap;
		}
	}
	else if ((id < NUM_ELEMENTS(g_volatile_bc)) && (idx == 0x7fff))
	{
		return g_volatile_bc[id];
	}

	error("get bitmap %d:%d\n", id, idx);
	return NULL;
}
Example #5
0
/* Retrieve a bitmap from the cache */
HBITMAP
cache_get_bitmap(rdcConnection conn, uint8 id, uint16 idx)
{
	if ((id < NUM_ELEMENTS(conn->bmpcache)) && (idx < NUM_ELEMENTS(conn->bmpcache[0])))
	{
		if (conn->bmpcache[id][idx].bitmap || pstcache_load_bitmap(conn, id, idx))
		{
			if (IS_PERSISTENT(id))
				cache_bump_bitmap(conn, id, idx, BUMP_COUNT);

			return conn->bmpcache[id][idx].bitmap;
		}
	}
	else if ((id < NUM_ELEMENTS(conn->volatileBc)) && (idx == 0x7fff))
	{
		return conn->volatileBc[id];
	}

	error("get bitmap %d:%d\n", id, idx);
	return NULL;
}