File: argsresources.c

package info (click to toggle)
ssvnc 1.0.29-4%2Bdeb10u1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 3,172 kB
  • sloc: ansic: 20,796; tcl: 15,833; java: 8,263; sh: 3,640; makefile: 2,044; perl: 41
file content (1796 lines) | stat: -rw-r--r-- 77,567 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
/*
 *  Copyright (C) 2002-2003 Constantin Kaplinsky.  All Rights Reserved.
 *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
 *
 *  This is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This software is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this software; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 *  USA.
 */

/*
 * argsresources.c - deal with command-line args and resources.
 */

#include "vncviewer.h"

/*
 * fallback_resources - these are used if there is no app-defaults file
 * installed in one of the standard places.
 */

char *fallback_resources[] = {

#if (defined(__MACH__) && defined(__APPLE__))
  "Ssvnc.title: SSVNC: %s - Press F7 for Menu",
#else
  "Ssvnc.title: SSVNC: %s - Press F8 for Menu",
#endif

  "Ssvnc.translations:\
    <Enter>: SelectionToVNC()\\n\
    <Leave>: SelectionFromVNC()",

  "*form.background: black",

  "*viewport.allowHoriz: True",
  "*viewport.allowVert: True",
  "*viewport.useBottom: True",
  "*viewport.useRight: True",
  "*viewport*Scrollbar*thumb: None",

           "*viewport.horizontal.height:   6 ",
              "*viewport.vertical.width:   6 ",
  "ssvnc*viewport.horizontal.height:   6 ",
     "ssvnc*viewport.vertical.width:   6 ",

  "*viewport.horizontal.translations: #override\\n\
     <KeyPress>Right:  StartScroll(Forward)\\n\
     <KeyRelease>Right:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Left:  StartScroll(Backward)\\n\
     <KeyRelease>Left:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Next:  StartScroll(Forward)\\n\
     <KeyRelease>Next:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Prior:  StartScroll(Backward)\\n\
     <KeyRelease>Prior:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>z:  StartScroll(Forward)\\n\
     <KeyRelease>z:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>a:  StartScroll(Backward)\\n\
     <KeyRelease>a:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>f:  StartScroll(Forward)\\n\
     <KeyRelease>f:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>b:  StartScroll(Backward)\\n\
     <KeyRelease>b:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Down:  StartScroll(Forward)\\n\
     <KeyRelease>Down:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Up:  StartScroll(Backward)\\n\
     <KeyRelease>Up:  NotifyScroll(FullLength) EndScroll()",

  "*viewport.vertical.translations: #override\\n\
     <KeyPress>Down:  StartScroll(Forward)\\n\
     <KeyRelease>Down:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Up:  StartScroll(Backward)\\n\
     <KeyRelease>Up:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Next:  StartScroll(Forward)\\n\
     <KeyRelease>Next:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Prior:  StartScroll(Backward)\\n\
     <KeyRelease>Prior:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>z:  StartScroll(Forward)\\n\
     <KeyRelease>z:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>a:  StartScroll(Backward)\\n\
     <KeyRelease>a:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>f:  StartScroll(Forward)\\n\
     <KeyRelease>f:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>b:  StartScroll(Backward)\\n\
     <KeyRelease>b:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Right:  StartScroll(Forward)\\n\
     <KeyRelease>Right:  NotifyScroll(FullLength) EndScroll()\\n\
     <KeyPress>Left:  StartScroll(Backward)\\n\
     <KeyRelease>Left:  NotifyScroll(FullLength) EndScroll()",

#if (defined(__MACH__) && defined(__APPLE__))
  "*desktop.baseTranslations:\
     <KeyPress>F7:  ShowPopup()\\n\
     <KeyRelease>F7:  Noop()\\n\
     <KeyPress>F8:  ShowPopup()\\n\
     <KeyRelease>F8:  Noop()\\n\
     <KeyPress>F9:  ToggleFullScreen()\\n\
     <KeyRelease>F9:  Noop()\\n\
     <ButtonPress>: SendRFBEvent()\\n\
     <ButtonRelease>: SendRFBEvent()\\n\
     <Motion>: SendRFBEvent()\\n\
     <KeyPress>: SendRFBEvent()\\n\
     <KeyRelease>: SendRFBEvent()",
#else
  "*desktop.baseTranslations:\
     <KeyPress>F8:  ShowPopup()\\n\
     <KeyRelease>F8:  Noop()\\n\
     <KeyPress>F9:  ToggleFullScreen()\\n\
     <KeyRelease>F9:  Noop()\\n\
     <ButtonPress>: SendRFBEvent()\\n\
     <ButtonRelease>: SendRFBEvent()\\n\
     <Motion>: SendRFBEvent()\\n\
     <KeyPress>: SendRFBEvent()\\n\
     <KeyRelease>: SendRFBEvent()",
#endif

  "*serverDialog.dialog.label: VNC server:",
  "*serverDialog.dialog.value:",
  "*serverDialog.dialog.value.width: 150",
  "*serverDialog.dialog.value.translations: #override\\n\
     <Key>Return: ServerDialogDone()",

  "*userDialog.dialog.label: SSVNC: Enter Username",
  "*userDialog.dialog.value:",
  "*userDialog.dialog.value.width: 150",
  "*userDialog.dialog.value.translations: #override\\n\
     <Key>Return: UserDialogDone()",

  "*scaleDialog.dialog.label: Scale: Enter 'none' (same as '1' or '1.0'),\\na geometry WxH (e.g. 1280x1024), or\\na fraction (e.g. 0.75 or 3/4).\\nUse 'fit' for full screen size.\\nUse 'auto' to match window size.\\nCurrent value:",
  "*scaleDialog.dialog.value:",
  "*scaleDialog.dialog.value.translations: #override\\n\
     <KeyRelease>Return: ScaleDialogDone()",

  "*escapeDialog.dialog.label: Escape Keys:  Enter a comma separated list of modifier keys to be the\\n"
                              "'escape sequence'.  When these keys are held down, the next keystroke is\\n"
                              "interpreted locally to invoke a special action instead of being sent to\\n"
                              "the remote VNC server.  In other words, a set of 'Hot Keys'.\\n"
                              "\\n"
                              "To enable or disable this, click on 'Escape Keys: Toggle' in the Popup.\\n"
                              "\\n"
                              "Here is the list of hot-key mappings to special actions:\\n"
                              "\\n"
                              "   r: refresh desktop  b: toggle bell   c: toggle full-color\\n"
                              "   f: file transfer    x: x11cursor     z: toggle Tight/ZRLE\\n"
                              "   l: full screen      g: graball       e: escape keys dialog\\n"
                              "   s: scale dialog     +: scale up (=)  -: scale down (_)\\n"
                              "   t: text chat                         a: alphablend cursor\\n"
                              "   V: toggle viewonly  Q: quit viewer   1 2 3 4 5 6: UltraVNC scale 1/n\\n"
                              "\\n"
                              "   Arrow keys:         pan the viewport about 10% for each keypress.\\n"
                              "   PageUp / PageDown:  pan the viewport by a screenful vertically.\\n"
                              "   Home   / End:       pan the viewport by a screenful horizontally.\\n"
                              "   KeyPad Arrow keys:  pan the viewport by 1 pixel for each keypress.\\n"
                              "   Dragging the Mouse with Button1 pressed also pans the viewport.\\n"
                              "   Clicking Mouse Button3 brings up the Popup Menu.\\n"
                              "\\n"
                              "The above mappings are *always* active in ViewOnly mode, unless you set the\\n"
                              "Escape Keys value to 'never'.\\n"
                              "\\n"
                              "x11vnc -appshare hot-keys:  x11vnc has a simple application sharing mode\\n"
                              "that enables the viewer-side to move, resize, or raise the remote toplevel\\n"
                              "windows.  To enable it, hold down Shift + the Escape Keys and press these:\\n"
                              "\\n"
                              "   Arrow keys:              move the remote window around in its desktop.\\n"
                              "   PageUp/PageDn/Home/End:  resize the remote window.\\n"
                              "   +/-                      raise or lower the remote window.\\n"
                              "   M or Button1 move win to local position;  D or Button3: delete remote win.\\n"
                              "\\n"
                              "If the Escape Keys value below is set to 'default' then a fixed list of\\n"
                              "modifier keys is used.  For Unix it is: Alt_L,Super_L and for MacOSX it is\\n"
                              "Control_L,Meta_L.  Note: the Super_L key usually has a Windows(TM) Flag.\\n"
                              "Also note the _L and _R mean the key is on the LEFT or RIGHT side of keyboard.\\n"
                              "\\n"
                              "On Unix   the default is Alt and Windows keys on Left side of keyboard.\\n"
                              "On MacOSX the default is Control and Command keys on Left side of keyboard.\\n"
                              "\\n"
                              "Example: Press and hold the Alt and Windows keys on the LEFT side of the\\n"
                              "keyboard and then press 'c' to toggle the full-color state.  Or press 't'\\n"
                              "to toggle the ultravnc Text Chat window, etc.\\n"
                              "\\n"
                              "To use something besides the default, supply a comma separated list (or a\\n"
                              "single one) from: Shift_L Shift_R Control_L Control_R Alt_L Alt_R Meta_L\\n"
                              "Meta_R Super_L Super_R Hyper_L Hyper_R or Mode_switch.\\n"
                              "\\n"
                              "Current Escape Keys Value:",
  "*escapeDialog.dialog.value:",
  "*escapeDialog.dialog.value.width: 280",
  "*escapeDialog.dialog.value.translations: #override\\n\
     <KeyRelease>Return: EscapeDialogDone()",

  "*ycropDialog.dialog.label: Y Crop (max-height in pixels):",
  "*ycropDialog.dialog.value:",
  "*ycropDialog.dialog.value.translations: #override\\n\
     <KeyRelease>Return: YCropDialogDone()",

  "*scbarDialog.dialog.label: Scroll Bars width:",
  "*scbarDialog.dialog.value:",
  "*scbarDialog.dialog.value.translations: #override\\n\
     <KeyRelease>Return: ScbarDialogDone()",

  "*scaleNDialog.dialog.label: Integer n for 1/n server scaling:",
  "*scaleNDialog.dialog.value:",
  "*scaleNDialog.dialog.value.translations: #override\\n\
     <KeyRelease>Return: ScaleNDialogDone()",

  "*passwordDialog.dialog.label: SSVNC: Enter Password",
  "*passwordDialog.dialog.value:",
  "*passwordDialog.dialog.value.width: 150",
  "*passwordDialog.dialog.value.AsciiSink.echo: False",
  "*passwordDialog.dialog.value.translations: #override\\n\
     <Key>Return: PasswordDialogDone()",

  "*popup.title: SSVNC popup",
  "*popup*background: grey",
  "*popup*font_old: -*-helvetica-bold-r-*-*-16-*-*-*-*-*-*-*",
  "*popup*font: -*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
  "*popup.buttonForm*.Command.borderWidth: 0",
  "*popup.buttonForm*.Toggle.borderWidth: 0",

  "*scaleN.title: 1/n scale",
  "*scaleN*background: grey",
  "*scaleN*font: -*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
  "*scaleN.buttonForm.Command.borderWidth: 0",
  "*scaleN.buttonForm.Toggle.borderWidth: 0",

  "*turboVNC.title: TurboVNC",
  "*turboVNC*background: grey",
  "*turboVNC*font: -*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
  "*turboVNC.buttonForm.Command.borderWidth: 0",
  "*turboVNC.buttonForm.Toggle.borderWidth: 0",

  "*quality.title: quality",
  "*quality*background: grey",
  "*quality*font: -*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
  "*quality.buttonForm.Command.borderWidth: 0",
  "*quality.buttonForm.Toggle.borderWidth: 0",

  "*compress.title: compress",
  "*compress*background: grey",
  "*compress*font: -*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
  "*compress.buttonForm.Command.borderWidth: 0",
  "*compress.buttonForm.Toggle.borderWidth: 0",

  "*popup.translations: #override <Message>WM_PROTOCOLS: HidePopup()",
  "*popup.buttonForm.translations: #override\\n\
     <KeyPress>: SendRFBEvent() HidePopup()",

  "*popupButtonCount: 44",
  "*popupButtonBreak: 22",

  "*popup*button1.label: Dismiss popup",
  "*popup*button1.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HidePopup()",

  "*popup*button2.label: Quit viewer",
  "*popup*button2.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: Quit()",

  "*popup*button3.label: Full screen  (also F9)",
  "*popup*button3.type: toggle",
  "*popup*button3.translations: #override\\n\
     <Visible>: SetFullScreenState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleFullScreen() HidePopup()",

  "*popup*button4.label: Clipboard: local -> remote",
  "*popup*button4.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SelectionToVNC(always) HidePopup()",

  "*popup*button5.label: Clipboard: local <- remote",
  "*popup*button5.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SelectionFromVNC(always) HidePopup()",

  "*popup*button6.label: Request refresh",
  "*popup*button6.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SendRFBEvent(fbupdate) HidePopup()",

  "*popup*button7.label: Send ctrl-alt-del",
  "*popup*button7.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SendRFBEvent(keydown,Control_L)\
     SendRFBEvent(keydown,Alt_L)\
     SendRFBEvent(key,Delete)\
     SendRFBEvent(keyup,Alt_L)\
     SendRFBEvent(keyup,Control_L)\
     HidePopup()",

#if (defined(__MACH__) && defined(__APPLE__))
  "*popup*button8.label: Send F7",
  "*popup*button8.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SendRFBEvent(key,F7) HidePopup()",
#else
  "*popup*button8.label: Send F8",
  "*popup*button8.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SendRFBEvent(key,F8) HidePopup()",
#endif

  "*popup*button9.label: Send F9",
  "*popup*button9.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SendRFBEvent(key,F9) HidePopup()",

  "*popup*button10.label: ViewOnly",
  "*popup*button10.type: toggle",
  "*popup*button10.translations: #override\\n\
     <Visible>: SetViewOnlyState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleViewOnly() HidePopup()",

  "*popup*button11.label: Disable Bell",
  "*popup*button11.type: toggle",
  "*popup*button11.translations: #override\\n\
     <Visible>: SetBellState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleBell() HidePopup()",

  "*popup*button12.label: Cursor Shape",
  "*popup*button12.type: toggle",
  "*popup*button12.translations: #override\\n\
     <Visible>: SetCursorShapeState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleCursorShape() HidePopup()",

  "*popup*button13.label: X11 Cursor",
  "*popup*button13.type: toggle",
  "*popup*button13.translations: #override\\n\
     <Visible>: SetX11CursorState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleX11Cursor() HidePopup()",

  "*popup*button14.label: Cursor Alphablend",
  "*popup*button14.type: toggle",
  "*popup*button14.translations: #override\\n\
     <Visible>: SetCursorAlphaState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleCursorAlpha() HidePopup()",

  "*popup*button15.label: Toggle Tight/Hextile",
  "*popup*button15.type: toggle",
  "*popup*button15.translations: #override\\n\
     <Visible>: SetHextileState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleTightHextile() HidePopup()",

  "*popup*button16.label: Toggle Tight/ZRLE",
  "*popup*button16.type: toggle",
  "*popup*button16.translations: #override\\n\
     <Visible>: SetZRLEState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleTightZRLE() HidePopup()",

  "*popup*button17.label: Toggle ZRLE/ZYWRLE",
  "*popup*button17.type: toggle",
  "*popup*button17.translations: #override\\n\
     <Visible>: SetZYWRLEState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleZRLEZYWRLE() HidePopup()",

  "*popup*button18.label: Quality Level",
  "*popup*button18.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HidePopup() ShowQuality()",

  "*popup*button19.label: Compress Level",
  "*popup*button19.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HidePopup() ShowCompress()",

  "*popup*button20.label: Disable JPEG",
  "*popup*button20.type: toggle",
  "*popup*button20.translations: #override\\n\
     <Visible>: SetNOJPEGState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleJPEG() HidePopup()",

  "*popup*button21.label: TurboVNC Settings",
  "*popup*button21.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HidePopup() ShowTurboVNC()",

  "*popup*button22.label: Pipeline Updates",
  "*popup*button22.type: toggle",
  "*popup*button22.translations: #override\\n\
     <Visible>: SetPipelineUpdates()\\n\
     <Btn1Down>,<Btn1Up>: toggle() TogglePipelineUpdates() HidePopup()",

  "*popup*button23.label: Full Color",
  "*popup*button23.type: toggle",
  "*popup*button23.translations: #override\\n\
     <Visible>: SetFullColorState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleFullColor() HidePopup()",

  "*popup*button24.label: Grey Scale (16 & 8-bpp)",
  "*popup*button24.type: toggle",
  "*popup*button24.translations: #override\\n\
     <Visible>: SetGreyScaleState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleGreyScale() HidePopup()",

  "*popup*button25.label: 16 bit color (BGR565)",
  "*popup*button25.type: toggle",
  "*popup*button25.translations: #override\\n\
     <Visible>: Set16bppState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() Toggle16bpp() HidePopup()",

  "*popup*button26.label: 8   bit color (BGR233)",
  "*popup*button26.type: toggle",
  "*popup*button26.translations: #override\\n\
     <Visible>: Set8bppState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() Toggle8bpp() HidePopup()",

  "*popup*button27.label: -     256 colors",
  "*popup*button27.type: toggle",
  "*popup*button27.translations: #override\\n\
     <Visible>: Set256ColorsState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() Toggle256Colors() HidePopup()",

  "*popup*button28.label: -       64 colors",
  "*popup*button28.type: toggle",
  "*popup*button28.translations: #override\\n\
     <Visible>: Set64ColorsState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() Toggle64Colors() HidePopup()",

  "*popup*button29.label: -         8 colors",
  "*popup*button29.type: toggle",
  "*popup*button29.translations: #override\\n\
     <Visible>: Set8ColorsState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() Toggle8Colors() HidePopup()",

  "*popup*button30.label: Scale Viewer",
  "*popup*button30.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HidePopup() SetScale()",

  "*popup*button31.label: Escape Keys: Toggle",
  "*popup*button31.type: toggle",
  "*popup*button31.translations: #override\\n\
     <Visible>: SetEscapeKeysState()\\n\
     <Btn1Down>, <Btn1Up>: toggle() ToggleEscapeActive() HidePopup()",

  "*popup*button32.label: Escape Keys: Help+Set",
  "*popup*button32.translations: #override\\n\
      <Btn1Down>, <Btn1Up>: HidePopup() SetEscapeKeys()",

  "*popup*button33.label: Set Y Crop (y-max)",
  "*popup*button33.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HidePopup() SetYCrop()",

  "*popup*button34.label: Set Scrollbar Width",
  "*popup*button34.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HidePopup() SetScbar()",

  "*popup*button35.label: XGrabServer",
  "*popup*button35.type: toggle",
  "*popup*button35.translations: #override\\n\
     <Visible>: SetXGrabState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleXGrab() HidePopup()",

  "*popup*button36.label: UltraVNC Extensions:",
  "*popup*button36.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HidePopup()",

  "*popup*button37.label: - Set 1/n Server Scale",
  "*popup*button37.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HidePopup() ShowScaleN()",

  "*popup*button38.label: - Text Chat",
  "*popup*button38.type: toggle",
  "*popup*button38.translations: #override\\n\
     <Visible>: SetTextChatState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleTextChat() HidePopup()",

  "*popup*button39.label: - File Transfer",
  "*popup*button39.type: toggle",
  "*popup*button39.translations: #override\\n\
     <Visible>: SetFileXferState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleFileXfer() HidePopup()",

  "*popup*button40.label: - Single Window",
  "*popup*button40.type: toggle",
  "*popup*button40.translations: #override\\n\
     <Visible>: SetSingleWindowState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleSingleWindow() HidePopup()",

  "*popup*button41.label: - Disable Remote Input",
  "*popup*button41.type: toggle",
  "*popup*button41.translations: #override\\n\
     <Visible>: SetServerInputState()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleServerInput() HidePopup()",

  "*popup*button42.label: Send Clipboard not Primary",
  "*popup*button42.type: toggle",
  "*popup*button42.translations: #override\\n\
     <Visible>: SetSendClipboard()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleSendClipboard() HidePopup()",

  "*popup*button43.label: Send Selection Every time",
  "*popup*button43.type: toggle",
  "*popup*button43.translations: #override\\n\
     <Visible>: SetSendAlways()\\n\
     <Btn1Down>,<Btn1Up>: toggle() ToggleSendAlways() HidePopup()",

  "*popup*button44.label: ",

  "*turboVNC*button0.label: Dismiss",
  "*turboVNC*button0.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HideTurboVNC()",

  "*turboVNC*button1.label: High Quality (LAN)",
  "*turboVNC*button1.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(1)",

  "*turboVNC*button2.label: Medium Quality",
  "*turboVNC*button2.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(2)",

  "*turboVNC*button3.label: Low Quality (WAN)",
  "*turboVNC*button3.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(3)",

  "*turboVNC*button4.label: Lossless (Gigabit)",
  "*turboVNC*button4.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(4)",

  "*turboVNC*button5.label: Lossless Zlib (WAN)",
  "*turboVNC*button5.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(5)",

  "*turboVNC*button6.label: Subsampling:",

  "*turboVNC*button7.label: -           None",
  "*turboVNC*button7.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(6)",

  "*turboVNC*button8.label: -           2X",
  "*turboVNC*button8.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(7)",

  "*turboVNC*button9.label: -           4X",
  "*turboVNC*button9.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(8)",

  "*turboVNC*button10.label: -          Gray",
  "*turboVNC*button10.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(9)",

  "*turboVNC*button11.label: Lossless Refresh",
  "*turboVNC*button11.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SetTurboVNC(10)",

  "*turboVNC*button12.label: Lossy Refresh",
  "*turboVNC*button12.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: SendRFBEvent(fbupdate)",

  "*turboVNC*buttonNone.label: Not Compiled with\\nTurboVNC Support.",
  "*turboVNC*buttonNone.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HideTurboVNC()",

  "*qualLabel.label: JPEG Image Quality:",
  "*qualBar.length: 100",
  "*qualBar.width: 130",
  "*qualBar.orientation: horizontal",
  "*qualBar.translations: #override\\n\
     <Btn1Down>: StartScroll(Continuous) MoveThumb() NotifyThumb()\\n\
     <Btn1Motion>: MoveThumb() NotifyThumb()\\n\
     <Btn3Down>: StartScroll(Continuous) MoveThumb() NotifyThumb()\\n\
     <Btn3Motion>: MoveThumb() NotifyThumb()",
    
  "*qualText.label: 000",

  "*scaleN*button0.label: Dismiss",
  "*scaleN*button0.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HideScaleN()",

  "*scaleN*button1.label: 1/1",
  "*scaleN*button1.translations: #override\\n\
     <Visible>: SetScaleNState(1)\\n\
     <Btn1Down>,<Btn1Up>: SetScaleN(1) HideScaleN()",

  "*scaleN*button2.label: 1/2",
  "*scaleN*button2.translations: #override\\n\
     <Visible>: SetScaleNState(2)\\n\
     <Btn1Down>,<Btn1Up>: SetScaleN(2) HideScaleN()",

  "*scaleN*button3.label: 1/3",
  "*scaleN*button3.translations: #override\\n\
     <Visible>: SetScaleNState(3)\\n\
     <Btn1Down>,<Btn1Up>: SetScaleN(3) HideScaleN()",

  "*scaleN*button4.label: 1/4",
  "*scaleN*button4.translations: #override\\n\
     <Visible>: SetScaleNState(4)\\n\
     <Btn1Down>,<Btn1Up>: SetScaleN(4) HideScaleN()",

  "*scaleN*button5.label: 1/5",
  "*scaleN*button5.translations: #override\\n\
     <Visible>: SetScaleNState(5)\\n\
     <Btn1Down>,<Btn1Up>: SetScaleN(5) HideScaleN()",

  "*scaleN*button6.label: Other",
  "*scaleN*button6.translations: #override\\n\
     <Visible>: SetScaleNState(6)\\n\
     <Btn1Down>,<Btn1Up>: HideScaleN() DoServerScale()",

  "*quality*buttonD.label: Dismiss",
  "*quality*buttonD.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HideQuality()",

  "*quality*button0.label: 0",
  "*quality*button0.type: toggle",
  "*quality*button0.translations: #override\\n\
     <Visible>: SetQualityState(0)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(0) HideQuality()",

  "*quality*button1.label: 1",
  "*quality*button1.type: toggle",
  "*quality*button1.translations: #override\\n\
     <Visible>: SetQualityState(1)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(1) HideQuality()",

  "*quality*button2.label: 2",
  "*quality*button2.type: toggle",
  "*quality*button2.translations: #override\\n\
     <Visible>: SetQualityState(2)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(2) HideQuality()",

  "*quality*button3.label: 3",
  "*quality*button3.type: toggle",
  "*quality*button3.translations: #override\\n\
     <Visible>: SetQualityState(3)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(3) HideQuality()",

  "*quality*button4.label: 4",
  "*quality*button4.type: toggle",
  "*quality*button4.translations: #override\\n\
     <Visible>: SetQualityState(4)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(4) HideQuality()",

  "*quality*button5.label: 5",
  "*quality*button5.type: toggle",
  "*quality*button5.translations: #override\\n\
     <Visible>: SetQualityState(5)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(5) HideQuality()",

  "*quality*button6.label: 6",
  "*quality*button6.type: toggle",
  "*quality*button6.translations: #override\\n\
     <Visible>: SetQualityState(6)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(6) HideQuality()",

  "*quality*button7.label: 7",
  "*quality*button7.type: toggle",
  "*quality*button7.translations: #override\\n\
     <Visible>: SetQualityState(7)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(7) HideQuality()",

  "*quality*button8.label: 8",
  "*quality*button8.type: toggle",
  "*quality*button8.translations: #override\\n\
     <Visible>: SetQualityState(8)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(8) HideQuality()",

  "*quality*button9.label: 9",
  "*quality*button9.type: toggle",
  "*quality*button9.translations: #override\\n\
     <Visible>: SetQualityState(9)\\n\
     <Btn1Down>,<Btn1Up>: SetQuality(9) HideQuality()",

  "*compress*buttonD.label: Dismiss",
  "*compress*buttonD.translations: #override\\n\
     <Btn1Down>,<Btn1Up>: HideCompress()",

  "*compress*button0.label: 0",
  "*compress*button0.translations: #override\\n\
     <Visible>: SetCompressState(0)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(0) HideCompress()",

  "*compress*button1.label: 1",
  "*compress*button1.translations: #override\\n\
     <Visible>: SetCompressState(1)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(1) HideCompress()",

  "*compress*button2.label: 2",
  "*compress*button2.translations: #override\\n\
     <Visible>: SetCompressState(2)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(2) HideCompress()",

  "*compress*button3.label: 3",
  "*compress*button3.translations: #override\\n\
     <Visible>: SetCompressState(3)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(3) HideCompress()",

  "*compress*button4.label: 4",
  "*compress*button4.translations: #override\\n\
     <Visible>: SetCompressState(4)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(4) HideCompress()",

  "*compress*button5.label: 5",
  "*compress*button5.translations: #override\\n\
     <Visible>: SetCompressState(5)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(5) HideCompress()",

  "*compress*button6.label: 6",
  "*compress*button6.translations: #override\\n\
     <Visible>: SetCompressState(6)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(6) HideCompress()",

  "*compress*button7.label: 7",
  "*compress*button7.translations: #override\\n\
     <Visible>: SetCompressState(7)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(7) HideCompress()",

  "*compress*button8.label: 8",
  "*compress*button8.translations: #override\\n\
     <Visible>: SetCompressState(8)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(8) HideCompress()",

  "*compress*button9.label: 9",
  "*compress*button9.translations: #override\\n\
     <Visible>: SetCompressState(9)\\n\
     <Btn1Down>,<Btn1Up>: SetCompress(9) HideCompress()",

  NULL
};


/*
 * vncServerHost and vncServerPort are set either from the command line or
 * from a dialog box.
 */

char vncServerHost[1024];
int vncServerPort = 0;


/*
 * appData is our application-specific data which can be set by the user with
 * application resource specs.  The AppData structure is defined in the header
 * file.
 */

AppData appData;
AppData appDataNew;

static XtResource appDataResourceList[] = {
  {"shareDesktop", "ShareDesktop", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, shareDesktop), XtRImmediate, (XtPointer) True},

  {"viewOnly", "ViewOnly", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, viewOnly), XtRImmediate, (XtPointer) False},

  {"fullScreen", "FullScreen", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, fullScreen), XtRImmediate, (XtPointer) False},

  {"raiseOnBeep", "RaiseOnBeep", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, raiseOnBeep), XtRImmediate, (XtPointer) True},

  {"passwordFile", "PasswordFile", XtRString, sizeof(String),
   XtOffsetOf(AppData, passwordFile), XtRImmediate, (XtPointer) 0},

  {"userLogin", "UserLogin", XtRString, sizeof(String),
   XtOffsetOf(AppData, userLogin), XtRImmediate, (XtPointer) 0},

  {"unixPW", "UnixPW", XtRString, sizeof(String),
   XtOffsetOf(AppData, unixPW), XtRImmediate, (XtPointer) 0},

  {"msLogon", "MSLogon", XtRString, sizeof(String),
   XtOffsetOf(AppData, msLogon), XtRImmediate, (XtPointer) 0},

  {"repeaterUltra", "RepeaterUltra", XtRString, sizeof(String),
   XtOffsetOf(AppData, repeaterUltra), XtRImmediate, (XtPointer) 0},

  {"ultraDSM", "UltraDSM", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, ultraDSM), XtRImmediate, (XtPointer) False},

  {"acceptPopup", "AcceptPopup", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, acceptPopup), XtRImmediate, (XtPointer) False},

  {"rfbVersion", "RfbVersion", XtRString, sizeof(String),
   XtOffsetOf(AppData, rfbVersion), XtRImmediate, (XtPointer) 0},

  {"passwordDialog", "PasswordDialog", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, passwordDialog), XtRImmediate, (XtPointer) False},

  {"encodings", "Encodings", XtRString, sizeof(String),
   XtOffsetOf(AppData, encodingsString), XtRImmediate, (XtPointer) 0},

  {"useBGR233", "UseBGR233", XtRInt, sizeof(int),
   XtOffsetOf(AppData, useBGR233), XtRImmediate, (XtPointer) 0},

  {"useBGR565", "UseBGR565", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useBGR565), XtRImmediate, (XtPointer) False},

  {"useGreyScale", "UseGreyScale", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useGreyScale), XtRImmediate, (XtPointer) False},

  {"yCrop", "yCrop", XtRInt, sizeof(int),
   XtOffsetOf(AppData, yCrop), XtRImmediate, (XtPointer) 0},

  {"sbWidth", "sbWidth", XtRInt, sizeof(int),
   XtOffsetOf(AppData, sbWidth), XtRImmediate, (XtPointer) 2},

  {"nColours", "NColours", XtRInt, sizeof(int),
   XtOffsetOf(AppData, nColours), XtRImmediate, (XtPointer) 256},

  {"useSharedColours", "UseSharedColours", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useSharedColours), XtRImmediate, (XtPointer) True},

  {"forceOwnCmap", "ForceOwnCmap", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, forceOwnCmap), XtRImmediate, (XtPointer) False},

  {"forceTrueColour", "ForceTrueColour", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, forceTrueColour), XtRImmediate, (XtPointer) False},

  {"requestedDepth", "RequestedDepth", XtRInt, sizeof(int),
   XtOffsetOf(AppData, requestedDepth), XtRImmediate, (XtPointer) 0},

  {"useShm", "UseShm", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useShm), XtRImmediate, (XtPointer) True},

  {"termChat", "TermChat", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, termChat), XtRImmediate, (XtPointer) False},

  {"wmDecorationWidth", "WmDecorationWidth", XtRInt, sizeof(int),
   XtOffsetOf(AppData, wmDecorationWidth), XtRImmediate, (XtPointer) 4},

  {"wmDecorationHeight", "WmDecorationHeight", XtRInt, sizeof(int),
   XtOffsetOf(AppData, wmDecorationHeight), XtRImmediate, (XtPointer) 24},

  {"popupButtonCount", "PopupButtonCount", XtRInt, sizeof(int),
   XtOffsetOf(AppData, popupButtonCount), XtRImmediate, (XtPointer) 0},

  {"popupButtonBreak", "PopupButtonBreak", XtRInt, sizeof(int),
   XtOffsetOf(AppData, popupButtonBreak), XtRImmediate, (XtPointer) 0},

  {"debug", "Debug", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, debug), XtRImmediate, (XtPointer) False},

  {"rawDelay", "RawDelay", XtRInt, sizeof(int),
   XtOffsetOf(AppData, rawDelay), XtRImmediate, (XtPointer) 0},

  {"copyRectDelay", "CopyRectDelay", XtRInt, sizeof(int),
   XtOffsetOf(AppData, copyRectDelay), XtRImmediate, (XtPointer) 0},

  {"bumpScrollTime", "BumpScrollTime", XtRInt, sizeof(int),
   XtOffsetOf(AppData, bumpScrollTime), XtRImmediate, (XtPointer) 25},

  {"bumpScrollPixels", "BumpScrollPixels", XtRInt, sizeof(int),
   XtOffsetOf(AppData, bumpScrollPixels), XtRImmediate, (XtPointer) 20},

  /* hardwired compress -1 vs . 7 */
  {"compressLevel", "CompressionLevel", XtRInt, sizeof(int),
   XtOffsetOf(AppData, compressLevel), XtRImmediate, (XtPointer) -1},

  /* hardwired quality was 6 */
  {"qualityLevel", "QualityLevel", XtRInt, sizeof(int),
   XtOffsetOf(AppData, qualityLevel), XtRImmediate, (XtPointer) -1},

  {"enableJPEG", "EnableJPEG", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, enableJPEG), XtRImmediate, (XtPointer) True},

  {"useRemoteCursor", "UseRemoteCursor", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useRemoteCursor), XtRImmediate, (XtPointer) True},

  {"useCursorAlpha", "UseCursorAlpha", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useCursorAlpha), XtRImmediate, (XtPointer) False},

  {"useRawLocal", "UseRawLocal", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useRawLocal), XtRImmediate, (XtPointer) False},

  {"notty", "NoTty", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, notty), XtRImmediate, (XtPointer) False},

  {"useX11Cursor", "UseX11Cursor", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useX11Cursor), XtRImmediate, (XtPointer) False},

  {"useBell", "UseBell", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useBell), XtRImmediate, (XtPointer) True},

  {"grabKeyboard", "GrabKeyboard", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, grabKeyboard), XtRImmediate, (XtPointer) True},

  {"autoPass", "AutoPass", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, autoPass), XtRImmediate, (XtPointer) False},

  {"grabAll", "GrabAll", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, grabAll), XtRImmediate, (XtPointer) False},

  {"useXserverBackingStore", "UseXserverBackingStore", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, useXserverBackingStore), XtRImmediate, (XtPointer) False},

  {"overrideRedir", "OverrideRedir", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, overrideRedir), XtRImmediate, (XtPointer) True},

  {"serverInput", "ServerInput", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, serverInput), XtRImmediate, (XtPointer) True},

  {"singleWindow", "SingleWindow", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, singleWindow), XtRImmediate, (XtPointer) False},

  {"serverScale", "ServerScale", XtRInt, sizeof(int),
   XtOffsetOf(AppData, serverScale), XtRImmediate, (XtPointer) 1},

  {"chatActive", "ChatActive", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, chatActive), XtRImmediate, (XtPointer) False},

  {"chatOnly", "ChatOnly", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, chatOnly), XtRImmediate, (XtPointer) False},

  {"fileActive", "FileActive", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, fileActive), XtRImmediate, (XtPointer) False},

  {"popupFix", "PopupFix", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, popupFix), XtRImmediate, (XtPointer) False},

  {"scale", "Scale", XtRString, sizeof(String),
   XtOffsetOf(AppData, scale), XtRImmediate, (XtPointer) 0},

  {"pipelineUpdates", "PipelineUpdates", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, pipelineUpdates), XtRImmediate, (XtPointer)
#ifdef TURBOVNC
 True},
#else
#if 0
 False},
#else
 True},
#endif
#endif

  {"noipv4", "noipv4", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, noipv4), XtRImmediate, (XtPointer) False},

  {"noipv6", "noipv6", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, noipv6), XtRImmediate, (XtPointer) False},

  {"sendClipboard", "SendClipboard", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, sendClipboard), XtRImmediate, (XtPointer) False},

  {"sendAlways", "SendAlways", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, sendAlways), XtRImmediate, (XtPointer) False},

  {"recvText", "RecvText", XtRString, sizeof(String),
   XtOffsetOf(AppData, recvText), XtRImmediate, (XtPointer) 0},

  {"appShare", "AppShare", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, appShare), XtRImmediate, (XtPointer) False},

  {"escapeKeys", "EscapeKeys", XtRString, sizeof(String),
   XtOffsetOf(AppData, escapeKeys), XtRImmediate, (XtPointer) 0},

  {"escapeActive", "EscapeActive", XtRBool, sizeof(Bool),
   XtOffsetOf(AppData, escapeActive), XtRImmediate, (XtPointer) False}

  /* check commas */
};


/*
 * The cmdLineOptions array specifies how certain app resource specs can be set
 * with command-line options.
 */

XrmOptionDescRec cmdLineOptions[] = {
  {"-shared",        "*shareDesktop",       XrmoptionNoArg,  "True"},
  {"-noshared",      "*shareDesktop",       XrmoptionNoArg,  "False"},
  {"-viewonly",      "*viewOnly",           XrmoptionNoArg,  "True"},
  {"-fullscreen",    "*fullScreen",         XrmoptionNoArg,  "True"},
  {"-noraiseonbeep", "*raiseOnBeep",        XrmoptionNoArg,  "False"},
  {"-passwd",        "*passwordFile",       XrmoptionSepArg, 0},
  {"-user",          "*userLogin",          XrmoptionSepArg, 0},
  {"-unixpw",        "*unixPW",             XrmoptionSepArg, 0},
  {"-mslogon",       "*msLogon",            XrmoptionSepArg, 0},
  {"-repeater",      "*repeaterUltra",      XrmoptionSepArg, 0},
  {"-ultradsm",      "*ultraDSM",           XrmoptionNoArg,  "True"},
  {"-acceptpopup",   "*acceptPopup",        XrmoptionNoArg,  "True"},
  {"-acceptpopupsc", "*acceptPopup",        XrmoptionNoArg,  "True"},
  {"-rfbversion",    "*rfbVersion",         XrmoptionSepArg, 0},
  {"-encodings",     "*encodings",          XrmoptionSepArg, 0},
  {"-bgr233",        "*useBGR233",          XrmoptionNoArg,  "256"},
  {"-use64",         "*useBGR233",          XrmoptionNoArg,   "64"},
  {"-bgr222",        "*useBGR233",          XrmoptionNoArg,   "64"},
  {"-use8",          "*useBGR233",          XrmoptionNoArg,    "8"},
  {"-bgr111",        "*useBGR233",          XrmoptionNoArg,    "8"},
  {"-16bpp",         "*useBGR565",          XrmoptionNoArg,  "True"},
  {"-bgr565",        "*useBGR565",          XrmoptionNoArg,  "True"},
  {"-grey",          "*useGreyScale",       XrmoptionNoArg,  "True"},
  {"-gray",          "*useGreyScale",       XrmoptionNoArg,  "True"},
  {"-sbwidth",       "*sbwidth",            XrmoptionSepArg, 0},
  {"-env",           "*envDummy",           XrmoptionSepArg, 0},
  {"-ycrop",         "*yCrop",              XrmoptionSepArg, 0},
  {"-rawlocal",      "*useRawLocal",        XrmoptionNoArg,  "True"},
  {"-notty",         "*notty",              XrmoptionNoArg,  "True"},
  {"-alpha",         "*useCursorAlpha",     XrmoptionNoArg,  "True"},
  {"-owncmap",       "*forceOwnCmap",       XrmoptionNoArg,  "True"},
  {"-truecolor",     "*forceTrueColour",    XrmoptionNoArg,  "True"},
  {"-truecolour",    "*forceTrueColour",    XrmoptionNoArg,  "True"},
  {"-depth",         "*requestedDepth",     XrmoptionSepArg, 0},
  {"-compresslevel", "*compressLevel",      XrmoptionSepArg, 0},
  {"-quality",       "*qualityLevel",       XrmoptionSepArg, 0},
  {"-nojpeg",        "*enableJPEG",         XrmoptionNoArg,  "False"},
  {"-nocursorshape", "*useRemoteCursor",    XrmoptionNoArg,  "False"},
  {"-x11cursor",     "*useX11Cursor",       XrmoptionNoArg,  "True"},
  {"-nobell",        "*useBell",            XrmoptionNoArg,  "False"},
  {"-autopass",      "*autoPass",           XrmoptionNoArg,  "True"},
  {"-graball",       "*grabAll",            XrmoptionNoArg,  "True"},
  {"-grabkbd",       "*grabKeyboard",       XrmoptionNoArg,  "True"},
  {"-nograbkbd",     "*grabKeyboard",       XrmoptionNoArg,  "False"},
  {"-grabkeyboard",  "*grabKeyboard",       XrmoptionNoArg,  "True"},
  {"-nograbkeyboard","*grabKeyboard",       XrmoptionNoArg,  "False"},
  {"-nooverride",    "*overrideRedir",      XrmoptionNoArg,  "False"},
  {"-bs",            "*useXserverBackingStore",    XrmoptionNoArg,  "True"},
  {"-nobs",          "*useXserverBackingStore",    XrmoptionNoArg,  "False"},
  {"-popupfix",      "*popupFix",           XrmoptionNoArg,  "True"},
  {"-noshm",         "*useShm",             XrmoptionNoArg,  "False"},
  {"-termchat",      "*termChat",           XrmoptionNoArg,  "True"},
  {"-chatonly",      "*chatOnly",           XrmoptionNoArg,  "True"},
  {"-scale",         "*scale",              XrmoptionSepArg, 0},
  {"-appshare",      "*appShare",           XrmoptionNoArg,  "True"},
  {"-escape",        "*escapeKeys",         XrmoptionSepArg, 0},
  {"-sendclipboard", "*sendClipboard",      XrmoptionNoArg,  "True"},
  {"-sendalways",    "*sendAlways",         XrmoptionNoArg,  "True"},
  {"-recvtext",      "*recvText",           XrmoptionSepArg, 0},
  {"-pipeline",      "*pipelineUpdates",    XrmoptionNoArg,  "True"},
  {"-nopipeline",    "*pipelineUpdates",    XrmoptionNoArg,  "False"},
  {"-noipv4",        "*noipv4",             XrmoptionNoArg,  "True"},
  {"-noipv6",        "*noipv6",             XrmoptionNoArg,  "True"}
};

int numCmdLineOptions = XtNumber(cmdLineOptions);


/*
 * actions[] specifies actions that can be used in widget resource specs.
 */

static XtActionsRec actions[] = {
    {"SendRFBEvent", SendRFBEvent},
    {"ShowPopup", ShowPopup},
    {"Noop", Noop},
    {"HidePopup", HidePopup},
    {"HideScaleN", HideScaleN},
    {"HideTurboVNC", HideTurboVNC},
    {"HideQuality", HideQuality},
    {"HideCompress", HideCompress},
    {"ToggleFullScreen", ToggleFullScreen},
    {"JumpLeft", JumpLeft},
    {"JumpRight", JumpRight},
    {"JumpUp", JumpUp},
    {"JumpDown", JumpDown},
    {"SetFullScreenState", SetFullScreenState},
    {"SelectionFromVNC", SelectionFromVNC},
    {"SelectionToVNC", SelectionToVNC},
    {"ServerDialogDone", ServerDialogDone},
    {"UserDialogDone", UserDialogDone},
    {"YCropDialogDone", YCropDialogDone},
    {"ScbarDialogDone", ScbarDialogDone},
    {"ScaleNDialogDone", ScaleNDialogDone},
    {"ScaleDialogDone", ScaleDialogDone},
    {"PasswordDialogDone", PasswordDialogDone},
    {"Pause", Pause},
    {"RunCommand", RunCommand},
    {"Quit", Quit},
    {"HideChat", HideChat},
    {"Toggle8bpp", Toggle8bpp},
    {"Toggle16bpp", Toggle16bpp},
    {"ToggleFullColor", ToggleFullColor},
    {"Toggle256Colors", Toggle256Colors},
    {"Toggle64Colors", Toggle64Colors},
    {"Toggle8Colors", Toggle8Colors},
    {"ToggleGreyScale", ToggleGreyScale},
    {"ToggleTightZRLE", ToggleTightZRLE},
    {"ToggleTightHextile", ToggleTightHextile},
    {"ToggleZRLEZYWRLE", ToggleZRLEZYWRLE},
    {"ToggleViewOnly", ToggleViewOnly},
    {"ToggleJPEG", ToggleJPEG},
    {"ToggleCursorShape", ToggleCursorShape},
    {"ToggleCursorAlpha", ToggleCursorAlpha},
    {"ToggleX11Cursor", ToggleX11Cursor},
    {"ToggleBell", ToggleBell},
    {"ToggleRawLocal", ToggleRawLocal},
    {"ToggleServerInput", ToggleServerInput},
    {"TogglePipelineUpdates", TogglePipelineUpdates},
    {"ToggleSendClipboard", ToggleSendClipboard},
    {"ToggleSendAlways", ToggleSendAlways},
    {"ToggleSingleWindow", ToggleSingleWindow},
    {"ToggleTextChat", ToggleTextChat},
    {"ToggleFileXfer", ToggleFileXfer},
    {"ToggleXGrab", ToggleXGrab},
    {"DoServerScale", DoServerScale},
    {"SetScale", SetScale},
    {"SetYCrop", SetYCrop},
    {"SetScbar", SetScbar},
    {"ShowScaleN", ShowScaleN},
    {"ShowTurboVNC", ShowTurboVNC},
    {"ShowQuality", ShowQuality},
    {"ShowCompress", ShowCompress},
    {"SetScaleN", SetScaleN},
    {"SetTurboVNC", SetTurboVNC},
    {"SetQuality", SetQuality},
    {"SetCompress", SetCompress},
    {"Set8bppState", Set8bppState},
    {"Set16bppState", Set16bppState},
    {"SetFullColorState", SetFullColorState},
    {"Set256ColorsState", Set256ColorsState},
    {"Set64ColorsState", Set64ColorsState},
    {"Set8ColorsState", Set8ColorsState},
    {"SetGreyScaleState", SetGreyScaleState},
    {"SetZRLEState", SetZRLEState},
    {"SetHextileState", SetHextileState},
    {"SetZYWRLEState", SetZYWRLEState},
    {"SetNOJPEGState", SetNOJPEGState},
    {"SetScaleNState", SetScaleNState},
    {"SetQualityState", SetQualityState},
    {"SetCompressState", SetCompressState},
    {"SetViewOnlyState", SetViewOnlyState},
    {"SetCursorShapeState", SetCursorShapeState},
    {"SetCursorAlphaState", SetCursorAlphaState},
    {"SetX11CursorState", SetX11CursorState},
    {"SetBellState", SetBellState},
    {"SetRawLocalState", SetRawLocalState},
    {"SetServerInputState", SetServerInputState},
    {"SetPipelineUpdates", SetPipelineUpdates},
    {"SetSendClipboard", SetSendClipboard},
    {"SetSendAlways", SetSendAlways},
    {"SetSingleWindowState", SetSingleWindowState},
    {"SetTextChatState", SetTextChatState},
    {"SetFileXferState", SetFileXferState},
    {"SetXGrabState", SetXGrabState},
    {"SetEscapeKeysState", SetEscapeKeysState},
    {"ToggleEscapeActive", ToggleEscapeActive},
    {"EscapeDialogDone", EscapeDialogDone},
    {"SetEscapeKeys", SetEscapeKeys}
};


/*
 * removeArgs() is used to remove some of command line arguments.
 */

void
removeArgs(int *argc, char** argv, int idx, int nargs)
{
  int i;
  if ((idx+nargs) > *argc) return;
  for (i = idx+nargs; i < *argc; i++) {
    argv[i-nargs] = argv[i];
  }
  *argc -= nargs;
}

/*
 * usage() prints out the usage message.
 */

void
usage(void)
{
  fprintf(stdout,
	  "SSVNC Viewer (based on TightVNC viewer version 1.3.9)\n"
	  "\n"
	  "Usage: %s [<OPTIONS>] [<HOST>][:<DISPLAY#>]\n"
	  "       %s [<OPTIONS>] [<HOST>][::<PORT#>]\n"
	  "       %s [<OPTIONS>] exec=[CMD ARGS...]\n"
	  "       %s [<OPTIONS>] fd=n\n"
	  "       %s [<OPTIONS>] /path/to/unix/socket\n"
	  "       %s [<OPTIONS>] unix=/path/to/unix/socket\n"
	  "       %s [<OPTIONS>] -listen [<DISPLAY#>]\n"
	  "       %s -help\n"
	  "\n"
	  "<OPTIONS> are standard Xt options, or:\n"
	  "        -via <GATEWAY>\n"
	  "        -shared (set by default)\n"
	  "        -noshared\n"
	  "        -viewonly\n"
	  "        -fullscreen\n"
	  "        -noraiseonbeep\n"
	  "        -passwd <PASSWD-FILENAME> (standard VNC authentication)\n"
	  "        -user <USERNAME> (Unix login authentication)\n"
	  "        -encodings <ENCODING-LIST> (e.g. \"tight,copyrect\")\n"
	  "        -bgr233\n"
	  "        -owncmap\n"
	  "        -truecolour\n"
	  "        -depth <DEPTH>\n"
	  "        -compresslevel <COMPRESS-VALUE> (0..9: 0-fast, 9-best)\n"
	  "        -quality <JPEG-QUALITY-VALUE> (0..9: 0-low, 9-high)\n"
	  "        -nojpeg\n"
	  "        -nocursorshape\n"
	  "        -x11cursor\n"
	  "        -autopass\n"
	  "\n"
	  "Option names may be abbreviated, e.g. -bgr instead of -bgr233.\n"
	  "See the manual page for more information.\n"
	  "\n"
	  "\n"
	  "Enhanced TightVNC viewer (SSVNC) options:\n"
	  "\n"
	  "   URL http://www.karlrunge.com/x11vnc/ssvnc.html\n"
	  "\n"
	  "   Note: ZRLE and ZYWRLE encodings are now supported.\n"
	  "\n"
	  "   Note: F9 is shortcut to Toggle FullScreen mode.\n"
	  "\n"
	  "   Note: In -listen mode set the env var. SSVNC_MULTIPLE_LISTEN=1\n"
	  "         to allow more than one incoming VNC server at a time.\n"
	  "         This is the same as -multilisten described below.  Set\n"
	  "         SSVNC_MULTIPLE_LISTEN=MAX:n to allow no more than \"n\"\n"
	  "         simultaneous reverse connections.\n"
	  "\n"
	  "   Note: If the host:port is specified as \"exec=command args...\"\n"
	  "         then instead of making a TCP/IP socket connection to the\n"
	  "         remote VNC server, \"command args...\" is executed and the\n"
	  "         viewer is attached to its stdio.  This enables tunnelling\n"
	  "         established via an external command, e.g. an stunnel(8)\n"
	  "         that does not involve a listening socket.  This mode does\n"
	  "         not work for -listen reverse connections.  To not have the\n"
	  "         exec= pid killed at exit, set SSVNC_NO_KILL_EXEC_CMD=1.\n"
	  "\n"
	  "         If the host:port is specified as \"fd=n\" then it is assumed\n"
	  "         n is an already opened file descriptor to the socket. (i.e\n"
	  "         the parent did fork+exec)\n"
	  "\n"
	  "         If the host:port contains a '/' and exists in the file system\n"
	  "         it is interpreted as a unix-domain socket (AF_LOCAL/AF_UNIX\n"
	  "         instead of AF_INET)  Prefix with unix= to force interpretation\n"
	  "         as a unix-domain socket.\n"
	  "\n"
	  "        -multilisten  As in -listen (reverse connection listening) except\n"
	  "                    allow more than one incoming VNC server to be connected\n"
	  "                    at a time.  The default for -listen of only one at a\n"
	  "                    time tries to play it safe by not allowing anyone on\n"
	  "                    the network to put (many) desktops on your screen over\n"
	  "                    a long window of time. Use -multilisten for no limit.\n"
	  "\n"
	  "        -acceptpopup  In -listen (reverse connection listening) mode when\n"
	  "                    a reverse VNC connection comes in show a popup asking\n"
	  "                    whether to Accept or Reject the connection.  The IP\n"
	  "                    address of the connecting host is shown.  Same as\n"
	  "                    setting the env. var. SSVNC_ACCEPT_POPUP=1.\n"
	  "\n"
	  "        -acceptpopupsc  As in -acceptpopup except assume UltraVNC Single\n"
	  "                    Click (SC) server.  Retrieve User and ComputerName\n"
	  "                    info from UltraVNC Server and display in the Popup.\n"
	  "\n"
	  "        -use64      In -bgr233 mode, use 64 colors instead of 256.\n"
	  "        -bgr222     Same as -use64.\n"
	  "\n"
	  "        -use8       In -bgr233 mode, use 8 colors instead of 256.\n"
	  "        -bgr111     Same as -use8.\n"
	  "\n"
	  "        -16bpp      If the vnc viewer X display is depth 24 at 32bpp\n"
	  "                    request a 16bpp format from the VNC server to cut\n"
	  "                    network traffic by up to 2X, then tranlate the\n"
	  "                    pixels to 32bpp locally.\n"
	  "        -bgr565     Same as -16bpp.\n"
	  "\n"
	  "        -grey       Use a grey scale for the 16- and 8-bpp modes.\n"
	  "\n"
	  "        -alpha      Use alphablending transparency for local cursors\n"
	  "                    requires: x11vnc server, both client and server\n"
          "                    must be 32bpp and same endianness.\n"
	  "\n"
	  "        -scale str  Scale the desktop locally.  The string \"str\" can\n"
	  "                    a floating point ratio, e.g. \"0.9\", or a fraction,\n"
	  "                    e.g. \"3/4\", or WxH, e.g. 1280x1024.  Use \"fit\"\n"
	  "                    to fit in the current screen size.  Use \"auto\" to\n"
	  "                    fit in the window size.  \"str\" can also be set by\n"
	  "                    the env. var. SSVNC_SCALE.\n"
	  "\n"
	  "                    If you observe mouse trail painting errors, enable\n"
	  "                    X11 Cursor mode (either via Popup or -x11cursor.)\n"
	  "\n"
	  "                    Note that scaling is done in software and so can be\n"
	  "                    slow and requires more memory.  Some speedup Tips:\n"
	  "\n"
	  "                        ZRLE is faster than Tight in this mode.  When\n"
	  "                        scaling is first detected, the encoding will\n"
	  "                        be automatically switched to ZRLE.  Use the\n"
	  "                        Popup menu if you want to go back to Tight.\n"
	  "                        Set SSVNC_PRESERVE_ENCODING=1 to disable this.\n"
	  "\n"
	  "                        Use a solid background on the remote side.\n"
	  "                        (e.g. manually or via x11vnc -solid ...)\n"
	  "\n"
	  "                        If the remote server is x11vnc, try client\n"
	  "                        side caching: x11vnc -ncache 10 ...\n"
	  "\n"
	  "        -ycrop n    Only show the top n rows of the framebuffer.  For\n"
	  "                    use with x11vnc -ncache client caching option\n"
	  "                    to help \"hide\" the pixel cache region.\n"
	  "                    Use a negative value (e.g. -1) for autodetection.\n"
	  "                    Autodetection will always take place if the remote\n"
	  "                    fb height is more than 2 times the width.\n"
	  "\n"
	  "        -sbwidth n  Scrollbar width for x11vnc -ncache mode (-ycrop),\n"
          "                    default is very narrow: 2 pixels, it is narrow to\n"
          "                    avoid distraction in -ycrop mode.\n"
	  "\n"
	  "        -nobell     Disable bell.\n"
	  "\n"
	  "        -rawlocal   Prefer raw encoding for localhost, default is\n"
	  "                    no, i.e. assumes you have a SSH tunnel instead.\n"
	  "\n"
	  "        -notty      Try to avoid using the terminal for interactive\n"
	  "                    responses: use windows for messages and prompting\n"
	  "                    instead.  Messages will also be printed to terminal.\n"
	  "\n"
	  "        -sendclipboard  Send the X CLIPBOARD selection (i.e. Ctrl+C,\n"
	  "                        Ctrl+V) instead of the X PRIMARY selection (mouse\n"
	  "                        select and middle button paste.)\n"
	  "\n"
	  "        -sendalways     Whenever the mouse enters the VNC viewer main\n"
	  "                        window, send the selection to the VNC server even if\n"
	  "                        it has not changed.  This is like the Xt resource\n"
	  "                        translation SelectionToVNC(always)\n"
	  "\n"
	  "        -recvtext str   When cut text is received from the VNC server,\n"
	  "                        ssvncviewer will set both the X PRIMARY and the\n"
	  "                        X CLIPBOARD local selections.  To control which\n"
	  "                        is set, specify 'str' as 'primary', 'clipboard',\n"
	  "                        or 'both' (the default.)\n"
	  "\n"
	  "        -graball    Grab the entire X server when in fullscreen mode,\n"
	  "                    needed by some old window managers like fvwm2.\n"
	  "\n"
	  "        -popupfix   Warp the popup back to the pointer position,\n"
	  "                    needed by some old window managers like fvwm2.\n"
	  "        -sendclipboard  Send the X CLIPBOARD selection (i.e. Ctrl+C,\n"
	  "                        Ctrl+V) instead of the X PRIMARY selection (mouse\n"
	  "                        select and middle button paste.)\n"
	  "\n"
	  "        -sendalways     Whenever the mouse enters the VNC viewer main\n"
	  "                        window, send the selection to the VNC server even if\n"
	  "                        it has not changed.  This is like the Xt resource\n"
	  "                        translation SelectionToVNC(always)\n"
	  "\n"
	  "        -recvtext str   When cut text is received from the VNC server,\n"
	  "                        ssvncviewer will set both the X PRIMARY and the\n"
	  "                        X CLIPBOARD local selections.  To control which\n"
	  "                        is set, specify 'str' as 'primary', 'clipboard',\n"
	  "                        or 'both' (the default.)\n"
	  "\n"
	  "        -graball    Grab the entire X server when in fullscreen mode,\n"
	  "                    needed by some old window managers like fvwm2.\n"
	  "\n"
	  "        -popupfix   Warp the popup back to the pointer position,\n"
	  "                    needed by some old window managers like fvwm2.\n"
	  "\n"
	  "        -grabkbd    Grab the X keyboard when in fullscreen mode,\n"
	  "                    needed by some window managers. Same as -grabkeyboard.\n"
	  "                    -grabkbd is the default, use -nograbkbd to disable.\n"
	  "\n"
	  "        -bs, -nobs  Whether or not to use X server Backingstore for the\n"
	  "                    main viewer window.  The default is to not, mainly\n"
	  "                    because most Linux, etc, systems X servers disable\n"
	  "                    *all* Backingstore by default.  To re-enable it put\n"
	  "\n"
	  "                        Option \"Backingstore\"\n"
	  "\n"
	  "                    in the Device section of /etc/X11/xorg.conf.\n"
	  "                    In -bs mode with no X server backingstore, whenever an\n"
	  "                    area of the screen is re-exposed it must go out to the\n"
	  "                    VNC server to retrieve the pixels. This is too slow.\n"
	  "\n"
	  "                    In -nobs mode, memory is allocated by the viewer to\n"
	  "                    provide its own backing of the main viewer window. This\n"
	  "                    actually makes some activities faster (changes in large\n"
	  "                    regions) but can appear to \"flash\" too much.\n"
	  "\n"
	  "        -noshm      Disable use of MIT shared memory extension (not recommended)\n"
	  "\n"
	  "        -termchat   Do the UltraVNC chat in the terminal vncviewer is in\n"
	  "                    instead of in an independent window.\n"
	  "\n"
	  "        -unixpw str Useful for logging into x11vnc in -unixpw mode. \"str\" is a\n"
	  "                    string that allows many ways to enter the Unix Username\n"
	  "                    and Unix Password.  These characters: username, newline,\n"
	  "                    password, newline are sent to the VNC server after any VNC\n"
	  "                    authentication has taken place.  Under x11vnc they are\n"
	  "                    used for the -unixpw login.  Other VNC servers could do\n"
	  "                    something similar.\n"
	  "\n"
	  "                    You can also indicate \"str\" via the environment\n"
	  "                    variable SSVNC_UNIXPW.\n"
	  "\n"
	  "                    Note that the Escape key is actually sent first to tell\n"
	  "                    x11vnc to not echo the Unix Username back to the VNC\n"
	  "                    viewer. Set SSVNC_UNIXPW_NOESC=1 to override this.\n"
	  "\n"
	  "                    If str is \".\", then you are prompted at the command line\n"
	  "                    for the username and password in the normal way.  If str is\n"
	  "                    \"-\" the stdin is read via getpass(3) for username@password.\n"
	  "                    Otherwise if str is a file, it is opened and the first line\n"
	  "                    read is taken as the Unix username and the 2nd as the\n"
	  "                    password. If str prefixed by \"rm:\" the file is removed\n"
	  "                    after reading. Otherwise, if str has a \"@\" character,\n"
	  "                    it is taken as username@password. Otherwise, the program\n"
	  "                    exits with an error. Got all that?\n"
	  "\n"
	  "     -repeater str  This is for use with UltraVNC repeater proxy described\n"  
	  "                    here: http://www.uvnc.com/addons/repeater.html.  The \"str\"\n"  
	  "                    is the ID string to be sent to the repeater.  E.g. ID:1234\n"  
	  "                    It can also be the hostname and port or display of the VNC\n"  
	  "                    server, e.g. 12.34.56.78:0 or snoopy.com:1.  Note that when\n"  
	  "                    using -repeater, the host:dpy on the cmdline is the repeater\n"  
	  "                    server, NOT the VNC server.  The repeater will connect you.\n"  
	  "\n"
	  "                    Example: vncviewer ... -repeater ID:3333 repeat.host:5900\n"  
	  "                    Example: vncviewer ... -repeater vhost:0 repeat.host:5900\n"  
	  "\n"
	  "                    Use, e.g., '-repeater SCIII=ID:3210' if the repeater is a\n"
	  "                    Single Click III (SSL) repeater (repeater_SSL.exe) and you\n"
	  "                    are passing the SSL part of the connection through stunnel,\n"
	  "                    socat, etc. This way the magic UltraVNC string 'testB'\n"
          "                    needed to work with the repeater is sent to it.\n"
	  "\n"
	  "     -rfbversion str Set the advertised RFB version.  E.g.: -rfbversion 3.6\n"
	  "                    For some servers, e.g. UltraVNC this needs to be done.\n"
	  "\n"
	  "     -ultradsm      UltraVNC has symmetric private key encryption DSM plugins:\n"  
	  "                    http://www.uvnc.com/features/encryption.html. It is assumed\n"  
	  "                    you are using a unix program (e.g. our ultravnc_dsm_helper)\n"  
	  "                    to encrypt and decrypt the UltraVNC DSM stream. IN ADDITION\n"  
	  "                    TO THAT supply -ultradsm to tell THIS viewer to modify the\n"  
	  "                    RFB data sent so as to work with the UltraVNC Server. For\n"  
	  "                    some reason, each RFB msg type must be sent twice under DSM.\n"  
	  "\n"
	  "     -mslogon user  Use Windows MS Logon to an UltraVNC server.  Supply the\n"  
	  "                    username or \"1\" to be prompted.  The default is to\n"
	  "                    autodetect the UltraVNC MS Logon server and prompt for\n"
	  "                    the username and password.\n"
	  "\n"
	  "                    IMPORTANT NOTE: The UltraVNC MS-Logon Diffie-Hellman\n"
	  "                    exchange is very weak and can be brute forced to recover\n"
	  "                    your username and password in a few seconds of CPU time.\n"
	  "                    To be safe, be sure to use an additional encrypted tunnel\n"
	  "                    (e.g. SSL or SSH) for the entire VNC session.\n"
	  "\n"
	  "     -chatonly      Try to be a client that only does UltraVNC text chat. This\n"  
	  "                    mode is used by x11vnc to present a chat window on the\n"
	  "                    physical X11 console (i.e. chat with the person at the\n"
	  "                    display).\n"
	  "\n"
	  "     -env VAR=VALUE To save writing a shell script to set environment variables,\n"
	  "                    specify as many as you need on the command line.  For\n"
	  "                    example, -env SSVNC_MULTIPLE_LISTEN=MAX:5 -env EDITOR=vi\n"
	  "\n"
	  "     -noipv6        Disable all IPv6 sockets.  Same as VNCVIEWER_NO_IPV6=1.\n"
	  "\n"
	  "     -noipv4        Disable all IPv4 sockets.  Same as VNCVIEWER_NO_IPV4=1.\n"
	  "\n"
	  "     -printres      Print out the Ssvnc X resources (appdefaults) and then exit\n"  
	  "                    You can save them to a file and customize them (e.g. the\n"  
	  "                    keybindings and Popup menu)  Then point to the file via\n"  
	  "                    XENVIRONMENT or XAPPLRESDIR.\n"  
	  "\n"
	  "     -pipeline      Like TurboVNC, request the next framebuffer update as soon\n"
	  "                    as possible instead of waiting until the end of the current\n"
	  "                    framebuffer update coming in.  Helps 'pipeline' the updates.\n"
	  "                    This is currently the default, use -nopipeline to disable.\n"
	  "\n"
	  "     -appshare      Enable features for use with x11vnc's -appshare mode where\n"
	  "                    instead of sharing the full desktop only the application's\n"
	  "                    windows are shared.  Viewer multilisten mode is used to\n"
	  "                    create the multiple windows: -multilisten is implied.\n"
	  "                    See 'x11vnc -appshare -help' more information on the mode.\n"
	  "\n"
	  "                    Features enabled in the viewer under -appshare are:\n"
	  "                    Minimum extra text in the title, auto -ycrop is disabled,\n"
	  "                    x11vnc -remote_prefix X11VNC_APPSHARE_CMD: message channel,\n"
	  "                    x11vnc initial window position hints.  See also Escape Keys\n"
	  "                    below for additional key and mouse bindings.\n"
	  "\n"
	  "     -escape str    This sets the 'Escape Keys' modifier sequence and enables\n"
	  "                    escape keys mode.  When the modifier keys escape sequence\n"
	  "                    is held down, the next keystroke is interpreted locally\n"
	  "                    to perform a special action instead of being sent to the\n"
	  "                    remote VNC server.\n"
	  "\n"
	  "                    Use '-escape default' for the default modifier sequence.\n"
	  "                    (Unix: Alt_L,Super_L and MacOSX: Control_L,Meta_L)\n"
	  "\n"
	  "    Here are the 'Escape Keys: Help+Set' instructions from the Popup Menu:\n"
	  "\n"
          "    Escape Keys:  Enter a comma separated list of modifier keys to be the\n"
          "    'escape sequence'.  When these keys are held down, the next keystroke is\n"
          "    interpreted locally to invoke a special action instead of being sent to\n"
          "    the remote VNC server.  In other words, a set of 'Hot Keys'.\n"
          "    \n"
          "    To enable or disable this, click on 'Escape Keys: Toggle' in the Popup.\n"
          "    \n"
          "    Here is the list of hot-key mappings to special actions:\n"
          "    \n"
          "       r: refresh desktop  b: toggle bell   c: toggle full-color\n"
          "       f: file transfer    x: x11cursor     z: toggle Tight/ZRLE\n"
          "       l: full screen      g: graball       e: escape keys dialog\n"
          "       s: scale dialog     +: scale up (=)  -: scale down (_)\n"
          "       t: text chat                         a: alphablend cursor\n"
          "       V: toggle viewonly  Q: quit viewer   1 2 3 4 5 6: UltraVNC scale 1/n\n"
          "    \n"
          "       Arrow keys:         pan the viewport about 10%% for each keypress.\n"
          "       PageUp / PageDown:  pan the viewport by a screenful vertically.\n"
          "       Home   / End:       pan the viewport by a screenful horizontally.\n"
          "       KeyPad Arrow keys:  pan the viewport by 1 pixel for each keypress.\n"
          "       Dragging the Mouse with Button1 pressed also pans the viewport.\n"
          "       Clicking Mouse Button3 brings up the Popup Menu.\n"
          "    \n"
          "    The above mappings are *always* active in ViewOnly mode, unless you set the\n"
          "    Escape Keys value to 'never'.\n"
          "    \n"
          "    If the Escape Keys value below is set to 'default' then a default list of\n"
          "    of modifier keys is used.  For Unix it is: Alt_L,Super_L and for MacOSX it\n"
          "    is Control_L,Meta_L.  Note: the Super_L key usually has a Windows(TM) Flag\n"
          "    on it.  Also note the _L and _R mean the key is on the LEFT or RIGHT side\n"
          "    of the keyboard.\n"
          "    \n"
          "    On Unix   the default is Alt and Windows keys on Left side of keyboard.\n"
          "    On MacOSX the default is Control and Command keys on Left side of keyboard.\n"
          "    \n"
          "    Example: Press and hold the Alt and Windows keys on the LEFT side of the\n"
          "    keyboard and then press 'c' to toggle the full-color state.  Or press 't'\n"
          "    to toggle the ultravnc Text Chat window, etc.\n"
          "    \n"
          "    To use something besides the default, supply a comma separated list (or a\n"
          "    single one) from: Shift_L Shift_R Control_L Control_R Alt_L Alt_R Meta_L\n"
          "    Meta_R Super_L Super_R Hyper_L Hyper_R or Mode_switch.\n"
	  "\n"
	  "\n"
	  "   New Popup actions:\n"
	  "\n"
	  "        ViewOnly:                ~ -viewonly\n"
	  "        Disable Bell:            ~ -nobell\n"
	  "        Cursor Shape:            ~ -nocursorshape\n"
	  "        X11 Cursor:              ~ -x11cursor\n"
	  "        Cursor Alphablend:       ~ -alpha\n"
	  "        Toggle Tight/Hextile:    ~ -encodings hextile...\n"
	  "        Toggle Tight/ZRLE:       ~ -encodings zrle...\n"
	  "        Toggle ZRLE/ZYWRLE:      ~ -encodings zywrle...\n"
	  "        Quality Level            ~ -quality (both Tight and ZYWRLE)\n"
	  "        Compress Level           ~ -compresslevel\n"
	  "        Disable JPEG:            ~ -nojpeg  (Tight)\n"
	  "        Pipeline Updates         ~ -pipeline\n"
	  "\n"
	  "        Full Color                 as many colors as local screen allows.\n"
	  "        Grey scale (16 & 8-bpp)  ~ -grey, for low colors 16/8bpp modes only.\n"
	  "        16 bit color (BGR565)    ~ -16bpp / -bgr565\n"
	  "        8  bit color (BGR233)    ~ -bgr233\n"
	  "        256 colors               ~ -bgr233 default # of colors.\n"
	  "         64 colors               ~ -bgr222 / -use64\n"
	  "          8 colors               ~ -bgr111 / -use8\n"
	  "        Scale Viewer             ~ -scale\n"
	  "        Escape Keys: Toggle      ~ -escape\n"
	  "        Escape Keys: Help+Set    ~ -escape\n"
	  "        Set Y Crop (y-max)       ~ -ycrop\n"
	  "        Set Scrollbar Width      ~ -sbwidth\n"
	  "        XGrabServer              ~ -graball\n"
	  "\n"
	  "        UltraVNC Extensions:\n"
	  "\n"
	  "          Set 1/n Server Scale     Ultravnc ext. Scale desktop by 1/n.\n"
	  "          Text Chat                Ultravnc ext. Do Text Chat.\n"
	  "          File Transfer            Ultravnc ext. File xfer via Java helper.\n"
	  "          Single Window            Ultravnc ext. Grab and view a single window.\n"
	  "                                   (select then click on the window you want).\n"
	  "          Disable Remote Input     Ultravnc ext. Try to prevent input and\n"
	  "                                   viewing of monitor at physical display.\n"
	  "\n"
	  "        Note: the Ultravnc extensions only apply to servers that support\n"
	  "              them.  x11vnc/libvncserver supports some of them.\n"
	  "\n"
	  "        Send Clipboard not Primary  ~ -sendclipboard\n"
	  "        Send Selection Every time   ~ -sendalways\n"
	  "\n"
	  "\n", programName, programName, programName, programName, programName, programName, programName, programName);
  exit(1);
}
#if 0
	  "        -nooverride Do not apply OverrideRedirect in fullscreen mode.\n"
#endif


/*
 * GetArgsAndResources() deals with resources and any command-line arguments
 * not already processed by XtVaAppInitialize().  It sets vncServerHost and
 * vncServerPort and all the fields in appData.
 */
extern int saw_appshare;

void
GetArgsAndResources(int argc, char **argv)
{
	char *vncServerName = NULL, *colonPos, *bracketPos;
	int len, portOffset;
	int disp;

  /* Turn app resource specs into our appData structure for the rest of the
     program to use */

	XtGetApplicationResources(toplevel, &appData, appDataResourceList,
	    XtNumber(appDataResourceList), 0, 0);

	/*
	 * we allow setting of some by env, to avoid clash with other
	 * viewer's cmdlines (e.g. change viewer in SSVNC).
	 */
	if (getenv("VNCVIEWER_ALPHABLEND")) {
		appData.useCursorAlpha = True;
	}
	if (getenv("VNCVIEWER_POPUP_FIX")) {
		if (getenv("NOPOPUPFIX")) {
			;
		} else if (!strcmp(getenv("VNCVIEWER_POPUP_FIX"), "0")) {
			;
		} else {
			appData.popupFix = True;
		}
	}
	if (getenv("VNCVIEWER_GRAB_SERVER")) {
		appData.grabAll = True;
	}
	if (getenv("VNCVIEWER_YCROP")) {
		int n = atoi(getenv("VNCVIEWER_YCROP"));
		if (n != 0) {
			appData.yCrop = n;
		}
	}
	if (getenv("VNCVIEWER_RFBVERSION") && strcmp(getenv("VNCVIEWER_RFBVERSION"), "")) {
		appData.rfbVersion = strdup(getenv("VNCVIEWER_RFBVERSION"));
	}
	if (getenv("VNCVIEWER_ENCODINGS") && strcmp(getenv("VNCVIEWER_ENCODINGS"), "")) {
		appData.encodingsString = strdup(getenv("VNCVIEWER_ENCODINGS"));
	}
	if (getenv("VNCVIEWER_NOBELL")) {
		appData.useBell = False;
	}
	if (getenv("VNCVIEWER_X11CURSOR")) {
		appData.useX11Cursor = True;
	}
	if (getenv("VNCVIEWER_RAWLOCAL")) {
		appData.useRawLocal = True;
	}
	if (getenv("VNCVIEWER_NOTTY") || getenv("SSVNC_VNCVIEWER_NOTTY")) {
		appData.notty = True;
	}
	if (getenv("VNCVIEWER_SBWIDTH")) {
		int n = atoi(getenv("VNCVIEWER_SBWIDTH"));
		if (n != 0) {
			appData.sbWidth = n;
		}
	}
	if (getenv("VNCVIEWER_ULTRADSM")) {
		appData.ultraDSM = True;
	}
	if (getenv("SSVNC_ULTRA_DSM") && strcmp(getenv("SSVNC_ULTRA_DSM"), "")) {
		appData.ultraDSM = True;
	}
	if (getenv("SSVNC_NO_ULTRA_DSM")) {
		appData.ultraDSM = False;
	}
	if (getenv("SSVNC_SCALE") && strcmp(getenv("SSVNC_SCALE"), "")) {
		if (appData.scale == NULL) {
			appData.scale = strdup(getenv("SSVNC_SCALE"));
		}
	}
	if (getenv("VNCVIEWER_ESCAPE") && strcmp(getenv("VNCVIEWER_ESCAPE"), "")) {
		if (appData.escapeKeys == NULL) {
			appData.escapeKeys = strdup(getenv("VNCVIEWER_ESCAPE"));
		}
	}
	if (saw_appshare) {
		appData.appShare = True;
	}
	if (appData.appShare && appData.escapeKeys == NULL) {
		appData.escapeKeys = strdup("default");
	}
	if (appData.escapeKeys != NULL) {
		appData.escapeActive = True;
	}
	if (getenv("VNCVIEWER_SEND_CLIPBOARD")) {
		appData.sendClipboard = True;
	}
	if (getenv("VNCVIEWER_SEND_ALWAYS")) {
		appData.sendAlways = True;
	}
	if (getenv("VNCVIEWER_RECV_TEXT")) {
		char *s = getenv("VNCVIEWER_RECV_TEXT");
		if (!strcasecmp(s, "clipboard")) {
			appData.recvText = strdup("clipboard");
		} else if (!strcasecmp(s, "primary")) {
			appData.recvText = strdup("primary");
		} else if (!strcasecmp(s, "both")) {
			appData.recvText = strdup("both");
		}
	}
	if (getenv("VNCVIEWER_PIPELINE_UPDATES")) {
		appData.pipelineUpdates = True;
	} else if (getenv("VNCVIEWER_NO_PIPELINE_UPDATES")) {
		appData.pipelineUpdates = False;
	}

	if (getenv("VNCVIEWER_NO_IPV4")) {
		appData.noipv4 = True;
	}
	if (getenv("VNCVIEWER_NO_IPV6")) {
		appData.noipv6 = True;
	}

	if (appData.useBGR233 && appData.useBGR565) {
		appData.useBGR233 = 0;
	}

	if (getenv("SSVNC_ULTRA_FTP_JAR") == NULL) {
	    putenv("SSVNC_ULTRA_FTP_JAR=/usr/lib/ssvnc/util/ultraftp.jar");
	}


  /* Add our actions to the actions table so they can be used in widget
     resource specs */

	XtAppAddActions(appContext, actions, XtNumber(actions));

  /* Check any remaining command-line arguments.  If -listen was specified
     there should be none.  Otherwise the only argument should be the VNC
     server name.  If not given then pop up a dialog box and wait for the
     server name to be entered. */

	if (listenSpecified) {
		if (argc != 1) {
			fprintf(stderr,"\n%s -listen: invalid command line argument: %s\n",
			programName, argv[1]);
			usage();
		}
		return;
	}

	if (argc == 1) {
		vncServerName = DoServerDialog();
		if (!use_tty()) {
			appData.passwordDialog = True;
		}
	} else if (argc != 2) {
		usage();
	} else {
		vncServerName = argv[1];

		if (!use_tty()) {
			appData.passwordDialog = True;
		}
		if (vncServerName[0] == '-') {
			usage();
		}
	}

	if (strlen(vncServerName) > 255) {
		fprintf(stderr,"VNC server name too long\n");
		exit(1);
	}

	colonPos = strrchr(vncServerName, ':');
	bracketPos = strrchr(vncServerName, ']');
	if (strstr(vncServerName, "exec=") == vncServerName) {
		/* special exec-external-command case */
		strcpy(vncServerHost, vncServerName);
		vncServerPort = SERVER_PORT_OFFSET;
	} else if (strstr(vncServerName, "fd=") == vncServerName) {
		/* special exec-external-command case */
		strcpy(vncServerHost, vncServerName);
		vncServerPort = SERVER_PORT_OFFSET;
	} else if (colonPos == NULL) {
		/* No colon -- use default port number */
		strcpy(vncServerHost, vncServerName);
		vncServerPort = SERVER_PORT_OFFSET;
	} else if (bracketPos != NULL && colonPos < bracketPos) {
		strcpy(vncServerHost, vncServerName);
		vncServerPort = SERVER_PORT_OFFSET;
	} else {
		if (colonPos > vncServerName && *(colonPos - 1) == ':') {
			colonPos--;
		}
		memcpy(vncServerHost, vncServerName, colonPos - vncServerName);
		vncServerHost[colonPos - vncServerName] = '\0';
		len = strlen(colonPos + 1);
		portOffset = SERVER_PORT_OFFSET;
		if (colonPos[1] == ':') {
			/* Two colons -- interpret as a port number */
			colonPos++;
			len--;
			portOffset = 0;
		}
		if (!len || strspn(colonPos + 1, "0123456789") != (size_t) len) {
			usage();
		}
#if 0
		vncServerPort = atoi(colonPos + 1) + portOffset;
#else
		disp = atoi(colonPos + 1);
		if (portOffset != 0 && disp >= 100) {
			portOffset = 0;
		}
		vncServerPort = disp + portOffset;
#endif
	}
}