summaryrefslogtreecommitdiffstats
path: root/rre.c
diff options
context:
space:
mode:
authordscho <dscho>2003-02-09 15:04:00 +0000
committerdscho <dscho>2003-02-09 15:04:00 +0000
commit5030d53ff08665d27e388244aa22b272716240bc (patch)
tree64aa4ced924efed1e8c66579fce4e93ef97499d6 /rre.c
parentf86f9cec24a85bff17b4635f09c00513a2c356c3 (diff)
downloadlibtdevnc-5030d53ff08665d27e388244aa22b272716240bc.tar.gz
libtdevnc-5030d53ff08665d27e388244aa22b272716240bc.zip
converted CARD{8,16,32} to uint{8,16,32}_t and included support for stdint.h
Diffstat (limited to 'rre.c')
-rw-r--r--rre.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/rre.c b/rre.c
index 9a552cb..df20668 100644
--- a/rre.c
+++ b/rre.c
@@ -26,7 +26,6 @@
* USA.
*/
-#include <stdio.h>
#include "rfb.h"
/*
@@ -43,10 +42,10 @@ static int rreAfterBufSize = 0;
static char *rreAfterBuf = NULL;
static int rreAfterBufLen;
-static int subrectEncode8(CARD8 *data, int w, int h);
-static int subrectEncode16(CARD16 *data, int w, int h);
-static int subrectEncode32(CARD32 *data, int w, int h);
-static CARD32 getBgColour(char *data, int size, int bpp);
+static int subrectEncode8(uint8_t *data, int w, int h);
+static int subrectEncode16(uint16_t *data, int w, int h);
+static int subrectEncode32(uint32_t *data, int w, int h);
+static uint32_t getBgColour(char *data, int size, int bpp);
/*
@@ -91,13 +90,13 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
switch (cl->format.bitsPerPixel) {
case 8:
- nSubrects = subrectEncode8((CARD8 *)rreBeforeBuf, w, h);
+ nSubrects = subrectEncode8((uint8_t *)rreBeforeBuf, w, h);
break;
case 16:
- nSubrects = subrectEncode16((CARD16 *)rreBeforeBuf, w, h);
+ nSubrects = subrectEncode16((uint16_t *)rreBeforeBuf, w, h);
break;
case 32:
- nSubrects = subrectEncode32((CARD32 *)rreBeforeBuf, w, h);
+ nSubrects = subrectEncode32((uint32_t *)rreBeforeBuf, w, h);
break;
default:
rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel);
@@ -177,25 +176,25 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
#define DEFINE_SUBRECT_ENCODE(bpp) \
static int \
subrectEncode##bpp(data,w,h) \
- CARD##bpp *data; \
+ uint##bpp##_t *data; \
int w; \
int h; \
{ \
- CARD##bpp cl; \
+ uint##bpp##_t cl; \
rfbRectangle subrect; \
int x,y; \
int i,j; \
int hx=0,hy,vx=0,vy; \
int hyflag; \
- CARD##bpp *seg; \
- CARD##bpp *line; \
+ uint##bpp##_t *seg; \
+ uint##bpp##_t *line; \
int hw,hh,vw,vh; \
int thex,they,thew,theh; \
int numsubs = 0; \
int newLen; \
- CARD##bpp bg = (CARD##bpp)getBgColour((char*)data,w*h,bpp); \
+ uint##bpp##_t bg = (uint##bpp##_t)getBgColour((char*)data,w*h,bpp); \
\
- *((CARD##bpp*)rreAfterBuf) = bg; \
+ *((uint##bpp##_t*)rreAfterBuf) = bg; \
\
rreAfterBufLen = (bpp/8); \
\
@@ -247,7 +246,7 @@ subrectEncode##bpp(data,w,h) \
return -1; \
\
numsubs += 1; \
- *((CARD##bpp*)(rreAfterBuf + rreAfterBufLen)) = cl; \
+ *((uint##bpp##_t*)(rreAfterBuf + rreAfterBufLen)) = cl; \
rreAfterBufLen += (bpp/8); \
memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbRectangle); \
rreAfterBufLen += sz_rfbRectangle; \
@@ -275,7 +274,7 @@ DEFINE_SUBRECT_ENCODE(32)
/*
* getBgColour() gets the most prevalent colour in a byte array.
*/
-static CARD32
+static uint32_t
getBgColour(data,size,bpp)
char *data;
int size;
@@ -288,13 +287,13 @@ getBgColour(data,size,bpp)
int i,j,k;
int maxcount = 0;
- CARD8 maxclr = 0;
+ uint8_t maxclr = 0;
if (bpp != 8) {
if (bpp == 16) {
- return ((CARD16 *)data)[0];
+ return ((uint16_t *)data)[0];
} else if (bpp == 32) {
- return ((CARD32 *)data)[0];
+ return ((uint32_t *)data)[0];
} else {
rfbLog("getBgColour: bpp %d?\n",bpp);
exit(1);
@@ -306,7 +305,7 @@ getBgColour(data,size,bpp)
}
for (j=0; j<size; j++) {
- k = (int)(((CARD8 *)data)[j]);
+ k = (int)(((uint8_t *)data)[j]);
if (k >= NUMCLRS) {
rfbLog("getBgColour: unusual colour = %d\n", k);
exit(1);
@@ -314,7 +313,7 @@ getBgColour(data,size,bpp)
counts[k] += 1;
if (counts[k] > maxcount) {
maxcount = counts[k];
- maxclr = ((CARD8 *)data)[j];
+ maxclr = ((uint8_t *)data)[j];
}
}