home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume16 / nethck31 / part97 < prev    next >
Encoding:
Internet Message Format  |  1993-02-05  |  58.8 KB

  1. Path: uunet!news.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v16i105:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Part97/108
  5. Message-ID: <4470@master.CNA.TEK.COM>
  6. Date: 5 Feb 93 22:03:12 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 2265
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1656
  11.  
  12. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  13. Posting-number: Volume 16, Issue 105
  14. Archive-name: nethack31/Part97
  15. Supersedes: nethack3p9: Volume 10, Issue 46-108
  16. Environment: Amiga, Atari, Mac, MS-DOS, OS2, Unix, VMS, X11
  17.  
  18.  
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 97 (of 108)."
  27. # Contents:  doc/dgn_comp.6 include/macconf.h include/tradstdc.h
  28. #   include/trampoli.h src/decl.c sys/unix/unixtty.c
  29. #   sys/unix/unixunix.c
  30. # Wrapped by billr@saab on Wed Jan 27 16:09:27 1993
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. if test -f 'doc/dgn_comp.6' -a "${1}" != "-c" ; then 
  33.   echo shar: Will not clobber existing file \"'doc/dgn_comp.6'\"
  34. else
  35. echo shar: Extracting \"'doc/dgn_comp.6'\" \(6956 characters\)
  36. sed "s/^X//" >'doc/dgn_comp.6' <<'END_OF_FILE'
  37. X.TH DGN_COMP 6 "1 May 1992"
  38. X.UC 4
  39. X.SH NAME
  40. Xdgn_comp \- NetHack dungeon compiler
  41. X.SH SYNOPSIS
  42. X.B dgn_comp
  43. X[
  44. X.I file
  45. X]
  46. X.PP
  47. XIf no arguments are given, it reads standard input.
  48. X.SH DESCRIPTION
  49. X.PP
  50. X.I Dgn_comp
  51. Xis a dungeon compiler for NetHack version 3.1 and higher.  It
  52. Xtakes a description file as an argument and produces a dungeon "script" 
  53. Xthat is to be loaded by NetHack at runtime.
  54. X.PP
  55. XThe purpose of this tool is to provide NetHack administrators and
  56. Ximplementors with a convenient way to create a custom dungeon for the
  57. Xgame, without having to recompile the entire world.
  58. X.SH GRAMMAR
  59. X.PP
  60. XDUNGEON: 
  61. X.B name
  62. X.B bonesmarker
  63. X(
  64. X.B base
  65. X,
  66. X.B rand
  67. X) [
  68. X.B %age
  69. X]
  70. X.PP
  71. Xwhere
  72. X.B name
  73. Xis the dungeon name,
  74. X.B bonesmarker
  75. Xis a letter for marking bones files, (
  76. X.B base
  77. X, 
  78. X.B rand
  79. X) is the number of levels, and
  80. X.B %age
  81. Xis its percentage chance of being generated (if absent, 100% chance).
  82. X
  83. XDESCRIPTION:
  84. X.B tag
  85. X.PP
  86. Xwhere
  87. X.B tag
  88. Xis currently one of
  89. X.BR HELLISH ,
  90. X.BR MAZELIKE ,
  91. Xor
  92. X.BR ROGUELIKE .
  93. X
  94. XALIGNMENT | LEVALIGN: [
  95. X.B lawful
  96. X|
  97. X.B neutral
  98. X|
  99. X.B chaotic
  100. X|
  101. X.B unaligned
  102. X]
  103. X.PP
  104. Xgives the alignment of the dungeon/level (default is unaligned).
  105. X
  106. XENTRY:
  107. X.B level
  108. X.PP
  109. Xthe dungeon entry point.  The dungeon connection attaches at this
  110. Xlevel of the given dungeon.
  111. XIf the value of
  112. X.B level
  113. Xis negative, the entry level is calculated from the bottom of the
  114. Xdungeon, with -1 being the last level.
  115. XIf this line is not present in a dungeon description, the entry level
  116. Xdefaults to 1.
  117. X
  118. XPROTOFILE:
  119. X.B name
  120. X.PP
  121. Xthe prototypical name for dungeon level files in this dungeon.
  122. XFor example, the PROTOFILE name for the dungeon
  123. X.I Vlad's Tower
  124. Xis
  125. X.IR tower .
  126. X
  127. XLEVEL:
  128. X.B name
  129. X.B bonesmarker
  130. X@ (
  131. X.B base
  132. X,
  133. X.B rand
  134. X) [
  135. X.B %age
  136. X]
  137. X.PP
  138. Xwhere
  139. X.B name
  140. Xis the level name,
  141. X.B bonesmarker
  142. Xis a letter for marking bones files, (
  143. X.B base
  144. X, 
  145. X.B rand
  146. X) is the location and
  147. X.B %age
  148. Xis the generation percentage, as above.
  149. X
  150. XRNDLEVEL:
  151. X.B name
  152. X.B bonesmarker
  153. X@ (
  154. X.B base
  155. X,
  156. X.B rand
  157. X)
  158. X[
  159. X.B %age
  160. X]
  161. X.B rndlevs
  162. X.PP
  163. Xwhere
  164. X.B name
  165. Xis the level name,
  166. X.B bonesmarker
  167. Xis a letter for marking bones files, (
  168. X.B base
  169. X, 
  170. X.B rand
  171. X) is the location,
  172. X.B %age
  173. Xis the generation percentage, as above, and
  174. X.B rndlevs
  175. Xis the number of similar levels available to choose from.
  176. X
  177. XCHAINLEVEL:
  178. X.B name
  179. X.B bonesmarker
  180. X.B prev_name
  181. X+ (
  182. X.B base
  183. X,
  184. X.B rand
  185. X) [
  186. X.B %age
  187. X]
  188. X.PP
  189. Xwhere
  190. X.B name
  191. Xis the level name,
  192. X.B bonesmarker
  193. Xis a letter for marking bones files,
  194. X.B prev_name
  195. Xis the name of a level defined previously, (
  196. X.B base
  197. X,
  198. X.B rand
  199. X) is the
  200. X.I offset
  201. Xfrom the level being chained from, and
  202. X.B %age
  203. Xis the generation percentage.
  204. X
  205. XRNDCHAINLEVEL:
  206. X.B name
  207. X.B bonesmarker
  208. X.B prev_name
  209. X+ (
  210. X.B base
  211. X,
  212. X.B rand
  213. X) [
  214. X.B %age
  215. X]
  216. X.B rndlevs
  217. X.PP
  218. Xwhere
  219. X.B name
  220. Xis the level name,
  221. X.B bonesmarker
  222. Xis a letter for marking bones files,
  223. X.B prev_name
  224. Xis the name of a level defined previously, (
  225. X.B base
  226. X,
  227. X.B rand
  228. X) is the
  229. X.I offset
  230. Xfrom the level being chained from,
  231. X.B %age
  232. Xis the generation percentage, and
  233. X.B rndlevs
  234. Xis the number of similar levels available to choose from.
  235. X
  236. XBRANCH:
  237. X.B name
  238. X@ (
  239. X.B base
  240. X,
  241. X.B rand
  242. X) [
  243. X.B stair
  244. X|
  245. X.B no_up
  246. X|
  247. X.B no_down
  248. X|
  249. X.B portal
  250. X] [
  251. X.B up
  252. X|
  253. X.B down
  254. X]
  255. X.PP
  256. Xwhere
  257. X.B name
  258. Xis the name of the dungeon to branch to, and (
  259. X.B base
  260. X,
  261. X.B rand
  262. X) is the location of the branch.
  263. XThe last two optional arguments are
  264. Xthe branch type and branch direction.
  265. XThe type of a branch can be a two-way stair connection,
  266. Xa one-way stair connection, or a magic portal.
  267. XA one-way stair is described by the types
  268. X.B no_up
  269. Xand
  270. X.B no_down
  271. Xwhich specify which stair direction is missing.
  272. XThe default branch type is
  273. X.BR stair .
  274. XThe direction for a stair can be either up or down; direction is not
  275. Xapplicable to portals.  The default direction is
  276. X.BR down .
  277. X
  278. XCHAINBRANCH:
  279. X.B name
  280. X.B prev_name
  281. X+ (
  282. X.B base
  283. X,
  284. X.B rand
  285. X) [
  286. X.B stair
  287. X|
  288. X.B no_up
  289. X|
  290. X.B no_down
  291. X|
  292. X.B portal
  293. X] [
  294. X.B up
  295. X|
  296. X.B down
  297. X]
  298. X.PP
  299. Xwhere
  300. X.B name
  301. Xis the name of the dungeon to branch to,
  302. X.B prev_name
  303. Xis the name of a previously defined
  304. X.B level
  305. Xand (
  306. X.B base
  307. X,
  308. X.B rand
  309. X) is the
  310. X.I offset
  311. Xfrom the level being chained from.
  312. XThe optional branch type and direction are the same as described above.
  313. X.SH GENERIC RULES
  314. X.PP
  315. XEach dungeon must have a unique
  316. X.B bonesmarker ,
  317. Xand each special level must have a
  318. X.B bonesmarker
  319. Xunique within its dungeon (letters may be reused in different dungeons).
  320. XIf the
  321. X.B bonesmarker
  322. Xhas the special value "none", no bones files will be created for that
  323. Xlevel or dungeon.
  324. X.PP
  325. XThe value
  326. X.B base
  327. Xmay be in the range of 1 to
  328. X.B MAXLEVEL
  329. X(as defined in
  330. X.I global.h
  331. X).
  332. X.PP
  333. XThe value
  334. X.B rand
  335. Xmay be in the range of -1 to
  336. X.BR MAXLEVEL .
  337. X.PP
  338. XIf
  339. X.B rand
  340. Xis -1 it will be replaced with the value (num_dunlevs(dungeon) - base)
  341. Xduring the load process (ie. from here to the end of the dungeon).
  342. X.PP
  343. XIf
  344. X.B rand
  345. Xis 0 the level is located absolutely at
  346. X.BR base .
  347. X.PP
  348. XBranches don't have a probability.  Dungeons do.  If a dungeon fails
  349. Xto be generated during load, all its levels and branches are skipped.
  350. X.PP
  351. XNo level or branch may be chained from a level with a percentage generation
  352. Xprobability.  This is to prevent non-resolution during the load.
  353. XIn addition, no branch may be made from a dungeon with a percentage
  354. Xgeneration probability for the same reason.
  355. X.PP
  356. XAs a general rule using the dungeon compiler:
  357. X.PP
  358. XIf a dungeon has a
  359. X.B protofile
  360. Xname associated with it
  361. X.RI ( eg.
  362. X.BR tower )
  363. Xthat file will be used.
  364. X.PP
  365. XIf a special level is present, it will override the above rule and
  366. Xthe appropriate file will be loaded.
  367. X.PP
  368. XIf neither of the above are present, the standard generator will
  369. Xtake over and make a "normal" level.
  370. X.PP
  371. XA level alignment, if present, will override
  372. Xthe alignment of the dungeon that it exists within.
  373. X.SH EXAMPLE
  374. X.PP
  375. XHere is the current syntax of the dungeon compiler's "language":
  376. X
  377. X.LP
  378. X.nf
  379. X.ta +8n +8n +8n
  380. X#
  381. X#    The dungeon description file for the "standard" original
  382. X#    3.0 NetHack.
  383. X#
  384. XDUNGEON:    "The Dungeons of Doom" "D" (25, 5)
  385. XLEVEL:        "rogue" "none" @ (15, 4)
  386. XLEVEL:        "oracle" "none" @ (5, 7)
  387. XLEVEL:        "bigroom" "B" @ (12, 3) 15
  388. XLEVEL:        "medusa" "none" @ (20, 5)
  389. XCHAINLEVEL:    "castle" "medusa" + (1, 4)
  390. XCHAINBRANCH:    "Hell" "castle" + (0, 0) no_down
  391. XBRANCH:        "The Astral Plane" @ (1, 0) no_down up
  392. X
  393. XDUNGEON:    "Hell" "H" (25, 5)
  394. XDESCRIPTION:    mazelike
  395. XDESCRIPTION:    hellish
  396. XBRANCH:        "Vlad's Tower" @ (13, 5) up
  397. XLEVEL:        "wizard" "none" @ (15, 10)
  398. XLEVEL:        "fakewiz" "A" @ (5, 5)
  399. XLEVEL:        "fakewiz" "B" @ (10, 5)
  400. XLEVEL:        "fakewiz" "C" @ (15, 5)
  401. XLEVEL:        "fakewiz" "D" @ (20, 5)
  402. XLEVEL:        "fakewiz" "E" @ (25, 5)
  403. X
  404. XDUNGEON:    "Vlad's Tower" "T" (3, 0)
  405. XPROTOFILE:    "tower"
  406. XDESCRIPTION:    mazelike
  407. XENTRY:        -1
  408. X
  409. XDUNGEON:    "The Astral Plane" "A" (1, 0)
  410. XDESCRIPTION:    mazelike
  411. XPROTOFILE:    "endgame"
  412. X.fi
  413. X.PP
  414. X.I NOTES:
  415. X.br
  416. XLines beginning with '#' are considered comments.
  417. X.br
  418. XA special level must be explicitly aligned.  The alignment of the dungeon
  419. Xit is in only applies to non-special levels within that dungeon.
  420. X.SH AUTHOR
  421. X.PP
  422. XM. Stephenson (from the level compiler by Jean-Christophe Collet).
  423. X.SH "SEE ALSO"
  424. X.PP
  425. Xlev_comp(6), nethack(6)
  426. X.SH BUGS
  427. X.PP
  428. XProbably infinite.
  429. END_OF_FILE
  430. if test 6956 -ne `wc -c <'doc/dgn_comp.6'`; then
  431.     echo shar: \"'doc/dgn_comp.6'\" unpacked with wrong size!
  432. fi
  433. # end of 'doc/dgn_comp.6'
  434. fi
  435. if test -f 'include/macconf.h' -a "${1}" != "-c" ; then 
  436.   echo shar: Will not clobber existing file \"'include/macconf.h'\"
  437. else
  438. echo shar: Extracting \"'include/macconf.h'\" \(7871 characters\)
  439. sed "s/^X//" >'include/macconf.h' <<'END_OF_FILE'
  440. X/*    SCCS Id: @(#)macconf.h    3.1    91/07/14    */
  441. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  442. X/* NetHack may be freely redistributed.  See license for details. */
  443. X
  444. X#ifdef MAC
  445. X# ifndef MACCONF_H
  446. X#  define MACCONF_H
  447. X
  448. X/*
  449. X * Select your compiler...
  450. X * This could probably be automagic later on - I believe there's
  451. X * a unique symbol for MPW at least (it's "macintosh")
  452. X */
  453. X#  define MAC_MPW32        /* Headers, and for avoiding a bug */
  454. X/* #  define MAC_THINKC5    /* Maybe supported now ... */
  455. X
  456. X#  define RANDOM
  457. X#  define NO_SIGNAL    /* You wouldn't believe our signals ... */
  458. X#  define FILENAME 256
  459. X
  460. X#  include "system.h"
  461. X
  462. Xtypedef long off_t ;
  463. X
  464. X/*
  465. X * Try and keep the number of files here to an ABSOLUTE minimum !
  466. X * include the relevant files in the relevant .c files instead !
  467. X */
  468. X#  include <segload.h>
  469. X#  include <stdlib.h>
  470. X#  include <windows.h>
  471. X#  include <memory.h>
  472. X#  include <quickdraw.h>
  473. X#  include <events.h>
  474. X#  include <controls.h>
  475. X#  include <dialogs.h>
  476. X#  include <fonts.h>
  477. X
  478. X/*
  479. X * We could use the PSN under sys 7 here ...
  480. X */
  481. X#  define getpid() 1
  482. X#  define getuid() 1
  483. X#  define index strchr
  484. X#  define rindex strrchr
  485. X
  486. X#  define Rand random
  487. X
  488. X#  define error progerror
  489. X
  490. X# if defined(VISION_TABLES) && defined(BRACES)
  491. X#  undef BRACES
  492. X# endif
  493. X
  494. X/*
  495. X * macfile.c
  496. X * MAC file I/O routines
  497. X */
  498. X
  499. Xextern int maccreat ( const char * name , long fileType ) ;
  500. Xextern int macopen ( const char * name , int flags , long fileType ) ;
  501. Xextern int macclose ( int fd ) ;
  502. Xextern int macread ( int fd , void * ptr , unsigned ) ;
  503. Xextern int macwrite ( int fd , void * ptr , unsigned ) ;
  504. Xextern long macseek ( int fd , long pos , short whence ) ;
  505. X
  506. X
  507. X# if !defined(O_WRONLY)
  508. X#  include <fcntl.h>
  509. X# endif
  510. X
  511. X#if !defined(SPEC_LEV) && !defined(DGN_COMP)
  512. X# define creat maccreat
  513. X# define open macopen
  514. X# define close macclose
  515. X# define read macread
  516. X# define write macwrite
  517. X# define lseek macseek
  518. X#endif
  519. X
  520. X# define TEXT_TYPE 'TEXT'
  521. X# define LEVL_TYPE 'LEVL'
  522. X# define BONE_TYPE 'BONE'
  523. X# define SAVE_TYPE 'SAVE'
  524. X# define PREF_TYPE 'PREF'
  525. X# define DATA_TYPE 'DATA'
  526. X# define MAC_CREATOR 'nh31' /* Registered with DTS ! */
  527. X
  528. Xtypedef struct macdirs {
  529. X    Str32        dataName ;
  530. X    short        dataRefNum ;
  531. X    long        dataDirID ;
  532. X
  533. X    Str32        saveName ;
  534. X    short        saveRefNum ;
  535. X    long        saveDirID ;
  536. X
  537. X    Str32        levelName ;
  538. X    short        levelRefNum ;
  539. X    long        levelDirID ;
  540. X} MacDirs ;
  541. X
  542. Xtypedef struct macflags {
  543. X    Bitfield ( processes , 1 ) ;
  544. X    Bitfield ( color , 1 ) ;
  545. X    Bitfield ( folders , 1 ) ;
  546. X    Bitfield ( tempMem , 1 ) ;
  547. X    Bitfield ( help , 1 ) ;
  548. X    Bitfield ( fsSpec , 1 ) ;
  549. X    Bitfield ( trueType , 1 ) ;
  550. X    Bitfield ( aux , 1 ) ;
  551. X    Bitfield ( alias , 1 ) ;
  552. X    Bitfield ( standardFile , 1 ) ;
  553. X} MacFlags ;
  554. X
  555. Xextern MacDirs theDirs ;
  556. Xextern MacFlags macFlags ;
  557. X
  558. X/*
  559. X * Mac windows
  560. X */
  561. X#define NUM_MACWINDOWS 15
  562. X#define TEXT_BLOCK 512L
  563. X#define WIN_BASE_RES 128
  564. X#define WIN_BASE_KIND 128
  565. X#define NUM_MENU_ITEMS 60 /* We've run out of letters by then ... */
  566. X#define CHAR_ENTER ((char)3)
  567. X#define CHAR_BS ((char)8)
  568. X#define CHAR_LF ((char)10)
  569. X#define CHAR_CR ((char)13)
  570. X#define CHAR_ESC ((char)27)
  571. X#define CHAR_BLANK ((char)32)
  572. X#define CHAR_DELETE ((char)127)
  573. X
  574. X#define MAC_GRAPHICS_ENV
  575. X
  576. X/* Window constants */
  577. X#define kMapWindow 0
  578. X#define kStatusWindow 1
  579. X#define kMessageWindow 2
  580. X#define kTextWindow 3
  581. X#define kMenuWindow 4
  582. X#define kLastWindowKind kMenuWindow
  583. X
  584. Xextern Boolean RetrievePosition ( short , short * , short * ) ;
  585. Xextern Boolean RetrieveSize ( short , short , short , short * , short * ) ;
  586. Xextern void SavePosition ( short , short , short ) ;
  587. Xextern void SaveSize ( short , short , short ) ;
  588. Xextern void SaveWindowPos ( WindowPtr ) ;
  589. Xextern void SaveWindowSize ( WindowPtr ) ;
  590. X
  591. X/*
  592. X * This determines the minimum logical line length in text windows
  593. X * That is; even if physical width is less, this is where line breaks
  594. X * go at the minimum. 350 is about right for score lines with a
  595. X * geneva 10 pt font.
  596. X */
  597. X#define MIN_RIGHT 350
  598. X
  599. X#define NUM_CANCEL_ITEMS 10
  600. X
  601. Xtypedef struct NhWindow {
  602. X    WindowPtr        theWindow ;
  603. X    short            kind ;
  604. X    void            ( * keyFunc ) ( EventRecord * , WindowPtr ) ;
  605. X    void            ( * clickFunc ) ( EventRecord * , WindowPtr ) ;
  606. X    void            ( * updateFunc ) ( EventRecord * , WindowPtr ) ;
  607. X    void            ( * cursorFunc ) ( EventRecord * , WindowPtr , RgnHandle ) ;
  608. X    Handle            windowText ;
  609. X    long            windowTextLen ;
  610. X    long            textBase ;
  611. X    Point            cursor ;        /* In CHARS / LINES */
  612. X    short            leading ;
  613. X    short            charHeight ;
  614. X    short            charWidth ;
  615. X    short            fontNum ;
  616. X    short            fontSize ;
  617. X    short            lin ;            /* Used by menus */
  618. X    short            wid ;            /* Used by menus */
  619. X    char            itemChars [ NUM_MENU_ITEMS ] ;
  620. X    char            cancelStr [ NUM_CANCEL_ITEMS ] ;
  621. X    char            cancelChar ;
  622. X    char            clear ;
  623. X    char            cursorDrawn ;
  624. X    short            scrollPos ;
  625. X    ControlHandle    scrollBar ;
  626. X} NhWindow ;
  627. X
  628. X#define NUM_STAT_ROWS 2
  629. X#define NUM_ROWS 22
  630. X#define NUM_COLS 81 /* We shouldn't use column 0 */
  631. X
  632. Xtypedef struct MapData {
  633. X    char        map [ NUM_ROWS ] [ NUM_COLS ] ;
  634. X} MapData ;
  635. X
  636. Xtypedef struct StatusData {
  637. X    char        map [ NUM_STAT_ROWS ] [ NUM_COLS ] ;
  638. X} StatusData ;
  639. X
  640. Xextern NhWindow * theWindows ;
  641. X
  642. Xextern struct window_procs mac_procs ;
  643. X
  644. Xextern short text_wind_font;
  645. X#define set_text_wind_font(fnt) (text_wind_font = fnt)
  646. X#define mono_font()    set_text_wind_font(monaco)
  647. X#define normal_font()    set_text_wind_font(geneva)
  648. X
  649. X#define E extern
  650. X
  651. X/*
  652. X * Define PORT_HELP to be the name of the port-specfic help file.
  653. X * This file is included into the resource fork of the application. 
  654. X */
  655. X#define PORT_HELP "MacHelp"
  656. X
  657. XE void NDECL(port_help);
  658. X
  659. XE void NDECL(mac_init_nhwindows);
  660. XE void NDECL(mac_player_selection);
  661. XE void NDECL(mac_askname);
  662. XE void NDECL(mac_get_nh_event) ;
  663. XE void FDECL(mac_exit_nhwindows, (const char *));
  664. XE void FDECL(mac_suspend_nhwindows, (const char *));
  665. XE void NDECL(mac_resume_nhwindows);
  666. XE winid FDECL(mac_create_nhwindow, (int));
  667. XE void FDECL(mac_clear_nhwindow, (winid));
  668. XE void FDECL(mac_display_nhwindow, (winid, BOOLEAN_P));
  669. XE void FDECL(mac_destroy_nhwindow, (winid));
  670. XE void FDECL(mac_curs, (winid,int,int));
  671. XE void FDECL(mac_putstr, (winid, int, const char *));
  672. XE void FDECL(mac_display_file, (const char *, BOOLEAN_P));
  673. XE void FDECL(mac_start_menu, (winid));
  674. XE void FDECL(mac_add_menu, (winid, CHAR_P, int, const char *));
  675. XE void FDECL(mac_end_menu, (winid, CHAR_P, const char *, const char *));
  676. XE char FDECL(mac_select_menu, (winid));
  677. XE void NDECL(mac_update_inventory);
  678. XE void NDECL(mac_mark_synch);
  679. XE void NDECL(mac_wait_synch);
  680. X#ifdef CLIPPING
  681. XE void FDECL(mac_cliparound, (int, int));
  682. X#endif
  683. XE void FDECL(mac_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
  684. XE void FDECL(mac_raw_print, (const char *));
  685. XE void FDECL(mac_raw_print_bold, (const char *));
  686. XE int NDECL(mac_nhgetch);
  687. XE int FDECL(mac_nh_poskey, (int *, int *, int *));
  688. XE void NDECL(mac_nhbell);
  689. XE int NDECL(mac_doprev_message);
  690. XE char FDECL(mac_yn_function, (const char *, const char *, CHAR_P));
  691. XE void FDECL(mac_getlin, (const char *,char *));
  692. X#ifdef COM_COMPL
  693. XE void FDECL(mac_get_ext_cmd, (char *));
  694. X#endif /* COM_COMPL */
  695. XE void FDECL(mac_number_pad, (int));
  696. XE void NDECL(mac_delay_output);
  697. X
  698. X/* defined in macwin.c and exported for used in mmodal.c */
  699. XE void        FDECL(HandleEvent, (EventRecord *));
  700. X
  701. X/* defined in mmodal.c */
  702. XE DialogPtr FDECL(mv_get_new_dialog, (short));
  703. XE void        FDECL(mv_close_dialog, (DialogPtr));
  704. XE void        FDECL(mv_modal_dialog, (ModalFilterProcPtr, short *));
  705. X
  706. X#undef E
  707. X
  708. Xextern void DimMenuBar ( void ) ;
  709. Xextern void UndimMenuBar ( void ) ;
  710. Xextern int SanePositions ( void ) ;
  711. X
  712. X#define NHW_BASE 0
  713. Xextern winid BASE_WINDOW , WIN_MAP , WIN_MESSAGE , WIN_INVEN , WIN_STATUS ;
  714. X
  715. Xextern Boolean itworked( short );
  716. Xextern void mustwork( short );
  717. Xextern void VDECL(progerror, (const char *,...));
  718. Xextern void attemptingto( char *  );
  719. Xextern void pushattemptingto( char *  );
  720. Xextern void popattempt( void );
  721. Xextern void UnloadAllSegments( void );
  722. Xextern void InitSegMgmt( void * );
  723. Xextern void IsResident ( void * );
  724. Xextern void NotResident ( void * );
  725. X
  726. X# endif /* ! MACCONF_H */
  727. X#endif /* MAC */
  728. END_OF_FILE
  729. if test 7871 -ne `wc -c <'include/macconf.h'`; then
  730.     echo shar: \"'include/macconf.h'\" unpacked with wrong size!
  731. fi
  732. # end of 'include/macconf.h'
  733. fi
  734. if test -f 'include/tradstdc.h' -a "${1}" != "-c" ; then 
  735.   echo shar: Will not clobber existing file \"'include/tradstdc.h'\"
  736. else
  737. echo shar: Extracting \"'include/tradstdc.h'\" \(7712 characters\)
  738. sed "s/^X//" >'include/tradstdc.h' <<'END_OF_FILE'
  739. X/*    SCCS Id: @(#)tradstdc.h    3.1    92/04/01    */
  740. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  741. X/* NetHack may be freely redistributed.  See license for details. */
  742. X
  743. X#ifndef TRADSTDC_H
  744. X#define TRADSTDC_H
  745. X
  746. X#if defined(DUMB) && !defined(NOVOID)
  747. X#define NOVOID
  748. X#endif
  749. X
  750. X#ifdef NOVOID
  751. X#define void int
  752. X#endif
  753. X
  754. X#if defined(__STDC__) && !defined(NOTSTDC)
  755. X#define NHSTDC
  756. X#endif
  757. X
  758. X#if defined(ultrix) && defined(__STDC__) && !defined(__LANGUAGE_C)
  759. X/* Ultrix seems to be in a constant state of flux.  This check attempts to
  760. X * set up ansi compatibility if it wasn't set up correctly by the compiler.
  761. X */
  762. X#ifdef mips
  763. X#define __mips mips
  764. X#endif
  765. X
  766. X#ifdef LANGUAGE_C
  767. X#define __LANGUAGE_C LANGUAGE_C
  768. X#endif
  769. X
  770. X#endif
  771. X
  772. X/*
  773. X * ANSI X3J11 detection.
  774. X * Makes substitutes for compatibility with the old C standard.
  775. X */
  776. X
  777. X/* Decide how to handle variable parameter lists:
  778. X * USE_STDARG means use the ANSI <stdarg.h> facilities (only ANSI compilers
  779. X * should do this, and only if the library supports it).
  780. X * USE_VARARGS means use the <varargs.h> facilities.  Again, this should only
  781. X * be done if the library supports it.  ANSI is *not* required for this.
  782. X * Otherwise, the kludgy old methods are used.
  783. X * The defaults are USE_STDARG for ANSI compilers, and USE_OLDARGS for
  784. X * others.
  785. X */
  786. X
  787. X/* #define USE_VARARGS        /* use <varargs.h> instead of <stdarg.h> */
  788. X/* #define USE_OLDARGS        /* don't use any variable argument facilites */
  789. X
  790. X#if defined(apollo)             /* Apollos have stdarg(3) but not stdarg.h */
  791. X# define USE_VARARGS
  792. X#endif
  793. X
  794. X#if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(MAC)
  795. X# if !defined(USE_VARARGS) && !defined(USE_OLDARGS) && !defined(USE_STDARG)
  796. X#   define USE_STDARG
  797. X# endif
  798. X#endif
  799. X
  800. X#ifdef NEED_VARARGS        /* only define these if necessary */
  801. X#ifdef USE_STDARG
  802. X# include <stdarg.h>
  803. X# define VA_DECL(typ1,var1)    (typ1 var1, ...) { va_list the_args;
  804. X# define VA_DECL2(typ1,var1,typ2,var2)    \
  805. X    (typ1 var1, typ2 var2, ...) { va_list the_args;
  806. X# define VA_INIT(var1,typ1)
  807. X# define VA_NEXT(var1,typ1)    var1 = va_arg(the_args, typ1)
  808. X# define VA_ARGS        the_args
  809. X# define VA_START(x)        va_start(the_args, x)
  810. X# define VA_END()        va_end(the_args)
  811. X# if defined(ULTRIX_PROTO) && !defined(_VA_LIST_)
  812. X#  define _VA_LIST_    /* prevents multiple def in stdio.h */
  813. X# endif
  814. X#else
  815. X# ifdef USE_VARARGS
  816. X#  include <varargs.h>
  817. X#  define VA_DECL(typ1,var1)    (va_alist) va_dcl {\
  818. X        va_list the_args; typ1 var1;
  819. X#  define VA_DECL2(typ1,var1,typ2,var2)    (va_alist) va_dcl {\
  820. X        va_list the_args; typ1 var1; typ2 var2;
  821. X#  define VA_ARGS        the_args
  822. X#  define VA_START(x)        va_start(the_args)
  823. X#  define VA_INIT(var1,typ1)    var1 = va_arg(the_args, typ1)
  824. X#  define VA_NEXT(var1,typ1)    var1 = va_arg(the_args,typ1)
  825. X#  define VA_END()        va_end(the_args)
  826. X# else
  827. X#   define VA_ARGS    arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9
  828. X#   define VA_DECL(typ1,var1)  (var1,VA_ARGS) typ1 var1; \
  829. X    char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; {
  830. X#   define VA_DECL2(typ1,var1,typ2,var2)  (var1,var2,VA_ARGS) \
  831. X    typ1 var1; typ2 var2;\
  832. X    char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; {
  833. X#   define VA_START(x)
  834. X#   define VA_INIT(var1,typ1)
  835. X#   define VA_END()
  836. X# endif
  837. X#endif
  838. X#endif /* NEED_VARARGS */
  839. X
  840. X#if defined(NHSTDC) || defined(MSDOS) || defined(MAC) || defined(ULTRIX_PROTO)
  841. X
  842. X/*
  843. X * Used for robust ANSI parameter forward declarations:
  844. X * int VDECL(sprintf, (char *, const char *, ...));
  845. X *
  846. X * NDECL() is used for functions with zero arguments;
  847. X * FDECL() is used for functions with a fixed number of arguments;
  848. X * VDECL() is used for functions with a variable number of arguments.
  849. X * Separate macros are needed because ANSI will mix old-style declarations
  850. X * with prototypes, except in the case of varargs, and the OVERLAY-specific
  851. X * trampoli.* mechanism conflicts with the ANSI <<f(void)>> syntax.
  852. X */
  853. X
  854. X# define NDECL(f)    f(void)    /* Must be overridden if OVERLAY set later */
  855. X
  856. X# define FDECL(f,p)    f p
  857. X
  858. X# if defined(MSDOS) || defined(USE_STDARG)
  859. X#  define VDECL(f,p)    f p
  860. X# else
  861. X#  define VDECL(f,p)    f()
  862. X# endif
  863. X
  864. X/* generic pointer, always a macro; genericptr_t is usually a typedef */
  865. X# define genericptr    void *
  866. X
  867. X# if defined(__TURBOC__) || (defined(ULTRIX_PROTO) && !defined(__GNUC__)) || defined(OS2_CSET2)
  868. X/* Cover for stupid Turbo C */
  869. X/* And Ultrix on a DECstation with 2.0 compiler, which coredumps on
  870. X *   typedef void * genericptr_t;
  871. X *   extern void a(void(*)(int, genericptr_t));
  872. X * Using the #define is OK for other compiler versions too.
  873. X */
  874. X/* And IBM CSet/2.  The redeclaration of free hoses the compile. */
  875. X#  define genericptr_t    genericptr
  876. X# else
  877. X#  if !defined(NHSTDC) && !defined(MAC)
  878. X#   define const
  879. X#   define signed
  880. X#   define volatile
  881. X#  endif
  882. X# endif
  883. X
  884. X# if !defined(LATTICE) && !defined(MAC)
  885. X        /* Lattice can't even PARSE the const below! */
  886. X        /* MPW can parse but expects an identifier, not a keyword... */
  887. X#  if defined(ULTRIX_PROTO) && !defined(NHSTDC) && !defined(const)
  888. X#  define const        /* the system header files are *not* __STDC__ */
  889. X#  endif
  890. X#  if defined(apollo) && !defined(const)
  891. X#  define const         /* too much trouble with printf(char *format, ...) */
  892. X#  endif                 /* instead of printf(const char *format, ...) etc. */
  893. X# endif
  894. X
  895. X#else /* NHSTDC */    /* a "traditional" C  compiler */
  896. X
  897. X# define NDECL(f)    f()
  898. X# define FDECL(f,p)    f()
  899. X# define VDECL(f,p)    f()
  900. X
  901. X# if defined(AMIGA) || defined(HPUX) || defined(POSIX_TYPES) || defined(__DECC)
  902. X#  define genericptr    void *
  903. X# endif
  904. X# ifndef genericptr
  905. X#  define genericptr    char *
  906. X# endif
  907. X
  908. X/*
  909. X * Traditional C compilers don't have "signed", "const", or "volatile".
  910. X */
  911. X# define signed
  912. X# define const
  913. X# define volatile
  914. X
  915. X#endif /* NHSTDC */
  916. X
  917. X
  918. X#ifndef genericptr_t
  919. Xtypedef genericptr genericptr_t;    /* (void *) or (char *) */
  920. X#endif
  921. X
  922. X
  923. X/*
  924. X * According to ANSI, prototypes for old-style declarations must widen the
  925. X * arguments to int.  However, the MSDOS compilers accept shorter arguments
  926. X * (char, short, etc.) in prototypes and do typechecking with them.  Therefore
  927. X * this mess to allow the better typechecking while also allowing some
  928. X * prototypes for the ANSI compilers so people quit trying to fix the
  929. X * prototypes to match the standard and thus lose the typechecking.
  930. X */
  931. X#if defined(MSDOS) && !defined(__TURBOC__) && !defined(__GO32__)
  932. X#define UNWIDENED_PROTOTYPES
  933. X#endif
  934. X#if defined(AMIGA) && !defined(AZTEC_50)
  935. X#define UNWIDENED_PROTOTYPES
  936. X#endif
  937. X#if defined(MAC) && !defined(THINK_C)
  938. X#define UNWIDENED_PROTOTYPES
  939. X#endif
  940. X
  941. X#if defined(ULTRIX_PROTO) && defined(ULTRIX_CC20)
  942. X#define UNWIDENED_PROTOTYPES
  943. X#endif
  944. X#if defined(apollo)
  945. X#define UNWIDENED_PROTOTYPES
  946. X#endif
  947. X
  948. X#ifndef UNWIDENED_PROTOTYPES
  949. X# if defined(NHSTDC) || defined(__TURBOC__) || defined(ULTRIX_PROTO) || defined(THINK_C)
  950. X# define WIDENED_PROTOTYPES
  951. X# endif
  952. X#endif
  953. X
  954. X#if defined(sgi) && !defined(__GNUC__)
  955. X/*
  956. X * As of IRIX 4.0.1, /bin/cc claims to be an ANSI compiler, but it thinks
  957. X * it's impossible for a prototype to match an old-style definition with
  958. X * unwidened argument types.  Thus, we have to turn off all NetHack
  959. X * prototypes, and avoid declaring several system functions, since the system
  960. X * include files have prototypes and the compiler also complains that
  961. X * prototyped and unprototyped declarations don't match.
  962. X */
  963. X# undef NDECL
  964. X# undef FDECL
  965. X# undef VDECL
  966. X# define NDECL(f)    f()
  967. X# define FDECL(f,p)    f()
  968. X# define VDECL(f,p)    f()
  969. X#endif
  970. X
  971. X
  972. X#ifdef __HC__    /* MetaWare High-C defaults to unsigned chars */
  973. X# undef signed
  974. X#endif
  975. X
  976. X
  977. X/*
  978. X * Allow gcc2 to check parameters of printf-like calls with -Wformat;
  979. X * append this to a prototype declaration (see pline() in extern.h).
  980. X */
  981. X#ifdef __GNUC__
  982. X# if __GNUC__ >= 2
  983. X#define PRINTF_F(f,v) __attribute__ ((format (printf, f, v)))
  984. X# endif
  985. X#endif
  986. X#ifndef PRINTF_F
  987. X#define PRINTF_F(f,v)
  988. X#endif
  989. X
  990. X#endif /* TRADSTDC_H */
  991. END_OF_FILE
  992. if test 7712 -ne `wc -c <'include/tradstdc.h'`; then
  993.     echo shar: \"'include/tradstdc.h'\" unpacked with wrong size!
  994. fi
  995. # end of 'include/tradstdc.h'
  996. fi
  997. if test -f 'include/trampoli.h' -a "${1}" != "-c" ; then 
  998.   echo shar: Will not clobber existing file \"'include/trampoli.h'\"
  999. else
  1000. echo shar: Extracting \"'include/trampoli.h'\" \(7978 characters\)
  1001. sed "s/^X//" >'include/trampoli.h' <<'END_OF_FILE'
  1002. X/*    SCCS Id: @(#)trampoli.h     3.1    92/10/06      */
  1003. X/* Copyright (c) 1989, by Norm Meluch and Stephen Spackman      */
  1004. X/* NetHack may be freely redistributed.  See license for details. */
  1005. X
  1006. X#ifndef TRAMPOLI_H
  1007. X#define TRAMPOLI_H
  1008. X
  1009. X#ifdef OVERLAY
  1010. X
  1011. X/* ### apply.c ### */
  1012. X#define dig()     dig_()
  1013. X#define doapply() doapply_()
  1014. X#define dojump()  dojump_()
  1015. X#define dorub()   dorub_()
  1016. X
  1017. X
  1018. X/* ### cmd.c ### */
  1019. X#define doextcmd()         doextcmd_()
  1020. X#define doextlist()        doextlist_()
  1021. X#ifdef POLYSELF
  1022. X#define domonability()     domonability_()
  1023. X#endif /* POLYSELF */
  1024. X#ifdef EXPLORE_MODE
  1025. X#define enter_explore_mode() enter_explore_mode_()
  1026. X#endif /* EXPLORE_MODE */
  1027. X#define doprev_message() doprev_message_()
  1028. X#define timed_occupation() timed_occupation_()
  1029. X#if defined(WIZARD) || defined(EXPLORE_MODE)
  1030. X#define wiz_attributes()   wiz_attributes_()
  1031. X#endif
  1032. X#ifdef WIZARD
  1033. X#define wiz_detect()       wiz_detect_()
  1034. X#define wiz_genesis()      wiz_genesis_()
  1035. X#define wiz_identify()     wiz_identify_()
  1036. X#define wiz_level_tele()   wiz_level_tele_()
  1037. X#define wiz_map()          wiz_map_()
  1038. X#define wiz_where()        wiz_where_()
  1039. X#define wiz_wish()         wiz_wish_()
  1040. X#endif
  1041. X
  1042. X/* ### display.c ### */
  1043. X#define doredraw() doredraw_()
  1044. X
  1045. X/* ### do.c ### */
  1046. X#define doddrop()  doddrop_()
  1047. X#define dodown()   dodown_()
  1048. X#define dodrop()   dodrop_()
  1049. X#define donull()   donull_()
  1050. X#define doup()     doup_()
  1051. X#define dowipe()   dowipe_()
  1052. X#define drop(x)    drop_(x)
  1053. X#define wipeoff()  wipeoff_()
  1054. X
  1055. X
  1056. X/* ### do_name.c ### */
  1057. X#define ddocall()  ddocall_()
  1058. X#define do_mname() do_mname_()
  1059. X
  1060. X
  1061. X/* ### do_wear.c ### */
  1062. X#define Armor_off()   Armor_off_()
  1063. X#define Boots_off()   Boots_off_()
  1064. X#define Gloves_off()  Gloves_off_()
  1065. X#define Helmet_off()  Helmet_off_()
  1066. X#define Armor_on()    Armor_on_()
  1067. X#define Boots_on()    Boots_on_()
  1068. X#define Gloves_on()   Gloves_on_()
  1069. X#define Helmet_on()   Helmet_on_()
  1070. X#define doddoremarm() doddoremarm_()
  1071. X#define doputon()     doputon_()
  1072. X#define doremring()   doremring_()
  1073. X#define dotakeoff()   dotakeoff_()
  1074. X#define dowear()      dowear_()
  1075. X#define select_off(x) select_off_(x)
  1076. X#define take_off()    take_off_()
  1077. X
  1078. X
  1079. X/* ### dogmove.c ### */
  1080. X#define wantdoor(x, y, dummy) wantdoor_(x, y, dummy)
  1081. X
  1082. X
  1083. X/* ### dokick.c ### */
  1084. X#define dokick() dokick_()
  1085. X
  1086. X
  1087. X/* ### dothrow.c ### */
  1088. X#define dothrow() dothrow_()
  1089. X
  1090. X
  1091. X/* ### eat.c ### */
  1092. X#define Hear_again() Hear_again_()
  1093. X#define eatmdone()   eatmdone_()
  1094. X#define doeat()      doeat_()
  1095. X#define eatfood()    eatfood_()
  1096. X#define opentin()    opentin_()
  1097. X#define unfaint()    unfaint_()
  1098. X
  1099. X
  1100. X/* ### end.c ### */
  1101. X#define done1()     done1_()
  1102. X#define done2()     done2_()
  1103. X#define hangup()    hangup_()
  1104. X#define done_intr() done_intr_()
  1105. X#if defined(UNIX) || defined (VMS)
  1106. X#define done_hangup() done_hangup_()
  1107. X#endif /* UNIX || VMS */
  1108. X
  1109. X
  1110. X/* ### engrave.c ### */
  1111. X#define doengrave() doengrave_()
  1112. X
  1113. X
  1114. X/* ### fountain.c ### */
  1115. X#define gush(x, y, poolcnt) gush_(x, y, poolcnt)
  1116. X
  1117. X
  1118. X/* ### hack.c ### */
  1119. X#define dopickup() dopickup_()
  1120. X#define identify(x) identify_(x)
  1121. X
  1122. X
  1123. X/* ### invent.c ### */
  1124. X#define ckunpaid(x)  ckunpaid_(x)
  1125. X#define ddoinv()     ddoinv_()
  1126. X#define dolook()     dolook_()
  1127. X#define dopramulet() dopramulet_()
  1128. X#define doprarm()    doprarm_()
  1129. X#define doprgold()   doprgold_()
  1130. X#define doprring()   doprring_()
  1131. X#define doprtool()   doprtool_()
  1132. X#define doprwep()    doprwep_()
  1133. X#define dotypeinv()  dotypeinv_()
  1134. X#define doorganize() doorganize_()
  1135. X
  1136. X
  1137. X/* ### ioctl.c ### */
  1138. X#ifdef UNIX
  1139. X# ifdef SUSPEND
  1140. X#define dosuspend() dosuspend_()
  1141. X# endif /* SUSPEND */
  1142. X#endif /* UNIX */
  1143. X
  1144. X
  1145. X/* ### lock.c ### */
  1146. X#define doclose()   doclose_()
  1147. X#define doforce()   doforce_()
  1148. X#define doopen()    doopen_()
  1149. X#define forcelock() forcelock_()
  1150. X#define picklock()  picklock_()
  1151. X
  1152. X
  1153. X/* ### mklev.c ### */
  1154. X#define do_comp(x, y)  comp_(x, y)
  1155. X
  1156. X
  1157. X/* ### mondata.c ### */
  1158. X/* See comment in trampoli.c before uncommenting canseemon. */
  1159. X/* #define canseemon(x)    canseemon_(x) */
  1160. X
  1161. X
  1162. X/* ### muse.c ### */
  1163. X#define mbhitm(x, y) mbhitm_(x, y)
  1164. X
  1165. X
  1166. X/* ### o_init.c ### */
  1167. X#define dodiscovered() dodiscovered_()
  1168. X
  1169. X
  1170. X/* ### objnam.c ### */
  1171. X#define doname(x)   doname_(x)
  1172. X#define xname(x)    xname_(x)
  1173. X
  1174. X
  1175. X/* ### options.c ### */
  1176. X#define doset()          doset_()
  1177. X#define dotogglepickup() dotogglepickup_()
  1178. X
  1179. X
  1180. X/* ### pager.c ### */
  1181. X#define dohelp()     dohelp_()
  1182. X#define dohistory()  dohistory_()
  1183. X#ifdef UNIX
  1184. X#define intruph()    intruph_()
  1185. X#endif /* UNIX */
  1186. X#define dowhatdoes() dowhatdoes_()
  1187. X#define dowhatis()   dowhatis_()
  1188. X#define doquickwhatis()   doquickwhatis_()
  1189. X
  1190. X
  1191. X/* ### pcsys.c ### */
  1192. X#ifdef SHELL
  1193. X#define dosh()       dosh_()
  1194. X#endif /* SHELL */
  1195. X
  1196. X
  1197. X/* ### pickup.c ### */
  1198. X#define ck_bag(x)        ck_bag_(x)
  1199. X#define doloot()         doloot_()
  1200. X#define in_container(x)  in_container_(x)
  1201. X#define out_container(x) out_container_(x)
  1202. X
  1203. X
  1204. X/* ### potion.c ### */
  1205. X#define dodrink() dodrink_()
  1206. X#define dodip()   dodip_()
  1207. X
  1208. X
  1209. X/* ### pray.c ### */
  1210. X#define doturn()      doturn_()
  1211. X#define dopray()      dopray_()
  1212. X#define prayer_done() prayer_done_()
  1213. X#define dosacrifice() dosacrifice_()
  1214. X
  1215. X
  1216. X/* ### read.c ### */
  1217. X#define doread()       doread_()
  1218. X#define set_lit(x, y, val) set_lit_(x, y, val)
  1219. X
  1220. X
  1221. X/* ### save.c ### */
  1222. X#define dosave() dosave_()
  1223. X
  1224. X
  1225. X/* ### search.c ### */
  1226. X#define doidtrap()         doidtrap_()
  1227. X#define dosearch()         dosearch_()
  1228. X#define findone(zx, zy, num) findone_(zx, zy, num)
  1229. X#define openone(zx, zy, num) openone_(zx, zy, num)
  1230. X
  1231. X
  1232. X/* ### shk.c ### */
  1233. X#define dopay() dopay_()
  1234. X
  1235. X
  1236. X/* ### sit.c ### */
  1237. X#define dosit() dosit_()
  1238. X
  1239. X
  1240. X/* ### sounds.c ### */
  1241. X#define dotalk() dotalk_()
  1242. X
  1243. X
  1244. X/* ### spell.c ### */
  1245. X#define learn()    learn_()
  1246. X#define docast()   docast_()
  1247. X#define dovspell() dovspell_()
  1248. X
  1249. X
  1250. X/* ### steal.c ### */
  1251. X#define stealarm() stealarm_()
  1252. X
  1253. X
  1254. X/* ### trap.c ### */
  1255. X#define dotele()     dotele_()
  1256. X#define dountrap()   dountrap_()
  1257. X#define float_down() float_down_()
  1258. X
  1259. X
  1260. X/* ### version.c ### */
  1261. X#define doversion()    doversion_()
  1262. X#define doextversion() doextversion_()
  1263. X
  1264. X
  1265. X/* ### wield.c ### */
  1266. X#define dowield() dowield_()
  1267. X
  1268. X
  1269. X/* ### zap.c ### */
  1270. X#define bhitm(x, y) bhitm_(x, y)
  1271. X#define bhito(x, y) bhito_(x, y)
  1272. X#define dozap()     dozap_()
  1273. X
  1274. X
  1275. X/* ### getline.c ### */
  1276. X#define tty_getlin(x,y)            tty_getlin_(x,y)
  1277. X#ifdef COM_COMPL
  1278. X#define tty_get_ext_cmd(x)        tty_get_ext_cmd_(x)
  1279. X#endif /* COM_COMPL */
  1280. X
  1281. X
  1282. X/* ### termcap.c ### */
  1283. X#define tty_nhbell()            tty_nhbell_()
  1284. X#define tty_number_pad(x)        tty_number_pad_(x)
  1285. X#define tty_delay_output()        tty_delay_output_()
  1286. X#define tty_start_screen()        tty_start_screen_()
  1287. X#define tty_end_screen()        tty_end_screen_()
  1288. X
  1289. X
  1290. X/* ### topl.c ### */
  1291. X#define tty_doprev_message()        tty_doprev_message_()
  1292. X#define tty_yn_function(x,y,z)        tty_yn_function_(x,y,z)
  1293. X
  1294. X
  1295. X/* ### wintty.c ### */
  1296. X#define tty_init_nhwindows()        tty_init_nhwindows_()
  1297. X#define tty_player_selection()        tty_player_selection_()
  1298. X#define tty_askname()            tty_askname_()
  1299. X#define tty_get_nh_event()        tty_get_nh_event_()
  1300. X#define tty_exit_nhwindows(x)        tty_exit_nhwindows_(x)
  1301. X#define tty_suspend_nhwindows(x)    tty_suspend_nhwindows_(x)
  1302. X#define tty_resume_nhwindows()        tty_resume_nhwindows_()
  1303. X#define tty_create_nhwindow(x)        tty_create_nhwindow_(x)
  1304. X#define tty_clear_nhwindow(x)        tty_clear_nhwindow_(x)
  1305. X#define tty_display_nhwindow(x,y)    tty_display_nhwindow_(x,y)
  1306. X#define tty_destroy_nhwindow(x)        tty_destroy_nhwindow_(x)
  1307. X#define tty_curs(x,y,z)            tty_curs_(x,y,z)
  1308. X#define tty_putstr(x,y,z)        tty_putstr_(x,y,z)
  1309. X#define tty_display_file(x,y)        tty_display_file_(x,y)
  1310. X#define tty_start_menu(x)        tty_start_menu_(x)
  1311. X#define tty_add_menu(a,b,c,d)        tty_add_menu_(a,b,c,d)
  1312. X#define tty_end_menu(a,b,c,d)        tty_end_menu_(a,b,c,d)
  1313. X#define tty_select_menu(x)        tty_select_menu_(x)
  1314. X#define tty_update_inventory()        tty_update_inventory_()
  1315. X#define tty_mark_synch()        tty_mark_synch_()
  1316. X#define tty_wait_synch()        tty_wait_synch_()
  1317. X#ifdef CLIPPING
  1318. X#define tty_cliparound(x,y)        tty_cliparound_(x,y)
  1319. X#endif
  1320. X#define tty_print_glyph(a,b,c,d)    tty_print_glyph_(a,b,c,d)
  1321. X#define tty_raw_print(x)        tty_raw_print_(x)
  1322. X#define tty_raw_print_bold(x)        tty_raw_print_bold_(x)
  1323. X#define tty_nhgetch()            tty_nhgetch_()
  1324. X#define tty_nh_poskey(x,y,z)        tty_nh_poskey_(x,y,z)
  1325. X
  1326. X#endif /* OVERLAY */
  1327. X
  1328. X#endif /* TRAMPOLI_H */
  1329. END_OF_FILE
  1330. if test 7978 -ne `wc -c <'include/trampoli.h'`; then
  1331.     echo shar: \"'include/trampoli.h'\" unpacked with wrong size!
  1332. fi
  1333. # end of 'include/trampoli.h'
  1334. fi
  1335. if test -f 'src/decl.c' -a "${1}" != "-c" ; then 
  1336.   echo shar: Will not clobber existing file \"'src/decl.c'\"
  1337. else
  1338. echo shar: Extracting \"'src/decl.c'\" \(7545 characters\)
  1339. sed "s/^X//" >'src/decl.c' <<'END_OF_FILE'
  1340. X/*    SCCS Id: @(#)decl.c    3.1    92/12/11    */
  1341. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1342. X/* NetHack may be freely redistributed.  See license for details. */
  1343. X
  1344. X#include    "hack.h"
  1345. X
  1346. Xint NDECL((*afternmv));
  1347. Xint NDECL((*occupation));
  1348. X
  1349. X/* from xxxmain.c */
  1350. Xconst char *hname = 0;        /* name of the game (argv[0] of main) */
  1351. Xint hackpid = 0;        /* current process id */
  1352. X#if defined(UNIX) || defined(VMS)
  1353. Xint locknum = 0;        /* max num of simultaneous users */
  1354. X#endif
  1355. X#ifdef DEF_PAGER
  1356. Xchar *catmore = 0;        /* default pager */
  1357. X#endif
  1358. X
  1359. Xint NEARDATA bases[MAXOCLASSES] = DUMMY;
  1360. X
  1361. Xint NEARDATA multi = 0;
  1362. Xint NEARDATA warnlevel = 0;        /* used by movemon and dochugw */
  1363. Xint NEARDATA nroom = 0;
  1364. Xint NEARDATA nsubroom = 0;
  1365. Xint NEARDATA occtime = 0;
  1366. X
  1367. Xint x_maze_max, y_maze_max;    /* initialized in main, used in mkmaze.c */
  1368. Xint otg_temp;            /* used by object_to_glyph() [otg] */
  1369. X
  1370. X#ifdef REDO
  1371. Xint NEARDATA in_doagain = 0;
  1372. X#endif
  1373. X
  1374. X/*
  1375. X *    The following structure will be initialized at startup time with
  1376. X *    the level numbers of some "important" things in the game.
  1377. X */
  1378. Xstruct dgn_topology dungeon_topology = {DUMMY};
  1379. X
  1380. X#ifdef MULDGN
  1381. X#include    "quest.h"
  1382. Xstruct q_score    quest_status = DUMMY;
  1383. X#endif
  1384. X
  1385. Xint NEARDATA smeq[MAXNROFROOMS+1] = DUMMY;
  1386. Xint NEARDATA doorindex = 0;
  1387. X
  1388. Xchar NEARDATA *save_cm = 0;
  1389. Xint NEARDATA killer_format = 0;
  1390. Xconst char NEARDATA *killer = 0;
  1391. Xconst char NEARDATA *nomovemsg = 0;
  1392. Xconst char NEARDATA nul[40] = DUMMY;        /* contains zeros */
  1393. Xchar NEARDATA plname[PL_NSIZ] = DUMMY;        /* player name */
  1394. Xchar NEARDATA pl_character[PL_CSIZ] = DUMMY;
  1395. X
  1396. X#ifdef TUTTI_FRUTTI
  1397. Xchar NEARDATA pl_fruit[PL_FSIZ] = DUMMY;
  1398. Xint NEARDATA current_fruit = 0;
  1399. Xstruct fruit NEARDATA *ffruit = (struct fruit *)0;
  1400. X#endif
  1401. X
  1402. Xchar NEARDATA tune[6] = DUMMY;
  1403. X
  1404. Xconst char NEARDATA *occtxt = DUMMY;
  1405. Xconst char NEARDATA quitchars[] = " \r\n\033";
  1406. Xconst char NEARDATA vowels[] = "aeiouAEIOU";
  1407. Xconst char NEARDATA ynchars[] = "yn";
  1408. Xconst char NEARDATA ynqchars[] = "ynq";
  1409. Xconst char NEARDATA ynaqchars[] = "ynaq";
  1410. Xconst char NEARDATA ynNaqchars[] = "yn#aq";
  1411. Xlong NEARDATA yn_number = 0L;
  1412. X
  1413. X#ifdef MICRO
  1414. Xchar hackdir[PATHLEN];        /* where rumors, help, record are */
  1415. Xchar levels[PATHLEN];        /* where levels are */
  1416. X#endif /* MICRO */
  1417. X
  1418. X#define INFOSIZE    MAXLEVEL * MAXDUNGEON
  1419. X
  1420. X#ifdef MFLOPPY
  1421. Xchar permbones[PATHLEN];    /* where permanent copy of bones go */
  1422. Xint ramdisk = FALSE;        /* whether to copy bones to levels or not */
  1423. Xint saveprompt = TRUE;
  1424. Xstruct finfo fileinfo[INFOSIZE];
  1425. Xconst char *alllevels = "levels.*";
  1426. Xconst char *allbones = "bones*.*";
  1427. X#else
  1428. Xboolean level_exists[INFOSIZE];
  1429. X#endif
  1430. X
  1431. X#undef INFOSIZE
  1432. X
  1433. X/* 'rogue'-like direction commands (cmd.c) */
  1434. Xconst char NEARDATA sdir[] = "hykulnjb><";
  1435. Xconst char NEARDATA ndir[] = "47896321><";    /* number pad mode */
  1436. Xconst schar NEARDATA xdir[10] = { -1,-1, 0, 1, 1, 1, 0,-1, 0, 0 };
  1437. Xconst schar NEARDATA ydir[10] = {  0,-1,-1,-1, 0, 1, 1, 1, 0, 0 };
  1438. Xconst schar zdir[10]          = {  0, 0, 0, 0, 0, 0, 0, 0, 1,-1 };
  1439. X
  1440. Xschar NEARDATA tbx = 0, NEARDATA tby = 0;    /* mthrowu: target */
  1441. Xint NEARDATA dig_effort = 0;    /* effort expended on current pos */
  1442. Xd_level NEARDATA dig_level = { 0, 0 };
  1443. Xcoord NEARDATA dig_pos = DUMMY;
  1444. Xboolean NEARDATA dig_down = FALSE;
  1445. X
  1446. Xdungeon NEARDATA dungeons[MAXDUNGEON];    /* ini'ed by init_dungeon() */
  1447. Xs_level NEARDATA *sp_levchn;
  1448. Xint NEARDATA done_stopprint = 0;
  1449. Xint NEARDATA done_hup = 0;
  1450. Xstairway NEARDATA upstair = { 0, 0 }, NEARDATA dnstair = { 0, 0 };
  1451. Xstairway NEARDATA upladder = { 0, 0 }, NEARDATA dnladder = { 0, 0 };
  1452. Xstairway NEARDATA sstairs = { 0, 0 };
  1453. Xdest_area NEARDATA updest = { 0, 0, 0, 0, 0, 0, 0, 0 };
  1454. Xdest_area NEARDATA dndest = { 0, 0, 0, 0, 0, 0, 0, 0 };
  1455. Xcoord NEARDATA inv_pos = { 0, 0 };
  1456. X
  1457. Xboolean NEARDATA in_mklev = FALSE;
  1458. Xboolean    NEARDATA stoned = FALSE;    /* done to monsters hit by 'c' */
  1459. Xboolean    NEARDATA unweapon = FALSE;
  1460. Xboolean NEARDATA mrg_to_wielded = FALSE;
  1461. X             /* weapon picked is merged with wielded one */
  1462. X
  1463. X#ifdef KOPS
  1464. Xboolean NEARDATA allow_kops = TRUE;
  1465. X#endif
  1466. X
  1467. Xcoord NEARDATA bhitpos = DUMMY;
  1468. Xcoord NEARDATA doors[DOORMAX] = {DUMMY};
  1469. X
  1470. Xstruct mkroom NEARDATA rooms[(MAXNROFROOMS+1)*2] = {DUMMY};
  1471. Xstruct mkroom* NEARDATA subrooms = &rooms[MAXNROFROOMS+1];
  1472. Xstruct mkroom *upstairs_room, *dnstairs_room, *sstairs_room;
  1473. X
  1474. Xdlevel_t level;        /* level map */
  1475. Xstruct trap *ftrap = (struct trap *)0;
  1476. Xstruct monst NEARDATA youmonst = DUMMY;
  1477. Xstruct flag NEARDATA flags = DUMMY;
  1478. Xstruct you NEARDATA u = DUMMY;
  1479. X
  1480. Xstruct obj NEARDATA *invent = (struct obj *)0, 
  1481. X        NEARDATA *uwep = (struct obj *)0, NEARDATA *uarm = (struct obj *)0,
  1482. X#ifdef TOURIST
  1483. X    NEARDATA *uarmu = (struct obj *)0, /* under-wear, so to speak */
  1484. X#endif
  1485. X#ifdef POLYSELF
  1486. X    NEARDATA *uskin = (struct obj *)0, /* dragon armor, if a dragon */
  1487. X#endif
  1488. X    NEARDATA *uarmc = (struct obj *)0, NEARDATA *uarmh = (struct obj *)0, 
  1489. X        NEARDATA *uarms = (struct obj *)0, NEARDATA *uarmg = (struct obj *)0,
  1490. X        NEARDATA *uarmf = (struct obj *)0, NEARDATA *uamul = (struct obj *)0,
  1491. X    NEARDATA *uright = (struct obj *)0,
  1492. X        NEARDATA *uleft = (struct obj *)0,
  1493. X        NEARDATA *ublindf = (struct obj *)0,
  1494. X    NEARDATA *uchain = (struct obj *)0,
  1495. X        NEARDATA *uball = (struct obj *)0;
  1496. X
  1497. X#ifdef TEXTCOLOR
  1498. X/*
  1499. X *  This must be the same order as used for buzz() in zap.c.
  1500. X */
  1501. Xconst int zapcolors[NUM_ZAP] = {
  1502. X    HI_ZAP,        /* 0 - missile */
  1503. X    ORANGE_COLORED,    /* 1 - fire */
  1504. X    WHITE,        /* 2 - frost */
  1505. X    HI_ZAP,        /* 3 - sleep */
  1506. X    BLACK,        /* 4 - death */
  1507. X    HI_ZAP,        /* 5 - lightning */
  1508. X    YELLOW,        /* 6 - poison gas */
  1509. X    GREEN,        /* 7 - acid */
  1510. X};
  1511. X#endif /* text color */
  1512. X
  1513. Xconst int shield_static[SHIELD_COUNT] = {
  1514. X    S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,    /* 7 per row */
  1515. X    S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
  1516. X    S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
  1517. X};
  1518. X
  1519. Xstruct spell NEARDATA spl_book[MAXSPELL + 1] = {DUMMY};
  1520. X
  1521. Xlong NEARDATA moves = 1L, NEARDATA monstermoves = 1L;
  1522. X     /* These diverge when player is Fast */
  1523. Xlong NEARDATA wailmsg = 0L;
  1524. X
  1525. X/* objects that are moving to another dungeon level */
  1526. Xstruct obj NEARDATA *migrating_objs = (struct obj *)0;
  1527. X/* objects not yet paid for */
  1528. Xstruct obj NEARDATA *billobjs = (struct obj *)0;
  1529. X
  1530. X/* used to zero all elements of a struct obj */
  1531. Xstruct obj NEARDATA zeroobj = DUMMY;
  1532. X
  1533. X/* originally from dog.c */
  1534. Xchar NEARDATA dogname[63] = DUMMY;
  1535. Xchar NEARDATA catname[63] = DUMMY;
  1536. Xchar preferred_pet;    /* '\0', 'c', 'd' */
  1537. X/* monsters that went down/up together with @ */
  1538. Xstruct monst NEARDATA *mydogs = (struct monst *)0;
  1539. X/* monsters that are moving to another dungeon level */
  1540. Xstruct monst NEARDATA *migrating_mons = (struct monst *)0;
  1541. X
  1542. Xstruct c_color_names NEARDATA c_color_names = {
  1543. X    "black", "amber", "golden",
  1544. X    "light blue", "red", "green",
  1545. X    "silver", "blue", "purple",
  1546. X    "white"
  1547. X};
  1548. X
  1549. Xstruct c_common_strings c_common_strings = {
  1550. X    "Nothing happens.",        "That's enough tries!",
  1551. X    "That is a silly thing to %s.",    "shudder for a moment."
  1552. X};
  1553. X
  1554. X/* Vision */
  1555. Xboolean    NEARDATA vision_full_recalc = 0;
  1556. Xchar    NEARDATA **viz_array = 0;/* used in cansee() and couldsee() macros */
  1557. X
  1558. X/* Global windowing data, defined here for multi-window-system support */
  1559. Xwinid NEARDATA WIN_MESSAGE = WIN_ERR, NEARDATA WIN_STATUS = WIN_ERR;
  1560. Xwinid NEARDATA WIN_MAP = WIN_ERR, NEARDATA WIN_INVEN = WIN_ERR;
  1561. Xchar toplines[BUFSZ];
  1562. X/* Windowing stuff that's really tty oriented, but present for all ports */
  1563. Xstruct tc_gbl_data tc_gbl_data = { 0,0, 0,0 };    /* AS,AE, LI,CO */
  1564. X
  1565. X#ifdef TOURIST
  1566. Xconst char NEARDATA *pl_classes = "ABCEHKPRSTVW";
  1567. X#else
  1568. Xconst char NEARDATA *pl_classes = "ABCEHKPRSVW";
  1569. X#endif
  1570. X
  1571. X/* dummy routine used to force linkage */
  1572. Xvoid
  1573. Xdecl_init()
  1574. X{
  1575. X    return;
  1576. X}
  1577. X
  1578. X/*decl.c*/
  1579. END_OF_FILE
  1580. if test 7545 -ne `wc -c <'src/decl.c'`; then
  1581.     echo shar: \"'src/decl.c'\" unpacked with wrong size!
  1582. fi
  1583. # end of 'src/decl.c'
  1584. fi
  1585. if test -f 'sys/unix/unixtty.c' -a "${1}" != "-c" ; then 
  1586.   echo shar: Will not clobber existing file \"'sys/unix/unixtty.c'\"
  1587. else
  1588. echo shar: Extracting \"'sys/unix/unixtty.c'\" \(7724 characters\)
  1589. sed "s/^X//" >'sys/unix/unixtty.c' <<'END_OF_FILE'
  1590. X/*    SCCS Id: @(#)unixtty.c    3.1    90/22/02
  1591. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1592. X/* NetHack may be freely redistributed.  See license for details. */
  1593. X
  1594. X/* tty.c - (Unix) version */
  1595. X
  1596. X/* With thanks to the people who sent code for SYSV - hpscdi!jon,
  1597. X * arnold@ucsf-cgl, wcs@bo95b, cbcephus!pds and others.
  1598. X */
  1599. X
  1600. X#define NEED_VARARGS
  1601. X#include "hack.h"
  1602. X
  1603. X#ifdef TTY_GRAPHICS
  1604. X#include "wintty.h"
  1605. X#endif
  1606. X
  1607. X/*
  1608. X * The distinctions here are not BSD - rest but rather USG - rest, as
  1609. X * BSD still has the old sgttyb structure, but SYSV has termio. Thus:
  1610. X */
  1611. X#if (defined(BSD) || defined(ULTRIX)) && !defined(POSIX_TYPES)
  1612. X#define    V7
  1613. X#else
  1614. X#define USG
  1615. X#endif
  1616. X
  1617. X
  1618. X#ifdef USG
  1619. X
  1620. X# ifdef POSIX_TYPES
  1621. X#include    <termios.h>
  1622. X#include    <unistd.h>
  1623. X#define termstruct    termios
  1624. X# else
  1625. X#include    <termio.h>
  1626. X#  if defined(TCSETS) && !defined(AIX_31)
  1627. X#define termstruct    termios
  1628. X#  else
  1629. X#define termstruct    termio
  1630. X#  endif
  1631. X# endif /* POSIX_TYPES */
  1632. X#define kill_sym    c_cc[VKILL]
  1633. X#define erase_sym    c_cc[VERASE]
  1634. X#define intr_sym    c_cc[VINTR]
  1635. X# ifdef TAB3    /* not a POSIX flag, but some have it anyway */
  1636. X#define EXTABS        TAB3
  1637. X# else
  1638. X#define EXTABS        0
  1639. X# endif
  1640. X#define tabflgs        c_oflag
  1641. X#define echoflgs    c_lflag
  1642. X#define cbrkflgs    c_lflag
  1643. X#define CBRKMASK    ICANON
  1644. X#define CBRKON        ! /* reverse condition */
  1645. X# ifdef POSIX_TYPES
  1646. X#define OSPEED(x)    (speednum(cfgetospeed(&x)))
  1647. X# else
  1648. X#  ifndef CBAUD
  1649. X# define CBAUD        _CBAUD /* for POSIX nitpickers (like RS/6000 cc) */
  1650. X#  endif
  1651. X#define OSPEED(x)    ((x).c_cflag & CBAUD)
  1652. X# endif
  1653. X#define IS_7BIT(x)    ((x).c_cflag & CS7)
  1654. X#define inputflags    c_iflag
  1655. X#define STRIPHI        ISTRIP
  1656. X# ifdef POSIX_TYPES
  1657. X#  define GTTY(x)    (tcgetattr(0, x))
  1658. X#  define STTY(x)    (tcsetattr(0, TCSADRAIN, x))
  1659. X# else
  1660. X#  if defined(TCSETS) && !defined(AIX_31)
  1661. X#   define GTTY(x)    (ioctl(0, TCGETS, x))
  1662. X#   define STTY(x)    (ioctl(0, TCSETSW, x))
  1663. X#  else
  1664. X#   define GTTY(x)    (ioctl(0, TCGETA, x))
  1665. X#   define STTY(x)    (ioctl(0, TCSETAW, x))
  1666. X#  endif
  1667. X# endif /* POSIX_TYPES */
  1668. X#define GTTY2(x)    1
  1669. X#define STTY2(x)    1
  1670. X# ifdef POSIX_TYPES
  1671. X#  ifdef BSD
  1672. X#   define nonesuch    _POSIX_VDISABLE
  1673. X#  else
  1674. X#   define nonesuch    (fpathconf(0, _PC_VDISABLE))
  1675. X#  endif
  1676. X# else
  1677. X#  define nonesuch    0
  1678. X# endif
  1679. X#define inittyb2    inittyb
  1680. X#define curttyb2    curttyb
  1681. X
  1682. X#else    /* V7 */
  1683. X
  1684. X#include    <sgtty.h>
  1685. X#define termstruct    sgttyb
  1686. X#define    kill_sym    sg_kill
  1687. X#define    erase_sym    sg_erase
  1688. X#define    intr_sym    t_intrc
  1689. X#define EXTABS        XTABS
  1690. X#define tabflgs        sg_flags
  1691. X#define echoflgs    sg_flags
  1692. X#define cbrkflgs    sg_flags
  1693. X#define CBRKMASK    CBREAK
  1694. X#define CBRKON        /* empty */
  1695. X#define inputflags    sg_flags    /* don't know how enabling meta bits */
  1696. X#define IS_7BIT(x)    (FALSE)
  1697. X#define STRIPHI        0        /* should actually be done on BSD */
  1698. X#define OSPEED(x)    (x).sg_ospeed
  1699. X#if defined(bsdi) || defined(__386BSD)
  1700. X# define GTTY(x)    (ioctl(0, TIOCGETP, (char *)x))
  1701. X# define STTY(x)    (ioctl(0, TIOCSETP, (char *)x))
  1702. X#else
  1703. X# define GTTY(x)    (gtty(0, x))
  1704. X# define STTY(x)    (stty(0, x))
  1705. X#endif
  1706. X#define GTTY2(x)    (ioctl(0, TIOCGETC, (char *)x))
  1707. X#define STTY2(x)    (ioctl(0, TIOCSETC, (char *)x))
  1708. X#define nonesuch    -1
  1709. Xstruct tchars inittyb2, curttyb2;
  1710. X
  1711. X#endif
  1712. X
  1713. X#if defined(TTY_GRAPHICS) && ((!defined(SYSV) && !defined(HPUX)) || defined(UNIXPC) || defined(SVR4))
  1714. X# ifndef LINT
  1715. Xextern            /* it is defined in libtermlib (libtermcap) */
  1716. X# endif
  1717. X    short ospeed;    /* terminal baudrate; set by gettty */
  1718. X#else
  1719. Xshort    ospeed = 0;    /* gets around "not defined" error message */
  1720. X#endif
  1721. X
  1722. X#if defined(POSIX_TYPES) && defined(BSD)
  1723. Xunsigned
  1724. X#endif
  1725. X    char erase_char, intr_char, kill_char;
  1726. Xstatic boolean settty_needed = FALSE;
  1727. Xstruct termstruct inittyb, curttyb;
  1728. X
  1729. X#ifdef POSIX_TYPES
  1730. Xstatic int
  1731. Xspeednum(speed)
  1732. Xspeed_t speed;
  1733. X{
  1734. X    switch (speed) {
  1735. X        case B0:    return 0;
  1736. X        case B50:    return 1;
  1737. X        case B75:    return 2;
  1738. X        case B110:    return 3;
  1739. X        case B134:    return 4;
  1740. X        case B150:    return 5;
  1741. X        case B200:    return 6;
  1742. X        case B300:    return 7;
  1743. X        case B600:    return 8;
  1744. X        case B1200:    return 9;
  1745. X        case B1800:    return 10;
  1746. X        case B2400:    return 11;
  1747. X        case B4800:    return 12;
  1748. X        case B9600:    return 13;
  1749. X        case B19200:    return 14;
  1750. X        case B38400:    return 15;
  1751. X    }
  1752. X
  1753. X    return 0;
  1754. X}
  1755. X#endif
  1756. X
  1757. Xstatic void
  1758. Xsetctty()
  1759. X{
  1760. X    if(STTY(&curttyb) < 0 || STTY2(&curttyb2) < 0)
  1761. X        perror("NetHack (setctty)");
  1762. X}
  1763. X
  1764. X/*
  1765. X * Get initial state of terminal, set ospeed (for termcap routines)
  1766. X * and switch off tab expansion if necessary.
  1767. X * Called by startup() in termcap.c and after returning from ! or ^Z
  1768. X */
  1769. Xvoid
  1770. Xgettty()
  1771. X{
  1772. X    if(GTTY(&inittyb) < 0 || GTTY2(&inittyb2) < 0)
  1773. X        perror("NetHack (gettty)");
  1774. X    curttyb = inittyb;
  1775. X    curttyb2 = inittyb2;
  1776. X    ospeed = OSPEED(inittyb);
  1777. X    erase_char = inittyb.erase_sym;
  1778. X    kill_char = inittyb.kill_sym;
  1779. X    intr_char = inittyb2.intr_sym;
  1780. X    getioctls();
  1781. X
  1782. X    /* do not expand tabs - they might be needed inside a cm sequence */
  1783. X    if(curttyb.tabflgs & EXTABS) {
  1784. X        curttyb.tabflgs &= ~EXTABS;
  1785. X        setctty();
  1786. X    }
  1787. X    settty_needed = TRUE;
  1788. X}
  1789. X
  1790. X/* reset terminal to original state */
  1791. Xvoid
  1792. Xsettty(s)
  1793. Xconst char *s;
  1794. X{
  1795. X    end_screen();
  1796. X    if(s) raw_print(s);
  1797. X    if(STTY(&inittyb) < 0 || STTY2(&inittyb2) < 0)
  1798. X        perror("NetHack (settty)");
  1799. X    flags.echo = (inittyb.echoflgs & ECHO) ? ON : OFF;
  1800. X    flags.cbreak = (CBRKON(inittyb.cbrkflgs & CBRKMASK)) ? ON : OFF;
  1801. X    curttyb.inputflags |= STRIPHI;
  1802. X    setioctls();
  1803. X}
  1804. X
  1805. Xvoid
  1806. Xsetftty()
  1807. X{
  1808. Xregister int ef = 0;            /* desired value of flags & ECHO */
  1809. X#ifdef LINT    /* cf = CBRKON(CBRKMASK); const expr to initialize is ok */
  1810. Xregister int cf = 0;
  1811. X#else
  1812. Xregister int cf = CBRKON(CBRKMASK);    /* desired value of flags & CBREAK */
  1813. X#endif
  1814. Xregister int change = 0;
  1815. X    flags.cbreak = ON;
  1816. X    flags.echo = OFF;
  1817. X    /* Should use (ECHO|CRMOD) here instead of ECHO */
  1818. X    if((curttyb.echoflgs & ECHO) != ef){
  1819. X        curttyb.echoflgs &= ~ECHO;
  1820. X/*        curttyb.echoflgs |= ef;                    */
  1821. X        change++;
  1822. X    }
  1823. X    if((curttyb.cbrkflgs & CBRKMASK) != cf){
  1824. X        curttyb.cbrkflgs &= ~CBRKMASK;
  1825. X        curttyb.cbrkflgs |= cf;
  1826. X#ifdef USG
  1827. X        /* be satisfied with one character; no timeout */
  1828. X        curttyb.c_cc[VMIN] = 1;        /* was VEOF */
  1829. X        curttyb.c_cc[VTIME] = 0;    /* was VEOL */
  1830. X# ifdef POSIX_JOB_CONTROL
  1831. X        /* turn off system suspend character
  1832. X         * due to differences in structure layout, this has to be
  1833. X         * here instead of in ioctl.c:getioctls() with the BSD
  1834. X         * equivalent
  1835. X         */
  1836. X#  ifdef VSUSP    /* real POSIX */
  1837. X        curttyb.c_cc[VSUSP] = nonesuch;
  1838. X#  else        /* other later SYSV */
  1839. X        curttyb.c_cc[VSWTCH] = nonesuch;
  1840. X#  endif
  1841. X# endif
  1842. X# ifdef VDSUSP /* SunOS Posix extensions */
  1843. X        curttyb.c_cc[VDSUSP] = nonesuch;
  1844. X# endif
  1845. X# ifdef VREPRINT
  1846. X        curttyb.c_cc[VREPRINT] = nonesuch;
  1847. X# endif
  1848. X# ifdef VDISCARD
  1849. X        curttyb.c_cc[VDISCARD] = nonesuch;
  1850. X# endif
  1851. X# ifdef VWERASE
  1852. X        curttyb.c_cc[VWERASE] = nonesuch;
  1853. X# endif
  1854. X# ifdef VLNEXT
  1855. X        curttyb.c_cc[VLNEXT] = nonesuch;
  1856. X# endif
  1857. X#endif
  1858. X        change++;
  1859. X    }
  1860. X    if(!IS_7BIT(inittyb)) curttyb.inputflags &=~ STRIPHI;
  1861. X    /* If an interrupt character is used, it will be overriden and
  1862. X     * set to ^C.
  1863. X     */
  1864. X    if(intr_char != nonesuch && curttyb2.intr_sym != '\003') {
  1865. X        curttyb2.intr_sym = '\003';
  1866. X        change++;
  1867. X    }
  1868. X
  1869. X    if(change) setctty();
  1870. X    start_screen();
  1871. X}
  1872. X
  1873. Xvoid
  1874. Xintron()        /* enable kbd interupts if enabled when game started */
  1875. X{
  1876. X#ifdef TTY_GRAPHICS
  1877. X    /* Ugly hack to keep from changing tty modes for non-tty games -dlc */
  1878. X    if (windowprocs.win_init_nhwindows == tty_init_nhwindows &&
  1879. X        intr_char != nonesuch && curttyb2.intr_sym != '\003') {
  1880. X        curttyb2.intr_sym = '\003';
  1881. X        setctty();
  1882. X    }
  1883. X#endif
  1884. X}
  1885. X
  1886. Xvoid
  1887. Xintroff()        /* disable kbd interrupts if required*/
  1888. X{
  1889. X#ifdef TTY_GRAPHICS
  1890. X    /* Ugly hack to keep from changing tty modes for non-tty games -dlc */
  1891. X    if (windowprocs.win_init_nhwindows == tty_init_nhwindows &&
  1892. X       curttyb2.intr_sym != nonesuch) {
  1893. X        curttyb2.intr_sym = nonesuch;
  1894. X        setctty();
  1895. X    }
  1896. X#endif
  1897. X}
  1898. X
  1899. X
  1900. X/* fatal error */
  1901. X/*VARARGS1*/
  1902. X
  1903. Xvoid
  1904. Xerror VA_DECL(const char *,s)
  1905. X    VA_START(s);
  1906. X    VA_INIT(s, const char *);
  1907. X    if(settty_needed)
  1908. X        settty(NULL);
  1909. X    Vprintf(s,VA_ARGS);
  1910. X    (void) putchar('\n');
  1911. X    VA_END();
  1912. X    exit(1);
  1913. X}
  1914. END_OF_FILE
  1915. if test 7724 -ne `wc -c <'sys/unix/unixtty.c'`; then
  1916.     echo shar: \"'sys/unix/unixtty.c'\" unpacked with wrong size!
  1917. fi
  1918. # end of 'sys/unix/unixtty.c'
  1919. fi
  1920. if test -f 'sys/unix/unixunix.c' -a "${1}" != "-c" ; then 
  1921.   echo shar: Will not clobber existing file \"'sys/unix/unixunix.c'\"
  1922. else
  1923. echo shar: Extracting \"'sys/unix/unixunix.c'\" \(7443 characters\)
  1924. sed "s/^X//" >'sys/unix/unixunix.c' <<'END_OF_FILE'
  1925. X/*    SCCS Id: @(#)unixunix.c    3.1    90/22/02
  1926. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1927. X/* NetHack may be freely redistributed.  See license for details. */
  1928. X
  1929. X/* This file collects some Unix dependencies */
  1930. X
  1931. X#include "hack.h"    /* mainly for index() which depends on BSD */
  1932. X
  1933. X#include <errno.h>
  1934. X#include <sys/stat.h>
  1935. X#ifdef NO_FILE_LINKS
  1936. X#include <fcntl.h>
  1937. X#endif
  1938. X#include <signal.h>
  1939. X#if defined(BSD) || defined(ULTRIX)
  1940. X#include <sys/wait.h>
  1941. X#endif
  1942. X
  1943. Xstatic struct stat buf, hbuf;
  1944. X
  1945. Xvoid
  1946. Xgethdate(name) const char *name; {
  1947. X/* old version - for people short of space */
  1948. X/*
  1949. X/* register char *np;
  1950. X/*    if(stat(name, &hbuf))
  1951. X/*        error("Cannot get status of %s.",
  1952. X/*            (np = rindex(name, '/')) ? np+1 : name);
  1953. X/*
  1954. X/* version using PATH from: seismo!gregc@ucsf-cgl.ARPA (Greg Couch) */
  1955. X
  1956. X
  1957. X/*
  1958. X * The problem with   #include    <sys/param.h>   is that this include file
  1959. X * does not exist on all systems, and moreover, that it sometimes includes
  1960. X * <sys/types.h> again, so that the compiler sees these typedefs twice.
  1961. X */
  1962. X#define        MAXPATHLEN    1024
  1963. X
  1964. Xregister const char *np, *path;
  1965. Xchar filename[MAXPATHLEN+1];
  1966. X    if (index(name, '/') != NULL || (path = getenv("PATH")) == NULL)
  1967. X        path = "";
  1968. X
  1969. X    for (;;) {
  1970. X        if ((np = index(path, ':')) == NULL)
  1971. X            np = path + strlen(path);    /* point to end str */
  1972. X        if (np - path <= 1)            /* %% */
  1973. X            Strcpy(filename, name);
  1974. X        else {
  1975. X            (void) strncpy(filename, path, np - path);
  1976. X            filename[np - path] = '/';
  1977. X            Strcpy(filename + (np - path) + 1, name);
  1978. X        }
  1979. X        if (stat(filename, &hbuf) == 0)
  1980. X            return;
  1981. X        if (*np == '\0')
  1982. X            break;
  1983. X        path = np + 1;
  1984. X    }
  1985. X#if defined(BOS) && defined(NHSTDC)
  1986. X/*
  1987. X *    This one is really **STUPID**.  I don't know why it's happening
  1988. X *    as similar constructs work elsewhere, but...
  1989. X */
  1990. X    if((np = rindex(name, '/')))
  1991. X         error("Cannot get status of %s.", np+1);
  1992. X    else error("Cannot get status of %s.", name);
  1993. X#else
  1994. X    error("Cannot get status of %s.",
  1995. X        (np = rindex(name, '/')) ? np+1 : name);
  1996. X#endif
  1997. X}
  1998. X
  1999. Xint
  2000. Xuptodate(fd)
  2001. Xint fd;
  2002. X{
  2003. X    if(fstat(fd, &buf)) {
  2004. X        pline("Cannot get status of saved level? ");
  2005. X        wait_synch();
  2006. X        return(0);
  2007. X    }
  2008. X    if(buf.st_mtime < hbuf.st_mtime) {
  2009. X        pline("Saved level is out of date. ");
  2010. X        wait_synch();
  2011. X        return(0);
  2012. X    }
  2013. X    return(1);
  2014. X}
  2015. X
  2016. X/* see whether we should throw away this xlock file */
  2017. Xstatic int
  2018. Xveryold(fd)
  2019. Xint fd;
  2020. X{
  2021. X    time_t date;
  2022. X
  2023. X    if(fstat(fd, &buf)) return(0);            /* cannot get status */
  2024. X#ifndef INSURANCE
  2025. X    if(buf.st_size != sizeof(int)) return(0);    /* not an xlock file */
  2026. X#endif
  2027. X#ifdef BSD
  2028. X    (void) time((long *)(&date));
  2029. X#else
  2030. X    (void) time(&date);
  2031. X#endif
  2032. X    if(date - buf.st_mtime < 3L*24L*60L*60L) {    /* recent */
  2033. X#ifndef NETWORK
  2034. X        extern int errno;
  2035. X#endif
  2036. X        int lockedpid;    /* should be the same size as hackpid */
  2037. X
  2038. X        if(read(fd, (genericptr_t)&lockedpid, sizeof(lockedpid)) !=
  2039. X            sizeof(lockedpid))
  2040. X            /* strange ... */
  2041. X            return(0);
  2042. X
  2043. X        /* From: Rick Adams <seismo!rick>
  2044. X        /* This will work on 4.1cbsd, 4.2bsd and system 3? & 5.
  2045. X        /* It will do nothing on V7 or 4.1bsd. */
  2046. X#ifndef NETWORK
  2047. X        /* It will do a VERY BAD THING if the playground is shared
  2048. X           by more than one machine! -pem */
  2049. X          if(!(kill(lockedpid, 0) == -1 && errno == ESRCH))
  2050. X#endif
  2051. X            return(0);
  2052. X    }
  2053. X    (void) close(fd);
  2054. X    return(1);
  2055. X}
  2056. X
  2057. Xstatic int
  2058. Xeraseoldlocks()
  2059. X{
  2060. X    register int i;
  2061. X
  2062. X    /* cannot use maxledgerno() here, because we need to find a lock name
  2063. X     * before starting everything (including the dungeon initialization
  2064. X     * that sets astral_level, needed for maxledgerno()) up
  2065. X     */
  2066. X    for(i = 1; i <= MAXDUNGEON*MAXLEVEL + 1; i++) {
  2067. X        /* try to remove all */
  2068. X        set_levelfile_name(lock, i);
  2069. X        (void) unlink(lock);
  2070. X    }
  2071. X    set_levelfile_name(lock, 0);
  2072. X    if(unlink(lock)) return(0);            /* cannot remove it */
  2073. X    return(1);                    /* success! */
  2074. X}
  2075. X
  2076. Xvoid
  2077. Xgetlock()
  2078. X{
  2079. X    extern int errno;
  2080. X    register int i = 0, fd, c;
  2081. X
  2082. X    /* idea from rpick%ucqais@uccba.uc.edu
  2083. X     * prevent automated rerolling of characters
  2084. X     * test input (fd0) so that tee'ing output to get a screen dump still
  2085. X     * works
  2086. X     * also incidentally prevents development of any hack-o-matic programs
  2087. X     */
  2088. X    if (!isatty(0))
  2089. X        error("You must play from a terminal.");
  2090. X
  2091. X    /* we ignore QUIT and INT at this point */
  2092. X    if (!lock_file(HLOCK, 10)) {
  2093. X        wait_synch();
  2094. X        error("");
  2095. X    }
  2096. X
  2097. X    regularize(lock);
  2098. X    set_levelfile_name(lock, 0);
  2099. X
  2100. X    if(locknum) {
  2101. X        if(locknum > 25) locknum = 25;
  2102. X
  2103. X        do {
  2104. X            lock[0] = 'a' + i++;
  2105. X
  2106. X            if((fd = open(lock, 0)) == -1) {
  2107. X                if(errno == ENOENT) goto gotlock; /* no such file */
  2108. X                perror(lock);
  2109. X                unlock_file(HLOCK);
  2110. X                error("Cannot open %s", lock);
  2111. X            }
  2112. X
  2113. X            if(veryold(fd) /* closes fd if true */
  2114. X                            && eraseoldlocks())
  2115. X                goto gotlock;
  2116. X            (void) close(fd);
  2117. X        } while(i < locknum);
  2118. X
  2119. X        unlock_file(HLOCK);
  2120. X        error("Too many hacks running now.");
  2121. X    } else {
  2122. X        if((fd = open(lock, 0)) == -1) {
  2123. X            if(errno == ENOENT) goto gotlock;    /* no such file */
  2124. X            perror(lock);
  2125. X            unlock_file(HLOCK);
  2126. X            error("Cannot open %s", lock);
  2127. X        }
  2128. X
  2129. X        if(veryold(fd) /* closes fd if true */ && eraseoldlocks())
  2130. X            goto gotlock;
  2131. X        (void) close(fd);
  2132. X
  2133. X        if(flags.window_inited) {
  2134. X            c = yn("There is already a game in progress under your name.  Destroy old game?");
  2135. X        } else {
  2136. X            (void) printf("\nThere is already a game in progress under your name.");
  2137. X            (void) printf("  Destroy old game? [yn] ");
  2138. X            (void) fflush(stdout);
  2139. X            c = getchar();
  2140. X            (void) putchar(c);
  2141. X            (void) fflush(stdout);
  2142. X            while (getchar() != '\n') ; /* eat rest of line and newline */
  2143. X        }
  2144. X        if(c == 'y' || c == 'Y')
  2145. X            if(eraseoldlocks())
  2146. X                goto gotlock;
  2147. X            else {
  2148. X                unlock_file(HLOCK);
  2149. X                error("Couldn't destroy old game.");
  2150. X            }
  2151. X        else {
  2152. X            unlock_file(HLOCK);
  2153. X            error("");
  2154. X        }
  2155. X    }
  2156. X
  2157. Xgotlock:
  2158. X    fd = creat(lock, FCMASK);
  2159. X    unlock_file(HLOCK);
  2160. X    if(fd == -1) {
  2161. X        error("cannot creat lock file.");
  2162. X    } else {
  2163. X        if(write(fd, (genericptr_t) &hackpid, sizeof(hackpid))
  2164. X            != sizeof(hackpid)){
  2165. X            error("cannot write lock");
  2166. X        }
  2167. X        if(close(fd) == -1) {
  2168. X            error("cannot close lock");
  2169. X        }
  2170. X    }
  2171. X}    
  2172. X
  2173. Xvoid
  2174. Xregularize(s)    /* normalize file name - we don't like .'s, /'s, spaces */
  2175. Xregister char *s;
  2176. X{
  2177. X    register char *lp;
  2178. X
  2179. X    while((lp=index(s, '.')) || (lp=index(s, '/')) || (lp=index(s,' ')))
  2180. X        *lp = '_';
  2181. X#if defined(SYSV) && !defined(AIX_31)
  2182. X    /* avoid problems with 14 character file name limit */
  2183. X# ifdef COMPRESS
  2184. X    if(strlen(s) > 10)
  2185. X        /* leave room for .e from error and .Z from compress
  2186. X         * appended to save files */
  2187. X        s[10] = '\0';
  2188. X# else
  2189. X    if(strlen(s) > 11)
  2190. X        /* leave room for .nn appended to level files */
  2191. X        s[11] = '\0';
  2192. X# endif
  2193. X#endif
  2194. X}
  2195. X
  2196. X#ifdef SHELL
  2197. Xint
  2198. Xdosh()
  2199. X{
  2200. X    register char *str;
  2201. X    if(child(0)) {
  2202. X        if(str = getenv("SHELL"))
  2203. X            (void) execl(str, str, NULL);
  2204. X        else
  2205. X            (void) execl("/bin/sh", "sh", NULL);
  2206. X        raw_print("sh: cannot execute.");
  2207. X        exit(1);
  2208. X    }
  2209. X    return 0;
  2210. X}
  2211. X#endif /* SHELL /**/
  2212. X
  2213. X#if defined(SHELL) || defined(DEF_PAGER) || defined(DEF_MAILREADER)
  2214. Xint
  2215. Xchild(wt)
  2216. Xint wt;
  2217. X{
  2218. X    register int f;
  2219. X    suspend_nhwindows(NULL);    /* also calls end_screen() */
  2220. X    if((f = fork()) == 0){        /* child */
  2221. X        (void) setgid(getgid());
  2222. X        (void) setuid(getuid());
  2223. X#ifdef CHDIR
  2224. X        (void) chdir(getenv("HOME"));
  2225. X#endif
  2226. X        return(1);
  2227. X    }
  2228. X    if(f == -1) {    /* cannot fork */
  2229. X        pline("Fork failed.  Try again.");
  2230. X        return(0);
  2231. X    }
  2232. X    /* fork succeeded; wait for child to exit */
  2233. X    (void) signal(SIGINT,SIG_IGN);
  2234. X    (void) signal(SIGQUIT,SIG_IGN);
  2235. X    (void) wait( (int *) 0);
  2236. X    (void) signal(SIGINT, (SIG_RET_TYPE) done1);
  2237. X#ifdef WIZARD
  2238. X    if(wizard) (void) signal(SIGQUIT,SIG_DFL);
  2239. X#endif
  2240. X    if(wt) {
  2241. X        raw_print("");
  2242. X        wait_synch();
  2243. X    }
  2244. X    resume_nhwindows();
  2245. X    return(0);
  2246. X}
  2247. X#endif
  2248. END_OF_FILE
  2249. if test 7443 -ne `wc -c <'sys/unix/unixunix.c'`; then
  2250.     echo shar: \"'sys/unix/unixunix.c'\" unpacked with wrong size!
  2251. fi
  2252. # end of 'sys/unix/unixunix.c'
  2253. fi
  2254. echo shar: End of archive 97 \(of 108\).
  2255. cp /dev/null ark97isdone
  2256. MISSING=""
  2257. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  2258. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
  2259. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
  2260. 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
  2261. 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \
  2262. 101 102 103 104 105 106 107 108 ; do
  2263.     if test ! -f ark${I}isdone ; then
  2264.     MISSING="${MISSING} ${I}"
  2265.     fi
  2266. done
  2267. if test "${MISSING}" = "" ; then
  2268.     echo You have unpacked all 108 archives.
  2269.     echo "Now execute 'rebuild.sh'"
  2270.     rm -f ark10[0-8]isdone ark[1-9]isdone ark[1-9][0-9]isdone
  2271. else
  2272.     echo You still need to unpack the following archives:
  2273.     echo "        " ${MISSING}
  2274. fi
  2275. ##  End of shell archive.
  2276. exit 0
  2277.