home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume7 / nethack3 / patch4f < prev    next >
Encoding:
Internet Message Format  |  1989-10-02  |  55.0 KB

  1. Path: uunet!zephyr.ens.tek.com!tekgen!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v08i042:  NetHack3 -  display oriented dungeons & dragons (Ver. 3.0), Patch4f
  5. Message-ID: <4632@tekred.CNA.TEK.COM>
  6. Date: 29 Sep 89 21:11:47 GMT
  7. Sender: nobody@tekred.CNA.TEK.COM
  8. Lines: 2018
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Izchak Miller <izchak@linc.cis.upenn.edu>
  12. Posting-number: Volume 8, Issue 42
  13. Archive-name: NetHack3/Patch4f
  14. Patch-To: NetHack3: Volume 7, Issue 56-93
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 6 (of 11)."
  23. # Contents:  patches04f
  24. # Wrapped by billr@saab on Fri Sep 29 13:14:30 1989
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'patches04f' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'patches04f'\"
  28. else
  29. echo shar: Extracting \"'patches04f'\" \(52494 characters\)
  30. sed "s/^X//" >'patches04f' <<'END_OF_FILE'
  31. X*** /dev/null    Wed Sep 27 12:46:46 1989
  32. X--- vms/Install.vms    Tue Sep 26 22:10:07 1989
  33. X***************
  34. X*** 0 ****
  35. X--- 1,44 ----
  36. X+ Instructions for installing NetHack 3.0 on a VMS system
  37. X+ =======================================================
  38. X+ 
  39. X+ First, consider reading Install.unix.  While many of the details will differ,
  40. X+ it should give you an idea of how the NetHack files are set up, and what a
  41. X+ full installation process is like.
  42. X+ 
  43. X+ You should not have to move any files from their default positions, but you
  44. X+ will want to edit config.h and vmsconf.h.  Then run vms_build.com and
  45. X+ spec_lev.com.  These will create all the necessary files, but not install
  46. X+ them anywhere in particular.  That is left as an exercise for the installer.
  47. X+ 
  48. X+ 
  49. X+ Some additional notes:
  50. X+ 
  51. X+ VMS Nethack uses the termcap routines supplied with GNU Emacs.  These have
  52. X+ been supplied for those who do not already have GNU Emacs, but they are not
  53. X+ properly a part of the NetHack distribution.  Since these files (vmstermcap.c
  54. X+ and vmstparam.c) bear the usual GNU license, any executable made with these
  55. X+ files is also under the GNU license, which among other things means you must
  56. X+ be prepared to distribute all the source that went into the executable if you
  57. X+ distribute the executable.  See the GNU license in the files for further
  58. X+ details.
  59. X+ 
  60. X+ No termcap file is supplied.  One should be snarfable from any Unix system.
  61. X+ If you do not have GNU Emacs installed, you will need to define the logical
  62. X+ TERMCAP to point to the termcap file.
  63. X+ 
  64. X+ There is code which attempts to make Nethack secure in case it is installed
  65. X+ with privileges (to allow the playground to be protected against world write).
  66. X+ THIS HAS NOT BEEN TESTED.  Install Nethack with privileges at your own risk.
  67. X+ If you do so, however, we would love to hear of your experiences, good or bad.
  68. X+ 
  69. X+ VMS Nethack uses SMG$READ_KEYSTROKE to read characters from the keyboard.
  70. X+ This means that arrow keys work!  It also means that using escape to abort
  71. X+ commands doesn't!  If you want to abort a command use ^Z.  Just about any
  72. X+ non-arrow function key should also work.  Note that under Unix ^Z is the
  73. X+ suspend command.  This is of little use on VMS so our use is harmless.
  74. X+ 
  75. X+ Nethack does not run in PASTHRU or PASSALL mode.  This is to allow ^C
  76. X+ interrupts.  An unpleasant (albeit minor) side-effect of this is that some
  77. X+ wizard commands don't work (^G, ^O, ^X).  Another side-effect is that ^Y and
  78. X+ ^C echo the stupid, inverse-video "CANCEL" and "INTERRUPT" banners.  Is there
  79. X+ no other way to turn these off???
  80. X*** /dev/null    Wed Sep 27 12:46:56 1989
  81. X--- vms/spec_lev.com    Tue Sep 26 20:00:12 1989
  82. X***************
  83. X*** 0 ****
  84. X--- 1,25 ----
  85. X+ $! yacc := bison/def            ! .CLD version of bison
  86. X+ $! yacc := $bison$dir:bison -y -d    ! non-CLD version of bison
  87. X+ $ yacc := $shell$exe:yacc -d        ! yacc from DEC/Shell
  88. X+ $! lex := $flex$dir:flex        ! flex
  89. X+ $ lex := $shell$exe:lex            ! lex from DEC/Shell
  90. X+ $ cc = "CC/NOLIST/OPT=NOINLINE/DEB/INCL=[-.INCLUDE]/DEFI=(""WIZARD=""""GENTZEL"""""")"
  91. X+ $ link := link/nomap
  92. X+ $
  93. X+ $ yacc lev_comp.y
  94. X+ $ rename y_tab.c lev_comp.c
  95. X+ $ rename y_tab.h [-.include]lev_comp.h
  96. X+ $ lex lev_comp.l
  97. X+ $ rename lex_yy.c lev_lex.c
  98. X+ $ cc lev_comp.c
  99. X+ $ cc lev_lex.c
  100. X+ $ cc lev_main.c
  101. X+ $ link lev_comp.obj,lev_lex.obj,lev_main.obj,alloc.obj,monst.obj,objects.obj,panic.obj,vmsmisc.obj,sys$input:/opt
  102. X+ sys$share:vaxcrtl/share
  103. X+ $
  104. X+ $ old_dir = f$environment("DEFAULT")
  105. X+ $ set default [-.auxil]
  106. X+ $ mcr sys$disk:[-.src]lev_comp castle.des
  107. X+ $ mcr sys$disk:[-.src]lev_comp endgame.des
  108. X+ $ mcr sys$disk:[-.src]lev_comp tower.des
  109. X+ $ set default 'old_dir
  110. X*** /dev/null    Wed Sep 27 12:47:07 1989
  111. X--- vms/vmsbuild.com    Wed Sep 27 09:36:05 1989
  112. X***************
  113. X*** 0 ****
  114. X--- 1,201 ----
  115. X+ $ makedefs := $sys$disk:[]makedefs
  116. X+ $ cc = "CC/NOLIST/OPT=NOINLINE/DEB/INCL=[-.INCLUDE]/DEFI=(""WIZARD=""""GENTZEL"""""")"
  117. X+ $ link := link/nomap
  118. X+ $ if p1 .eqs. "LINK" then goto link
  119. X+ $ cc alloc.c
  120. X+ $ cc makedefs.c
  121. X+ $ cc monst.c
  122. X+ $ cc objects.c
  123. X+ $ cc panic.c
  124. X+ $ cc [-.vms]vmsmisc
  125. X+ $ link makedefs.obj,monst.obj,objects.obj,panic.obj,vmsmisc.obj,sys$input:/opt
  126. X+ sys$share:vaxcrtl/share
  127. X+ $ makedefs -p
  128. X+ $ makedefs -o
  129. X+ $ makedefs -t
  130. X+ $ cc allmain.c
  131. X+ $ cc apply.c
  132. X+ $ cc artifact.c
  133. X+ $ cc attrib.c
  134. X+ $ cc bones.c
  135. X+ $ cc cmd.c
  136. X+ $ cc dbridge.c
  137. X+ $ cc decl.c
  138. X+ $ cc demon.c
  139. X+ $ cc do.c
  140. X+ $ cc do_name.c
  141. X+ $ cc do_wear.c
  142. X+ $ cc dog.c
  143. X+ $ cc dogmove.c
  144. X+ $ cc dokick.c
  145. X+ $ cc dothrow.c
  146. X+ $ cc eat.c
  147. X+ $ cc end.c
  148. X+ $ cc engrave.c
  149. X+ $ cc exper.c
  150. X+ $ cc extralev.c
  151. X+ $ cc fountain.c
  152. X+ $ cc getline.c
  153. X+ $ cc hack.c
  154. X+ $ cc invent.c
  155. X+ $ cc lock.c
  156. X+ $ cc mail.c
  157. X+ $ cc [-.vms]vmsmain.c/obj=main.obj
  158. X+ $ cc makemon.c
  159. X+ $ cc mcastu.c
  160. X+ $ cc mhitm.c
  161. X+ $ cc mhitu.c
  162. X+ $ cc mklev.c
  163. X+ $ cc mkmaze.c
  164. X+ $ cc mkobj.c
  165. X+ $ cc mkroom.c
  166. X+ $ cc mon.c
  167. X+ $ cc mondata.c
  168. X+ $ cc monmove.c
  169. X+ $ cc mthrowu.c
  170. X+ $ cc music.c
  171. X+ $ cc o_init.c
  172. X+ $ cc objnam.c
  173. X+ $ cc options.c
  174. X+ $ cc pager.c
  175. X+ $ cc pickup.c
  176. X+ $ cc polyself.c
  177. X+ $ cc potion.c
  178. X+ $ cc pray.c
  179. X+ $ cc pri.c
  180. X+ $ cc priest.c
  181. X+ $ cc prisym.c
  182. X+ $ cc read.c
  183. X+ $ cc restore.c
  184. X+ $ cc rip.c
  185. X+ $ cc rnd.c
  186. X+ $ cc rumors.c
  187. X+ $ cc save.c
  188. X+ $ cc search.c
  189. X+ $ cc shk.c
  190. X+ $ cc shknam.c
  191. X+ $ cc sit.c
  192. X+ $ cc sounds.c
  193. X+ $ cc sp_lev.c
  194. X+ $ cc spell.c
  195. X+ $ cc steal.c
  196. X+ $ cc termcap.c
  197. X+ $ cc timeout.c
  198. X+ $ cc topl.c
  199. X+ $ cc topten.c
  200. X+ $ cc track.c
  201. X+ $ cc trap.c
  202. X+ $ cc [-.vms]vmstty.c/obj=tty.obj
  203. X+ $ cc u_init.c
  204. X+ $ cc uhitm.c
  205. X+ $ cc [-.vms]vmsunix.c/obj=unix.obj
  206. X+ $ cc vault.c
  207. X+ $ makedefs -v
  208. X+ $ cc version.c
  209. X+ $ cc weapon.c
  210. X+ $ cc were.c
  211. X+ $ cc wield.c
  212. X+ $ cc wizard.c
  213. X+ $ cc worm.c
  214. X+ $ cc worn.c
  215. X+ $ cc write.c
  216. X+ $ cc zap.c
  217. X+ $ cc [-.others]random.c
  218. X+ $ cc/def="bcopy(s1,s2,sz)=memcpy(s2,s1,sz)" [-.vms]vmstermcap.c
  219. X+ $ cc [-.vms]vmstparam.c
  220. X+ $link:
  221. X+ $ link/exe=nethack sys$input:/opt
  222. X+ allmain.obj,-
  223. X+ alloc.obj,-
  224. X+ apply.obj,-
  225. X+ artifact.obj,-
  226. X+ attrib.obj,-
  227. X+ bones.obj,-
  228. X+ cmd.obj,-
  229. X+ dbridge.obj,-
  230. X+ decl.obj,-
  231. X+ demon.obj,-
  232. X+ do.obj,-
  233. X+ do_name.obj,-
  234. X+ do_wear.obj,-
  235. X+ dog.obj,-
  236. X+ dogmove.obj,-
  237. X+ dokick.obj,-
  238. X+ dothrow.obj,-
  239. X+ eat.obj,-
  240. X+ end.obj,-
  241. X+ engrave.obj,-
  242. X+ exper.obj,-
  243. X+ extralev.obj,-
  244. X+ fountain.obj,-
  245. X+ getline.obj,-
  246. X+ hack.obj,-
  247. X+ invent.obj,-
  248. X+ lock.obj,-
  249. X+ mail.obj,-
  250. X+ main.obj,-
  251. X+ makemon.obj,-
  252. X+ mcastu.obj,-
  253. X+ mhitm.obj,-
  254. X+ mhitu.obj,-
  255. X+ mklev.obj,-
  256. X+ mkmaze.obj,-
  257. X+ mkobj.obj,-
  258. X+ mkroom.obj,-
  259. X+ mon.obj,-
  260. X+ mondata.obj,-
  261. X+ monmove.obj,-
  262. X+ monst.obj,-
  263. X+ mthrowu.obj,-
  264. X+ music.obj,-
  265. X+ o_init.obj,-
  266. X+ objects.obj,-
  267. X+ objnam.obj,-
  268. X+ options.obj,-
  269. X+ pager.obj,-
  270. X+ pickup.obj,-
  271. X+ polyself.obj,-
  272. X+ potion.obj,-
  273. X+ pray.obj,-
  274. X+ pri.obj,-
  275. X+ priest.obj,-
  276. X+ prisym.obj,-
  277. X+ read.obj,-
  278. X+ restore.obj,-
  279. X+ rip.obj,-
  280. X+ rnd.obj,-
  281. X+ rumors.obj,-
  282. X+ save.obj,-
  283. X+ search.obj,-
  284. X+ shk.obj,-
  285. X+ shknam.obj,-
  286. X+ sit.obj,-
  287. X+ sounds.obj,-
  288. X+ sp_lev.obj,-
  289. X+ spell.obj,-
  290. X+ steal.obj,-
  291. X+ termcap.obj,-
  292. X+ timeout.obj,-
  293. X+ topl.obj,-
  294. X+ topten.obj,-
  295. X+ track.obj,-
  296. X+ trap.obj,-
  297. X+ tty.obj,-
  298. X+ u_init.obj,-
  299. X+ uhitm.obj,-
  300. X+ unix.obj,-
  301. X+ vault.obj,-
  302. X+ version.obj,-
  303. X+ weapon.obj,-
  304. X+ were.obj,-
  305. X+ wield.obj,-
  306. X+ wizard.obj,-
  307. X+ worm.obj,-
  308. X+ worn.obj,-
  309. X+ write.obj,-
  310. X+ zap.obj,-
  311. X+ random.obj,-
  312. X+ vmsmisc.obj,-
  313. X+ vmstermcap.obj,-
  314. X+ vmstparam.obj
  315. X+ sys$library:vaxcrtl/library
  316. X*** /dev/null    Wed Sep 27 12:47:15 1989
  317. X--- vms/vmsmain.c    Tue Sep 26 18:45:52 1989
  318. X***************
  319. X*** 0 ****
  320. X--- 1,378 ----
  321. X+ /*    SCCS Id: @(#)vmsmain.c    3.0    89/01/13
  322. X+ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  323. X+ /* NetHack may be freely redistributed.  See license for details. */
  324. X+ /* main.c - VMS NetHack */
  325. X+ 
  326. X+ #include <signal.h>
  327. X+ 
  328. X+ #include "hack.h"
  329. X+ 
  330. X+ char SAVEF[PL_NSIZ + 20];            /* [.save]<uic>player;1 */
  331. X+ 
  332. X+ char *hname = 0;        /* name of the game (argv[0] of call) */
  333. X+ char obuf[BUFSIZ];    /* BUFSIZ is defined in stdio.h */
  334. X+ int hackpid = 0;                /* current pid */
  335. X+ int locknum = 0;                /* max num of players */
  336. X+ 
  337. X+ static void whoami();
  338. X+ static void byebye();
  339. X+ 
  340. X+ int
  341. X+ main(argc,argv)
  342. X+ int argc;
  343. X+ char *argv[];
  344. X+ {
  345. X+     extern int x_maze_max, y_maze_max;
  346. X+     register int fd;
  347. X+ #ifdef CHDIR
  348. X+     register char *dir;
  349. X+ #endif
  350. X+ 
  351. X+     atexit(byebye);
  352. X+     hname = argv[0];
  353. X+     hackpid = getpid();
  354. X+     (void) umask(0);
  355. X+ 
  356. X+     /*
  357. X+      *  Remember tty modes, to be restored on exit.
  358. X+      *
  359. X+      *  gettty() must be called before startup()
  360. X+      *    due to ordering of LI/CO settings
  361. X+      *  startup() must be called before initoptions()
  362. X+      *    due to ordering of graphics settings
  363. X+      */
  364. X+     gettty();
  365. X+     setbuf(stdout,obuf);
  366. X+     startup();
  367. X+     initoptions();
  368. X+     whoami();
  369. X+ 
  370. X+ #ifdef CHDIR            /* otherwise no chdir() */
  371. X+     /*
  372. X+      * See if we must change directory to the playground.
  373. X+      * (Perhaps hack is installed with privs and playground is
  374. X+      *  inaccessible for the player.)
  375. X+      * The logical name HACKDIR is overridden by a
  376. X+      *  -d command line option (must be the first option given)
  377. X+      */
  378. X+     dir = getenv("HACKDIR");
  379. X+ #endif
  380. X+     if(argc > 1) {
  381. X+ #ifdef CHDIR
  382. X+         if (!strncmp(argv[1], "-d", 2)) {
  383. X+         argc--;
  384. X+         argv++;
  385. X+         dir = argv[0]+2;
  386. X+         if(*dir == '=' || *dir == ':') dir++;
  387. X+         if(!*dir && argc > 1) {
  388. X+             argc--;
  389. X+             argv++;
  390. X+             dir = argv[0];
  391. X+         }
  392. X+         if(!*dir)
  393. X+             error("Flag -d must be followed by a directory name.");
  394. X+         } else
  395. X+ #endif /* CHDIR /**/
  396. X+ 
  397. X+     /*
  398. X+      * Now we know the directory containing 'record' and
  399. X+      * may do a prscore().
  400. X+      */
  401. X+         if (!strncmp(argv[1], "-s", 2)) {
  402. X+ #ifdef CHDIR
  403. X+         chdirx(dir,0);
  404. X+ #endif
  405. X+         prscore(argc, argv);
  406. X+         getret();
  407. X+         settty(NULL);
  408. X+         exit(0);
  409. X+         }
  410. X+     }
  411. X+ 
  412. X+     /*
  413. X+      * It seems you really want to play.
  414. X+      */
  415. X+     setrandom();
  416. X+     cls();
  417. X+     u.uhp = 1;    /* prevent RIP on early quits */
  418. X+     u.ux = FAR;    /* prevent nscr() */
  419. X+     (void) signal(SIGHUP, (SIG_RET_TYPE) hangup);
  420. X+ 
  421. X+     /*
  422. X+      * Find the creation date of this game,
  423. X+      * so as to avoid restoring outdated savefiles.
  424. X+      */
  425. X+     gethdate(hname);
  426. X+ 
  427. X+     /*
  428. X+      * We cannot do chdir earlier, otherwise gethdate will fail.
  429. X+      */
  430. X+ #ifdef CHDIR
  431. X+     chdirx(dir,1);
  432. X+ #endif
  433. X+ 
  434. X+     /*
  435. X+      * Process options.
  436. X+      */
  437. X+     while(argc > 1 && argv[1][0] == '-'){
  438. X+         argv++;
  439. X+         argc--;
  440. X+         switch(argv[0][1]){
  441. X+ #if defined(WIZARD) || defined(EXPLORE_MODE)
  442. X+ # ifndef EXPLORE_MODE
  443. X+         case 'X':
  444. X+         case 'x':
  445. X+ # endif
  446. X+         case 'D':
  447. X+ # ifdef WIZARD
  448. X+             if(!strcmp(getenv("USER"), WIZARD))
  449. X+                 wizard = TRUE;
  450. X+                 break;
  451. X+             }
  452. X+             /* otherwise fall thru to discover */
  453. X+ # endif
  454. X+ # ifdef EXPLORE_MODE
  455. X+         case 'X':
  456. X+         case 'x':
  457. X+             discover = TRUE;
  458. X+ # endif
  459. X+             break;
  460. X+ #endif
  461. X+ #ifdef NEWS
  462. X+         case 'n':
  463. X+             flags.nonews = TRUE;
  464. X+             break;
  465. X+ #endif
  466. X+         case 'u':
  467. X+             if(argv[0][2])
  468. X+               (void) strncpy(plname, argv[0]+2, sizeof(plname)-1);
  469. X+             else if(argc > 1) {
  470. X+               argc--;
  471. X+               argv++;
  472. X+               (void) strncpy(plname, argv[0], sizeof(plname)-1);
  473. X+             } else
  474. X+                 Printf("Player name expected after -u\n");
  475. X+             break;
  476. X+         default:
  477. X+             /* allow -T for Tourist, etc. */
  478. X+             (void) strncpy(pl_character, argv[0]+1,
  479. X+                 sizeof(pl_character)-1);
  480. X+ 
  481. X+             /* Printf("Unknown option: %s\n", *argv); */
  482. X+         }
  483. X+     }
  484. X+ 
  485. X+     if(argc > 1)
  486. X+         locknum = atoi(argv[1]);
  487. X+ #ifdef MAX_NR_OF_PLAYERS
  488. X+     if(!locknum || locknum > MAX_NR_OF_PLAYERS)
  489. X+         locknum = MAX_NR_OF_PLAYERS;
  490. X+ #endif
  491. X+ #ifdef WIZARD
  492. X+     if (wizard)
  493. X+         Strcpy(plname, "wizard");
  494. X+     else
  495. X+ #endif
  496. X+     if(!*plname || !strncmp(plname, "games", 4))
  497. X+         askname();
  498. X+     plnamesuffix();        /* strip suffix from name; calls askname() */
  499. X+                 /* again if suffix was whole name */
  500. X+                 /* accepts any suffix */
  501. X+ #ifdef WIZARD
  502. X+     if(!wizard) {
  503. X+ #endif
  504. X+         /*
  505. X+          * check for multiple games under the same name
  506. X+          * (if !locknum) or check max nr of players (otherwise)
  507. X+          */
  508. X+         (void) signal(SIGQUIT,SIG_IGN);
  509. X+         (void) signal(SIGINT,SIG_IGN);
  510. X+         if(!locknum)
  511. X+             Sprintf(lock, "%d%s", getuid(), plname);
  512. X+         getlock();    /* sets lock if locknum != 0 */
  513. X+ #ifdef WIZARD
  514. X+     } else
  515. X+         Sprintf(lock, "%d%s", getuid(), plname);
  516. X+ #endif /* WIZARD /**/
  517. X+     setftty();
  518. X+ 
  519. X+     /*
  520. X+      * Initialisation of the boundaries of the mazes
  521. X+      * Both boundaries have to be even.
  522. X+      */
  523. X+ 
  524. X+     x_maze_max = COLNO-1;
  525. X+     if (x_maze_max % 2)
  526. X+         x_maze_max--;
  527. X+     y_maze_max = ROWNO-1;
  528. X+     if (y_maze_max % 2)
  529. X+         y_maze_max--;
  530. X+ 
  531. X+     /* initialize static monster strength array */
  532. X+     init_monstr();
  533. X+ 
  534. X+     Sprintf(SAVEF, "[.save]%d%s", getuid(), plname);
  535. X+     regularize(SAVEF+7);    /* avoid bogus chars in name */
  536. X+     if((fd = open(SAVEF,0)) >= 0 &&
  537. X+        (uptodate(fd) || unlink(SAVEF) >= 0)) {
  538. X+ #ifdef WIZARD
  539. X+         /* Since wizard is actually flags.debug, restoring might
  540. X+          * overwrite it.
  541. X+          */
  542. X+         boolean remember_wiz_mode = wizard;
  543. X+ #endif
  544. X+         (void) signal(SIGINT, (SIG_RET_TYPE) done1);
  545. X+         pline("Restoring old save file...");
  546. X+         (void) fflush(stdout);
  547. X+         if(!dorecover(fd))
  548. X+             goto not_recovered;
  549. X+ #ifdef WIZARD
  550. X+         if(!wizard && remember_wiz_mode) wizard = TRUE;
  551. X+ #endif
  552. X+         pline("Hello %s, welcome to NetHack!", plname);
  553. X+         /* get shopkeeper set properly if restore is in shop */
  554. X+         (void) inshop();
  555. X+ #ifdef EXPLORE_MODE
  556. X+         if (discover)
  557. X+             You("are in non-scoring discovery mode.");
  558. X+ #endif
  559. X+ #if defined(EXPLORE_MODE) || defined(WIZARD)
  560. X+         if (discover || wizard) {
  561. X+             pline("Do you want to keep the save file? ");
  562. X+             if(yn() == 'n')
  563. X+                 (void) unlink(SAVEF);
  564. X+         }
  565. X+ #endif
  566. X+         flags.move = 0;
  567. X+     } else {
  568. X+ not_recovered:
  569. X+         newgame();
  570. X+         /* give welcome message before pickup messages */
  571. X+         pline("Hello %s, welcome to NetHack!", plname);
  572. X+ #ifdef EXPLORE_MODE
  573. X+         if (discover)
  574. X+             You("are in non-scoring discovery mode.");
  575. X+ #endif
  576. X+         flags.move = 0;
  577. X+         set_wear();
  578. X+         pickup(1);
  579. X+         read_engr_at(u.ux,u.uy);
  580. X+     }
  581. X+ 
  582. X+     flags.moonphase = phase_of_the_moon();
  583. X+     if(flags.moonphase == FULL_MOON) {
  584. X+         You("are lucky!  Full moon tonight.");
  585. X+         if(!u.uluck) change_luck(1);
  586. X+     } else if(flags.moonphase == NEW_MOON) {
  587. X+         pline("Be careful!  New moon tonight.");
  588. X+     }
  589. X+ 
  590. X+     initrack();
  591. X+ 
  592. X+     moveloop();
  593. X+     return(0);
  594. X+ }
  595. X+ 
  596. X+ void
  597. X+ glo(foo)
  598. X+ register int foo;
  599. X+ {
  600. X+     /* construct the string  xlock.n  */
  601. X+     register char *tf;
  602. X+ 
  603. X+     tf = lock;
  604. X+     while(*tf && *tf != '.') tf++;
  605. X+     Sprintf(tf, ".%d;1", foo);
  606. X+ }
  607. X+ 
  608. X+ /*
  609. X+  * plname is filled either by an option (-u Player  or  -uPlayer) or
  610. X+  * explicitly (by being the wizard) or by askname.
  611. X+  * It may still contain a suffix denoting pl_character.
  612. X+  */
  613. X+ void
  614. X+ askname() {
  615. X+     register int c, ct;
  616. X+ 
  617. X+     Printf("\nWho are you? ");
  618. X+     (void) fflush(stdout);
  619. X+     ct = 0;
  620. X+     while((c = getchar()) != '\n') {
  621. X+         if(c == EOF) error("End of input\n");
  622. X+         if(c != '-')
  623. X+         if(c < 'A' || (c > 'Z' && c < 'a') || c > 'z') c = '_';
  624. X+         if(ct < sizeof(plname)-1)
  625. X+             plname[ct++] = c;
  626. X+     }
  627. X+     plname[ct] = 0;
  628. X+     if(ct == 0) askname();
  629. X+ }
  630. X+ 
  631. X+ #ifdef CHDIR
  632. X+ void
  633. X+ chdirx(dir, wr)
  634. X+ char *dir;
  635. X+ boolean wr;
  636. X+ {
  637. X+     static char *defdir = HACKDIR;
  638. X+ 
  639. X+ # ifdef HACKDIR
  640. X+     if(dir == NULL)
  641. X+         dir = defdir;
  642. X+     else if (wr)
  643. X+         /* If we're playing anywhere other than HACKDIR, turn off any
  644. X+            privs we may have been installed with. */
  645. X+         privoff();
  646. X+ # endif
  647. X+ 
  648. X+     if(dir && chdir(dir) < 0) {
  649. X+         perror(dir);
  650. X+         error("Cannot chdir to %s.", dir);
  651. X+     }
  652. X+ 
  653. X+     /* warn the player if we can't write the record file */
  654. X+     if(wr) {
  655. X+         register int fd;
  656. X+ 
  657. X+         if(dir == NULL)
  658. X+         dir = "";
  659. X+         if((fd = open(RECORD, 2)) < 0) {
  660. X+         Printf("Warning: cannot write %s%s", dir, RECORD);
  661. X+         getret();
  662. X+         } else
  663. X+         (void) close(fd);
  664. X+     }
  665. X+     defdir = dir;
  666. X+ }
  667. X+ #endif /* CHDIR /**/
  668. X+ 
  669. X+ static void
  670. X+ whoami() {
  671. X+     /*
  672. X+      * Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS
  673. X+      *            2. Use $USER    (if 1. fails)
  674. X+      * The resulting name is overridden by command line options.
  675. X+      * If everything fails, or if the resulting name is some generic
  676. X+      * account like "games" then eventually we'll ask him.
  677. X+      * Note that we trust him here; it is possible to play under
  678. X+      * somebody else's name.
  679. X+      */
  680. X+     register char *s;
  681. X+ 
  682. X+     if(!*plname && (s = getenv("USER")))
  683. X+         (void) strncpy(plname, s, sizeof(plname)-1);
  684. X+ }
  685. X+ 
  686. X+ static void
  687. X+ byebye()
  688. X+ {
  689. X+     void (*hup)();
  690. X+     extern unsigned int dosh_pid;
  691. X+ 
  692. X+     /* SIGHUP doesn't seem to do anything on VMS, so we fudge it here... */
  693. X+     hup = signal(SIGHUP, SIG_IGN);
  694. X+     if (hup != SIG_DFL && hup != SIG_IGN)
  695. X+     (*hup)();
  696. X+     if (dosh_pid)
  697. X+     SYS$DELPRC(&dosh_pid, 0);
  698. X+ }
  699. X*** /dev/null    Wed Sep 27 12:47:25 1989
  700. X--- vms/vmsmisc.c    Sat Sep 16 12:25:25 1989
  701. X***************
  702. X*** 0 ****
  703. X--- 1,14 ----
  704. X+ #include <ssdef.h>
  705. X+ 
  706. X+ void
  707. X+ vms_exit(status)
  708. X+ int status;
  709. X+ {
  710. X+     exit(status ? SS$_ABORT : SS$_NORMAL);
  711. X+ }
  712. X+ 
  713. X+ void
  714. X+ vms_abort()
  715. X+ {
  716. X+     (void) LIB$SIGNAL(SS$_DEBUG);
  717. X+ }
  718. X*** /dev/null    Wed Sep 27 12:47:33 1989
  719. X--- vms/vmstermcap.c    Sat Sep 16 12:24:04 1989
  720. X***************
  721. X*** 0 ****
  722. X--- 1,742 ----
  723. X+ /* Work-alike for termcap, plus extra features.
  724. X+    Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  725. X+ 
  726. X+                NO WARRANTY
  727. X+ 
  728. X+   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  729. X+ NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  730. X+ WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  731. X+ RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  732. X+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  733. X+ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  734. X+ FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  735. X+ AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  736. X+ DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  737. X+ CORRECTION.
  738. X+ 
  739. X+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  740. X+ STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  741. X+ WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  742. X+ LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  743. X+ OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  744. X+ USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  745. X+ DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  746. X+ A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  747. X+ PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  748. X+ DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  749. X+ 
  750. X+         GENERAL PUBLIC LICENSE TO COPY
  751. X+ 
  752. X+   1. You may copy and distribute verbatim copies of this source file
  753. X+ as you receive it, in any medium, provided that you conspicuously and
  754. X+ appropriately publish on each copy a valid copyright notice "Copyright
  755. X+ (C) 1986 Free Software Foundation, Inc."; and include following the
  756. X+ copyright notice a verbatim copy of the above disclaimer of warranty
  757. X+ and of this License.  You may charge a distribution fee for the
  758. X+ physical act of transferring a copy.
  759. X+ 
  760. X+   2. You may modify your copy or copies of this source file or
  761. X+ any portion of it, and copy and distribute such modifications under
  762. X+ the terms of Paragraph 1 above, provided that you also do the following:
  763. X+ 
  764. X+     a) cause the modified files to carry prominent notices stating
  765. X+     that you changed the files and the date of any change; and
  766. X+ 
  767. X+     b) cause the whole of any work that you distribute or publish,
  768. X+     that in whole or in part contains or is a derivative of this
  769. X+     program or any part thereof, to be licensed at no charge to all
  770. X+     third parties on terms identical to those contained in this
  771. X+     License Agreement (except that you may choose to grant more extensive
  772. X+     warranty protection to some or all third parties, at your option).
  773. X+ 
  774. X+     c) You may charge a distribution fee for the physical act of
  775. X+     transferring a copy, and you may at your option offer warranty
  776. X+     protection in exchange for a fee.
  777. X+ 
  778. X+ Mere aggregation of another unrelated program with this program (or its
  779. X+ derivative) on a volume of a storage or distribution medium does not bring
  780. X+ the other program under the scope of these terms.
  781. X+ 
  782. X+   3. You may copy and distribute this program (or a portion or derivative
  783. X+ of it, under Paragraph 2) in object code or executable form under the terms
  784. X+ of Paragraphs 1 and 2 above provided that you also do one of the following:
  785. X+ 
  786. X+     a) accompany it with the complete corresponding machine-readable
  787. X+     source code, which must be distributed under the terms of
  788. X+     Paragraphs 1 and 2 above; or,
  789. X+ 
  790. X+     b) accompany it with a written offer, valid for at least three
  791. X+     years, to give any third party free (except for a nominal
  792. X+     shipping charge) a complete machine-readable copy of the
  793. X+     corresponding source code, to be distributed under the terms of
  794. X+     Paragraphs 1 and 2 above; or,
  795. X+ 
  796. X+     c) accompany it with the information you received as to where the
  797. X+     corresponding source code may be obtained.  (This alternative is
  798. X+     allowed only for noncommercial distribution and only if you
  799. X+     received the program in object code or executable form alone.)
  800. X+ 
  801. X+ For an executable file, complete source code means all the source code for
  802. X+ all modules it contains; but, as a special exception, it need not include
  803. X+ source code for modules which are standard libraries that accompany the
  804. X+ operating system on which the executable file runs.
  805. X+ 
  806. X+   4. You may not copy, sublicense, distribute or transfer this program
  807. X+ except as expressly provided under this License Agreement.  Any attempt
  808. X+ otherwise to copy, sublicense, distribute or transfer this program is void and
  809. X+ your rights to use the program under this License agreement shall be
  810. X+ automatically terminated.  However, parties who have received computer
  811. X+ software programs from you with this License Agreement will not have
  812. X+ their licenses terminated so long as such parties remain in full compliance.
  813. X+ 
  814. X+   5. If you wish to incorporate parts of this program into other free
  815. X+ programs whose distribution conditions are different, write to the Free
  816. X+ Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  817. X+ worked out a simple rule that can be stated here, but we will often permit
  818. X+ this.  We will be guided by the two goals of preserving the free status of
  819. X+ all derivatives of our free software and of promoting the sharing and reuse of
  820. X+ software.
  821. X+ 
  822. X+ 
  823. X+ In other words, you are welcome to use, share and improve this program.
  824. X+ You are forbidden to forbid anyone else to use, share and improve
  825. X+ what you give them.   Help stamp out software-hoarding!  */
  826. X+ 
  827. X+ 
  828. X+ 
  829. X+ /* BUFSIZE is the initial size allocated for the buffer
  830. X+    for reading the termcap file.
  831. X+    It is not a limit.
  832. X+    Make it large normally for speed.
  833. X+    Make it variable when debugging, so can exercise
  834. X+    increasing the space dynamically.  */
  835. X+ 
  836. X+ #ifdef emacs
  837. X+ #include "config.h"
  838. X+ #endif
  839. X+ 
  840. X+ #ifndef BUFSIZE
  841. X+ #ifdef DEBUG
  842. X+ #define BUFSIZE bufsize
  843. X+ 
  844. X+ int bufsize = 128;
  845. X+ #else
  846. X+ #define BUFSIZE 2048
  847. X+ #endif
  848. X+ #endif
  849. X+ 
  850. X+ #ifndef emacs
  851. X+ static
  852. X+ memory_out ()
  853. X+ {
  854. X+   write (2, "Virtual memory exhausted\n", 25);
  855. X+   exit (1);
  856. X+ }
  857. X+ 
  858. X+ static int
  859. X+ xmalloc (size)
  860. X+      int size;
  861. X+ {
  862. X+   register tem = malloc (size);
  863. X+   if (!tem)
  864. X+     memory_out ();
  865. X+   return tem;
  866. X+ }
  867. X+ 
  868. X+ static int
  869. X+ xrealloc (ptr, size)
  870. X+      int ptr;
  871. X+      int size;
  872. X+ {
  873. X+   register tem = realloc (ptr, size);
  874. X+   if (!tem)
  875. X+     memory_out ();
  876. X+   return tem;
  877. X+ }
  878. X+ #endif /* not emacs */
  879. X+ 
  880. X+ /* Looking up capabilities in the entry already found */
  881. X+ 
  882. X+ /* The pointer to the data made by tgetent is left here
  883. X+    for tgetnum, tgetflag and tgetstr to find.  */
  884. X+ 
  885. X+ static char *term_entry;
  886. X+ 
  887. X+ static char *tgetst1 ();
  888. X+ 
  889. X+ /* This is the main subroutine that is used to search
  890. X+    an entry for a particular capability */
  891. X+ 
  892. X+ static char *
  893. X+ find_capability (bp, cap)
  894. X+      register char *bp, *cap;
  895. X+ {
  896. X+   for (; *bp; bp++)
  897. X+     if (bp[0] == ':'
  898. X+     && bp[1] == cap[0]
  899. X+     && bp[2] == cap[1])
  900. X+       return &bp[4];
  901. X+   return 0;
  902. X+ }
  903. X+ 
  904. X+ int
  905. X+ tgetnum (cap)
  906. X+      char *cap;
  907. X+ {
  908. X+   register char *ptr = find_capability (term_entry, cap);
  909. X+   if (!ptr || ptr[-1] != '#')
  910. X+     return -1;
  911. X+   return atoi (ptr);
  912. X+ }
  913. X+ 
  914. X+ int
  915. X+ tgetflag (cap)
  916. X+      char *cap;
  917. X+ {
  918. X+   register char *ptr = find_capability (term_entry, cap);
  919. X+   return 0 != ptr && ptr[-1] == ':';
  920. X+ }
  921. X+ 
  922. X+ /* Look up a string-valued capability `cap'.
  923. X+    If `area' is nonzero, it points to a pointer to a block in which
  924. X+    to store the string.  That pointer is advanced over the space used.
  925. X+    If `area' is zero, space is allocated with `malloc'.  */
  926. X+ 
  927. X+ char *
  928. X+ tgetstr (cap, area)
  929. X+      char *cap;
  930. X+      char **area;
  931. X+ {
  932. X+   register char *ptr = find_capability (term_entry, cap);
  933. X+   if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~'))
  934. X+     return 0;
  935. X+   return tgetst1 (ptr, area);
  936. X+ }
  937. X+ 
  938. X+ /* Table, indexed by a character in range 0100 to 0140 with 0100 subtracted,
  939. X+    gives meaning of character following \, or a space if no special meaning.
  940. X+    Eight characters per line within the string.  */
  941. X+ 
  942. X+ static char esctab[]
  943. X+   = " \007\010  \033\014 \
  944. X+       \012 \
  945. X+   \015 \011 \013 \
  946. X+         ";
  947. X+ 
  948. X+ /* Given a pointer to a string value inside a termcap entry (`ptr'),
  949. X+    copy the value and process \ and ^ abbreviations.
  950. X+    Copy into block that *area points to,
  951. X+    or to newly allocated storage if area is 0.  */
  952. X+ 
  953. X+ static char *
  954. X+ tgetst1 (ptr, area)
  955. X+      char *ptr;
  956. X+      char **area;
  957. X+ {
  958. X+   register char *p, *r;
  959. X+   register int c;
  960. X+   register int size;
  961. X+   char *ret;
  962. X+   register int c1;
  963. X+ 
  964. X+   if (!ptr)
  965. X+     return 0;
  966. X+ 
  967. X+   /* `ret' gets address of where to store the string */
  968. X+   if (!area)
  969. X+     {
  970. X+       /* Compute size of block needed (may overestimate) */
  971. X+       p = ptr;
  972. X+       while ((c = *p++) && c != ':' && c != '\n');
  973. X+       ret = (char *) xmalloc (p - ptr + 1);
  974. X+     }
  975. X+   else
  976. X+     ret = *area;
  977. X+ 
  978. X+   /* Copy the string value, stopping at null or colon.  */
  979. X+   /* Also process ^ and \ abbreviations.  */
  980. X+   p = ptr;
  981. X+   r = ret;
  982. X+   while ((c = *p++) && c != ':' && c != '\n')
  983. X+     {
  984. X+       if (c == '^')
  985. X+     c = *p++ & 037;
  986. X+       else if (c == '\\')
  987. X+     {
  988. X+       c = *p++;
  989. X+       if (c >= '0' && c <= '7')
  990. X+         {
  991. X+           c -= '0';
  992. X+           size = 0;
  993. X+ 
  994. X+           while (++size < 3 && (c1 = *p) >= '0' && c1 <= '7')
  995. X+         {
  996. X+           c *= 8;
  997. X+           c += c1 - '0';
  998. X+           p++;
  999. X+         }
  1000. X+         }
  1001. X+       else if (c >= 0100 && c < 0200)
  1002. X+         {
  1003. X+           c1 = esctab[(c & ~040) - 0100];
  1004. X+           if (c1 != ' ')
  1005. X+         c = c1;
  1006. X+         }
  1007. X+     }
  1008. X+       *r++ = c;
  1009. X+     }
  1010. X+   *r = 0;
  1011. X+   /* Update *area */
  1012. X+   if (area)
  1013. X+     *area = r + 1;
  1014. X+   return ret;
  1015. X+ }
  1016. X+ 
  1017. X+ /* Outputting a string with padding */
  1018. X+ 
  1019. X+ short ospeed;
  1020. X+ char PC;
  1021. X+ 
  1022. X+ /* Actual baud rate if positive;
  1023. X+    - baud rate / 100 if negative.  */
  1024. X+ 
  1025. X+ static short speeds[] =
  1026. X+   {
  1027. X+ #ifdef VMS
  1028. X+     0, 50, 75, 110, 134, 150, -3, -6, -12, -18,
  1029. X+     -20, -24, -36, -48, -72, -96, -192
  1030. X+ #else /* not VMS */
  1031. X+     0, 50, 75, 110, 135, 150, -2, -3, -6, -12,
  1032. X+     -18, -24, -48, -96, -192, -384
  1033. X+ #endif /* not VMS */
  1034. X+   };
  1035. X+ 
  1036. X+ tputs (string, nlines, outfun)
  1037. X+      register char *string;
  1038. X+      int nlines;
  1039. X+      register int (*outfun) ();
  1040. X+ {
  1041. X+   register int padcount = 0;
  1042. X+ 
  1043. X+   if (string == (char *) 0)
  1044. X+     return;
  1045. X+   while (*string >= '0' && *string <= '9')
  1046. X+     {
  1047. X+       padcount += *string++ - '0';
  1048. X+       padcount *= 10;
  1049. X+     }
  1050. X+   if (*string == '.')
  1051. X+     {
  1052. X+       string++;
  1053. X+       padcount += *string++ - '0';
  1054. X+     }
  1055. X+   if (*string == '*')
  1056. X+     {
  1057. X+       string++;
  1058. X+       padcount *= nlines;
  1059. X+     }
  1060. X+   while (*string)
  1061. X+     (*outfun) (*string++);
  1062. X+ 
  1063. X+   /* padcount is now in units of tenths of msec.  */
  1064. X+   padcount *= speeds[ospeed];
  1065. X+   padcount += 500;
  1066. X+   padcount /= 1000;
  1067. X+   if (speeds[ospeed] < 0)
  1068. X+     padcount = -padcount;
  1069. X+   else
  1070. X+     {
  1071. X+       padcount += 50;
  1072. X+       padcount /= 100;
  1073. X+     }
  1074. X+ 
  1075. X+   while (padcount-- > 0)
  1076. X+     (*outfun) (PC);
  1077. X+ }
  1078. X+ 
  1079. X+ /* Finding the termcap entry in the termcap data base */
  1080. X+ 
  1081. X+ struct buffer
  1082. X+   {
  1083. X+     char *beg;
  1084. X+     int size;
  1085. X+     char *ptr;
  1086. X+     int ateof;
  1087. X+     int full;
  1088. X+   };
  1089. X+ 
  1090. X+ /* Forward declarations of static functions */
  1091. X+ 
  1092. X+ static int scan_file ();
  1093. X+ static char *gobble_line ();
  1094. X+ static int compare_contin ();
  1095. X+ static int name_match ();
  1096. X+ 
  1097. X+ #ifdef VMS
  1098. X+ 
  1099. X+ #include <rmsdef.h>
  1100. X+ #include <fab.h>
  1101. X+ #include <nam.h>
  1102. X+ 
  1103. X+ static int
  1104. X+ legal_filename_p (fn)
  1105. X+      char *fn;
  1106. X+ {
  1107. X+   struct FAB fab = cc$rms_fab;
  1108. X+   struct NAM nam = cc$rms_nam;
  1109. X+   char esa[NAM$C_MAXRSS];
  1110. X+ 
  1111. X+   fab.fab$l_fna = fn;
  1112. X+   fab.fab$b_fns = strlen(fn);
  1113. X+   fab.fab$l_nam = &nam;
  1114. X+   fab.fab$l_fop = FAB$M_NAM;
  1115. X+ 
  1116. X+   nam.nam$l_esa = esa;
  1117. X+   nam.nam$b_ess = sizeof esa;
  1118. X+ 
  1119. X+   return SYS$PARSE(&fab, 0, 0) == RMS$_NORMAL;
  1120. X+ }
  1121. X+ 
  1122. X+ #endif /* VMS */
  1123. X+ 
  1124. X+ /* Find the termcap entry data for terminal type `name'
  1125. X+    and store it in the block that `bp' points to.
  1126. X+    Record its address for future use.
  1127. X+ 
  1128. X+    If `bp' is zero, space is dynamically allocated.  */
  1129. X+ 
  1130. X+ int
  1131. X+ tgetent (bp, name)
  1132. X+      char *bp, *name;
  1133. X+ {
  1134. X+   register char *tem;
  1135. X+   register int fd;
  1136. X+   struct buffer buf;
  1137. X+   register char *bp1;
  1138. X+   char *bp2;
  1139. X+   char *term;
  1140. X+   int malloc_size = 0;
  1141. X+   register int c;
  1142. X+   char *tcenv;            /* TERMCAP value, if it contais :tc=.  */
  1143. X+   char *indirect = 0;        /* Terminal type in :tc= in TERMCAP value.  */
  1144. X+   int filep;
  1145. X+ 
  1146. X+   tem = (char *) getenv ("TERMCAP");
  1147. X+   if (tem && *tem == 0) tem = 0;
  1148. X+ 
  1149. X+ #ifdef VMS
  1150. X+   filep = tem && legal_filename_p (tem);
  1151. X+ #else
  1152. X+   filep = tem && (*tem == '/');
  1153. X+ #endif /* VMS */
  1154. X+ 
  1155. X+   /* If tem is non-null and starts with / (in the un*x case, that is),
  1156. X+      it is a file name to use instead of /etc/termcap.
  1157. X+      If it is non-null and does not start with /,
  1158. X+      it is the entry itself, but only if
  1159. X+      the name the caller requested matches the TERM variable.  */
  1160. X+ 
  1161. X+   if (tem && !filep && !strcmp (name, getenv ("TERM")))
  1162. X+     {
  1163. X+       indirect = tgetst1 (find_capability (tem, "tc"), 0);
  1164. X+       if (!indirect)
  1165. X+     {
  1166. X+       if (!bp)
  1167. X+         bp = tem;
  1168. X+       else
  1169. X+         strcpy (bp, tem);
  1170. X+       goto ret;
  1171. X+     }
  1172. X+       else
  1173. X+     {            /* we will need to read /etc/termcap */
  1174. X+       tcenv = tem;
  1175. X+        tem = 0;
  1176. X+     }
  1177. X+     }
  1178. X+   else
  1179. X+     indirect = (char *) 0;
  1180. X+ 
  1181. X+   if (!tem)
  1182. X+ #ifdef VMS
  1183. X+     tem = "emacs_library:[etc]termcap.dat";
  1184. X+ #else
  1185. X+     tem = "/etc/termcap";
  1186. X+ #endif
  1187. X+ 
  1188. X+   /* Here we know we must search a file and tem has its name.  */
  1189. X+ 
  1190. X+   fd = open (tem, 0, 0);
  1191. X+   if (fd < 0)
  1192. X+     return -1;
  1193. X+ 
  1194. X+   buf.size = BUFSIZE;
  1195. X+   buf.beg = (char *) xmalloc (buf.size);
  1196. X+   term = indirect ? indirect : name;
  1197. X+ 
  1198. X+   if (!bp)
  1199. X+     {
  1200. X+       malloc_size = indirect ? strlen (tcenv) + 1 : buf.size;
  1201. X+       bp = (char *) xmalloc (malloc_size);
  1202. X+     }
  1203. X+   bp1 = bp;
  1204. X+ 
  1205. X+   if (indirect)            /* copy the data from the environment variable */
  1206. X+     {
  1207. X+       strcpy (bp, tcenv);
  1208. X+       bp1 += strlen (tcenv);
  1209. X+     }
  1210. X+ 
  1211. X+   while (term)
  1212. X+     {
  1213. X+       /* Scan file, reading it via buf, till find start of main entry */
  1214. X+       if (scan_file (term, fd, &buf) == 0)
  1215. X+     return 0;
  1216. X+ 
  1217. X+       /* Free old `term' if appropriate.  */
  1218. X+       if (term != name)
  1219. X+     free (term);
  1220. X+ 
  1221. X+       /* If `bp' is malloc'd by us, make sure it is big enough.  */
  1222. X+       if (malloc_size)
  1223. X+     {
  1224. X+       malloc_size = bp1 - bp + buf.size;
  1225. X+       tem = (char *) xrealloc (bp, malloc_size);
  1226. X+       bp1 += tem - bp;
  1227. X+       bp = tem;
  1228. X+     }
  1229. X+ 
  1230. X+       bp2 = bp1;
  1231. X+ 
  1232. X+       /* Copy the line of the entry from buf into bp.  */
  1233. X+       tem = buf.ptr;
  1234. X+       while ((*bp1++ = c = *tem++) && c != '\n')
  1235. X+     /* Drop out any \ newline sequence. */
  1236. X+     if (c == '\\' && *tem == '\n')
  1237. X+       {
  1238. X+         bp1--;
  1239. X+         tem++;
  1240. X+       }
  1241. X+       *bp1 = 0;
  1242. X+ 
  1243. X+       /* Does this entry refer to another terminal type's entry?  */
  1244. X+       /* If something is found, copy it into heap and null-terminate it */
  1245. X+       term = tgetst1 (find_capability (bp2, "tc"), 0);
  1246. X+     }
  1247. X+ 
  1248. X+   close (fd);
  1249. X+   free (buf.beg);
  1250. X+ 
  1251. X+   if (malloc_size)
  1252. X+     {
  1253. X+       bp = (char *) xrealloc (bp, bp1 - bp + 1);
  1254. X+     }
  1255. X+ 
  1256. X+  ret:
  1257. X+   term_entry = bp;
  1258. X+   if (malloc_size)
  1259. X+     return (int) bp;
  1260. X+   return 1;
  1261. X+ }
  1262. X+ 
  1263. X+ /* Given file open on `fd' and buffer `bufp',
  1264. X+    scan the file from the beginning until a line is found
  1265. X+    that starts the entry for terminal type `string'.
  1266. X+    Returns 1 if successful, with that line in `bufp',
  1267. X+    or returns 0 if no entry found in the file.  */
  1268. X+ 
  1269. X+ static int
  1270. X+ scan_file (string, fd, bufp)
  1271. X+      char *string;
  1272. X+      int fd;
  1273. X+      register struct buffer *bufp;
  1274. X+ {
  1275. X+   register char *tem;
  1276. X+   register char *end;
  1277. X+ 
  1278. X+   bufp->ptr = bufp->beg;
  1279. X+   bufp->full = 0;
  1280. X+   bufp->ateof = 0;
  1281. X+   *bufp->ptr = 0;
  1282. X+ 
  1283. X+   lseek (fd, 0L, 0);
  1284. X+ 
  1285. X+   while (!bufp->ateof)
  1286. X+     {
  1287. X+       /* Read a line into the buffer */
  1288. X+       end = 0;
  1289. X+       do
  1290. X+     {
  1291. X+       /* if it is continued, append another line to it,
  1292. X+          until a non-continued line ends */
  1293. X+       end = gobble_line (fd, bufp, end);
  1294. X+     }
  1295. X+       while (!bufp->ateof && end[-2] == '\\');
  1296. X+ 
  1297. X+       if (*bufp->ptr != '#'
  1298. X+       && name_match (bufp->ptr, string))
  1299. X+     return 1;
  1300. X+ 
  1301. X+       /* Discard the line just processed */
  1302. X+       bufp->ptr = end;
  1303. X+     }
  1304. X+   return 0;
  1305. X+ }
  1306. X+ 
  1307. X+ /* Return nonzero if NAME is one of the names specified
  1308. X+    by termcap entry LINE.  */
  1309. X+ 
  1310. X+ static int
  1311. X+ name_match (line, name)
  1312. X+      char *line, *name;
  1313. X+ {
  1314. X+   register char *tem;
  1315. X+ 
  1316. X+   if (!compare_contin (line, name))
  1317. X+     return 1;
  1318. X+   /* This line starts an entry.  Is it the right one?  */
  1319. X+   for (tem = line; *tem && *tem != '\n' && *tem != ':'; tem++)
  1320. X+     if (*tem == '|' && !compare_contin (tem + 1, name))
  1321. X+       return 1;
  1322. X+ 
  1323. X+   return 0;
  1324. X+ }
  1325. X+ 
  1326. X+ static int
  1327. X+ compare_contin (str1, str2)
  1328. X+      register char *str1, *str2;
  1329. X+ {
  1330. X+   register int c1, c2;
  1331. X+   while (1)
  1332. X+     {
  1333. X+       c1 = *str1++;
  1334. X+       c2 = *str2++;
  1335. X+       while (c1 == '\\' && *str1 == '\n')
  1336. X+     {
  1337. X+       str1++;
  1338. X+       while ((c1 = *str1++) == ' ' || c1 == '\t');
  1339. X+     }
  1340. X+       if (c2 == '\0')        /* end of type being looked up */
  1341. X+     {
  1342. X+       if (c1 == '|' || c1 == ':') /* If end of name in data base, */
  1343. X+         return 0;        /* we win. */
  1344. X+       else
  1345. X+         return 1;
  1346. X+         }
  1347. X+       else if (c1 != c2)
  1348. X+     return 1;
  1349. X+     }
  1350. X+ }
  1351. X+ 
  1352. X+ /* Make sure that the buffer <- `bufp' contains a full line
  1353. X+    of the file open on `fd', starting at the place `bufp->ptr'
  1354. X+    points to.  Can read more of the file, discard stuff before
  1355. X+    `bufp->ptr', or make the buffer bigger.
  1356. X+ 
  1357. X+    Returns the pointer to after the newline ending the line,
  1358. X+    or to the end of the file, if there is no newline to end it.
  1359. X+ 
  1360. X+    Can also merge on continuation lines.  If `append_end' is
  1361. X+    nonzero, it points past the newline of a line that is
  1362. X+    continued; we add another line onto it and regard the whole
  1363. X+    thing as one line.  The caller decides when a line is continued.  */
  1364. X+ 
  1365. X+ static char *
  1366. X+ gobble_line (fd, bufp, append_end)
  1367. X+      int fd;
  1368. X+      register struct buffer *bufp;
  1369. X+      char *append_end;
  1370. X+ {
  1371. X+   register char *end;
  1372. X+   register int nread;
  1373. X+   register char *buf = bufp->beg;
  1374. X+   register char *tem;
  1375. X+ 
  1376. X+   if (append_end == 0)
  1377. X+     append_end = bufp->ptr;
  1378. X+ 
  1379. X+   while (1)
  1380. X+     {
  1381. X+       end = append_end;
  1382. X+       while (*end && *end != '\n') end++;
  1383. X+       if (*end)
  1384. X+         break;
  1385. X+       if (bufp->ateof)
  1386. X+     return buf + bufp->full;
  1387. X+       if (bufp->ptr == buf)
  1388. X+     {
  1389. X+       if (bufp->full == bufp->size)
  1390. X+         {
  1391. X+           bufp->size *= 2;
  1392. X+           tem = (char *) xrealloc (buf, bufp->size);
  1393. X+           bufp->ptr += tem - buf;
  1394. X+           append_end += tem - buf;
  1395. X+           bufp->beg = buf = tem;
  1396. X+         }
  1397. X+     }
  1398. X+       else
  1399. X+     {
  1400. X+       append_end -= bufp->ptr - buf;
  1401. X+       bcopy (bufp->ptr, buf, bufp->full -= bufp->ptr - buf);
  1402. X+       bufp->ptr = buf;
  1403. X+     }
  1404. X+       if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full)))
  1405. X+     bufp->ateof = 1;
  1406. X+       bufp->full += nread;
  1407. X+       if (bufp->full != bufp->size)
  1408. X+     buf[bufp->full] = 0;
  1409. X+     }
  1410. X+   return end + 1;
  1411. X+ }
  1412. X+ 
  1413. X+ #ifdef TEST
  1414. X+ 
  1415. X+ #include <stdio.h>
  1416. X+ 
  1417. X+ main (argc, argv)
  1418. X+      int argc;
  1419. X+      char **argv;
  1420. X+ {
  1421. X+   char *term;
  1422. X+   char *buf;
  1423. X+ 
  1424. X+   term = argv[1];
  1425. X+   printf ("TERM: %s\n", term);
  1426. X+ 
  1427. X+   buf = (char *) tgetent (0, term);
  1428. X+   if ((int) buf <= 0)
  1429. X+     {
  1430. X+       printf ("No entry.\n");
  1431. X+       return 0;
  1432. X+     }
  1433. X+ 
  1434. X+   printf ("Entry: %s\n", buf);
  1435. X+ 
  1436. X+   tprint ("cm");
  1437. X+   tprint ("AL");
  1438. X+ 
  1439. X+   printf ("co: %d\n", tgetnum ("co"));
  1440. X+   printf ("am: %d\n", tgetflag ("am"));
  1441. X+ }
  1442. X+ 
  1443. X+ tprint (cap)
  1444. X+      char *cap;
  1445. X+ {
  1446. X+   char *x = tgetstr (cap, 0);
  1447. X+   register char *y;
  1448. X+ 
  1449. X+   printf ("%s: ", cap);
  1450. X+   if (x)
  1451. X+     {
  1452. X+       for (y = x; *y; y++)
  1453. X+     if (*y <= ' ' || *y == 0177)
  1454. X+       printf ("\\%0o", *y);
  1455. X+     else
  1456. X+       putchar (*y);
  1457. X+       free (x);
  1458. X+     }
  1459. X+   else
  1460. X+     printf ("none");
  1461. X+   putchar ('\n');
  1462. X+ }
  1463. X+ 
  1464. X+ #endif /* TEST */
  1465. X*** /dev/null    Wed Sep 27 12:47:48 1989
  1466. X--- vms/vmstparam.c    Sat Sep 16 12:24:46 1989
  1467. X***************
  1468. X*** 0 ****
  1469. X--- 1,360 ----
  1470. X+ /* Merge parameters into a termcap entry string.
  1471. X+    Copyright (C) 1985, 1987 Free Software Foundation, Inc.
  1472. X+ 
  1473. X+ 
  1474. X+                NO WARRANTY
  1475. X+ 
  1476. X+   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  1477. X+ NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  1478. X+ WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  1479. X+ RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  1480. X+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  1481. X+ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1482. X+ FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  1483. X+ AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  1484. X+ DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  1485. X+ CORRECTION.
  1486. X+ 
  1487. X+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  1488. X+ STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  1489. X+ WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  1490. X+ LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  1491. X+ OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  1492. X+ USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  1493. X+ DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  1494. X+ A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  1495. X+ PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  1496. X+ DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  1497. X+ 
  1498. X+         GENERAL PUBLIC LICENSE TO COPY
  1499. X+ 
  1500. X+   1. You may copy and distribute verbatim copies of this source file
  1501. X+ as you receive it, in any medium, provided that you conspicuously and
  1502. X+ appropriately publish on each copy a valid copyright notice "Copyright
  1503. X+ (C) 1986 Free Software Foundation, Inc."; and include following the
  1504. X+ copyright notice a verbatim copy of the above disclaimer of warranty
  1505. X+ and of this License.  You may charge a distribution fee for the
  1506. X+ physical act of transferring a copy.
  1507. X+ 
  1508. X+   2. You may modify your copy or copies of this source file or
  1509. X+ any portion of it, and copy and distribute such modifications under
  1510. X+ the terms of Paragraph 1 above, provided that you also do the following:
  1511. X+ 
  1512. X+     a) cause the modified files to carry prominent notices stating
  1513. X+     that you changed the files and the date of any change; and
  1514. X+ 
  1515. X+     b) cause the whole of any work that you distribute or publish,
  1516. X+     that in whole or in part contains or is a derivative of this
  1517. X+     program or any part thereof, to be licensed at no charge to all
  1518. X+     third parties on terms identical to those contained in this
  1519. X+     License Agreement (except that you may choose to grant more extensive
  1520. X+     warranty protection to some or all third parties, at your option).
  1521. X+ 
  1522. X+     c) You may charge a distribution fee for the physical act of
  1523. X+     transferring a copy, and you may at your option offer warranty
  1524. X+     protection in exchange for a fee.
  1525. X+ 
  1526. X+ Mere aggregation of another unrelated program with this program (or its
  1527. X+ derivative) on a volume of a storage or distribution medium does not bring
  1528. X+ the other program under the scope of these terms.
  1529. X+ 
  1530. X+   3. You may copy and distribute this program (or a portion or derivative
  1531. X+ of it, under Paragraph 2) in object code or executable form under the terms
  1532. X+ of Paragraphs 1 and 2 above provided that you also do one of the following:
  1533. X+ 
  1534. X+     a) accompany it with the complete corresponding machine-readable
  1535. X+     source code, which must be distributed under the terms of
  1536. X+     Paragraphs 1 and 2 above; or,
  1537. X+ 
  1538. X+     b) accompany it with a written offer, valid for at least three
  1539. X+     years, to give any third party free (except for a nominal
  1540. X+     shipping charge) a complete machine-readable copy of the
  1541. X+     corresponding source code, to be distributed under the terms of
  1542. X+     Paragraphs 1 and 2 above; or,
  1543. X+ 
  1544. X+     c) accompany it with the information you received as to where the
  1545. X+     corresponding source code may be obtained.  (This alternative is
  1546. X+     allowed only for noncommercial distribution and only if you
  1547. X+     received the program in object code or executable form alone.)
  1548. X+ 
  1549. X+ For an executable file, complete source code means all the source code for
  1550. X+ all modules it contains; but, as a special exception, it need not include
  1551. X+ source code for modules which are standard libraries that accompany the
  1552. X+ operating system on which the executable file runs.
  1553. X+ 
  1554. X+   4. You may not copy, sublicense, distribute or transfer this program
  1555. X+ except as expressly provided under this License Agreement.  Any attempt
  1556. X+ otherwise to copy, sublicense, distribute or transfer this program is void and
  1557. X+ your rights to use the program under this License agreement shall be
  1558. X+ automatically terminated.  However, parties who have received computer
  1559. X+ software programs from you with this License Agreement will not have
  1560. X+ their licenses terminated so long as such parties remain in full compliance.
  1561. X+ 
  1562. X+   5. If you wish to incorporate parts of this program into other free
  1563. X+ programs whose distribution conditions are different, write to the Free
  1564. X+ Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  1565. X+ worked out a simple rule that can be stated here, but we will often permit
  1566. X+ this.  We will be guided by the two goals of preserving the free status of
  1567. X+ all derivatives of our free software and of promoting the sharing and reuse of
  1568. X+ software.
  1569. X+ 
  1570. X+ 
  1571. X+ In other words, you are welcome to use, share and improve this program.
  1572. X+ You are forbidden to forbid anyone else to use, share and improve
  1573. X+ what you give them.   Help stamp out software-hoarding!  */
  1574. X+ 
  1575. X+ 
  1576. X+ /* config.h may rename various library functions such as malloc.  */
  1577. X+ #ifdef emacs
  1578. X+ #include "config.h"
  1579. X+ #endif
  1580. X+ 
  1581. X+ /* Assuming STRING is the value of a termcap string entry
  1582. X+    containing `%' constructs to expand parameters,
  1583. X+    merge in parameter values and store result in block OUTSTRING points to.
  1584. X+    LEN is the length of OUTSTRING.  If more space is needed,
  1585. X+    a block is allocated with `malloc'.
  1586. X+ 
  1587. X+    The value returned is the address of the resulting string.
  1588. X+    This may be OUTSTRING or may be the address of a block got with `malloc'.
  1589. X+    In the latter case, the caller must free the block.
  1590. X+ 
  1591. X+    The fourth and following args to tparam serve as the parameter values.  */
  1592. X+ 
  1593. X+ static char *tparam1 ();
  1594. X+ 
  1595. X+ /* VARARGS 2 */
  1596. X+ char *
  1597. X+ tparam (string, outstring, len, arg0, arg1, arg2, arg3)
  1598. X+      char *string;
  1599. X+      char *outstring;
  1600. X+      int len;
  1601. X+      int arg0, arg1, arg2, arg3;
  1602. X+ {
  1603. X+ #ifdef NO_ARG_ARRAY
  1604. X+   int arg[4];
  1605. X+   arg[0] = arg0;
  1606. X+   arg[1] = arg1;
  1607. X+   arg[2] = arg2;
  1608. X+   arg[3] = arg3;
  1609. X+   return tparam1 (string, outstring, len, 0, 0, arg);
  1610. X+ #else
  1611. X+   return tparam1 (string, outstring, len, 0, 0, &arg0);
  1612. X+ #endif
  1613. X+ }
  1614. X+ 
  1615. X+ char *BC;
  1616. X+ char *UP;
  1617. X+ 
  1618. X+ static char tgoto_buf[50];
  1619. X+ 
  1620. X+ char *
  1621. X+ tgoto (cm, hpos, vpos)
  1622. X+      char *cm;
  1623. X+      int hpos, vpos;
  1624. X+ {
  1625. X+   int args[2];
  1626. X+   if (!cm)
  1627. X+     return 0;
  1628. X+   args[0] = vpos;
  1629. X+   args[1] = hpos;
  1630. X+   return tparam1 (cm, tgoto_buf, 50, UP, BC, args);
  1631. X+ }
  1632. X+ 
  1633. X+ static char *
  1634. X+ tparam1 (string, outstring, len, up, left, argp)
  1635. X+      char *string;
  1636. X+      char *outstring;
  1637. X+      int len;
  1638. X+      char *up, *left;
  1639. X+      register int *argp;
  1640. X+ {
  1641. X+   register int c;
  1642. X+   register char *p = string;
  1643. X+   register char *op = outstring;
  1644. X+   char *outend;
  1645. X+   int outlen = 0;
  1646. X+ 
  1647. X+   register int tem;
  1648. X+   int *oargp = argp;
  1649. X+   int doleft = 0;
  1650. X+   int doup = 0;
  1651. X+ 
  1652. X+   outend = outstring + len;
  1653. X+ 
  1654. X+   while (1)
  1655. X+     {
  1656. X+       /* If the buffer might be too short, make it bigger.  */
  1657. X+       if (op + 5 >= outend)
  1658. X+     {
  1659. X+       register char *new;
  1660. X+       if (outlen == 0)
  1661. X+         {
  1662. X+           new = (char *) malloc (outlen = 40 + len);
  1663. X+           outend += 40;
  1664. X+         }
  1665. X+       else
  1666. X+         {
  1667. X+           outend += outlen;
  1668. X+           new = (char *) realloc (outstring, outlen *= 2);
  1669. X+         }
  1670. X+       op += new - outstring;
  1671. X+       outend += new - outstring;
  1672. X+       outstring = new;
  1673. X+     }
  1674. X+       if (!(c = *p++))
  1675. X+     break;
  1676. X+       if (c == '%')
  1677. X+     {
  1678. X+       c = *p++;
  1679. X+       tem = *argp;
  1680. X+       switch (c)
  1681. X+         {
  1682. X+         case 'd':        /* %d means output in decimal */
  1683. X+           if (tem < 10)
  1684. X+         goto onedigit;
  1685. X+           if (tem < 100)
  1686. X+         goto twodigit;
  1687. X+         case '3':        /* %3 means output in decimal, 3 digits. */
  1688. X+           if (tem > 999)
  1689. X+         {
  1690. X+           *op++ = tem / 1000 + '0';
  1691. X+           tem %= 1000;
  1692. X+         }
  1693. X+           *op++ = tem / 100 + '0';
  1694. X+         case '2':        /* %2 means output in decimal, 2 digits. */
  1695. X+         twodigit:
  1696. X+           tem %= 100;
  1697. X+           *op++ = tem / 10 + '0';
  1698. X+         onedigit:
  1699. X+           *op++ = tem % 10 + '0';
  1700. X+           argp++;
  1701. X+           break;
  1702. X+ 
  1703. X+         case 'C':
  1704. X+           /* For c-100: print quotient of value by 96, if nonzero,
  1705. X+          then do like %+ */
  1706. X+           if (tem >= 96)
  1707. X+         {
  1708. X+           *op++ = tem / 96;
  1709. X+           tem %= 96;
  1710. X+         }
  1711. X+         case '+':        /* %+x means add character code of char x */
  1712. X+           tem += *p++;
  1713. X+         case '.':        /* %. means output as character */
  1714. X+           if (left)
  1715. X+         {
  1716. X+           /* If want to forbid output of 0 and \n and \t,
  1717. X+              and this is one of them, increment it.  */
  1718. X+           while (tem == 0 || tem == '\n' || tem == '\t')
  1719. X+             {
  1720. X+               tem++;
  1721. X+               if (argp == oargp)
  1722. X+             doleft++, outend -= strlen (left);
  1723. X+               else
  1724. X+             doup++, outend -= strlen (up);
  1725. X+             }
  1726. X+         }
  1727. X+           *op++ = tem | 0200;
  1728. X+         case 'f':        /* %f means discard next arg */
  1729. X+           argp++;
  1730. X+           break;
  1731. X+ 
  1732. X+         case 'b':        /* %b means back up one arg (and re-use it) */
  1733. X+           argp--;
  1734. X+           break;
  1735. X+ 
  1736. X+         case 'r':        /* %r means interchange following two args */
  1737. X+           argp[0] = argp[1];
  1738. X+           argp[1] = tem;
  1739. X+           oargp++;
  1740. X+           break;
  1741. X+ 
  1742. X+         case '>':        /* %>xy means if arg is > char code of x, */
  1743. X+           if (argp[0] > *p++) /* then add char code of y to the arg, */
  1744. X+         argp[0] += *p;    /* and in any case don't output. */
  1745. X+           p++;        /* Leave the arg to be output later. */
  1746. X+           break;
  1747. X+ 
  1748. X+         case 'a':        /* %a means arithmetic */
  1749. X+           /* Next character says what operation.
  1750. X+          Add or subtract either a constant or some other arg */
  1751. X+           /* First following character is + to add or - to subtract
  1752. X+          or = to assign.  */
  1753. X+           /* Next following char is 'p' and an arg spec
  1754. X+          (0100 plus position of that arg relative to this one)
  1755. X+          or 'c' and a constant stored in a character */
  1756. X+           tem = p[2] & 0177;
  1757. X+           if (p[1] == 'p')
  1758. X+         tem = argp[tem - 0100];
  1759. X+           if (p[0] == '-')
  1760. X+         argp[0] -= tem;
  1761. X+           else if (p[0] == '+')
  1762. X+         argp[0] += tem;
  1763. X+           else if (p[0] == '*')
  1764. X+         argp[0] *= tem;
  1765. X+           else if (p[0] == '/')
  1766. X+         argp[0] /= tem;
  1767. X+           else
  1768. X+         argp[0] = tem;
  1769. X+ 
  1770. X+           p += 3;
  1771. X+           break;
  1772. X+ 
  1773. X+         case 'i':        /* %i means add one to arg, */
  1774. X+           argp[0] ++;    /* and leave it to be output later. */
  1775. X+           argp[1] ++;    /* Increment the following arg, too!  */
  1776. X+           break;
  1777. X+ 
  1778. X+         case '%':        /* %% means output %; no arg. */
  1779. X+           goto ordinary;
  1780. X+ 
  1781. X+         case 'n':        /* %n means xor each of next two args with 140 */
  1782. X+           argp[0] ^= 0140;
  1783. X+           argp[1] ^= 0140;
  1784. X+           break;
  1785. X+ 
  1786. X+         case 'm':        /* %m means xor each of next two args with 177 */
  1787. X+           argp[0] ^= 0177;
  1788. X+           argp[1] ^= 0177;
  1789. X+           break;
  1790. X+ 
  1791. X+         case 'B':        /* %B means express arg as BCD char code. */
  1792. X+           argp[0] += 6 * (tem / 10);
  1793. X+           break;
  1794. X+ 
  1795. X+         case 'D':        /* %D means weird Delta Data transformation */
  1796. X+           argp[0] -= 2 * (tem % 16);
  1797. X+           break;
  1798. X+         }
  1799. X+     }
  1800. X+       else
  1801. X+     /* Ordinary character in the argument string.  */
  1802. X+       ordinary:
  1803. X+     *op++ = c;
  1804. X+     }
  1805. X+   *op = 0;
  1806. X+   while (doleft-- > 0)
  1807. X+     strcpy (op, left);
  1808. X+   while (doup-- > 0)
  1809. X+     strcpy (op, up);
  1810. X+   return outstring;
  1811. X+ }
  1812. X+ 
  1813. X+ #ifdef DEBUG
  1814. X+ 
  1815. X+ main (argc, argv)
  1816. X+      int argc;
  1817. X+      char **argv;
  1818. X+ {
  1819. X+   char buf[50];
  1820. X+   int args[3];
  1821. X+   args[0] = atoi (argv[2]);
  1822. X+   args[1] = atoi (argv[3]);
  1823. X+   args[2] = atoi (argv[4]);
  1824. X+   tparam1 (argv[1], buf, "LEFT", "UP", args);
  1825. X+   printf ("%s\n", buf);
  1826. X+   return 0;
  1827. X+ }
  1828. X+ 
  1829. X+ #endif /* DEBUG */
  1830. X*** /dev/null    Wed Sep 27 12:48:01 1989
  1831. X--- vms/vmstty.c    Wed Sep 27 09:29:57 1989
  1832. X***************
  1833. X*** 0 ****
  1834. X--- 1,170 ----
  1835. X+ /*    SCCS Id: @(#)vmstty.c    3.0    88/05/03
  1836. X+ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1837. X+ /* NetHack may be freely redistributed.  See license for details. */
  1838. X+ /* tty.c - (VMS) version */
  1839. X+ 
  1840. X+ #define NEED_VARARGS
  1841. X+ #include "hack.h"
  1842. X+ 
  1843. X+ #include    <descrip.h>
  1844. X+ #include    <iodef.h>
  1845. X+ #include    <smgdef.h>
  1846. X+ 
  1847. X+ #define LIB$M_CLI_CTRLT 0x100000
  1848. X+ #define LIB$M_CLI_CTRLY 0x2000000
  1849. X+ 
  1850. X+ extern short ospeed;
  1851. X+ char erase_char, intr_char, kill_char;
  1852. X+ static boolean settty_needed = FALSE;
  1853. X+ static unsigned int kb = 0;
  1854. X+ 
  1855. X+ int
  1856. X+ vms_getchar()
  1857. X+ {
  1858. X+     short key;
  1859. X+ 
  1860. X+     if (kb)
  1861. X+     {
  1862. X+     SMG$READ_KEYSTROKE(&kb, &key);
  1863. X+     switch (key)
  1864. X+     {
  1865. X+       case SMG$K_TRM_UP:
  1866. X+         key = 'k';
  1867. X+         break;
  1868. X+       case SMG$K_TRM_DOWN:
  1869. X+         key = 'j';
  1870. X+         break;
  1871. X+       case SMG$K_TRM_LEFT:
  1872. X+         key = 'h';
  1873. X+         break;
  1874. X+       case SMG$K_TRM_RIGHT:
  1875. X+         key = 'l';
  1876. X+         break;
  1877. X+       case '\r':
  1878. X+         key = '\n';
  1879. X+         break;
  1880. X+       default:
  1881. X+         if (key == '\007' || key == '\032' || key > 255)
  1882. X+         key = '\033';
  1883. X+         break;
  1884. X+     }
  1885. X+     }
  1886. X+     else
  1887. X+     key = getchar();
  1888. X+     return key;
  1889. X+ }
  1890. X+ 
  1891. X+ static struct sensemode {
  1892. X+     short status;
  1893. X+     unsigned char xmit_baud;
  1894. X+     unsigned char rcv_baud;
  1895. X+     unsigned char crfill;
  1896. X+     unsigned char lffill;
  1897. X+     unsigned char parity;
  1898. X+     unsigned char unused;
  1899. X+     char class;
  1900. X+     char type;
  1901. X+     short scr_wid;
  1902. X+     unsigned long tt_char: 24, scr_len: 8;
  1903. X+     unsigned long tt2_char;
  1904. X+ } sg;
  1905. X+ unsigned int ctrl_mask;
  1906. X+ 
  1907. X+ static void
  1908. X+ setctty(){
  1909. X+ }
  1910. X+ 
  1911. X+ /*
  1912. X+  * Get initial state of terminal, set ospeed (for termcap routines)
  1913. X+  * and switch off tab expansion if necessary.
  1914. X+  * Called by startup() in termcap.c and after returning from ! or ^Z
  1915. X+  */
  1916. X+ void
  1917. X+ gettty(){
  1918. X+     int status;
  1919. X+     int input_chan;
  1920. X+     $DESCRIPTOR (input_dsc, "TT");
  1921. X+     unsigned int zero = 0;
  1922. X+ 
  1923. X+     if (!(SYS$ASSIGN (&input_dsc, &input_chan, 0, 0) & 1))
  1924. X+     perror("NetHack (gettty)");
  1925. X+     status = SYS$QIOW(0, input_chan, IO$_SENSEMODE, &sg, 0, 0, &sg.class, 12,
  1926. X+               0, 0, 0, 0);
  1927. X+     SYS$DASSGN (input_chan);
  1928. X+     if (!(status & 1))
  1929. X+     perror("NetHack (gettty)");
  1930. X+     ospeed = sg.xmit_baud;
  1931. X+     erase_char = '\177';
  1932. X+     kill_char = '\025';
  1933. X+     intr_char = '\003';
  1934. X+     (void) LIB$ENABLE_CTRL(&zero, &ctrl_mask);
  1935. X+     /* Use the systems's values for lines and columns if it has any idea. */
  1936. X+     if (sg.scr_len)
  1937. X+     LI = sg.scr_len;
  1938. X+     if (sg.scr_wid)
  1939. X+     CO = sg.scr_wid;
  1940. X+     settty_needed = TRUE;
  1941. X+ }
  1942. X+ 
  1943. X+ #ifdef MAIL
  1944. X+ unsigned long pasteboard_id = 0;
  1945. X+ #endif
  1946. X+ 
  1947. X+ /* reset terminal to original state */
  1948. X+ void
  1949. X+ settty(s)
  1950. X+ char *s;
  1951. X+ {
  1952. X+     clear_screen();
  1953. X+     end_screen();
  1954. X+     if(s) Printf(s);
  1955. X+     (void) fflush(stdout);
  1956. X+     SMG$DELETE_VIRTUAL_KEYBOARD(&kb);
  1957. X+ #ifdef MAIL
  1958. X+     SMG$DELETE_PASTEBOARD(&pasteboard_id);
  1959. X+ #endif
  1960. X+     if (ctrl_mask)
  1961. X+         (void) LIB$ENABLE_CTRL(&ctrl_mask, 0);
  1962. X+     flags.echo = ON;
  1963. X+     flags.cbreak = OFF;
  1964. X+ }
  1965. X+ 
  1966. X+ #ifdef MAIL
  1967. X+ static void
  1968. X+ broadcast_ast(dummy)
  1969. X+ {
  1970. X+     extern int broadcasts;
  1971. X+ 
  1972. X+     broadcasts++;
  1973. X+ }
  1974. X+ #endif
  1975. X+ 
  1976. X+ void
  1977. X+ setftty(){
  1978. X+     unsigned int mask = LIB$M_CLI_CTRLT | LIB$M_CLI_CTRLY;
  1979. X+ 
  1980. X+     flags.cbreak = ON;
  1981. X+     flags.echo = OFF;
  1982. X+     (void) LIB$DISABLE_CTRL(&mask, 0);
  1983. X+     SMG$CREATE_VIRTUAL_KEYBOARD(&kb);
  1984. X+ #ifdef MAIL
  1985. X+     SMG$CREATE_PASTEBOARD(&pasteboard_id, 0, 0, 0, 0);
  1986. X+     SMG$SET_BROADCAST_TRAPPING(&pasteboard_id, broadcast_ast, 0);
  1987. X+ #endif
  1988. X+     start_screen();
  1989. X+ }
  1990. X+ 
  1991. X+ 
  1992. X+ /* fatal error */
  1993. X+ /*VARARGS1*/
  1994. X+ void
  1995. X+ error VA_DECL(char *,s)
  1996. X+     VA_START(s);
  1997. X+     VA_INIT(char *,s);
  1998. X+     if(settty_needed)
  1999. X+         settty(NULL);
  2000. X+     Vprintf(s,VA_ARGS);
  2001. X+     (void) putchar('\n');
  2002. X+     VA_END();
  2003. X+     exit(1);
  2004. X+ }
  2005. X
  2006. END_OF_FILE
  2007. if test 52494 -ne `wc -c <'patches04f'`; then
  2008.     echo shar: \"'patches04f'\" unpacked with wrong size!
  2009. fi
  2010. # end of 'patches04f'
  2011. fi
  2012. echo shar: End of archive 6 \(of 11\).
  2013. cp /dev/null ark6isdone
  2014. MISSING=""
  2015. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  2016.     if test ! -f ark${I}isdone ; then
  2017.     MISSING="${MISSING} ${I}"
  2018.     fi
  2019. done
  2020. if test "${MISSING}" = "" ; then
  2021.     echo You have unpacked all 11 archives.
  2022.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2023. else
  2024.     echo You still need to unpack the following archives:
  2025.     echo "        " ${MISSING}
  2026. fi
  2027. ##  End of shell archive.
  2028. exit 0
  2029.