comments & new example: pnmshow

pull/1/head
dscho 24 years ago
parent 47341aa554
commit 2634379912

@ -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 \ stats.o corre.o hextile.o rre.o translate.o cutpaste.o \
zlib.o tight.o zlib.o tight.o
all: example storepasswd all: example pnmshow storepasswd
install_OSX: OSXvnc-server install_OSX: OSXvnc-server
cp OSXvnc-server storepasswd ../OSXvnc/build/OSXvnc.app/Contents/MacOS 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 example: example.o libvncauth/libvncauth.a libvncserver.a
$(CC) -o example example.o $(LIBS) $(PTHREAD_LIBS) $(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 OSXvnc-server: mac.o libvncauth/libvncauth.a libvncserver.a
$(CC) -o OSXvnc-server mac.o $(LIBS) $(OSX_LIBS) $(CC) -o OSXvnc-server mac.o $(LIBS) $(OSX_LIBS)

@ -145,6 +145,7 @@ int main(int argc,char** argv)
initBuffer(rfbScreen->frameBuffer); initBuffer(rfbScreen->frameBuffer);
/* this is the blocking event loop, i.e. it never returns */ /* this is the blocking event loop, i.e. it never returns */
/* 40000 are the microseconds, i.e. 0.04 seconds */
runEventLoop(rfbScreen,40000,FALSE); runEventLoop(rfbScreen,40000,FALSE);
/* this is the non-blocking event loop; a background thread is started */ /* this is the non-blocking event loop; a background thread is started */

@ -276,7 +276,7 @@ processArguments(rfbScreenInfoPtr rfbScreen,int argc, char *argv[])
} else if (strcmp(argv[i], "-dontdisconnect") == 0) { } else if (strcmp(argv[i], "-dontdisconnect") == 0) {
rfbScreen->rfbDontDisconnect = TRUE; rfbScreen->rfbDontDisconnect = TRUE;
} else { } else {
usage(); /* usage(); we no longer exit for unknown arguments */
} }
} }
} }

@ -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);
}
Loading…
Cancel
Save