diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/copyrecttest.c | 5 | ||||
-rwxr-xr-x | test/cursortest.c | 20 | ||||
-rw-r--r-- | test/encodingstest.c | 48 |
3 files changed, 39 insertions, 34 deletions
diff --git a/test/copyrecttest.c b/test/copyrecttest.c index da036bc..1986f72 100644 --- a/test/copyrecttest.c +++ b/test/copyrecttest.c @@ -1,7 +1,8 @@ +#define _BSD_SOURCE #include <rfb/rfb.h> #include <math.h> -void initBackground(rfbScreenInfoPtr server) +static void initBackground(rfbScreenInfoPtr server) { unsigned int i,j; @@ -16,7 +17,7 @@ void initBackground(rfbScreenInfoPtr server) int main(int argc,char** argv) { int width=400,height=300,w=20,x,y; - double r,phi; + double r,phi=0; rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,width,height,8,3,4); server->frameBuffer=(char*)malloc(width*height*4); diff --git a/test/cursortest.c b/test/cursortest.c index 4c75f23..7a4efd3 100755 --- a/test/cursortest.c +++ b/test/cursortest.c @@ -24,12 +24,12 @@ #include <rfb/rfb.h> -const int bpp=4; -int maxx=800, maxy=600; +static const int bpp=4; +static int maxx=800, maxy=600; /* This initializes a nice (?) background */ -void initBuffer(unsigned char* buffer) +static void initBuffer(unsigned char* buffer) { int i,j; for(j=0;j<maxy;++j) { @@ -43,7 +43,7 @@ void initBuffer(unsigned char* buffer) /* Example for an XCursor (foreground/background only) */ -void SetXCursor(rfbScreenInfoPtr rfbScreen) +static void SetXCursor(rfbScreenInfoPtr rfbScreen) { int width=13,height=11; char cursor[]= @@ -78,7 +78,7 @@ void SetXCursor(rfbScreenInfoPtr rfbScreen) rfbSetCursor(rfbScreen, c); } -void SetXCursor2(rfbScreenInfoPtr rfbScreen) +static void SetXCursor2(rfbScreenInfoPtr rfbScreen) { int width=13,height=22; char cursor[]= @@ -136,7 +136,7 @@ void SetXCursor2(rfbScreenInfoPtr rfbScreen) /* Example for a rich cursor (full-colour) */ -void SetRichCursor(rfbScreenInfoPtr rfbScreen) +static void SetRichCursor(rfbScreenInfoPtr rfbScreen) { int i,j,w=32,h=32; /* runge */ @@ -192,7 +192,7 @@ void SetRichCursor(rfbScreenInfoPtr rfbScreen) } /* runge */ -void SetRichCursor2(rfbScreenInfoPtr rfbScreen) +static void SetRichCursor2(rfbScreenInfoPtr rfbScreen) { int i,j,w=17,h=16; /* rfbCursorPtr c = rfbScreen->cursor; */ @@ -232,7 +232,7 @@ void SetRichCursor2(rfbScreenInfoPtr rfbScreen) /* alpha channel */ -void SetAlphaCursor(rfbScreenInfoPtr screen,int mode) +static void SetAlphaCursor(rfbScreenInfoPtr screen,int mode) { int i,j; rfbCursorPtr c = screen->cursor; @@ -243,7 +243,7 @@ void SetAlphaCursor(rfbScreenInfoPtr screen,int mode) if(c->alphaSource) { free(c->alphaSource); - c->alphaSource=0; + c->alphaSource=NULL; } if(mode==0) @@ -265,7 +265,7 @@ void SetAlphaCursor(rfbScreenInfoPtr screen,int mode) /* Here the pointer events are handled */ -void doptr(int buttonMask,int x,int y,rfbClientPtr cl) +static void doptr(int buttonMask,int x,int y,rfbClientPtr cl) { static int oldButtonMask=0; static int counter=0; diff --git a/test/encodingstest.c b/test/encodingstest.c index 3868314..5f84a5b 100644 --- a/test/encodingstest.c +++ b/test/encodingstest.c @@ -1,3 +1,4 @@ +#define _BSD_SOURCE #include <time.h> #include <stdarg.h> #include <rfb/rfb.h> @@ -8,12 +9,12 @@ #endif #define ALL_AT_ONCE -//#define VERY_VERBOSE +/*#define VERY_VERBOSE*/ -MUTEX(frameBufferMutex); +static MUTEX(frameBufferMutex); typedef struct { int id; char* str; } encoding_t; -encoding_t testEncodings[]={ +static encoding_t testEncodings[]={ { rfbEncodingRaw, "raw" }, { rfbEncodingRRE, "rre" }, /* TODO: fix corre */ @@ -28,22 +29,22 @@ encoding_t testEncodings[]={ { rfbEncodingTight, "tight" }, #endif #endif - { 0, 0 } + { 0, NULL } }; #define NUMBER_OF_ENCODINGS_TO_TEST (sizeof(testEncodings)/sizeof(encoding_t)-1) -//#define NUMBER_OF_ENCODINGS_TO_TEST 1 +/*#define NUMBER_OF_ENCODINGS_TO_TEST 1*/ /* Here come the variables/functions to handle the test output */ -const int width=400,height=300; -struct { int x1,y1,x2,y2; } lastUpdateRect; -unsigned int statistics[2][NUMBER_OF_ENCODINGS_TO_TEST]; -unsigned int totalFailed,totalCount; -unsigned int countGotUpdate; -MUTEX(statisticsMutex); +static const int width=400,height=300; +static struct { int x1,y1,x2,y2; } lastUpdateRect; +static unsigned int statistics[2][NUMBER_OF_ENCODINGS_TO_TEST]; +static unsigned int totalFailed,totalCount; +static unsigned int countGotUpdate; +static MUTEX(statisticsMutex); -void initStatistics() { +static void initStatistics(void) { memset(statistics[0],0,sizeof(int)*NUMBER_OF_ENCODINGS_TO_TEST); memset(statistics[1],0,sizeof(int)*NUMBER_OF_ENCODINGS_TO_TEST); totalFailed=totalCount=0; @@ -54,7 +55,7 @@ void initStatistics() { INIT_MUTEX(statisticsMutex); } -void updateServerStatistics(int x1,int y1,int x2,int y2) { +static void updateServerStatistics(int x1,int y1,int x2,int y2) { LOCK(statisticsMutex); countGotUpdate=0; lastUpdateRect.x1=x1; @@ -64,7 +65,7 @@ void updateServerStatistics(int x1,int y1,int x2,int y2) { UNLOCK(statisticsMutex); } -void updateStatistics(int encodingIndex,rfbBool failed) { +static void updateStatistics(int encodingIndex,rfbBool failed) { LOCK(statisticsMutex); if(failed) { statistics[1][encodingIndex]++; @@ -83,7 +84,7 @@ void updateStatistics(int encodingIndex,rfbBool failed) { /* maxDelta=0 means they are expected to match exactly; * maxDelta>0 means that the average difference must be lower than maxDelta */ -rfbBool doFramebuffersMatch(rfbScreenInfo* server,rfbClient* client, +static rfbBool doFramebuffersMatch(rfbScreenInfo* server,rfbClient* client, int maxDelta) { int i,j,k; @@ -116,7 +117,10 @@ static rfbBool resize(rfbClient* cl) { if(cl->frameBuffer) free(cl->frameBuffer); cl->frameBuffer=(char*)malloc(cl->width*cl->height*cl->format.bitsPerPixel/8); + if(!cl->frameBuffer) + return FALSE; SendFramebufferUpdateRequest(cl,0,0,cl->width,cl->height,FALSE); + return TRUE; } typedef struct clientData { @@ -169,11 +173,11 @@ static void* clientLoop(void* data) { rfbClientLog("Starting client (encoding %s, display %s)\n", testEncodings[cd->encodingIndex].str, cd->display); - if(!rfbInitClient(client,0,0)) { + if(!rfbInitClient(client,NULL,NULL)) { rfbClientErr("Had problems starting client (encoding %s)\n", testEncodings[cd->encodingIndex].str); updateStatistics(cd->encodingIndex,TRUE); - return 0; + return NULL; } while(1) { if(WaitForMessage(client,50)>=0) @@ -185,7 +189,7 @@ static void* clientLoop(void* data) { if(client->frameBuffer) free(client->frameBuffer); rfbClientCleanup(client); - return 0; + return NULL; } static void startClient(int encodingIndex,rfbScreenInfo* server) { @@ -258,7 +262,7 @@ static void idle(rfbScreenInfo* server) /* log function (to show what messages are from the client) */ -void +static void rfbTestLog(const char *format, ...) { va_list args; @@ -295,7 +299,7 @@ int main(int argc,char** argv) server=rfbGetScreen(&argc,argv,width,height,8,3,4); server->frameBuffer=malloc(400*300*4); - server->cursor=0; + server->cursor=NULL; for(j=0;j<400*300*4;j++) server->frameBuffer[j]=j; rfbInitServer(server); @@ -311,9 +315,9 @@ int main(int argc,char** argv) #endif startClient(i,server); - t=time(0); + t=time(NULL); /* test 20 seconds */ - while(time(0)-t<20) { + while(time(NULL)-t<20) { idle(server); |