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
|
#if !defined( lint ) && !defined( SABER )
static const char sccsid[] = "@(#)resource.c 4.07 97/11/24 xlockmore";
#endif
/*-
* resource.c - resource management for xlock, the X Window System lockscreen.
*
* Copyright (c) 1991 by Patrick J. Naughton.
*
* See xlock.c for copying information.
*
* Revision History:
*
* Changes maintained by David Bagley <bagleyd@bigfoot.com>
* 01-Apr-97: Tom Schmidt <tschmidt@micron.com>
* Fixed memory leak. Made -visual option a hacker mode for now.
* 20-Mar-97: Tom Schmidt <tschmidt@micron.com>
* Added -visual option.
* 3-Apr-96: Jouk Jansen <joukj@crys.chem.uva.nl>
* Supply for wildcards for filenames for random selection
* 18-Mar-96: Ron Hitchens <ron@idiom.com>
* Setup chosen mode with set_default_mode() for new hook scheme.
* 6-Mar-96: Jouk Jansen <joukj@crys.chem.uva.nl>
* Remote node checking for VMS fixed
* 20-Dec-95: Ron Hitchens <ron@idiom.com>
* Resource parsing fixed for "nolock".
* 02-Aug-95: Patch to use default delay, etc., from mode.h thanks to
* Roland Bock <exp120@physik.uni-kiel.d400.de>
* 17-Jun-95: Split out mode.h from resource.c .
* 29-Mar-95: Added -cycles for more control over a lockscreen similar to
* -delay, -batchcount, and -saturation.
* 21-Feb-95: MANY patches from Heath A. Kehoe <hakehoe@icaen.uiowa.edu>.
* 21-Dec-94: patch for -delay, -batchcount and -saturation for X11R5+
* from Patrick D Sullivan <pds@bss.com>.
* 18-Dec-94: -inroot option added from Bill Woodward <wpwood@pencom.com>.
* 20-Sep-94: added bat mode from Lorenzo Patocchi <patol@info.isbiel.ch>.
* 11-Jul-94: added grav mode, and inwindow option from Greg Bowering
* <greg@cs.adelaide.edu.au>
* 22-Jun-94: Modified for VMS
* <Anthony.D.Clarke@Support.Hatfield.Raytheon.bae.eurokom.ie>
* 17-Jun-94: default changed from life to blank
* 21-Mar-94: patch fix for AIXV3 from <R.K.Lloyd@csc.liv.ac.uk>
* 01-Dec-93: added patch for AIXV3 from Tom McConnell
* <tmcconne@sedona.intel.com>
* 29-Jun-93: added spline, maze, sphere, hyper, helix, rock, and blot mode.
*
* Changes of Patrick J. Naughton
* 25-Sep-91: added worm mode.
* 24-Jun-91: changed name to username.
* 06-Jun-91: Added flame mode.
* 24-May-91: Added -name and -usefirst and -resources.
* 16-May-91: Added random mode and pyro mode.
* 26-Mar-91: checkResources: delay must be >= 0.
* 29-Oct-90: Added #include <ctype.h> for missing isupper() on some OS revs.
* moved -mode option, reordered Xrm database evaluation.
* 28-Oct-90: Added text strings.
* 26-Oct-90: Fix bug in mode specific options.
* 31-Jul-90: Fix ':' handling in parsefilepath
* 07-Jul-90: Created from resource work in xlock.c
*
*/
#include "xlock.h"
#include "mode.h"
#include "version.h"
#if VMS
#if ( __VMS_VER < 70000000 )
#ifdef __DECC
#define gethostname decc$gethostname
#define gethostbyname decc$gethostbyname
#endif
#else
#include <socket.h>
#endif
#endif
#ifndef offsetof
#define offsetof(s,m) ((char*)(&((s *)0)->m)-(char*)0)
#endif
#if defined( USE_AUTO_LOGOUT ) || defined( USE_BUTTON_LOGOUT )
extern int fullLock();
#endif
extern char *getenv(const char *);
#ifdef USE_MODULES
#ifndef DEF_MODULEPATH
#define DEF_MODULEPATH "/usr/lib/X11/xlock_modules"
#endif
#endif
#ifndef DEF_FILESEARCHPATH
#ifdef VMS
#include <descrip>
#include <iodef>
#include <ssdef>
#include <stsdef>
#include <types.h>
#include <starlet.h>
#define DEF_FILESEARCHPATH "DECW$SYSTEM_DEFAULTS:DECW$%N.DAT%S"
#define BUFSIZE 132
#define DECW$C_WS_DSP_TRANSPORT 2 /* taken from wsdriver.lis */
#define IO$M_WS_DISPLAY 0x00000040 /* taken from wsdriver */
struct descriptor_t { /* descriptor structure */
unsigned short len;
unsigned char type;
unsigned char c_class;
char *ptr;
};
typedef struct descriptor_t dsc;
/* $dsc creates a descriptor for a predefined string */
#define $dsc(name,string) dsc name = { sizeof(string)-1,14,1,string}
/* $dscp creates a descriptor pointing to a buffer allocated elsewhere */
#define $dscp(name,size,addr) dsc name = { size,14,1,addr }
static int descr();
#else
#define DEF_FILESEARCHPATH "/usr/lib/X11/%T/%N%S"
#endif
#endif
#ifndef DEF_MODE
#if 0
#define DEF_MODE "blank" /* May be safer */
#else
#define DEF_MODE "random" /* May be more interesting */
#endif
#endif
#define DEF_DELAY "200000" /* microseconds between batches */
#define DEF_BATCHCOUNT "100" /* vectors (or whatever) per batch */
#define DEF_CYCLES "1000" /* timeout in cycles for a batch */
#define DEF_SIZE "0" /* size, default if 0 */
#define DEF_NCOLORS "64" /* maximum number of colors */
#define DEF_SATURATION "1.0" /* color ramp saturation 0->1 */
#define DEF_NICE "10" /* xlock process nicelevel */
#define DEF_LOCKDELAY "0" /* secs until lock */
#define DEF_TIMEOUT "30" /* secs until password entry times out */
#ifndef DEF_FONT
#ifdef AIXV3
#define DEF_FONT "fixed"
#else /* !AIXV3 */
#define DEF_FONT "-b&h-lucida-medium-r-normal-sans-24-*-*-*-*-*-iso8859-1"
#endif /* !AIXV3 */
#endif
#define DEF_MSGFONT "-adobe-courier-medium-r-*-*-14-*-*-*-m-*-iso8859-1"
#ifdef USE_MB
#define DEF_FONTSET DEF_FONT ## ",-*-24-*"
#endif
#define DEF_BG "White"
#define DEF_FG "Black"
#define DEF_NAME "Name: "
#define DEF_PASS "Password: "
#ifdef SAFEWORD
#define DEF_DPASS "Dynamic password: "
#define DEF_FPASS "Fixed Password: "
#define DEF_CHALL "Challenge: "
#endif
#define DEF_INFO "Enter password to unlock; select icon to lock."
#define DEF_VALID "Validating login..."
#define DEF_INVALID "Invalid login."
#define DEF_GEOMETRY ""
#define DEF_ICONGEOMETRY ""
#ifdef FX
#define DEF_GLGEOMETRY ""
#endif
#define DEF_DELTA3D "1.5" /* space between things in 3d mode relative to their size */
#ifndef DEF_MESSAGESFILE
#define DEF_MESSAGESFILE ""
#endif
#ifndef DEF_MESSAGEFILE
#define DEF_MESSAGEFILE ""
#endif
#ifndef DEF_MESSAGE
/* #define DEF_MESSAGE "I am out running around." */
#define DEF_MESSAGE ""
#endif
#ifndef DEF_IMAGEFILE
#define DEF_IMAGEFILE ""
#endif
#define DEF_CLASSNAME "XLock"
/*-
Grid Number of Neigbors
---- ------------------
Square 4 or 8
Hexagon 6
Triangle 3, 9 or 12 <- 9 is not too mathematically sound...
*/
#define DEF_NEIGHBORS "0" /* automata mode will choose best or random value */
#define DEF_MOUSE "False"
#ifdef USE_RPLAY
#define DEF_LOCKSOUND "thank-you"
#define DEF_INFOSOUND "identify-please"
#define DEF_VALIDSOUND "complete"
#define DEF_INVALIDSOUND "not-programmed"
#else /* !USE_RPLAY */
#if defined ( DEF_PLAY ) || defined ( USE_NAS )
#define DEF_LOCKSOUND "thank-you.au"
#define DEF_INFOSOUND "identify-please.au"
#define DEF_VALIDSOUND "complete.au"
#define DEF_INVALIDSOUND "not-programmed.au"
#else /* !DEF_PLAY && !USE_NAS */
#ifdef USE_VMSPLAY
#define DEF_LOCKSOUND "[]thank-you.au"
#define DEF_INFOSOUND "[]identify-please.au"
#define DEF_VALIDSOUND "[]complete.au"
#define DEF_INVALIDSOUND "[]not-programmed.au"
#endif /* !USE_VMSPLAY */
#endif /* !DEF_PLAY && !USE_NAS */
#endif /* !USE_RPLAY */
#if defined( USE_AUTO_LOGOUT ) && !defined( DEF_AUTO_LOGOUT )
#if ( USE_AUTO_LOGOUT <= 0 )
#define DEF_AUTO_LOGOUT "120" /* User Default, can be overridden */
#else
#define DEF_AUTO_LOGOUT "0" /* User Default, can be overridden */
#endif
#endif
#if defined( USE_BUTTON_LOGOUT )
#if !defined( DEF_BUTTON_LOGOUT )
#if ( USE_BUTTON_LOGOUT <= 0 )
#define DEF_BUTTON_LOGOUT "5" /* User Default, can be overridden */
#else
#define DEF_BUTTON_LOGOUT "0" /* User Default, can be overridden */
#endif
#endif
#define DEF_BTN_LABEL "Logout" /* string that appears in logout button */
/* this string appears immediately below logout button */
#define DEF_BTN_HELP "Click here to logout"
/* this string appears in place of the logout button if user could not be
logged out */
#define DEF_FAIL "Auto-logout failed"
#endif
extern char *ProgramName;
extern Display *dsp;
/* For modes with text, marquee & nose */
extern char *program;
extern char *messagesfile;
extern char *messagefile;
extern char *message;
extern char *mfont;
/* For modes with images: xbm, xpm, and ras */
char *imagefile;
/* For automata modes */
int neighbors;
/* For eyes, julia, & swarm modes */
Bool mouse;
char hostname[MAXHOSTNAMELEN];
static char *mode;
char *displayname = NULL;
static char *classname;
static char *modename;
static char *modeclassname;
extern Window parent;
static char *parentname;
extern Bool parentSet;
#if HAVE_DIRENT_H
static struct dirent ***images_list;
int num_list;
struct dirent **image_list;
char filename_r[MAXNAMLEN];
char directory_r[DIRBUF];
#endif
static XrmOptionDescRec genTable[] =
{
{"-mode", ".mode", XrmoptionSepArg, (caddr_t) NULL},
{"-nolock", ".nolock", XrmoptionNoArg, (caddr_t) "on"},
{"+nolock", ".nolock", XrmoptionNoArg, (caddr_t) "off"},
{"-inwindow", ".inwindow", XrmoptionNoArg, (caddr_t) "on"},
{"+inwindow", ".inwindow", XrmoptionNoArg, (caddr_t) "off"},
{"-inroot", ".inroot", XrmoptionNoArg, (caddr_t) "on"},
{"+inroot", ".inroot", XrmoptionNoArg, (caddr_t) "off"},
{"-remote", ".remote", XrmoptionNoArg, (caddr_t) "on"},
{"+remote", ".remote", XrmoptionNoArg, (caddr_t) "off"},
{"-mono", ".mono", XrmoptionNoArg, (caddr_t) "on"},
{"+mono", ".mono", XrmoptionNoArg, (caddr_t) "off"},
{"-allowaccess", ".allowaccess", XrmoptionNoArg, (caddr_t) "on"},
{"+allowaccess", ".allowaccess", XrmoptionNoArg, (caddr_t) "off"},
{"-allowroot", ".allowroot", XrmoptionNoArg, (caddr_t) "on"},
{"+allowroot", ".allowroot", XrmoptionNoArg, (caddr_t) "off"},
{"-debug", ".debug", XrmoptionNoArg, (caddr_t) "on"},
{"+debug", ".debug", XrmoptionNoArg, (caddr_t) "off"},
{"-echokeys", ".echokeys", XrmoptionNoArg, (caddr_t) "on"},
{"+echokeys", ".echokeys", XrmoptionNoArg, (caddr_t) "off"},
{"-enablesaver", ".enablesaver", XrmoptionNoArg, (caddr_t) "on"},
{"+enablesaver", ".enablesaver", XrmoptionNoArg, (caddr_t) "off"},
{"-resetsaver", ".resetsaver", XrmoptionNoArg, (caddr_t) "on"},
{"+resetsaver", ".resetsaver", XrmoptionNoArg, (caddr_t) "off"},
{"-fullrandom", ".fullrandom", XrmoptionNoArg, (caddr_t) "on"},
{"+fullrandom", ".fullrandom", XrmoptionNoArg, (caddr_t) "off"},
{"-grabmouse", ".grabmouse", XrmoptionNoArg, (caddr_t) "on"},
{"+grabmouse", ".grabmouse", XrmoptionNoArg, (caddr_t) "off"},
{"-grabserver", ".grabserver", XrmoptionNoArg, (caddr_t) "on"},
{"+grabserver", ".grabserver", XrmoptionNoArg, (caddr_t) "off"},
{"-install", ".install", XrmoptionNoArg, (caddr_t) "on"},
{"+install", ".install", XrmoptionNoArg, (caddr_t) "off"},
{"-mousemotion", ".mousemotion", XrmoptionNoArg, (caddr_t) "on"},
{"+mousemotion", ".mousemotion", XrmoptionNoArg, (caddr_t) "off"},
{"-sound", ".sound", XrmoptionNoArg, (caddr_t) "on"},
{"+sound", ".sound", XrmoptionNoArg, (caddr_t) "off"},
{"-timeelapsed", ".timeelapsed", XrmoptionNoArg, (caddr_t) "on"},
{"+timeelapsed", ".timeelapsed", XrmoptionNoArg, (caddr_t) "off"},
{"-usefirst", ".usefirst", XrmoptionNoArg, (caddr_t) "on"},
{"+usefirst", ".usefirst", XrmoptionNoArg, (caddr_t) "off"},
{"-verbose", ".verbose", XrmoptionNoArg, (caddr_t) "on"},
{"+verbose", ".verbose", XrmoptionNoArg, (caddr_t) "off"},
{"-nice", ".nice", XrmoptionSepArg, (caddr_t) NULL},
{"-lockdelay", ".lockdelay", XrmoptionSepArg, (caddr_t) NULL},
{"-timeout", ".timeout", XrmoptionSepArg, (caddr_t) NULL},
{"-font", ".font", XrmoptionSepArg, (caddr_t) NULL},
{"-msgfont", ".msgfont", XrmoptionSepArg, (caddr_t) NULL},
#ifdef USE_MB
{"-fontset", ".fontset", XrmoptionSepArg, (caddr_t) NULL},
#endif
{"-bg", ".background", XrmoptionSepArg, (caddr_t) NULL},
{"-fg", ".foreground", XrmoptionSepArg, (caddr_t) NULL},
{"-background", ".background", XrmoptionSepArg, (caddr_t) NULL},
{"-foreground", ".foreground", XrmoptionSepArg, (caddr_t) NULL},
{"-username", ".username", XrmoptionSepArg, (caddr_t) NULL},
{"-password", ".password", XrmoptionSepArg, (caddr_t) NULL},
{"-info", ".info", XrmoptionSepArg, (caddr_t) NULL},
{"-validate", ".validate", XrmoptionSepArg, (caddr_t) NULL},
{"-invalid", ".invalid", XrmoptionSepArg, (caddr_t) NULL},
{"-geometry", ".geometry", XrmoptionSepArg, (caddr_t) NULL},
{"-icongeometry", ".icongeometry", XrmoptionSepArg, (caddr_t) NULL},
#ifdef FX
{"-glgeometry", ".glgeometry", XrmoptionSepArg, (caddr_t) NULL},
#endif
{"-wireframe", ".wireframe", XrmoptionNoArg, (caddr_t) "on"},
{"+wireframe", ".wireframe", XrmoptionNoArg, (caddr_t) "off"},
{"-use3d", ".use3d", XrmoptionNoArg, (caddr_t) "on"},
{"+use3d", ".use3d", XrmoptionNoArg, (caddr_t) "off"},
{"-delta3d", ".delta3d", XrmoptionSepArg, (caddr_t) NULL},
{"-none3d", ".none3d", XrmoptionSepArg, (caddr_t) NULL},
{"-right3d", ".right3d", XrmoptionSepArg, (caddr_t) NULL},
{"-left3d", ".left3d", XrmoptionSepArg, (caddr_t) NULL},
{"-both3d", ".both3d", XrmoptionSepArg, (caddr_t) NULL},
/* For modes with text, marquee & nose */
{"-program", ".program", XrmoptionSepArg, (caddr_t) NULL},
{"-messagesfile", ".messagesfile", XrmoptionSepArg, (caddr_t) NULL},
{"-messagefile", ".messagefile", XrmoptionSepArg, (caddr_t) NULL},
{"-message", ".message", XrmoptionSepArg, (caddr_t) NULL},
{"-mfont", ".mfont", XrmoptionSepArg, (caddr_t) NULL},
/* For automata modes */
{"-neighbors", ".neighbors", XrmoptionSepArg, (caddr_t) NULL},
/* For eyes and julia modes */
{"-mouse", ".mouse", XrmoptionNoArg, (caddr_t) "on"},
{"+mouse", ".mouse", XrmoptionNoArg, (caddr_t) "off"},
#if defined( USE_XLOCKRC ) || defined( FALLBACK_XLOCKRC )
{"-cpasswd", ".cpasswd", XrmoptionSepArg, (caddr_t) NULL},
#endif
#ifdef USE_AUTO_LOGOUT
{"-logoutAuto", ".logoutAuto", XrmoptionSepArg, (caddr_t) NULL},
#endif
#ifdef USE_BUTTON_LOGOUT
{"-logoutButton", ".logoutButton", XrmoptionSepArg, (caddr_t) NULL},
{"-logoutButtonLabel", ".logoutButtonLabel", XrmoptionSepArg, (caddr_t) NULL},
{"-logoutButtonHelp", ".logoutButtonHelp", XrmoptionSepArg, (caddr_t) NULL},
{"-logoutFailedString", ".logoutFailedString", XrmoptionSepArg, (caddr_t) NULL},
#endif
#ifdef USE_DTSAVER
{"-dtsaver", ".dtsaver", XrmoptionNoArg, (caddr_t) "on"},
{"+dtsaver", ".dtsaver", XrmoptionNoArg, (caddr_t) "off"},
#endif
#ifdef USE_SOUND
{"-locksound", ".locksound", XrmoptionSepArg, (caddr_t) NULL},
{"-infosound", ".infosound", XrmoptionSepArg, (caddr_t) NULL},
{"-validsound", ".validsound", XrmoptionSepArg, (caddr_t) NULL},
{"-invalidsound", ".invalidsound", XrmoptionSepArg, (caddr_t) NULL},
#endif
{"-startCmd", ".startCmd", XrmoptionSepArg, (caddr_t) NULL},
{"-endCmd", ".endCmd", XrmoptionSepArg, (caddr_t) NULL},
{"-logoutCmd", ".logoutCmd", XrmoptionSepArg, (caddr_t) NULL},
};
#define genEntries (sizeof genTable / sizeof genTable[0])
static XrmOptionDescRec modeTable[] =
{
{"-delay", "*delay", XrmoptionSepArg, (caddr_t) NULL},
{"-batchcount", "*batchcount", XrmoptionSepArg, (caddr_t) NULL},
{"-cycles", "*cycles", XrmoptionSepArg, (caddr_t) NULL},
{"-size", "*size", XrmoptionSepArg, (caddr_t) NULL},
{"-ncolors", "*ncolors", XrmoptionSepArg, (caddr_t) NULL},
{"-saturation", "*saturation", XrmoptionSepArg, (caddr_t) NULL},
/* For modes with images, xbm, xpm, & ras */
{"-imagefile", "*imagefile", XrmoptionSepArg, (caddr_t) NULL},
};
#define modeEntries (sizeof modeTable / sizeof modeTable[0])
static XrmOptionDescRec cmdlineTable[] =
{
{"-display", ".display", XrmoptionSepArg, (caddr_t) NULL},
{"-visual", ".visual", XrmoptionSepArg, (caddr_t) NULL},
{"-parent", ".parent", XrmoptionSepArg, (caddr_t) NULL},
{"-nolock", ".nolock", XrmoptionNoArg, (caddr_t) "on"},
{"+nolock", ".nolock", XrmoptionNoArg, (caddr_t) "off"},
{"-remote", ".remote", XrmoptionNoArg, (caddr_t) "on"},
{"+remote", ".remote", XrmoptionNoArg, (caddr_t) "off"},
{"-inwindow", ".inwindow", XrmoptionNoArg, (caddr_t) "on"},
{"+inwindow", ".inwindow", XrmoptionNoArg, (caddr_t) "off"},
{"-inroot", ".inroot", XrmoptionNoArg, (caddr_t) "on"},
{"+inroot", ".inroot", XrmoptionNoArg, (caddr_t) "off"},
#ifdef USE_DTSAVER
{"-dtsaver", ".dtsaver", XrmoptionNoArg, (caddr_t) "on"},
{"+dtsaver", ".dtsaver", XrmoptionNoArg, (caddr_t) "off"},
#endif
{"-xrm", NULL, XrmoptionResArg, (caddr_t) NULL}
};
#define cmdlineEntries (sizeof cmdlineTable / sizeof cmdlineTable[0])
static XrmOptionDescRec nameTable[] =
{
{"-name", ".name", XrmoptionSepArg, (caddr_t) NULL},
};
#ifdef USE_MODULES
static XrmOptionDescRec modulepathTable[] =
{
{"-modulepath", ".modulepath", XrmoptionSepArg, (caddr_t) NULL},
};
#endif
static OptionStruct opDesc[] =
{
{"-help", "print out this message to standard output"},
{"-version", "print version number (if >= 4.00) to standard output"},
{"-resources", "print default resource file to standard output"},
{"-display displayname", "X server to contact"},
#ifdef USE_MODULES
{"-modulepath", "directory where screensaver modules are stored"},
#endif
{"-visual visualname", "X visual to use"},
{"-parent", "parent window id (for inwindow)"},
{"-name resourcename", "class name to use for resources (default is XLock)"},
{"-delay usecs", "microsecond delay between screen updates"},
{"-batchcount num", "number of things per batch"},
{"-cycles num", "number of cycles per batch"},
{"-size num", "size of a unit in a mode, default is 0"},
{"-ncolors num", "maximum number of colors, default is 64"},
{"-saturation value", "saturation of color ramp"},
/* For modes with images, xbm, xpm, & ras */
{"-imagefile filename", "image file"},
{"-/+nolock", "turn on/off no password required"},
{"-/+inwindow", "turn on/off making xlock run in a window"},
{"-/+inroot", "turn on/off making xlock run in the root window"},
{"-/+remote", "turn on/off remote host access"},
{"-/+mono", "turn on/off monochrome override"},
{"-/+allowaccess", "turn on/off allow new clients to connect"},
#ifndef ALWAYS_ALLOW_ROOT
{"-/+allowroot", "turn on/off allow root password to unlock"},
#else
{"-/+allowroot", "turn on/off allow root password to unlock (off ignored)"},
#endif
{"-/+debug", "whether to use debug xlock (yes/no)"},
{"-/+echokeys", "turn on/off echo '?' for each password key"},
{"-/+enablesaver", "turn on/off enable X server screen saver"},
{"-/+resetsaver", "turn on/off enable X server screen saver"},
{"-/+grabmouse", "turn on/off grabbing of mouse and keyboard"},
{"-/+grabserver", "turn on/off grabbing of server"},
{"-/+install", "whether to use private colormap if needed (yes/no)"},
{"-/+fullrandom", "turn on/off full random choice of mode-options"},
{"-/+mousemotion", "turn on/off sensitivity to mouse"},
{"-/+sound", "whether to use sound if configured for it (yes/no)"},
{"-/+timeelapsed", "turn on/off clock"},
{"-/+usefirst", "turn on/off using the first char typed in password"},
{"-/+verbose", "turn on/off verbosity"},
{"-nice level", "nice level for xlock process"},
{"-lockdelay seconds", "number of seconds until lock"},
{"-timeout seconds", "number of seconds before password times out"},
{"-font fontname", "font to use for password prompt"},
{"-msgfont fontname", "font to use for message"},
#ifdef USE_MB
{"-fontset fontsetname", "fontset to use for Xmb..."},
#endif
{"-bg color", "background color to use for password prompt"},
{"-fg color", "foreground color to use for password prompt"},
{"-background color", "background color to use for password prompt"},
{"-foreground color", "foreground color to use for password prompt"},
{"-username string", "text string to use for Name prompt"},
{"-password string", "text string to use for Password prompt"},
{"-info string", "text string to use for instructions"},
{"-validate string", "text string to use for validating password message"},
{"-invalid string", "text string to use for invalid password message"},
{"-geometry geom", "geometry for non-full screen lock"},
{"-icongeometry geom", "geometry for password window (location ignored)"},
#ifdef FX
{"-glgeometry geom", "geometry for gl modes (location ignored)"},
#endif
{"-/+wireframe", "turn on/off wireframe"},
{"-/+use3d", "turn on/off 3d view"},
{"-delta3d value", "space between the center of your 2 eyes for 3d mode"},
{"-none3d color", "color to be used for null in 3d mode"},
{"-right3d color", "color to be used for the right eye in 3d mode"},
{"-left3d color", "color to be used for the left eye in 3d mode"},
{"-both3d color", "color to be used overlap in 3d mode"},
/* For modes with text, marquee & nose */
{"-program programname", "program to get messages from, usually fortune"},
{"-messagesfile formatted-filename", "formatted file message to say"},
{"-messagefile filename", "file message to say"},
{"-message string", "message to say"},
{"-mfont mode-fontname", "font for a specific mode"},
/* For automata modes */
{"-neighbors num", "squares 4 or 8, hexagons 6, triangles 3, 9 or 12"},
/* For eyes and julia modes */
{"-/+mouse", "turn on/off the grabbing the mouse"},
#if defined( USE_XLOCKRC ) || defined( FALLBACK_XLOCKRC )
{"-cpasswd crypted-password", "text string of encrypted password"},
#endif
#ifdef USE_AUTO_LOGOUT
{"-logoutAuto minutes", "number of minutes until auto logout (not more than forced auto logout time)"},
#endif
#ifdef USE_BUTTON_LOGOUT
{"-logoutButton minutes", "number of minutes until logout button appears (not more than forced button time)"},
{"-logoutButtonLabel string", "text string to use inside logout button"},
{"-logoutButtonHelp string", "text string to use for logout button help"},
{"-logoutFailedString string", "text string to use for failed logout attempts"},
#endif
#ifdef USE_DTSAVER
{"-/+dtsaver", "turn on/off CDE Saver Mode"},
#endif
#ifdef USE_SOUND
{"-locksound string", "sound to use at locktime"},
{"-infosound string", "sound to use for information"},
{"-validsound string", "sound to use when password is valid"},
{"-invalidsound string", "sound to use when password is invalid"},
#endif
{"-startCmd string", "command to run at locktime"},
{"-endCmd string", "command to run when unlocking"},
{"-logoutCmd string", "command to run when automatically logging out"},
};
#define opDescEntries (sizeof opDesc / sizeof opDesc[0])
int delay;
int batchcount;
int cycles;
int size;
int ncolors;
float saturation;
#ifdef USE_MODULES
char *modulepath;
#endif
Bool nolock;
Bool inwindow;
Bool inroot;
Bool mono;
Bool allowaccess;
#ifdef ALWAYS_ALLOW_ROOT
Bool allowroot = 1;
#else
Bool allowroot;
#endif
Bool debug;
Bool echokeys;
Bool enablesaver;
Bool resetsaver;
Bool fullrandom;
Bool grabmouse;
Bool grabserver;
Bool install;
Bool mousemotion;
Bool sound;
Bool timeelapsed;
Bool usefirst;
Bool verbose;
Bool remote;
static char *visualname;
int VisualClassWanted;
int nicelevel;
int lockdelay;
int timeout;
char *fontname;
char *messagefont;
#ifdef USE_MB
char *fontsetname;
#endif
char *background;
char *foreground;
char *text_user;
char *text_pass;
#ifdef SAFEWORD
char *text_dpass;
char *text_fpass;
char *text_chall;
#endif
char *text_info;
char *text_valid;
char *text_invalid;
char *geometry;
char *icongeometry;
#ifdef FX
char *glgeometry;
#endif
Bool wireframe;
Bool use3d;
float delta3d;
char *none3d;
char *right3d;
char *left3d;
char *both3d;
#if defined( USE_XLOCKRC ) || defined( FALLBACK_XLOCKRC)
char *cpasswd;
#endif
#ifdef USE_AUTO_LOGOUT
int logoutAuto;
#endif
#ifdef USE_BUTTON_LOGOUT
int enable_button = 1;
int logoutButton;
char *logoutButtonLabel;
char *logoutButtonHelp;
char *logoutFailedString;
#endif
#ifdef USE_DTSAVER
Bool dtsaver;
#endif
#ifdef USE_SOUND
char *locksound;
char *infosound;
char *validsound;
char *invalidsound;
#endif
char *startCmd;
char *endCmd;
char *logoutCmd;
static argtype genvars[] =
{
{(caddr_t *) & allowaccess, "allowaccess", "AllowAccess", "off", t_Bool},
#ifndef ALWAYS_ALLOW_ROOT
{(caddr_t *) & allowroot, "allowroot", "AllowRoot", "off", t_Bool},
#endif
{(caddr_t *) & debug, "debug", "Debug", "off", t_Bool},
{(caddr_t *) & echokeys, "echokeys", "EchoKeys", "off", t_Bool},
{(caddr_t *) & enablesaver, "enablesaver", "EnableSaver", "off", t_Bool},
{(caddr_t *) & resetsaver, "resetsaver", "ResetSaver", "on", t_Bool},
{(caddr_t *) & fullrandom, "fullrandom", "FullRandom", "off", t_Bool},
{(caddr_t *) & grabmouse, "grabmouse", "GrabMouse", "on", t_Bool},
{(caddr_t *) & grabserver, "grabserver", "GrabServer", "off", t_Bool},
{(caddr_t *) & install, "install", "Install", "on", t_Bool},
{(caddr_t *) & mousemotion, "mousemotion", "MouseMotion", "off", t_Bool},
{(caddr_t *) & mono, "mono", "Mono", "off", t_Bool},
{(caddr_t *) & sound, "sound", "Sound", "off", t_Bool},
{(caddr_t *) & timeelapsed, "timeelapsed", "TimeElapsed", "off", t_Bool},
{(caddr_t *) & usefirst, "usefirst", "UseFirst", "on", t_Bool},
{(caddr_t *) & verbose, "verbose", "Verbose", "off", t_Bool},
{(caddr_t *) & visualname, "visual", "Visual", "", t_String},
{(caddr_t *) & nicelevel, "nice", "Nice", DEF_NICE, t_Int},
{(caddr_t *) & lockdelay, "lockdelay", "LockDelay", DEF_LOCKDELAY, t_Int},
{(caddr_t *) & timeout, "timeout", "Timeout", DEF_TIMEOUT, t_Int},
{(caddr_t *) & fontname, "font", "Font", DEF_FONT, t_String},
{(caddr_t *) & messagefont, "msgfont", "MsgFont", DEF_MSGFONT, t_String},
#ifdef USE_MB
{(caddr_t *) & fontsetname, "fontset", "FontSet", DEF_FONTSET, t_String},
#endif
{(caddr_t *) & background, "background", "Background", DEF_BG, t_String},
{(caddr_t *) & foreground, "foreground", "Foreground", DEF_FG, t_String},
{(caddr_t *) & text_user, "username", "Username", DEF_NAME, t_String},
{(caddr_t *) & text_pass, "password", "Password", DEF_PASS, t_String},
#ifdef SAFEWORD
{(caddr_t *) & text_dpass, "dynpass", "Dynpass", DEF_DPASS, t_String},
{(caddr_t *) & text_fpass, "fixpass", "Fixpass", DEF_FPASS, t_String},
{(caddr_t *) & text_chall, "challenge", "Challenge", DEF_CHALL, t_String},
#endif
{(caddr_t *) & text_info, "info", "Info", DEF_INFO, t_String},
{(caddr_t *) & text_valid, "validate", "Validate", DEF_VALID, t_String},
{(caddr_t *) & text_invalid, "invalid", "Invalid", DEF_INVALID, t_String},
{(caddr_t *) & geometry, "geometry", "Geometry", DEF_GEOMETRY, t_String},
{(caddr_t *) & icongeometry, "icongeometry", "IconGeometry", DEF_ICONGEOMETRY, t_String},
#ifdef FX
{(caddr_t *) & glgeometry, "glgeometry", "GLGeometry", DEF_GLGEOMETRY, t_String},
#endif
{(caddr_t *) & wireframe, "wireframe", "WireFrame", "off", t_Bool},
{(caddr_t *) & use3d, "use3d", "Use3D", "off", t_Bool},
{(caddr_t *) & delta3d, "delta3d", "Delta3D", DEF_DELTA3D, t_Float},
{(caddr_t *) & none3d, "none3d", "None3D", DEF_NONE3D, t_String},
{(caddr_t *) & right3d, "right3d", "Right3D", DEF_RIGHT3D, t_String},
{(caddr_t *) & left3d, "left3d", "Left3D", DEF_LEFT3D, t_String},
{(caddr_t *) & both3d, "both3d", "Both3D", DEF_BOTH3D, t_String},
{(caddr_t *) & program, "program", "Program", DEF_PROGRAM, t_String},
{(caddr_t *) & messagesfile, "messagesfile", "Messagesfile", DEF_MESSAGESFILE, t_String},
{(caddr_t *) & messagefile, "messagefile", "Messagefile", DEF_MESSAGEFILE, t_String},
{(caddr_t *) & message, "message", "Message", DEF_MESSAGE, t_String},
{(caddr_t *) & mfont, "mfont", "MFont", DEF_MFONT, t_String},
{(caddr_t *) & neighbors, "neighbors", "Neighbors", DEF_NEIGHBORS, t_Int},
{(caddr_t *) & mouse, "mouse", "Mouse", DEF_MOUSE, t_Bool},
#if defined( USE_XLOCKRC ) || defined( FALLBACK_XLOCKRC )
{(caddr_t *) & cpasswd, "cpasswd", "cpasswd", "", t_String},
#endif
#ifdef USE_AUTO_LOGOUT
{(caddr_t *) & logoutAuto, "logoutAuto", "logoutAuto", DEF_AUTO_LOGOUT, t_Int},
#endif
#ifdef USE_BUTTON_LOGOUT
{(caddr_t *) & logoutButton, "logoutButton", "LogoutButton", DEF_BUTTON_LOGOUT, t_Int},
{(caddr_t *) & logoutButtonLabel, "logoutButtonLabel",
"LogoutButtonLabel", DEF_BTN_LABEL, t_String},
{(caddr_t *) & logoutButtonHelp, "logoutButtonHelp",
"LogoutButtonHelp", DEF_BTN_HELP, t_String},
{(caddr_t *) & logoutFailedString, "logoutFailedString",
"LogoutFailedString", DEF_FAIL, t_String},
#endif
#ifdef USE_SOUND
{(caddr_t *) & locksound, "locksound", "LockSound", DEF_LOCKSOUND, t_String},
{(caddr_t *) & infosound, "infosound", "InfoSound", DEF_INFOSOUND, t_String},
{(caddr_t *) & validsound, "validsound", "ValidSound", DEF_VALIDSOUND, t_String},
{(caddr_t *) & invalidsound, "invalidsound", "InvalidSound", DEF_INVALIDSOUND, t_String},
#endif
{(caddr_t *) & startCmd, "startCmd", "StartCmd", "", t_String},
{(caddr_t *) & endCmd, "endCmd", "EndCmd", "", t_String},
{(caddr_t *) & logoutCmd, "logoutCmd", "LogoutCmd", "", t_String},
#if 0
/* These resources require special handling. They must be examined
* before the display is opened. They are evaluated by individual
* calls to GetResource(), so they should not be evaluated again here.
* For example, X-terminals need this special treatment.
*/
{(caddr_t *) & nolock, "nolock", "NoLock", "off", t_Bool},
{(caddr_t *) & inwindow, "inwindow", "InWindow", "off", t_Bool},
{(caddr_t *) & inroot, "inroot", "InRoot", "off", t_Bool},
{(caddr_t *) & remote, "remote", "Remote", "off", t_Bool},
#endif
};
#define NGENARGS (sizeof genvars / sizeof genvars[0])
static argtype modevars[] =
{
{(caddr_t *) & delay, "delay", "Delay", DEF_DELAY, t_Int},
{(caddr_t *) & batchcount, "batchcount", "BatchCount", DEF_BATCHCOUNT, t_Int},
{(caddr_t *) & cycles, "cycles", "Cycles", DEF_CYCLES, t_Int},
{(caddr_t *) & size, "size", "Size", DEF_SIZE, t_Int},
{(caddr_t *) & ncolors, "ncolors", "NColors", DEF_NCOLORS, t_Int},
{(caddr_t *) & saturation, "saturation", "Saturation", DEF_SATURATION, t_Float},
{(caddr_t *) & imagefile, "imagefile", "Imagefile", DEF_IMAGEFILE, t_String}
};
#define NMODEARGS (sizeof modevars / sizeof modevars[0])
static int modevaroffs[NMODEARGS] =
{
offsetof(LockStruct, def_delay),
offsetof(LockStruct, def_batchcount),
offsetof(LockStruct, def_cycles),
offsetof(LockStruct, def_size),
offsetof(LockStruct, def_ncolors),
offsetof(LockStruct, def_saturation),
offsetof(LockStruct, def_imagefile)
};
#ifdef VMS
static char *
stripname(char *string)
{
char *characters;
while (string && *string++ != ']');
characters = string;
while (characters)
if (*characters == '.') {
*characters = '\0';
return string;
} else
characters++;
return string;
}
#endif
static void
Syntax(char *badOption)
{
int col, len, i;
(void) fprintf(stderr, "%s: bad command line option \"%s\"\n\n",
ProgramName, badOption);
(void) fprintf(stderr, "usage: %s", ProgramName);
col = 8 + strlen(ProgramName);
for (i = 0; i < (int) opDescEntries; i++) {
len = 3 + strlen(opDesc[i].opt); /* space [ string ] */
if (col + len > 79) {
(void) fprintf(stderr, "\n "); /* 3 spaces */
col = 3;
}
(void) fprintf(stderr, " [%s]", opDesc[i].opt);
col += len;
}
len = 8 + strlen(LockProcs[0].cmdline_arg);
if (col + len > 79) {
(void) fprintf(stderr, "\n "); /* 3 spaces */
col = 3;
}
(void) fprintf(stderr, " [-mode %s", LockProcs[0].cmdline_arg);
col += len;
for (i = 1; i < numprocs; i++) {
len = 3 + strlen(LockProcs[i].cmdline_arg);
if (col + len > 79) {
(void) fprintf(stderr, "\n "); /* 3 spaces */
col = 3;
}
(void) fprintf(stderr, " | %s", LockProcs[i].cmdline_arg);
col += len;
}
(void) fprintf(stderr, "]\n");
(void) fprintf(stderr, "\nType %s -help for a full description.\n\n",
ProgramName);
exit(1);
}
static void
Help(void)
{
int i;
(void) printf("usage:\n %s [-options ...]\n\n", ProgramName);
(void) printf("where options include:\n");
for (i = 0; i < (int) opDescEntries; i++) {
(void) printf(" %-28s %s\n", opDesc[i].opt, opDesc[i].desc);
}
(void) printf(" %-28s %s\n", "-mode mode", "animation mode");
(void) printf(" where mode is one of:\n");
for (i = 0; i < numprocs; i++) {
int j;
(void) printf(" %-23s %s\n",
LockProcs[i].cmdline_arg, LockProcs[i].desc);
for (j = 0; j < LockProcs[i].msopt->numvarsdesc; j++)
(void) printf(" %-23s %s\n",
LockProcs[i].msopt->desc[j].opt, LockProcs[i].msopt->desc[j].desc);
}
(void) printf("\n");
exit(0);
}
static void
Version(void)
{
(void) printf("XLock version %s\n", VERSION);
exit(0);
}
static void
DumpResources(void)
{
int i, j;
(void) printf("%s.mode: %s\n", classname, DEF_MODE);
for (i = 0; i < (int) NGENARGS; i++)
(void) printf("%s.%s: %s\n",
classname, genvars[i].name, genvars[i].def);
for (i = 0; i < numprocs; i++) {
(void) printf("%s.%s.%s: %d\n", classname, LockProcs[i].cmdline_arg,
"delay", LockProcs[i].def_delay);
(void) printf("%s.%s.%s: %d\n", classname, LockProcs[i].cmdline_arg,
"batchcount", LockProcs[i].def_batchcount);
(void) printf("%s.%s.%s: %d\n", classname, LockProcs[i].cmdline_arg,
"cycles", LockProcs[i].def_cycles);
(void) printf("%s.%s.%s: %d\n", classname, LockProcs[i].cmdline_arg,
"size", LockProcs[i].def_size);
(void) printf("%s.%s.%s: %d\n", classname, LockProcs[i].cmdline_arg,
"ncolors", LockProcs[i].def_ncolors);
(void) printf("%s.%s.%s: %g\n", classname, LockProcs[i].cmdline_arg,
"saturation", LockProcs[i].def_saturation);
(void) printf("%s.%s.%s: %s\n", classname, LockProcs[i].cmdline_arg,
"imagefile",
(LockProcs[i].def_imagefile) ? LockProcs[i].def_imagefile : "");
for (j = 0; j < LockProcs[i].msopt->numvarsdesc; j++)
(void) printf("%s.%s.%s: %s\n", classname, LockProcs[i].cmdline_arg,
LockProcs[i].msopt->vars[j].name,
LockProcs[i].msopt->vars[j].def);
}
exit(0);
}
static void
LowerString(char *s)
{
while (*s) {
if (isupper((int) *s))
*s += ('a' - 'A');
s++;
}
}
static void
GetResource(XrmDatabase database, char *parentname, char *parentclassname,
char *name, char *classname, int valueType, char *def, caddr_t * valuep)
{
char *type;
XrmValue value;
char *string;
char buffer[1024];
char *fullname;
char *fullclassname;
int len, temp;
fullname = (char *) malloc(strlen(parentname) + strlen(name) + 2);
fullclassname = (char *) malloc(strlen(parentclassname) +
strlen(classname) + 2);
(void) sprintf(fullname, "%s.%s", parentname, name);
(void) sprintf(fullclassname, "%s.%s", parentclassname, classname);
temp = XrmGetResource(database, fullname, fullclassname, &type, &value);
(void) free((void *) fullname);
(void) free((void *) fullclassname);
if (temp) {
string = value.addr;
len = value.size - 1;
} else {
string = def;
if (!string || !*string) {
*valuep = NULL;
return;
}
len = strlen(string);
}
(void) strncpy(buffer, string, sizeof (buffer));
buffer[sizeof (buffer) - 1] = '\0';
switch (valueType) {
case t_String:
{
/*-
* PURIFY 4.0.1 on Solaris 2 and on SunOS4 reports a 1 byte memory leak on
* the following line. */
char *s = (char *) malloc(len + 1);
if (s == (char *) NULL) {
char *buf = (char *) malloc(strlen(ProgramName) + 80);
(void) sprintf(buf,
"%s: GetResource - could not allocate memory", ProgramName);
error(buf);
(void) free((void *) buf); /* Should never get here */
}
(void) strncpy(s, string, len);
s[len] = '\0';
*((char **) valuep) = s;
}
break;
case t_Float:
*((float *) valuep) = (float) atof(buffer);
break;
case t_Int:
*((int *) valuep) = atoi(buffer);
break;
case t_Bool:
LowerString(buffer);
*((int *) valuep) = (!strcmp(buffer, "true") ||
!strcmp(buffer, "on") ||
!strcmp(buffer, "enabled") ||
!strcmp(buffer, "yes")) ? True : False;
break;
}
}
static XrmDatabase
parsefilepath(char *xfilesearchpath, char *TypeName, char *ClassName)
{
XrmDatabase database = NULL;
char *appdefaults;
char *src;
char *dst;
int i, maxlen;
i = maxlen = 0;
for (src = xfilesearchpath; *src != '\0'; src++) {
if (*src == '%') {
src++;
switch (*src) {
case '%':
case ':':
i++;
break;
case 'T':
i += strlen(TypeName);
break;
case 'N':
i += strlen(ClassName);
break;
default:
break;
}
#ifdef VMS
} else if (*src == '#') { /* Colons required in VMS use # */
#else
} else if (*src == ':') {
#endif
if (i > maxlen)
maxlen = i;
i = 0;
} else
i++;
}
if (i > maxlen)
maxlen = i;
/* appdefaults will be at most this long */
appdefaults = (char *) malloc(maxlen + 1);
src = xfilesearchpath;
dst = appdefaults;
*dst = '\0';
for (;;) {
if (*src == '%') {
src++;
switch (*src) {
case '%':
case ':':
*dst++ = *src++;
*dst = '\0';
break;
case 'T':
(void) strcat(dst, TypeName);
src++;
dst += strlen(TypeName);
break;
case 'N':
(void) strcat(dst, ClassName);
src++;
dst += strlen(ClassName);
break;
case 'S':
src++;
break;
default:
src++;
break;
}
#ifdef VMS
} else if (*src == '#') { /* Colons required in VMS use # */
#else
} else if (*src == ':') {
#endif
database = XrmGetFileDatabase(appdefaults);
if (database == NULL) {
dst = appdefaults;
src++;
} else
break;
} else if (*src == '\0') {
/* PURIFY 4.0.1 on Solaris 2 reports an uninitialized memory read on the next
* line. PURIFY 4.0.1 on SunOS4 reports this also when using X11R5, but not
* with OpenWindow 3.0 (X11R4 based). */
database = XrmGetFileDatabase(appdefaults);
break;
} else {
*dst++ = *src++;
*dst = '\0';
}
}
(void) free((void *) appdefaults);
return database;
}
#ifdef VMS
/*-
* FUNCTIONAL DESCRIPTION:
* int get_info (chan, item, ret_str, ret_len)
* Fetch a single characteristics from the pseudo-workstation
* device and return the information.
* (Taken and modified from the v5.4 fiche. PPL/SG 2/10/91
* FORMAL PARAMETERS:
* chan: the device channel
* item: the characteristic to show
* ret_str: str pointer to information
* ret_len: length of above string
* IMPLICIT INPUTS:
* none
* IMPLICIT OUTPUTS:
* none
* COMPLETION CODES:
* errors returned by SYS$QIO
* SIDE EFFECTS:
* none
* Hacked from Steve Garrett's xservername (as posted to INFO-VAX)
*/
int
get_info(unsigned long chan, unsigned long item,
char *ret_str, unsigned long *ret_len)
{
unsigned long iosb[2];
int status;
char itembuf[BUFSIZE];
struct dsc$descriptor itemval;
itemval.dsc$w_length = BUFSIZE;
itemval.dsc$b_dtype = 0;
itemval.dsc$b_class = 0;
itemval.dsc$a_pointer = &itembuf[0];
status = sys$qiow(0, chan, IO$_SENSEMODE | IO$M_WS_DISPLAY, &iosb, 0, 0,
itemval.dsc$a_pointer,
itemval.dsc$w_length,
item, 0, 0, 0);
if (status != SS$_NORMAL)
return (status);
if (iosb[0] != SS$_NORMAL)
return (iosb[0]);
itemval.dsc$w_length = iosb[1];
*ret_len = iosb[1];
itembuf[*ret_len] = 0;
(void) strcpy(ret_str, &itembuf[0]);
return (status);
}
/* routine that will return descripter of asciz string */
static int
descr(char *name)
{
static $dscp(d1, 0, 0);
static $dscp(d2, 0, 0);
static $dscp(d3, 0, 0);
static $dscp(d4, 0, 0);
static $dscp(d5, 0, 0);
static $dscp(d6, 0, 0);
static dsc *tbl[] =
{&d1, &d2, &d3, &d4, &d5, &d6};
static int didx = 0;
if (didx == 6)
didx = 0;
tbl[didx]->len = strlen(name);
tbl[didx]->ptr = name;
return (int) tbl[didx++];
}
#endif
static void
open_display(void)
{
char *buf;
struct hostent *host;
#if defined(__cplusplus) || defined(c_plusplus) /* !__bsdi__ */
#if HAVE_GETHOSTNAME
extern int gethostname(char *, size_t);
extern struct hostent *gethostbyname(const char *);
#else
#define gethostname(name,namelen) sysinfo(SI_HOSTNAME,name,namelen)
#endif
#endif
if (!(dsp = XOpenDisplay((displayname) ? displayname : ""))) {
buf = (char *) malloc(strlen(ProgramName) +
((displayname) ? strlen(displayname) : 0) + 80);
(void) sprintf(buf,
"%s: unable to open display %s.\n", ProgramName,
((displayname) ? displayname : ""));
error(buf);
(void) free((void *) buf); /* Should never get here */
}
displayname = DisplayString(dsp);
/*
* only restrict access to other displays if we are locking and if the
* Remote resource is not set.
*/
if (nolock || inwindow || inroot)
remote = True;
if (gethostname(hostname, MAXHOSTNAMELEN)) {
buf = (char *) malloc(strlen(ProgramName) + 80);
(void) sprintf(buf,
"%s: Can not get local hostname.\n", ProgramName);
error(buf);
(void) free((void *) buf); /* Should never get here */
}
#ifdef VMS
if (!remote && ((displayname[0] == '_') |
((displayname[0] == 'W') &
(displayname[1] == 'S') &
(displayname[2] == 'A')))) { /* this implies a v5.4 system. The return
value is a device name, which must be
interrogated to find the real information */
unsigned long chan;
unsigned int status;
unsigned long len;
char server_transport[100];
status = sys$assign(descr(displayname), &chan, 0, 0);
if (!(status & 1))
displayname = " ";
else {
status = get_info(chan, DECW$C_WS_DSP_TRANSPORT,
server_transport, &len);
if (!(status & 1))
exit(status);
if (strcmp(server_transport, "LOCAL")) {
(void) strcat(displayname, "'s display via ");
(void) strncat(displayname, server_transport, len);
buf = (char *) malloc(strlen(ProgramName) + strlen(displayname) + 80);
(void) sprintf(buf,
"%s: can not lock %s\n", ProgramName, displayname);
error(buf);
(void) free((void *) buf); /* Should never get here */
}
}
} else {
#endif /* VMS */
if (displayname != NULL) {
char *colon = (char *) strchr(displayname, ':');
int n = colon - displayname;
if (colon == NULL) {
buf = (char *) malloc(strlen(ProgramName) +
strlen(displayname) + 80);
(void) sprintf(buf,
"%s: Malformed -display argument, \"%s\"\n",
ProgramName, displayname);
error(buf);
(void) free((void *) buf); /* Should never get here */
}
if (!remote && n
&& strncmp(displayname, "unix", n)
&& strncmp(displayname, "localhost", n)) {
int badhost = 1;
char **hp;
if (!(host = (struct hostent *) gethostbyname(hostname))) {
if (debug || verbose) {
(void) fprintf(stderr, "%s: Can not get hostbyname.\n",
ProgramName);
(void) fprintf(stderr,
"Contact your administrator to fix /etc/hosts.\n");
}
} else if (strncmp(displayname, host->h_name, n)) {
for (hp = host->h_aliases; *hp; hp++) {
if (!strncmp(displayname, *hp, n)) {
badhost = 0;
break;
}
}
if (badhost) {
*colon = (char) 0;
buf = (char *) malloc(strlen(ProgramName) +
strlen(displayname) + 80);
(void) sprintf(buf,
"%s: can not lock %s's display\n",
ProgramName, displayname);
error(buf);
(void) free((void *) buf); /* Should never get here */
}
}
}
}
#ifdef VMS
}
#endif
}
static void
printvar(char *classname, argtype var)
{
switch (var.type) {
case t_String:
(void) fprintf(stderr, "%s.%s: %s\n",
classname, var.name,
(*((char **) var.var)) ? *((char **) var.var) : "");
break;
case t_Float:
(void) fprintf(stderr, "%s.%s: %g\n",
classname, var.name, *((float *) var.var));
break;
case t_Int:
(void) fprintf(stderr, "%s.%s: %d\n",
classname, var.name, *((int *) var.var));
break;
case t_Bool:
(void) fprintf(stderr, "%s.%s: %s\n",
classname, var.name, *((int *) var.var) ? "True" : "False");
break;
}
}
void
getResources(int argc, char **argv)
{
XrmDatabase RDB = NULL;
#ifdef USE_MODULES
XrmDatabase modulepathDB = NULL;
#endif
XrmDatabase nameDB = NULL;
XrmDatabase modeDB = NULL;
XrmDatabase cmdlineDB = NULL;
XrmDatabase generalDB = NULL;
XrmDatabase homeDB = NULL;
XrmDatabase applicationDB = NULL;
XrmDatabase serverDB = NULL;
XrmDatabase userDB = NULL;
char *userfile = NULL;
char *homeenv;
char *userpath;
char *env;
char *serverString;
int i, j;
int max_length;
extern Display *dsp;
XrmInitialize();
#ifndef USE_MODULES
/*
* Moved back because its annoying if you need -remote and
* you do not know it.
*/
for (i = 0; i < argc; i++) {
if (!strncmp(argv[i], "-help", strlen(argv[i])))
Help();
if (!strncmp(argv[i], "-version", strlen(argv[i])))
Version();
}
#endif
/*
* get -name arg from command line so you can have different resource
* files for different configurations/machines etc...
*/
#ifdef VMS
/*Strip off directory and .exe; parts */
ProgramName = stripname(ProgramName);
#endif
XrmParseCommand(&nameDB, nameTable, 1, ProgramName,
&argc, argv);
GetResource(nameDB, ProgramName, "*", "name", "Name", t_String,
DEF_CLASSNAME, &classname);
homeenv = getenv("HOME");
if (!homeenv)
homeenv = "";
env = getenv("XFILESEARCHPATH");
applicationDB = parsefilepath(env ? env : DEF_FILESEARCHPATH,
"app-defaults", classname);
XrmParseCommand(&cmdlineDB, cmdlineTable, cmdlineEntries, ProgramName,
&argc, argv);
userpath = getenv("XUSERFILESEARCHPATH");
if (!userpath) {
env = getenv("XAPPLRESDIR");
if (env) {
userfile = (char *) malloc(strlen(env) + strlen(homeenv) + 8);
(void) strcpy(userfile, env);
(void) strcat(userfile, "/%N:");
(void) strcat(userfile, homeenv);
(void) strcat(userfile, "/%N");
} else {
#ifdef VMS
userfile = (char *) malloc(2 * strlen(homeenv) + 31);
(void) strcpy(userfile, homeenv);
(void) strcat(userfile, "DECW$%N.DAT#");
(void) strcat(userfile, homeenv);
(void) strcat(userfile, "DECW$XDEFAULTS.DAT");
#else
userfile = (char *) malloc(strlen(homeenv) + 4);
(void) strcpy(userfile, homeenv);
(void) strcat(userfile, "/%N");
#endif
}
userpath = userfile;
}
userDB = parsefilepath(userpath, "app-defaults", classname);
if (userfile)
(void) free((void *) userfile);
(void) XrmMergeDatabases(applicationDB, &RDB);
(void) XrmMergeDatabases(userDB, &RDB);
/* PURIFY 4.0.1 on Solaris 2 reports an uninitialized memory read on the next
* line. PURIFY 4.0.1 on SunOS4 does not report this error. */
(void) XrmMergeDatabases(cmdlineDB, &RDB);
GetResource(RDB, ProgramName, classname, "display", "Display", t_String,
"", &displayname);
GetResource(RDB, ProgramName, classname, "parent", "Parent", t_String,
"", &parentname);
if (parentname && *parentname) {
if (sscanf(parentname, "%ld", &parent))
parentSet = True;
}
GetResource(RDB, ProgramName, classname, "nolock", "NoLock", t_Bool,
"off", (caddr_t *) & nolock);
GetResource(RDB, ProgramName, classname, "inwindow", "InWindow", t_Bool,
"off", (caddr_t *) & inwindow);
GetResource(RDB, ProgramName, classname, "inroot", "InRoot", t_Bool,
"off", (caddr_t *) & inroot);
GetResource(RDB, ProgramName, classname, "remote", "Remote", t_Bool,
"off", (caddr_t *) & remote);
#ifdef USE_DTSAVER
GetResource(RDB, ProgramName, classname, "dtsaver", "DtSaver", t_Bool,
"off", (caddr_t *) & dtsaver);
if (dtsaver) {
inroot = False;
inwindow = True;
nolock = True;
}
#endif
open_display();
serverString = XResourceManagerString(dsp);
if (serverString) {
/* PURIFY 4.0.1 on Solaris 2 reports an uninitialized memory read on the next
* line. PURIFY 4.0.1 on SunOS4 reports this also when using X11R5, but not
* with OpenWindow 3.0 (X11R4 based). */
serverDB = XrmGetStringDatabase(serverString);
/* PURIFY 4.0.1 on Solaris 2 reports an uninitialized memory read on the next
* line. PURIFY 4.0.1 on SunOS4 does not report this error. */
(void) XrmMergeDatabases(serverDB, &RDB);
} else {
char *buf = (char *) malloc(strlen(homeenv) + 12);
(void) sprintf(buf, "%s/.Xdefaults", homeenv);
homeDB = XrmGetFileDatabase(buf);
(void) XrmMergeDatabases(homeDB, &RDB);
(void) free((void *) buf);
}
#ifdef USE_MODULES
/*
* Now that all the resource files have been loaded, check for the
* modules directory, so we'll know what modes are available.
*/
XrmParseCommand(&modulepathDB, modulepathTable, 1, ProgramName,
&argc, argv);
(void) XrmMergeDatabases(modulepathDB, &RDB);
GetResource(RDB, ProgramName, classname, "modulepath", "Modulepath",
t_String, DEF_MODULEPATH, &modulepath);
/* read modules from modules directory */
atexit(UnloadModules); /* make sure modules get unloaded */
LoadModules(modulepath);
/*
* Moved the search for help to here because now the modules
* have been loaded so they can be listed by help.
*/
for (i = 0; i < argc; i++) {
if (!strncmp(argv[i], "-help", strlen(argv[i])))
Help();
if (!strncmp(argv[i], "-version", strlen(argv[i])))
Version();
}
#endif
XrmParseCommand(&generalDB, genTable, genEntries, ProgramName, &argc, argv);
/* PURIFY 4.0.1 on Solaris 2 reports an uninitialized memory read on the next
* line. PURIFY 4.0.1 on SunOS4 does not report this error. */
(void) XrmMergeDatabases(generalDB, &RDB);
GetResource(RDB, ProgramName, classname, "mode", "Mode", t_String,
DEF_MODE, (caddr_t *) & mode);
XrmParseCommand(&modeDB, modeTable, modeEntries, ProgramName, &argc, argv);
(void) XrmMergeDatabases(modeDB, &RDB);
for (i = 0; i < numprocs; i++) {
XrmDatabase optDB = NULL;
ModeSpecOpt *ms = LockProcs[i].msopt;
if (!ms->numopts)
continue;
XrmParseCommand(&optDB, ms->opts, ms->numopts,
ProgramName, &argc, argv);
/* PURIFY 4.0.1 on Solaris 2 reports an uninitialized memory read on the next
* line. PURIFY 4.0.1 on SunOS4 does not report this error. */
(void) XrmMergeDatabases(optDB, &RDB);
}
/* the RDB is set, now query load the variables from the database */
for (i = 0; i < (int) NGENARGS; i++)
GetResource(RDB, ProgramName, classname,
genvars[i].name, genvars[i].classname,
genvars[i].type, genvars[i].def, genvars[i].var);
max_length = 0;
for (i = 0; i < numprocs; i++) {
j = strlen(LockProcs[i].cmdline_arg);
if (j > max_length)
max_length = j;
}
modename = (char *) malloc(strlen(ProgramName) + max_length + 2);
modeclassname = (char *) malloc(strlen(classname) + max_length + 2);
for (i = 0; i < numprocs; i++) {
argtype *v;
ModeSpecOpt *ms = LockProcs[i].msopt;
(void) sprintf(modename, "%s.%s", ProgramName, LockProcs[i].cmdline_arg);
(void) sprintf(modeclassname, "%s.%s", classname, LockProcs[i].cmdline_arg);
for (j = 0; j < (int) NMODEARGS; j++) {
char *buf = NULL;
void *p = (void *) ((char *) (&LockProcs[i]) + modevaroffs[j]);
switch (modevars[j].type) {
case t_String:
buf = (char *) malloc(strlen(*((char **) p)) + 1);
(void) sprintf(buf, "%s", *((char **) p));
break;
case t_Float:
buf = (char *) malloc(16);
(void) sprintf(buf, "%g", *((float *) p));
break;
case t_Int:
buf = (char *) malloc(16);
(void) sprintf(buf, "%d", *((int *) p));
break;
case t_Bool:
buf = (char *) malloc(6);
(void) sprintf(buf, "%s", *((int *) p) ? "True" : "False");
break;
}
GetResource(RDB, modename, modeclassname,
modevars[j].name, modevars[j].classname,
modevars[j].type, buf, (caddr_t *) p);
if (!strcmp(mode, LockProcs[i].cmdline_arg)) {
GetResource(RDB, modename, modeclassname,
modevars[j].name, modevars[j].classname,
modevars[j].type, buf, modevars[j].var);
}
if (buf) {
(void) free((void *) buf);
buf = NULL;
}
}
if (!ms->numvarsdesc)
continue;
v = ms->vars;
for (j = 0; j < ms->numvarsdesc; j++)
GetResource(RDB, modename, modeclassname, v[j].name, v[j].classname,
v[j].type, v[j].def, v[j].var);
}
/*XrmPutFileDatabase(RDB, "/tmp/xlock.rsrc.out"); */
/* PURIFY 4.0.1 on Solaris 2 reports an uninitialized memory read on the next
* line. PURIFY 4.0.1 on SunOS4 reports this also when using X11R5, but not
* with OpenWindow 3.0 (X11R4 based). */
(void) XrmDestroyDatabase(RDB);
/* Parse the rest of the command line */
for (argc--, argv++; argc > 0; argc--, argv++) {
if (**argv != '-')
Syntax(*argv);
switch (argv[0][1]) {
case 'r':
DumpResources();
/* NOTREACHED */
default:
Syntax(*argv);
/* NOTREACHED */
}
}
#if defined( USE_AUTO_LOGOUT ) || defined( USE_BUTTON_LOGOUT )
if (fullLock()) {
#ifdef USE_AUTO_LOGOUT
logoutAuto = 0;
#endif
#ifdef USE_BUTTON_LOGOUT
enable_button = 0;
#endif
} else {
#ifdef USE_AUTO_LOGOUT
#if ( USE_AUTO_LOGOUT > 0 ) /* Could be USER defined if 0 */
if (logoutAuto > USE_AUTO_LOGOUT)
logoutAuto = USE_AUTO_LOGOUT;
else if (logoutAuto <= 0) /* Handle 0 as a special case */
logoutAuto = USE_AUTO_LOGOUT;
#else
if (logoutAuto <= 0) /* Handle 0 as a special case */
(void) sscanf(DEF_AUTO_LOGOUT, "%d", &logoutAuto);
#endif
#endif
#ifdef USE_BUTTON_LOGOUT
#if ( USE_BUTTON_LOGOUT > 0 ) /* Could be USER defined if 0 */
if (logoutButton > USE_BUTTON_LOGOUT)
logoutButton = USE_BUTTON_LOGOUT;
else if (logoutButton <= 0) /* Handle 0 as a special case */
logoutButton = USE_BUTTON_LOGOUT;
#else
if (logoutButton <= 0) /* Handle 0 as a special case */
(void) sscanf(DEF_BUTTON_LOGOUT, "%d", &logoutButton);
#endif
#endif
}
#endif
#ifdef USE_DTSAVER
if (dtsaver) {
inroot = False;
inwindow = True;
nolock = True;
enablesaver = True;
grabmouse = False;
grabserver = False;
install = False;
lockdelay = 0;
geometry = DEF_GEOMETRY;
}
#endif
if (verbose) {
for (i = 0; i < (int) NGENARGS; i++)
printvar(classname, genvars[i]);
for (i = 0; i < (int) NMODEARGS; i++)
printvar(modename, modevars[i]);
}
if (!visualname || !*visualname || !strcmp(visualname, "default")) {
VisualClassWanted = -1;
if (verbose)
(void) fprintf(stderr, "Using default visual class\n");
} else {
VisualClassWanted = visualClassFromName(visualname);
if (verbose)
(void) fprintf(stderr, "Using visual class %s\n",
nameOfVisualClass(VisualClassWanted));
}
#if HAVE_DIRENT_H
/* Evaluate imagefile */
if (imagefile && strcmp(imagefile, DEF_IMAGEFILE)) {
extern void get_dir(char *fullpath, char *dir, char *filename);
extern int sel_image(struct dirent *name);
extern int scan_dir(const char *directoryname, struct dirent ***namelist,
int (*select) (struct dirent *),
int (*compare) (const void *, const void *));
get_dir(imagefile, directory_r, filename_r);
images_list = (struct dirent ***) malloc(sizeof (struct dirent **));
num_list = scan_dir(directory_r, images_list, sel_image, NULL);
image_list = *images_list;
if (debug)
for (i = 0; i < num_list; i++)
(void) printf("File number %d: %s\n", i, image_list[i]->d_name);
} else {
num_list = 0;
}
#endif
(void) free((void *) modename);
(void) free((void *) modeclassname);
(void) free((void *) classname);
}
void
checkResources(void)
{
extern char old_default_mode[];
int i;
/* in case they have a 'xlock*mode: ' empty resource */
if (!mode || *mode == '\0')
mode = DEF_MODE;
if (!strcmp(old_default_mode, "")) {
(void) strcpy(old_default_mode, mode);
}
for (i = 0; i < numprocs; i++) {
if (!strcmp(LockProcs[i].cmdline_arg, mode)) {
set_default_mode(&LockProcs[i]);
break;
}
}
if (i == numprocs) {
(void) fprintf(stderr, "Unknown mode: ");
Syntax(mode);
} else {
/* batchcount and size we allow negative
to mean randomize up to that number */
if (delay < 0)
Syntax("-delay argument must not be negative.");
if (cycles < 0)
Syntax("-cycles argument must not be negative.");
if (ncolors < 2 || ncolors > 200)
Syntax("-ncolors argument must be between 2 and 200.");
if (saturation < 0.0 || saturation > 1.0)
Syntax("-saturation argument must be between 0.0 and 1.0.");
if (delta3d < 0.0 || delta3d > 20.0)
Syntax("-delta3d argument must be between 0.0 and 20.0.");
}
}
|