summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authordscho <dscho>2005-05-15 13:57:51 +0000
committerdscho <dscho>2005-05-15 13:57:51 +0000
commit8bee4eb990273c3654431467ba6618eb916f030a (patch)
treef3077e1cb12a4cb778047814583fc0b2f26bb7b2 /examples
parentbe5b1296e4aa4d8a51cd709853408ec0cd7b768b (diff)
downloadlibtdevnc-8bee4eb990273c3654431467ba6618eb916f030a.tar.gz
libtdevnc-8bee4eb990273c3654431467ba6618eb916f030a.zip
ANSIfy, fix some warnings from Linus' sparse
Diffstat (limited to 'examples')
-rw-r--r--examples/example.c28
-rw-r--r--examples/fontsel.c10
-rw-r--r--examples/pnmshow.c4
-rw-r--r--examples/pnmshow24.c2
-rw-r--r--examples/radon.h6
-rw-r--r--examples/storepasswd.c2
-rw-r--r--examples/vncev.c27
7 files changed, 44 insertions, 35 deletions
diff --git a/examples/example.c b/examples/example.c
index 59ac518..15bedec 100644
--- a/examples/example.c
+++ b/examples/example.c
@@ -34,13 +34,13 @@
#include <rfb/rfb.h>
#include <rfb/keysym.h>
-const int bpp=4;
-int maxx=800, maxy=600;
+static const int bpp=4;
+static int maxx=800, maxy=600;
/* TODO: odd maxx doesn't work (vncviewer bug) */
/* 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) {
@@ -63,12 +63,12 @@ typedef struct ClientData {
int oldx,oldy;
} ClientData;
-void clientgone(rfbClientPtr cl)
+static void clientgone(rfbClientPtr cl)
{
free(cl->clientData);
}
-enum rfbNewClientAction newclient(rfbClientPtr cl)
+static enum rfbNewClientAction newclient(rfbClientPtr cl)
{
cl->clientData = (void*)calloc(sizeof(ClientData),1);
cl->clientGoneHook = clientgone;
@@ -77,7 +77,7 @@ enum rfbNewClientAction newclient(rfbClientPtr cl)
/* switch to new framebuffer contents */
-void newframebuffer(rfbScreenInfoPtr screen, int width, int height)
+static void newframebuffer(rfbScreenInfoPtr screen, int width, int height)
{
unsigned char *oldfb, *newfb;
@@ -94,7 +94,7 @@ void newframebuffer(rfbScreenInfoPtr screen, int width, int height)
/* aux function to draw a line */
-void drawline(unsigned char* buffer,int rowstride,int bpp,int x1,int y1,int x2,int y2)
+static void drawline(unsigned char* buffer,int rowstride,int bpp,int x1,int y1,int x2,int y2)
{
int i,j;
i=x1-x2; j=y1-y2;
@@ -121,7 +121,7 @@ void drawline(unsigned char* buffer,int rowstride,int bpp,int x1,int y1,int x2,i
/* 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)
{
ClientData* cd=cl->clientData;
@@ -163,7 +163,7 @@ void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
/* Here the key events are handled */
-void dokey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
+static void dokey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
{
if(down) {
if(key==XK_Escape)
@@ -205,8 +205,10 @@ void dokey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
/* Example for an XCursor (foreground/background only) */
-int exampleXCursorWidth=9,exampleXCursorHeight=7;
-char exampleXCursor[]=
+#ifdef JUST_AN_EXAMPLE
+
+static int exampleXCursorWidth=9,exampleXCursorHeight=7;
+static char exampleXCursor[]=
" "
" xx xx "
" xx xx "
@@ -215,9 +217,11 @@ char exampleXCursor[]=
" xx xx "
" ";
+#endif
+
/* Example for a rich cursor (full-colour) */
-void MakeRichCursor(rfbScreenInfoPtr rfbScreen)
+static void MakeRichCursor(rfbScreenInfoPtr rfbScreen)
{
int i,j,w=32,h=32;
rfbCursorPtr c = rfbScreen->cursor;
diff --git a/examples/fontsel.c b/examples/fontsel.c
index a2a2f82..85d2624 100644
--- a/examples/fontsel.c
+++ b/examples/fontsel.c
@@ -3,16 +3,16 @@
#define FONTDIR "/usr/lib/kbd/consolefonts/"
#define DEFAULTFONT FONTDIR "default8x16"
-char *fontlist[50]={
+static char *fontlist[50]={
"8x16alt", "b.fnt", "c.fnt", "default8x16", "m.fnt", "ml.fnt", "mod_d.fnt",
"mod_s.fnt", "mr.fnt", "mu.fnt", "r.fnt", "rl.fnt", "ro.fnt", "s.fnt",
"sc.fnt", "scrawl_s.fnt", "scrawl_w.fnt", "sd.fnt", "t.fnt",
- 0
+ NULL
};
-rfbScreenInfoPtr rfbScreen = 0;
-rfbFontDataPtr curFont = 0;
-void showFont(int index)
+static rfbScreenInfoPtr rfbScreen = NULL;
+static rfbFontDataPtr curFont = NULL;
+static void showFont(int index)
{
char buffer[1024];
diff --git a/examples/pnmshow.c b/examples/pnmshow.c
index b40cf53..9e4a509 100644
--- a/examples/pnmshow.c
+++ b/examples/pnmshow.c
@@ -2,7 +2,7 @@
#include <rfb/rfb.h>
#include <rfb/keysym.h>
-void HandleKey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
+static void HandleKey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
{
if(down && (key==XK_Escape || key=='q' || key=='Q'))
rfbCloseClient(cl);
@@ -96,6 +96,8 @@ int main(int argc,char** argv)
rfbScreen->frameBuffer[j*paddedWidth*4+i]=0;
}
break;
+ case GRAY:
+ break;
case BW:
/* correct the format from 1 bit to 8 bits */
for(j=height-1;j>=0;j--)
diff --git a/examples/pnmshow24.c b/examples/pnmshow24.c
index bcee3e4..b59b3b5 100644
--- a/examples/pnmshow24.c
+++ b/examples/pnmshow24.c
@@ -6,7 +6,7 @@
#error "I need the ALLOW24BPP flag to work"
#endif
-void HandleKey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
+static void HandleKey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
{
if(down && (key==XK_Escape || key=='q' || key=='Q'))
rfbCloseClient(cl);
diff --git a/examples/radon.h b/examples/radon.h
index 6aa5242..b6209a9 100644
--- a/examples/radon.h
+++ b/examples/radon.h
@@ -1,4 +1,4 @@
-unsigned char radonFontData[2280]={
+static unsigned char radonFontData[2280]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 32 */
0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x10,0x10,0x00,0x00, /* 33 */
0x00,0x28,0x28,0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 34 */
@@ -190,6 +190,6 @@ unsigned char radonFontData[2280]={
0x04,0x18,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x3a,0x02,0x3c, /* 253 */
0x00,0x80,0x80,0x9c,0xa2,0x82,0xa2,0x9c,0x80,0x80,0x00,0x00, /* 254 */
};
-int radonFontMetaData[256*5]={
+static int radonFontMetaData[256*5]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,12,0,-2,12,8,12,0,-2,24,8,12,0,-2,36,8,12,0,-2,48,8,12,0,-2,60,8,12,0,-2,72,8,12,0,-2,84,8,12,0,-2,96,8,12,0,-2,108,8,12,0,-2,120,8,12,0,-2,132,8,12,0,-2,144,8,12,0,-2,156,8,12,0,-2,168,8,12,0,-2,180,8,12,0,-2,192,8,12,0,-2,204,8,12,0,-2,216,8,12,0,-2,228,8,12,0,-2,240,8,12,0,-2,252,8,12,0,-2,264,8,12,0,-2,276,8,12,0,-2,288,8,12,0,-2,300,8,12,0,-2,312,8,12,0,-2,324,8,12,0,-2,336,8,12,0,-2,348,8,12,0,-2,360,8,12,0,-2,372,8,12,0,-2,384,8,12,0,-2,396,8,12,0,-2,408,8,12,0,-2,420,8,12,0,-2,432,8,12,0,-2,444,8,12,0,-2,456,8,12,0,-2,468,8,12,0,-2,480,8,12,0,-2,492,8,12,0,-2,504,8,12,0,-2,516,8,12,0,-2,528,8,12,0,-2,540,8,12,0,-2,552,8,12,0,-2,564,8,12,0,-2,576,8,12,0,-2,588,8,12,0,-2,600,8,12,0,-2,612,8,12,0,-2,624,8,12,0,-2,636,8,12,0,-2,648,8,12,0,-2,660,8,12,0,-2,672,8,12,0,-2,684,8,12,0,-2,696,8,12,0,-2,708,8,12,0,-2,720,8,12,0,-2,732,8,12,0,-2,744,8,12,0,-2,756,8,12,0,-2,768,8,12,0,-2,780,8,12,0,-2,792,8,12,0,-2,804,8,12,0,-2,816,8,12,0,-2,828,8,12,0,-2,840,8,12,0,-2,852,8,12,0,-2,864,8,12,0,-2,876,8,12,0,-2,888,8,12,0,-2,900,8,12,0,-2,912,8,12,0,-2,924,8,12,0,-2,936,8,12,0,-2,948,8,12,0,-2,960,8,12,0,-2,972,8,12,0,-2,984,8,12,0,-2,996,8,12,0,-2,1008,8,12,0,-2,1020,8,12,0,-2,1032,8,12,0,-2,1044,8,12,0,-2,1056,8,12,0,-2,1068,8,12,0,-2,1080,8,12,0,-2,1092,8,12,0,-2,1104,8,12,0,-2,1116,8,12,0,-2,1128,8,12,0,-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1140,8,12,0,-2,1152,8,12,0,-2,1164,8,12,0,-2,1176,8,12,0,-2,1188,8,12,0,-2,1200,8,12,0,-2,1212,8,12,0,-2,1224,8,12,0,-2,1236,8,12,0,-2,1248,8,12,0,-2,1260,8,12,0,-2,1272,8,12,0,-2,1284,8,12,0,-2,1296,8,12,0,-2,1308,8,12,0,-2,1320,8,12,0,-2,1332,8,12,0,-2,1344,8,12,0,-2,1356,8,12,0,-2,1368,8,12,0,-2,1380,8,12,0,-2,1392,8,12,0,-2,1404,8,12,0,-2,1416,8,12,0,-2,1428,8,12,0,-2,1440,8,12,0,-2,1452,8,12,0,-2,1464,8,12,0,-2,1476,8,12,0,-2,1488,8,12,0,-2,1500,8,12,0,-2,1512,8,12,0,-2,1524,8,12,0,-2,1536,8,12,0,-2,1548,8,12,0,-2,1560,8,12,0,-2,1572,8,12,0,-2,1584,8,12,0,-2,1596,8,12,0,-2,1608,8,12,0,-2,1620,8,12,0,-2,1632,8,12,0,-2,1644,8,12,0,-2,1656,8,12,0,-2,1668,8,12,0,-2,1680,8,12,0,-2,1692,8,12,0,-2,1704,8,12,0,-2,1716,8,12,0,-2,1728,8,12,0,-2,1740,8,12,0,-2,1752,8,12,0,-2,1764,8,12,0,-2,1776,8,12,0,-2,1788,8,12,0,-2,1800,8,12,0,-2,1812,8,12,0,-2,1824,8,12,0,-2,1836,8,12,0,-2,1848,8,12,0,-2,1860,8,12,0,-2,1872,8,12,0,-2,1884,8,12,0,-2,1896,8,12,0,-2,1908,8,12,0,-2,1920,8,12,0,-2,1932,8,12,0,-2,1944,8,12,0,-2,1956,8,12,0,-2,1968,8,12,0,-2,1980,8,12,0,-2,1992,8,12,0,-2,2004,8,12,0,-2,2016,8,12,0,-2,2028,8,12,0,-2,2040,8,12,0,-2,2052,8,12,0,-2,2064,8,12,0,-2,2076,8,12,0,-2,2088,8,12,0,-2,2100,8,12,0,-2,2112,8,12,0,-2,2124,8,12,0,-2,2136,8,12,0,-2,2148,8,12,0,-2,2160,8,12,0,-2,2172,8,12,0,-2,2184,8,12,0,-2,2196,8,12,0,-2,2208,8,12,0,-2,2220,8,12,0,-2,2232,8,12,0,-2,2244,8,12,0,-2,2256,8,12,0,-2,2268,8,12,0,-2,0,0,0,0,0,};
-rfbFontData radonFont={radonFontData, radonFontMetaData};
+static rfbFontData radonFont={radonFontData, radonFontMetaData};
diff --git a/examples/storepasswd.c b/examples/storepasswd.c
index d0a3f7e..7c358d9 100644
--- a/examples/storepasswd.c
+++ b/examples/storepasswd.c
@@ -22,7 +22,7 @@
#include <stdio.h>
#include <rfb/rfb.h>
-void usage(void)
+static void usage(void)
{
printf("\nusage: storepasswd <password> <filename>\n\n");
diff --git a/examples/vncev.c b/examples/vncev.c
index 5d7fb1b..e93dc57 100644
--- a/examples/vncev.c
+++ b/examples/vncev.c
@@ -1,4 +1,5 @@
/* This program is a simple server to show events coming from the client */
+#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -8,10 +9,12 @@
#include <rfb/rfb.h>
#include <rfb/default8x16.h>
-char f[640*480];
-char* keys[0x400];
+#define width 100
+#define height 100
+static char f[width*height];
+static char* keys[0x400];
-int hex2number(unsigned char c)
+static int hex2number(unsigned char c)
{
if(c>'f') return(-1);
else if(c>'F')
@@ -22,7 +25,7 @@ int hex2number(unsigned char c)
return(c-'0');
}
-void read_keys()
+static void read_keys(void)
{
int i,j,k;
char buffer[1024];
@@ -60,15 +63,15 @@ void read_keys()
fclose(keysyms);
}
-int lineHeight=16,lineY=480-16;
-void output(rfbScreenInfoPtr s,char* line)
+static int lineHeight=16,lineY=height-16;
+static void output(rfbScreenInfoPtr s,char* line)
{
- rfbDoCopyRect(s,0,0,640,480-lineHeight,0,-lineHeight);
+ rfbDoCopyRect(s,0,0,width,height-lineHeight,0,-lineHeight);
rfbDrawString(s,&default8x16Font,10,lineY,line,0x01);
rfbLog("%s\n",line);
}
-void dokey(rfbBool down,rfbKeySym k,rfbClientPtr cl)
+static void dokey(rfbBool down,rfbKeySym k,rfbClientPtr cl)
{
char buffer[1024+32];
@@ -77,7 +80,7 @@ void dokey(rfbBool down,rfbKeySym k,rfbClientPtr cl)
output(cl->screen,buffer);
}
-void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
+static void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
{
char buffer[1024];
if(buttonMask) {
@@ -87,7 +90,7 @@ void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
}
-enum rfbNewClientAction newclient(rfbClientPtr cl)
+static enum rfbNewClientAction newclient(rfbClientPtr cl)
{
char buffer[1024];
struct sockaddr_in addr;
@@ -103,7 +106,7 @@ enum rfbNewClientAction newclient(rfbClientPtr cl)
int main(int argc,char** argv)
{
- rfbScreenInfoPtr s=rfbGetScreen(&argc,argv,640,480,8,1,1);
+ rfbScreenInfoPtr s=rfbGetScreen(&argc,argv,width,height,8,1,1);
s->colourMap.is16=FALSE;
s->colourMap.count=2;
s->colourMap.data.bytes=(unsigned char*)"\xd0\xd0\xd0\x30\x01\xe0";
@@ -113,7 +116,7 @@ int main(int argc,char** argv)
s->ptrAddEvent=doptr;
s->newClientHook=newclient;
- memset(f,0,640*480);
+ memset(f,0,width*height);
read_keys();
rfbInitServer(s);