~ubuntu-branches/debian/lenny/italc/lenny

« back to all changes in this revision

Viewing changes to ica/x11/x11vnc/x11vnc.h

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Winnertz
  • Date: 2008-06-17 13:46:54 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080617134654-cl0gi4u524cv1ici
Tags: 1:1.0.9~rc3-1
* Package new upstream version
  - upstream ported the code to qt4.4 (Closes: #481974)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _X11VNC_X11VNC_H
 
2
#define _X11VNC_X11VNC_H
 
3
 
 
4
/* -- x11vnc.h -- */
 
5
/* 
 
6
 * These ' -- filename.[ch] -- ' comments represent a partial cleanup:
 
7
 * they are an odd way to indicate how this huge file would be split up
 
8
 * someday into multiple files.
 
9
 *
 
10
 * The primary reason we have not broken up this file is for user
 
11
 * convenience: those wanting to use the latest version download a single
 
12
 * file, x11vnc.c, and off they go...
 
13
 */
 
14
 
 
15
/****************************************************************************/
 
16
 
 
17
/* Standard includes and libvncserver */
 
18
 
 
19
#include <unistd.h>
 
20
#include <signal.h>
 
21
#include <sys/utsname.h>
 
22
#ifdef __hpux
 
23
/* to avoid select() compiler warning */
 
24
#include <sys/time.h>
 
25
#endif
 
26
#include <time.h>
 
27
#include <errno.h>
 
28
 
 
29
#include <sys/stat.h>
 
30
#include <fcntl.h>
 
31
#include <ctype.h>
 
32
 
 
33
#include <rfb/rfb.h>
 
34
#include <rfb/rfbregion.h>
 
35
 
 
36
 
 
37
/* we can now build under --without-x: */
 
38
#if LIBVNCSERVER_HAVE_X11
 
39
 
 
40
#define NO_X11 0
 
41
#include <X11/Xlib.h>
 
42
#include <X11/Xutil.h>
 
43
 
 
44
#include <X11/keysym.h>
 
45
#include <X11/Xatom.h>
 
46
 
 
47
#else
 
48
 
 
49
#define NO_X11 1
 
50
#ifndef SKIP_NO_X11
 
51
#include "nox11.h"
 
52
#endif
 
53
#include <rfb/keysym.h>
 
54
 
 
55
#endif
 
56
 
 
57
/****************************************************************************/
 
58
 
 
59
 
 
60
/*
 
61
 * Build-time customization via CPPFLAGS.
 
62
 *
 
63
 * Summary of options to include in CPPFLAGS for custom builds:
 
64
 *
 
65
 * -DVNCSHARED  to have the vnc display shared by default.
 
66
 * -DFOREVER  to have -forever on by default.
 
67
 * -DNOREPEAT=0  to have -repeat on by default.
 
68
 * -DXINERAMA=0  to have -noxinerama on by default.
 
69
 * -DADDKEYSYMS=0  to have -noadd_keysyms the default.
 
70
 *
 
71
 * -DREMOTE_DEFAULT=0  to disable remote-control on by default (-yesremote).
 
72
 * -DREMOTE_CONTROL=0  to disable remote-control mechanism completely.
 
73
 * -DEXTERNAL_COMMANDS=0  to disable the running of all external commands.
 
74
 * -DTIGHTFILEXFER=0  disable tightfilexfer.
 
75
 *
 
76
 * -DHARDWIRE_PASSWD=...      hardwired passwords, quoting necessary.
 
77
 * -DHARDWIRE_VIEWPASSWD=...
 
78
 * -DNOPW=1                   make -nopw the default (skip warning)
 
79
 * -DUSEPW=1                  make -usepw the default
 
80
 * -DPASSWD_REQUIRED=1        exit unless a password is supplied.
 
81
 * -DPASSWD_UNLESS_NOPW=1     exit unless a password is supplied and no -nopw.
 
82
 *
 
83
 * -DCURSOR_DRAG=1  to have -cursor_drag as the default.
 
84
 * -DWIREFRAME=0  to have -nowireframe as the default.
 
85
 * -DWIREFRAME_COPYRECT=0  to have -nowirecopyrect as the default.
 
86
 * -DWIREFRAME_PARMS=...   set default -wirecopyrect parameters.
 
87
 * -DSCROLL_COPYRECT=0     to have -noscrollcopyrect as the default.
 
88
 * -DSCROLL_COPYRECT_PARMS=...  set default -scrollcopyrect parameters.
 
89
 * -DSCALING_COPYRECT=0
 
90
 * -DXDAMAGE=0    to have -noxdamage as the default.
 
91
 * -DSKIPDUPS=0   to have -noskip_dups as the default or vice versa.
 
92
 *
 
93
 * -DPOINTER_MODE_DEFAULT={0,1,2,3,4}  set default -pointer_mode.
 
94
 * -DBOLDLY_CLOSE_DISPLAY=0  to not close X DISPLAY under -rawfb.
 
95
 * -DSMALL_FOOTPRINT=1  for smaller binary size (no help, no gui, etc) 
 
96
 *                      use 2 or 3 for even smaller footprint.
 
97
 * -DNOGUI  do not include the gui tkx11vnc.
 
98
 * -DSKIP_HELP=1   smaller.
 
99
 * -DSKIP_XKB=1    a little smaller.
 
100
 * -DSKIP_8to24=1  a little smaller.
 
101
 * -DPOLL_8TO24_DELAY=N  
 
102
 * -DDEBUG_XEVENTS=1  enable printout for X events.
 
103
 *
 
104
 * Set these in CPPFLAGS before running configure. E.g.:
 
105
 *
 
106
 *   % env CPPFLAGS="-DFOREVER -DREMOTE_CONTROL=0" ./configure
 
107
 *   % make
 
108
 */
 
109
 
 
110
/*
 
111
 * This can be used to disable the remote control mechanism.
 
112
 */
 
113
#ifndef REMOTE_CONTROL
 
114
#define REMOTE_CONTROL 1
 
115
#endif
 
116
 
 
117
#ifndef XINERAMA
 
118
#define XINERAMA 1
 
119
#endif
 
120
 
 
121
#ifndef NOPW
 
122
#define NOPW 0
 
123
#endif
 
124
 
 
125
#ifndef USEPW
 
126
#define USEPW 0
 
127
#endif
 
128
 
 
129
#ifndef PASSWD_REQUIRED
 
130
#define PASSWD_REQUIRED 0
 
131
#endif
 
132
 
 
133
#ifndef PASSWD_UNLESS_NOPW
 
134
#define PASSWD_UNLESS_NOPW 0
 
135
#endif
 
136
 
 
137
/* these are for delaying features: */
 
138
#define xxNO_SSL_OR_UNIXPW
 
139
#define xxNO_NCACHE
 
140
 
 
141
/*
 
142
 * Beginning of support for small binary footprint build for embedded
 
143
 * systems, PDA's etc.  It currently just cuts out the low-hanging
 
144
 * fruit (large text passages).  Set to 2, 3 to cut out some of the
 
145
 * more esoteric extensions.  More tedious is to modify LDFLAGS in the
 
146
 * Makefile to not link against the extension libraries... but that
 
147
 * should be done too (manually for now).
 
148
 *
 
149
 * If there is interest more of the bloat can be removed...  Currently
 
150
 * these shrink the binary from 1100K to about 600K.
 
151
 */
 
152
#ifndef SMALL_FOOTPRINT
 
153
#define SMALL_FOOTPRINT 0
 
154
#endif
 
155
 
 
156
#ifndef SKIP_XKB
 
157
#define SKIP_XKB 0
 
158
#endif
 
159
#ifndef SKIP_8TO24
 
160
#define SKIP_8TO24 0
 
161
#endif
 
162
#ifndef SKIP_HELP
 
163
#define SKIP_HELP 0
 
164
#endif
 
165
 
 
166
#if SMALL_FOOTPRINT
 
167
#undef  NOGUI
 
168
#define NOGUI
 
169
#undef  SKIP_HELP
 
170
#define SKIP_HELP 1
 
171
#endif
 
172
 
 
173
#if (SMALL_FOOTPRINT > 1)
 
174
#undef SKIP_XKB
 
175
#undef SKIP_8TO24
 
176
#undef LIBVNCSERVER_HAVE_LIBXINERAMA
 
177
#undef LIBVNCSERVER_HAVE_LIBXFIXES
 
178
#undef LIBVNCSERVER_HAVE_LIBXDAMAGE
 
179
#define SKIP_XKB 1
 
180
#define SKIP_8TO24 1
 
181
#define LIBVNCSERVER_HAVE_LIBXINERAMA 0
 
182
#define LIBVNCSERVER_HAVE_LIBXFIXES 0
 
183
#define LIBVNCSERVER_HAVE_LIBXDAMAGE 0
 
184
#endif
 
185
 
 
186
#if (SMALL_FOOTPRINT > 2)
 
187
#undef LIBVNCSERVER_HAVE_UTMPX_H
 
188
#undef LIBVNCSERVER_HAVE_PWD_H
 
189
#undef REMOTE_CONTROL
 
190
#define LIBVNCSERVER_HAVE_UTMPX_H 0
 
191
#define LIBVNCSERVER_HAVE_PWD_H 0
 
192
#define REMOTE_CONTROL 0
 
193
#endif
 
194
 
 
195
/*
 
196
 * Not recommended unless you know what you are getting into, but if you
 
197
 * define the HARDWIRE_PASSWD or HARDWIRE_VIEWPASSWD variables here or in
 
198
 * CPPFLAGS you can set a default -passwd and -viewpasswd string values,
 
199
 * perhaps this would be better than nothing on an embedded system, etc.
 
200
 * These default values will be overridden by the command line.
 
201
 * We don't even give an example ;-)
 
202
 */
 
203
 
 
204
/****************************************************************************/
 
205
 
 
206
/* Extensions and related includes: */
 
207
 
 
208
#if LIBVNCSERVER_HAVE_XSHM
 
209
#  if defined(__hpux) && defined(__ia64)  /* something weird on hp/itanic */
 
210
#    undef _INCLUDE_HPUX_SOURCE
 
211
#  endif
 
212
#include <sys/ipc.h>
 
213
#include <sys/shm.h>
 
214
#include <X11/extensions/XShm.h>
 
215
#endif
 
216
 
 
217
#include <dirent.h>
 
218
 
 
219
#if LIBVNCSERVER_HAVE_XTEST
 
220
#include <X11/extensions/XTest.h>
 
221
#endif
 
222
extern int xtest_base_event_type;
 
223
 
 
224
#if LIBVNCSERVER_HAVE_LIBXTRAP
 
225
#define NEED_EVENTS
 
226
#define NEED_REPLIES
 
227
#include <X11/extensions/xtraplib.h>
 
228
#include <X11/extensions/xtraplibp.h>
 
229
extern XETC *trap_ctx;
 
230
#endif
 
231
extern int xtrap_base_event_type;
 
232
 
 
233
#if LIBVNCSERVER_HAVE_RECORD
 
234
#include <X11/Xproto.h>
 
235
#include <X11/extensions/record.h>
 
236
#endif
 
237
 
 
238
#if LIBVNCSERVER_HAVE_XKEYBOARD
 
239
#include <X11/XKBlib.h>
 
240
#endif
 
241
 
 
242
#if LIBVNCSERVER_HAVE_LIBXINERAMA
 
243
#include <X11/extensions/Xinerama.h>
 
244
#endif
 
245
 
 
246
#if LIBVNCSERVER_HAVE_SYS_SOCKET_H
 
247
#include <sys/socket.h>
 
248
#endif
 
249
 
 
250
#include <netdb.h>
 
251
#ifndef _AIX
 
252
extern int h_errno;
 
253
#endif
 
254
 
 
255
#if LIBVNCSERVER_HAVE_NETINET_IN_H
 
256
#include <netinet/in.h>
 
257
#include <netinet/tcp.h>
 
258
#include <arpa/inet.h>
 
259
#endif
 
260
 
 
261
#if LIBVNCSERVER_HAVE_PWD_H
 
262
#include <pwd.h>
 
263
#include <grp.h>
 
264
#endif
 
265
#if LIBVNCSERVER_HAVE_SYS_WAIT_H
 
266
#include <sys/wait.h>
 
267
#endif
 
268
#if LIBVNCSERVER_HAVE_UTMPX_H
 
269
#include <utmpx.h>
 
270
#endif
 
271
 
 
272
#if LIBVNCSERVER_HAVE_MMAP
 
273
#include <sys/mman.h>
 
274
#endif
 
275
 
 
276
/*
 
277
 * overlay/multi-depth screen reading support
 
278
 * undef SOLARIS_OVERLAY or IRIX_OVERLAY if there are problems building.
 
279
 */
 
280
 
 
281
/* solaris/sun */
 
282
#if defined (__SVR4) && defined (__sun)
 
283
# define SOLARIS
 
284
# ifdef LIBVNCSERVER_HAVE_SOLARIS_XREADSCREEN
 
285
#  define SOLARIS_OVERLAY
 
286
#  define OVERLAY_OS
 
287
# endif
 
288
#endif
 
289
 
 
290
#ifdef SOLARIS_OVERLAY
 
291
#include <X11/extensions/transovl.h>
 
292
#endif
 
293
 
 
294
/* irix/sgi */
 
295
#if defined(__sgi)
 
296
# define IRIX
 
297
# ifdef LIBVNCSERVER_HAVE_IRIX_XREADDISPLAY
 
298
#  define IRIX_OVERLAY
 
299
#  define OVERLAY_OS
 
300
# endif
 
301
#endif
 
302
 
 
303
/*
 
304
 * For reference, the OS header defines:
 
305
 __SVR4 && __sun   is solaris
 
306
 __sgi
 
307
 __hpux
 
308
 __osf__
 
309
 __OpenBSD__
 
310
 __FreeBSD__
 
311
 __NetBSD__
 
312
 __linux__
 
313
 (defined(__MACH__) && defined(__APPLE__))
 
314
 _AIX
 
315
 */
 
316
#if (defined(__MACH__) && defined(__APPLE__))
 
317
#define MACOSX
 
318
#endif
 
319
 
 
320
 
 
321
#ifdef IRIX_OVERLAY
 
322
#include <X11/extensions/readdisplay.h>
 
323
#endif
 
324
 
 
325
extern int overlay_present;
 
326
 
 
327
#if LIBVNCSERVER_HAVE_LIBXRANDR
 
328
#include <X11/extensions/Xrandr.h>
 
329
#endif
 
330
extern int xrandr_base_event_type;
 
331
 
 
332
#if LIBVNCSERVER_HAVE_LIBXFIXES
 
333
#include <X11/extensions/Xfixes.h>
 
334
#endif
 
335
extern int xfixes_base_event_type;
 
336
 
 
337
#if LIBVNCSERVER_HAVE_LIBXDAMAGE
 
338
#include <X11/extensions/Xdamage.h>
 
339
#endif
 
340
extern int xdamage_base_event_type;
 
341
 
 
342
#define RAWFB_RET(y)   if (raw_fb && ! dpy) return y;
 
343
#define RAWFB_RET_VOID if (raw_fb && ! dpy) return;
 
344
 
 
345
extern char lastmod[];
 
346
 
 
347
/* X display info */
 
348
 
 
349
extern Display *dpy;            /* the single display screen we connect to */
 
350
extern int scr;
 
351
extern char *xauth_raw_data;
 
352
extern int xauth_raw_len;
 
353
extern Window window, rootwin;          /* polled window, root window (usu. same) */
 
354
extern Visual *default_visual;          /* the default visual (unless -visual) */
 
355
extern int bpp, depth;
 
356
extern int indexed_color;
 
357
extern int dpy_x, dpy_y;                /* size of display */
 
358
extern int fb_x, fb_y, fb_b;            /* fb size and bpp guesses at display */
 
359
extern int off_x, off_y;                /* offsets for -sid */
 
360
extern int wdpy_x, wdpy_y;              /* for actual sizes in case of -clip */
 
361
extern int cdpy_x, cdpy_y, coff_x, coff_y;      /* the -clip params */
 
362
extern int button_mask;         /* button state and info */
 
363
extern int button_mask_prev;
 
364
extern int num_buttons;
 
365
 
 
366
extern long xselectinput_rootwin;
 
367
 
 
368
extern unsigned int display_button_mask;
 
369
extern unsigned int display_mod_mask;
 
370
 
 
371
/* image structures */
 
372
extern XImage *scanline;
 
373
extern XImage *fullscreen;
 
374
extern XImage **tile_row;       /* for all possible row runs */
 
375
extern XImage *snaprect;        /* for XShmGetImage (fs_factor) */
 
376
extern XImage *snap;            /* the full snap fb */
 
377
extern XImage *raw_fb_image;    /* the raw fb */
 
378
 
 
379
#if !LIBVNCSERVER_HAVE_XSHM
 
380
/*
 
381
 * for simplicity, define this struct since we'll never use them
 
382
 * under using_shm = 0.
 
383
 */
 
384
typedef struct {
 
385
        int shmid; char *shmaddr; Bool readOnly;
 
386
} XShmSegmentInfo;
 
387
#endif
 
388
 
 
389
/* corresponding shm structures */
 
390
extern XShmSegmentInfo scanline_shm;
 
391
extern XShmSegmentInfo fullscreen_shm;
 
392
extern XShmSegmentInfo *tile_row_shm;   /* for all possible row runs */
 
393
extern XShmSegmentInfo snaprect_shm;
 
394
 
 
395
/* rfb screen info */
 
396
extern rfbScreenInfoPtr screen;
 
397
extern char *rfb_desktop_name;
 
398
extern char *http_dir;
 
399
extern char vnc_desktop_name[];
 
400
extern char *main_fb;                   /* our copy of the X11 fb */
 
401
extern char *rfb_fb;                    /* same as main_fb unless transformation */
 
402
extern char *fake_fb;                   /* used under -padgeom */
 
403
extern char *snap_fb;                   /* used under -snapfb */
 
404
extern char *cmap8to24_fb;              /* used under -8to24 */
 
405
extern char *rot_fb;                    /* used under -rotate */
 
406
extern char *raw_fb;
 
407
extern char *raw_fb_addr;
 
408
extern int raw_fb_offset;
 
409
extern int raw_fb_shm;
 
410
extern int raw_fb_mmap;
 
411
extern int raw_fb_seek;
 
412
extern int raw_fb_fd;
 
413
extern int raw_fb_back_to_X;
 
414
 
 
415
extern int rfb_bytes_per_line;
 
416
extern int main_bytes_per_line;
 
417
extern int rot_bytes_per_line;
 
418
extern unsigned long  main_red_mask,  main_green_mask,  main_blue_mask;
 
419
extern unsigned short main_red_max,   main_green_max,   main_blue_max;
 
420
extern unsigned short main_red_shift, main_green_shift, main_blue_shift;
 
421
 
 
422
extern int raw_fb_bytes_per_line;       /* of actual raw region we poll, not our raw_fb */
 
423
 
 
424
/* scaling parameters */
 
425
extern char *scale_str;
 
426
extern double scale_fac;
 
427
extern int scaling;
 
428
extern int scaling_blend;               /* for no blending option (very course) */
 
429
extern int scaling_nomult4;             /* do not require width = n * 4 */
 
430
extern int scaling_pad;         /* pad out scaled sizes to fit denominator */
 
431
extern int scaling_interpolate; /* use interpolation scheme when shrinking */
 
432
extern int scaled_x, scaled_y;          /* dimensions of scaled display */
 
433
extern int scale_numer, scale_denom;    /* n/m */
 
434
extern char *rotating_str;
 
435
extern int rotating;
 
436
extern int rotating_same;
 
437
extern int rotating_cursors;
 
438
 
 
439
/* scale cursor */
 
440
extern char *scale_cursor_str;
 
441
extern double scale_cursor_fac;
 
442
extern int scaling_cursor;
 
443
extern int scaling_cursor_blend;
 
444
extern int scaling_cursor_interpolate;
 
445
extern int scale_cursor_numer, scale_cursor_denom;
 
446
 
 
447
/* size of the basic tile unit that is polled for changes: */
 
448
extern int tile_x;
 
449
extern int tile_y;
 
450
extern int ntiles, ntiles_x, ntiles_y;
 
451
 
 
452
/* arrays that indicate changed or checked tiles. */
 
453
extern unsigned char *tile_has_diff, *tile_tried, *tile_copied;
 
454
extern unsigned char *tile_has_xdamage_diff, *tile_row_has_xdamage_diff;
 
455
 
 
456
/* times of recent events */
 
457
extern time_t last_event, last_input, last_client;
 
458
extern time_t last_keyboard_input, last_pointer_input; 
 
459
extern time_t last_local_input;
 
460
extern time_t last_fb_bytes_sent;
 
461
extern double last_keyboard_time;
 
462
extern double last_pointer_time;
 
463
extern double last_pointer_click_time;
 
464
extern double last_pointer_motion_time;
 
465
extern double last_key_to_button_remap_time;
 
466
extern double last_copyrect;
 
467
extern double last_copyrect_fix;
 
468
extern double last_wireframe;
 
469
extern double servertime_diff;
 
470
extern double x11vnc_start;
 
471
extern double x11vnc_current;
 
472
extern double g_now;
 
473
 
 
474
extern double last_get_wm_frame_time;
 
475
extern Window last_get_wm_frame;
 
476
extern double last_bs_restore;
 
477
extern double last_su_restore;
 
478
extern double last_bs_save;
 
479
extern double last_su_save;
 
480
 
 
481
extern int hack_val;
 
482
 
 
483
/* last client to move pointer */
 
484
extern rfbClientPtr last_pointer_client;
 
485
extern rfbClientPtr latest_client;
 
486
extern double last_client_gone;
 
487
 
 
488
extern int waited_for_client;
 
489
extern int findcreatedisplay;
 
490
extern char *terminal_services_daemon;
 
491
 
 
492
extern int client_count;
 
493
extern int clients_served;
 
494
 
 
495
/* more transient kludge variables: */
 
496
extern int cursor_x, cursor_y;          /* x and y from the viewer(s) */
 
497
extern int button_change_x, button_change_y;
 
498
extern int got_user_input;
 
499
extern int got_pointer_input;
 
500
extern int got_local_pointer_input;
 
501
extern int got_pointer_calls;
 
502
extern int got_keyboard_input;
 
503
extern int got_keyboard_calls;
 
504
extern int urgent_update;
 
505
extern int last_keyboard_keycode;
 
506
extern rfbBool last_rfb_down;
 
507
extern rfbBool last_rfb_key_accepted;
 
508
extern rfbKeySym last_rfb_keysym;
 
509
extern double last_rfb_keytime;
 
510
extern int fb_copy_in_progress; 
 
511
extern int drag_in_progress;    
 
512
extern int shut_down;   
 
513
extern int do_copy_screen;      
 
514
extern time_t damage_time;
 
515
extern int damage_delay;
 
516
 
 
517
extern int program_pid;
 
518
extern char *program_name;
 
519
extern char *program_cmdline;
 
520
 
 
521
extern struct utsname UT;
 
522
 
 
523
typedef struct hint {
 
524
        /* location x, y, height, and width of a change-rectangle  */
 
525
        /* (grows as adjacent horizontal tiles are glued together) */
 
526
        int x, y, w, h;
 
527
} hint_t;
 
528
 
 
529
/* struct with client specific data: */
 
530
#define CILEN 10
 
531
typedef struct _ClientData {
 
532
        int uid;
 
533
        char *hostname;
 
534
        char *username;
 
535
        char *unixname;
 
536
        int client_port;
 
537
        int server_port;
 
538
        char *server_ip;
 
539
        char input[CILEN];
 
540
        int login_viewonly;
 
541
        time_t login_time;
 
542
 
 
543
        pid_t ssl_helper_pid;
 
544
 
 
545
        int had_cursor_shape_updates;
 
546
        int had_cursor_pos_updates;
 
547
 
 
548
        double timer;
 
549
        double send_cmp_rate;
 
550
        double send_raw_rate;
 
551
        double latency;
 
552
        int cmp_bytes_sent;
 
553
        int raw_bytes_sent;
 
554
 
 
555
} ClientData;
 
556
 
 
557
extern void nox11_exit(int rc);
 
558
 
 
559
#include "params.h"
 
560
#include "enums.h"
 
561
#include "options.h"
 
562
#include "util.h"
 
563
 
 
564
#endif /* _X11VNC_X11VNC_H */