8 #include <rfb/rfbconfig.h>
11 #include <sys/types.h>
12 #if LIBVNCSERVER_HAVE_SYS_SOCKET_H
13 #include <sys/socket.h>
16 #include <rfb/default8x16.h>
21 static char* keys[0x400];
23 static int hex2number(
unsigned char c)
34 static void read_keys(
void)
38 FILE* keysyms=fopen(
"keysym.h",
"r");
40 memset(keys,0,0x400*
sizeof(
char*));
45 while(!feof(keysyms)) {
46 fgets(buffer,1024,keysyms);
47 if(!strncmp(buffer,
"#define XK_",strlen(
"#define XK_"))) {
48 for(i=strlen(
"#define XK_");buffer[i] && buffer[i]!=
' '
49 && buffer[i]!=
'\t';i++);
53 for(i++;buffer[i] && buffer[i]!=
'0';i++);
54 if(buffer[i]==0 || buffer[i+1]!=
'x')
continue;
55 for(j=0,i+=2;(k=hex2number(buffer[i]))>=0;i++)
58 char*
x=(
char*)malloc(1+strlen(keys[j&0x3ff])+1+strlen(buffer+strlen(
"#define ")));
60 memset(keys,0,0x400*
sizeof(
char*));
64 strcpy(
x,keys[j&0x3ff]);
66 strcat(
x,buffer+strlen(
"#define "));
70 keys[j&0x3ff] = strdup(buffer+strlen(
"#define "));
77 static int lineHeight=16,lineY=
height-16;
78 static void output(rfbScreenInfoPtr s,
char* line)
89 sprintf(buffer,
"%s: %s (0x%x)",
90 down?
"down":
"up",keys[k&0x3ff]?keys[k&0x3ff]:
"",(
unsigned int)k);
91 output(cl->screen,buffer);
94 static void doptr(
int buttonMask,
int x,
int y,rfbClientPtr cl)
98 sprintf(buffer,
"Ptr: mouse button mask 0x%x at %d,%d",buttonMask,
x,
y);
99 output(cl->screen,buffer);
107 struct sockaddr_in addr;
108 socklen_t len=
sizeof(addr);
111 getpeername(cl->sock,(
struct sockaddr*)&addr,&len);
112 ip=ntohl(addr.sin_addr.s_addr);
113 sprintf(buffer,
"Client connected from ip %d.%d.%d.%d",
114 (ip>>24)&0xff,(ip>>16)&0xff,(ip>>8)&0xff,ip&0xff);
115 output(cl->screen,buffer);
124 s->colourMap.is16=
FALSE;
125 s->colourMap.count=2;
126 s->colourMap.data.bytes=(
unsigned char*)
"\xd0\xd0\xd0\x30\x01\xe0";
127 s->serverFormat.trueColour=
FALSE;
129 s->kbdAddEvent=dokey;
130 s->ptrAddEvent=doptr;
131 s->newClientHook=newclient;
void rfbDoCopyRect(rfbScreenInfoPtr rfbScreen, int x1, int y1, int x2, int y2, int dx, int dy)
void rfbInitServer(rfbScreenInfoPtr rfbScreen)
rfbScreenInfoPtr rfbGetScreen(int *argc, char **argv, int width, int height, int bitsPerSample, int samplesPerPixel, int bytesPerPixel)
rfbBool rfbProcessEvents(rfbScreenInfoPtr screenInfo, long usec)
void rfbDrawString(rfbScreenInfoPtr rfbScreen, rfbFontDataPtr font, int x, int y, const char *string, rfbPixel colour)
int main(int argc, char **argv)