~ubuntu-branches/ubuntu/lucid/vino/lucid

« back to all changes in this revision

Viewing changes to server/libvncserver/rfb/rfb.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2008-05-27 09:06:36 UTC
  • mfrom: (1.1.21 upstream) (2.1.31 hardy)
  • Revision ID: james.westby@ubuntu.com-20080527090636-lg1whxlkub1wtsw7
Tags: 2.22.2-1
New upstream bugfix release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include <netinet/in.h>
50
50
#endif
51
51
 
52
 
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
53
 
#include <pthread.h>
54
 
#if 0 /* debugging */
55
 
#define LOCK(mutex) (rfbLog("%s:%d LOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_lock(&(mutex)))
56
 
#define UNLOCK(mutex) (rfbLog("%s:%d UNLOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_unlock(&(mutex)))
57
 
#define MUTEX(mutex) pthread_mutex_t (mutex)
58
 
#define INIT_MUTEX(mutex) (rfbLog("%s:%d INIT_MUTEX(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_init(&(mutex),NULL))
59
 
#define TINI_MUTEX(mutex) (rfbLog("%s:%d TINI_MUTEX(%s)\n",__FILE__,__LINE__,#mutex), pthread_mutex_destroy(&(mutex)))
60
 
#define TSIGNAL(cond) (rfbLog("%s:%d TSIGNAL(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_signal(&(cond)))
61
 
#define WAIT(cond,mutex) (rfbLog("%s:%d WAIT(%s,%s)\n",__FILE__,__LINE__,#cond,#mutex), pthread_cond_wait(&(cond),&(mutex)))
62
 
#define COND(cond) pthread_cond_t (cond)
63
 
#define INIT_COND(cond) (rfbLog("%s:%d INIT_COND(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_init(&(cond),NULL))
64
 
#define TINI_COND(cond) (rfbLog("%s:%d TINI_COND(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_destroy(&(cond)))
65
 
#define IF_PTHREADS(x) x
66
 
#else
67
 
#define LOCK(mutex) pthread_mutex_lock(&(mutex));
68
 
#define UNLOCK(mutex) pthread_mutex_unlock(&(mutex));
69
 
#define MUTEX(mutex) pthread_mutex_t (mutex)
70
 
#define INIT_MUTEX(mutex) pthread_mutex_init(&(mutex),NULL)
71
 
#define TINI_MUTEX(mutex) pthread_mutex_destroy(&(mutex))
72
 
#define TSIGNAL(cond) pthread_cond_signal(&(cond))
73
 
#define WAIT(cond,mutex) pthread_cond_wait(&(cond),&(mutex))
74
 
#define COND(cond) pthread_cond_t (cond)
75
 
#define INIT_COND(cond) pthread_cond_init(&(cond),NULL)
76
 
#define TINI_COND(cond) pthread_cond_destroy(&(cond))
77
 
#define IF_PTHREADS(x) x
78
 
#endif
79
 
#else
80
52
#define LOCK(mutex)
81
53
#define UNLOCK(mutex)
82
 
#define MUTEX(mutex)
83
 
#define INIT_MUTEX(mutex)
84
 
#define TINI_MUTEX(mutex)
85
 
#define TSIGNAL(cond)
86
 
#define WAIT(cond,mutex) this_is_unsupported
87
 
#define COND(cond)
88
 
#define INIT_COND(cond)
89
 
#define TINI_COND(cond)
90
 
#define IF_PTHREADS(x)
91
 
#endif
92
54
 
93
55
/* end of stuff for autoconf */
94
56
 
95
 
/* if you use pthreads, but don't define LIBVNCSERVER_HAVE_LIBPTHREAD, the structs
96
 
   get all mixed up. So this gives a linker error reminding you to compile
97
 
   the library and your application (at least the parts including rfb.h)
98
 
   with the same support for pthreads. */
99
 
#if 0
100
 
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
101
 
#ifdef HAVE_LIBZ
102
 
#define rfbInitServer rfbInitServerWithPthreadsAndZRLE
103
 
#else
104
 
#define rfbInitServer rfbInitServerWithPthreadsButWithoutZRLE
105
 
#endif
106
 
#else
107
 
#ifdef HAVE_LIBZ
108
 
#define rfbInitServer rfbInitServerWithoutPthreadsButWithZRLE
109
 
#else
110
 
#define rfbInitServer rfbInitServerWithoutPthreadsAndZRLE
111
 
#endif
112
 
#endif
113
 
#endif
114
 
 
115
57
struct _rfbClientRec;
116
58
struct _rfbScreenInfo;
117
59
struct rfbCursor;
166
108
 
167
109
    rfbPixelFormat rfbServerFormat;
168
110
    rfbColourMap colourMap; /* set this if rfbServerFormat.trueColour==FALSE */
169
 
    const char* desktopName;
 
111
    char* desktopName;
170
112
    char rfbThisHost[255];
171
113
 
172
114
    rfbBool autoPort;
 
115
    rfbBool localOnly;
173
116
    int rfbPort;
174
117
    SOCKET rfbListenSock;
175
118
    int maxSock;
224
167
     */
225
168
    AuthenticatedClientHookPtr authenticatedClientHook;
226
169
 
227
 
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
228
 
    MUTEX(cursorMutex);
229
 
    rfbBool backgroundLoop;
230
 
#endif
231
 
 
232
170
} rfbScreenInfo, *rfbScreenInfoPtr;
233
171
 
234
172
 
274
212
    rfbBool useTLS;
275
213
#endif
276
214
    char *host;
277
 
 
278
 
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
279
 
    pthread_t client_thread;
280
 
#endif
281
215
                                /* Possible client states: */
282
216
    enum {
283
217
        RFB_PROTOCOL_VERSION,   /* establishing protocol version */
411
345
    struct _rfbClientRec *prev;
412
346
    struct _rfbClientRec *next;
413
347
 
414
 
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
415
 
    /* whenever a client is referenced, the refCount has to be incremented
416
 
       and afterwards decremented, so that the client is not cleaned up
417
 
       while being referenced.
418
 
       Use the functions rfbIncrClientRef(cl) and rfbDecrClientRef(cl);
419
 
    */
420
 
    int refCount;
421
 
    MUTEX(refCountMutex);
422
 
    COND(deleteCond);
423
 
 
424
 
    MUTEX(outputMutex);
425
 
    MUTEX(updateMutex);
426
 
    COND(updateCond);
427
 
#endif
428
 
 
429
348
#ifdef HAVE_LIBZ
430
349
    void* zrleData;
431
350
#endif
468
387
extern int rfbMaxClientWait;
469
388
 
470
389
extern void rfbInitSockets(rfbScreenInfoPtr rfbScreen);
 
390
extern void rfbSetAutoPort(rfbScreenInfoPtr rfbScreen, rfbBool autoPort);
 
391
extern void rfbSetPort(rfbScreenInfoPtr rfbScreen, int Port);
 
392
extern void rfbSetLocalOnly(rfbScreenInfoPtr rfbScreen, rfbBool localOnly);
471
393
extern void rfbCloseClient(rfbClientPtr cl);
472
394
extern int ReadExact(rfbClientPtr cl, char *buf, int len);
473
395
extern int ReadExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout);
474
396
extern int WriteExact(rfbClientPtr cl, const char *buf, int len);
475
397
extern void rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen);
476
398
extern void rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec);
477
 
extern int rfbConnect(rfbScreenInfoPtr rfbScreen, char* host, int port);
478
 
extern int ConnectToTcpAddr(char* host, int port);
479
 
extern int ListenOnTCPPort(int port);
 
399
extern int ListenOnTCPPort(int port, rfbBool localOnly);
480
400
 
481
401
/* rfbserver.c */
482
402
 
493
413
extern rfbClientPtr rfbClientIteratorNext(rfbClientIteratorPtr iterator);
494
414
extern void rfbReleaseClientIterator(rfbClientIteratorPtr iterator);
495
415
 
496
 
extern void rfbIncrClientRef(rfbClientPtr cl);
497
 
extern void rfbDecrClientRef(rfbClientPtr cl);
498
 
 
499
416
extern void rfbNewClientConnection(rfbScreenInfoPtr rfbScreen,int sock);
500
417
extern rfbClientPtr rfbNewClient(rfbScreenInfoPtr rfbScreen,int sock);
501
418
extern void rfbClientConnectionGone(rfbClientPtr cl);
665
582
extern void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen,char *framebuffer,
666
583
 int width,int height);
667
584
 
 
585
extern void rfbSetDesktopName(rfbScreenInfoPtr rfbScreen, const char *name);
 
586
 
668
587
extern void rfbScreenCleanup(rfbScreenInfoPtr screenInfo);
669
588
 
670
 
/* functions to accept/refuse a client that has been put on hold
671
 
   by a NewClientHookPtr function. Must not be called in other
672
 
   situations. */
673
 
extern void rfbStartOnHoldClient(rfbClientPtr cl);
674
 
extern void rfbRefuseOnHoldClient(rfbClientPtr cl);
675
 
 
676
589
/* call one of these two functions to service the vnc clients.
677
590
 usec are the microseconds the select on the fds waits.
678
591
 if you are using the event loop, set this to some value > 0, so the