summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordscho <dscho>2001-08-14 10:24:32 +0000
committerdscho <dscho>2001-08-14 10:24:32 +0000
commit2634379912ea972dedc0d389049945716c90c0db (patch)
tree1dd12c9611b772e1c113980bbf7de1e61b7c37a0
parent47341aa5545e8b354c8cd45e1372f96d9e4f6c0d (diff)
downloadlibtdevnc-2634379912ea972dedc0d389049945716c90c0db.tar.gz
libtdevnc-2634379912ea972dedc0d389049945716c90c0db.zip
comments & new example: pnmshow
-rw-r--r--Makefile5
-rw-r--r--example.c1
-rw-r--r--main.c2
-rw-r--r--pnmshow.c67
4 files changed, 73 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 1969adc..07fcb11 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ OBJS=main.o rfbserver.o miregion.o auth.o sockets.o xalloc.o \
stats.o corre.o hextile.o rre.o translate.o cutpaste.o \
zlib.o tight.o
-all: example storepasswd
+all: example pnmshow storepasswd
install_OSX: OSXvnc-server
cp OSXvnc-server storepasswd ../OSXvnc/build/OSXvnc.app/Contents/MacOS
@@ -41,6 +41,9 @@ libvncserver.a: $(OBJS)
example: example.o libvncauth/libvncauth.a libvncserver.a
$(CC) -o example example.o $(LIBS) $(PTHREAD_LIBS)
+pnmshow: pnmshow.o libvncauth/libvncauth.a libvncserver.a
+ $(CC) -o pnmshow pnmshow.o $(LIBS) $(PTHREAD_LIBS)
+
OSXvnc-server: mac.o libvncauth/libvncauth.a libvncserver.a
$(CC) -o OSXvnc-server mac.o $(LIBS) $(OSX_LIBS)
diff --git a/example.c b/example.c
index 22d1c04..2ef78d8 100644
--- a/example.c
+++ b/example.c
@@ -145,6 +145,7 @@ int main(int argc,char** argv)
initBuffer(rfbScreen->frameBuffer);
/* this is the blocking event loop, i.e. it never returns */
+ /* 40000 are the microseconds, i.e. 0.04 seconds */
runEventLoop(rfbScreen,40000,FALSE);
/* this is the non-blocking event loop; a background thread is started */
diff --git a/main.c b/main.c
index 9736b0d..43cb0e0 100644
--- a/main.c
+++ b/main.c
@@ -276,7 +276,7 @@ processArguments(rfbScreenInfoPtr rfbScreen,int argc, char *argv[])
} else if (strcmp(argv[i], "-dontdisconnect") == 0) {
rfbScreen->rfbDontDisconnect = TRUE;
} else {
- usage();
+ /* usage(); we no longer exit for unknown arguments */
}
}
}
diff --git a/pnmshow.c b/pnmshow.c
new file mode 100644
index 0000000..0f29d90
--- /dev/null
+++ b/pnmshow.c
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include "rfb.h"
+#define XK_MISCELLANY
+#include "keysymdef.h"
+
+void HandleKey(Bool down,KeySym key,rfbClientPtr cl)
+{
+ if(down && (key==XK_Escape || key=='q' || key=='Q'))
+ rfbCloseClient(cl);
+}
+
+int main(int argc,char** argv)
+{
+ FILE* in=stdin;
+ int i,width,height;
+ unsigned char buffer[1024];
+ rfbScreenInfoPtr rfbScreen;
+
+ if(argc>1) {
+ in=fopen(argv[1],"rb");
+ if(!in) {
+ printf("Couldn't find file %s.\n",argv[1]);
+ exit(1);
+ }
+ }
+
+ fgets(buffer,1024,in);
+ if(strncmp(buffer,"P6",2)) {
+ printf("Not a ppm.\n");
+ exit(2);
+ }
+
+ /* skip comments */
+ do {
+ fgets(buffer,1024,in);
+ } while(buffer[0]=='#');
+
+ /* get width & height */
+ sscanf(buffer,"%d %d",&width,&height);
+ fprintf(stderr,"Got width %d and height %d (%s).\n",width,height,buffer);
+ fgets(buffer,1024,in);
+
+ /* initialize data for vnc server */
+ rfbScreen = rfbDefaultScreenInit(argc,argv,width,height,8,3,4);
+ if(argc>1)
+ rfbScreen->desktopName = argv[1];
+ else
+ rfbScreen->desktopName = "Picture";
+ rfbScreen->rfbAlwaysShared = TRUE;
+ rfbScreen->kbdAddEvent = HandleKey;
+
+ /* allocate picture and read it */
+ rfbScreen->frameBuffer = (char*)malloc(width*height*4);
+ fread(rfbScreen->frameBuffer,width*3,height,in);
+
+ /* correct the format to 4 bytes instead of 3 */
+ for(i=width*height-1;i>=0;i--) {
+ rfbScreen->frameBuffer[i*4+3]=rfbScreen->frameBuffer[i*3+2];
+ rfbScreen->frameBuffer[i*4+2]=rfbScreen->frameBuffer[i*3+1];
+ rfbScreen->frameBuffer[i*4+1]=rfbScreen->frameBuffer[i*3+0];
+ }
+
+ /* run event loop */
+ runEventLoop(rfbScreen,40000,FALSE);
+
+ return(0);
+}