home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume16 / nethck31 / part89 < prev    next >
Encoding:
Internet Message Format  |  1993-02-05  |  57.7 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: v16i097:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Part89/108
  5. Message-ID: <4460@master.CNA.TEK.COM>
  6. Date: 5 Feb 93 19:22:18 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1856
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1648
  11.  
  12. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  13. Posting-number: Volume 16, Issue 97
  14. Archive-name: nethack31/Part89
  15. Supersedes: nethack3p9: Volume 10, Issue 46-102
  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 89 (of 108)."
  27. # Contents:  dat/Samurai.des include/trap.h src/fountain.c
  28. #   sys/msdos/exesmurf.c sys/vms/gnutparam.c
  29. # Wrapped by billr@saab on Wed Jan 27 16:09:23 1993
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'dat/Samurai.des' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'dat/Samurai.des'\"
  33. else
  34. echo shar: Extracting \"'dat/Samurai.des'\" \(13527 characters\)
  35. sed "s/^X//" >'dat/Samurai.des' <<'END_OF_FILE'
  36. X#    SCCS Id: @(#)Samurai.des    3.1    92/10/24
  37. X#    Copyright (c) 1989 by Jean-Christophe Collet
  38. X#    Copyright (c) 1991-92 by M. Stephenson, P. Winner
  39. X# NetHack may be freely redistributed.  See license for details.
  40. X#
  41. X#    The "start" level for the quest.
  42. X#
  43. X#    Here you meet your (besieged) class leader, Lord Sato
  44. X#    and receive your quest assignment.
  45. X#
  46. XMAZE: "S-start",' '
  47. XFLAGS: noteleport,hardfloor
  48. XGEOMETRY:center,center
  49. XMAP
  50. X..............................................................PP............
  51. X...............................................................PP...........
  52. X..........---------------------------------------------------...PPP.........
  53. X..........|......|.........|...|..............|...|.........|....PPPPP......
  54. X......... |......|.........S...|..............|...S.........|.....PPPP......
  55. X..........|......|.........|---|..............|---|.........|.....PPP.......
  56. X..........+......|.........+...-------++-------...+.........|......PP.......
  57. X..........+......|.........|......................|.........|......PP.......
  58. X......... |......---------------------++--------------------|........PP.....
  59. X..........|.................................................|.........PP....
  60. X..........|.................................................|...........PP..
  61. X..........----------------------------------------...-------|............PP.
  62. X..........................................|.................|.............PP
  63. X.............. ................. .........|.................|..............P
  64. X............. } ............... } ........|.................|...............
  65. X.............. ........PP....... .........|.................|...............
  66. X.....................PPP..................|.................|...............
  67. X......................PP..................-------------------...............
  68. X............................................................................
  69. X............................................................................
  70. XENDMAP
  71. X# Random Monsters
  72. XRANDOM_MONSTERS: 'd', 'I'
  73. X# Dungeon Description
  74. XREGION:(00,00,75,19),lit,"ordinary"
  75. XREGION:(18,03,26,07),lit,"throne",unfilled
  76. X# Portal arrival zone
  77. XBRANCH:(62,12,70,17),(0,0,0,0)
  78. X# Stairs
  79. XSTAIR:(29,04),down
  80. X# Doors
  81. XDOOR:locked,(10,06)
  82. XDOOR:locked,(10,07)
  83. XDOOR:closed,(27,04)
  84. XDOOR:closed,(27,06)
  85. XDOOR:closed,(38,06)
  86. XDOOR:locked,(38,08)
  87. XDOOR:closed,(39,06)
  88. XDOOR:locked,(39,08)
  89. XDOOR:closed,(50,04)
  90. XDOOR:closed,(50,06)
  91. X# Lord Sato
  92. XMONSTER:'@',"Lord Sato",(20,04)
  93. X# The treasure of Lord Sato
  94. XOBJECT:'(',"chest",(20,04)
  95. X# ninja guards for the audience chamber
  96. XMONSTER:'@',"ninja",(18,04)
  97. XMONSTER:'@',"ninja",(18,05)
  98. XMONSTER:'@',"ninja",(18,06)
  99. XMONSTER:'@',"ninja",(18,07)
  100. XMONSTER:'@',"ninja",(26,04)
  101. XMONSTER:'@',"ninja",(26,05)
  102. XMONSTER:'@',"ninja",(26,06)
  103. XMONSTER:'@',"ninja",(26,07)
  104. X# Non diggable walls
  105. XNON_DIGGABLE:(00,00,75,19)
  106. X# Random traps
  107. XTRAP:random,random
  108. XTRAP:random,random
  109. XTRAP:random,random
  110. XTRAP:random,random
  111. XTRAP:random,random
  112. XTRAP:random,random
  113. X# Monsters on siege duty.
  114. XMONSTER: '@',"ronin",(64,00),hostile
  115. XMONSTER: 'd',"wolf",(65,01)
  116. XMONSTER: '@',"ronin",(66,02),hostile
  117. XMONSTER: '@',"ronin",(69,05),hostile
  118. XMONSTER: '@',"ronin",(69,06),hostile
  119. XMONSTER: 'd',"wolf",(69,07)
  120. XMONSTER: '@',"ronin",(70,06),hostile
  121. XMONSTER: '@',"ronin",(70,07),hostile
  122. XMONSTER: '@',"ronin",(72,01),hostile
  123. XMONSTER: 'd',"wolf",(75,09)
  124. XMONSTER: '@',"ronin",(73,05),hostile
  125. XMONSTER: '@',"ronin",(68,02),hostile
  126. XMONSTER:'I',"stalker",random
  127. X#
  128. X#    The "locate" level for the quest.
  129. X#
  130. X#    Here you have to invade the Shogun's Castle to go
  131. X#    further towards your assigned quest.
  132. X#
  133. X
  134. XMAZE: "S-locate",' '
  135. XFLAGS: hardfloor
  136. XGEOMETRY:center,center
  137. XMAP
  138. X............................................................................
  139. X............................................................................
  140. X........-----..................................................-----........
  141. X........|...|..................................................|...|........
  142. X........|...---..}..--+------------------------------+--..}..---...|........
  143. X........|-|...|.....|...|....|....|....|....|....|.|...|.....|...|-|........
  144. X..........|...-------...|....|....|....|....|....S.|...-------...|..........
  145. X..........|-|.........------+----+-+-------+-+--------.........|-|..........
  146. X............|..--------.|}........................}|.--------..|............
  147. X............|..+........+..........................+........+..|............
  148. X............|..+........+..........................+........+..|............
  149. X............|..--------.|}........................}|.--------..|............
  150. X..........|-|.........--------+-+-------+-+----+------.........|-|..........
  151. X..........|...-------...|.S....|....|....|....|....|...-------...|..........
  152. X........|-|...|.....|...|.|....|....|....|....|....|...|.....|...|-|........
  153. X........|...---..}..--+------------------------------+--..}..---...|........
  154. X........|...|..................................................|...|........
  155. X........-----..................................................-----........
  156. X............................................................................
  157. X............................................................................
  158. XENDMAP
  159. X# Random Monsters
  160. XRANDOM_MONSTERS: 'd', 'I'
  161. X# Dungeon Description
  162. XREGION:(00,00,75,19),lit,"ordinary"
  163. X# Doors
  164. XDOOR:locked,(22,04)
  165. XDOOR:locked,(22,15)
  166. XDOOR:locked,(53,04)
  167. XDOOR:locked,(53,15)
  168. XDOOR:locked,(49,06)
  169. XDOOR:locked,(26,13)
  170. XDOOR:locked,(28,07)
  171. XDOOR:locked,(30,12)
  172. XDOOR:locked,(33,07)
  173. XDOOR:locked,(32,12)
  174. XDOOR:locked,(35,07)
  175. XDOOR:locked,(40,12)
  176. XDOOR:locked,(43,07)
  177. XDOOR:locked,(42,12)
  178. XDOOR:locked,(45,07)
  179. XDOOR:locked,(47,12)
  180. XDOOR:closed,(15,09)
  181. XDOOR:closed,(15,10)
  182. XDOOR:closed,(24,09)
  183. XDOOR:closed,(24,10)
  184. XDOOR:closed,(51,09)
  185. XDOOR:closed,(51,10)
  186. XDOOR:closed,(60,09)
  187. XDOOR:closed,(60,10)
  188. X# Stairs
  189. XSTAIR:(10,10),up
  190. XSTAIR:(25,14),down
  191. X# Non diggable walls
  192. XNON_DIGGABLE:(00,00,75,19)
  193. X# Objects
  194. XOBJECT:'*',random,(25,05)
  195. XOBJECT:'*',random,(26,05)
  196. XOBJECT:'*',random,(27,05)
  197. XOBJECT:'*',random,(28,05)
  198. XOBJECT:'*',random,(25,06)
  199. XOBJECT:'*',random,(26,06)
  200. XOBJECT:'*',random,(27,06)
  201. XOBJECT:'*',random,(28,06)
  202. X#
  203. XOBJECT:'[',random,(40,05)
  204. XOBJECT:'[',random,(41,05)
  205. XOBJECT:'[',random,(42,05)
  206. XOBJECT:'[',random,(43,05)
  207. XOBJECT:'[',random,(40,06)
  208. XOBJECT:'[',random,(41,06)
  209. XOBJECT:'[',random,(42,06)
  210. XOBJECT:'[',random,(43,06)
  211. X#
  212. XOBJECT:')',random,(27,13)
  213. XOBJECT:')',random,(28,13)
  214. XOBJECT:')',random,(29,13)
  215. XOBJECT:')',random,(30,13)
  216. XOBJECT:')',random,(27,14)
  217. XOBJECT:')',random,(28,14)
  218. XOBJECT:')',random,(29,14)
  219. XOBJECT:')',random,(30,14)
  220. X#
  221. XOBJECT:'(',random,(37,13)
  222. XOBJECT:'(',random,(38,13)
  223. XOBJECT:'(',random,(39,13)
  224. XOBJECT:'(',random,(40,13)
  225. XOBJECT:'(',random,(37,14)
  226. XOBJECT:'(',random,(38,14)
  227. XOBJECT:'(',random,(39,14)
  228. XOBJECT:'(',random,(40,14)
  229. X# Random traps
  230. XTRAP:random,random
  231. XTRAP:random,random
  232. XTRAP:random,random
  233. XTRAP:random,random
  234. XTRAP:random,random
  235. XTRAP:random,random
  236. X# Random monsters.
  237. XMONSTER:'@',"ronin",(15,05),hostile
  238. XMONSTER:'@',"ronin",(16,05),hostile
  239. XMONSTER:'d',"wolf",(17,05)
  240. XMONSTER:'d',"wolf",(18,05)
  241. XMONSTER:'@',"ronin",(19,05),hostile
  242. XMONSTER:'d',"wolf",(15,14)
  243. XMONSTER:'d',"wolf",(16,14)
  244. XMONSTER:'@',"ronin",(17,14),hostile
  245. XMONSTER:'@',"ronin",(18,14),hostile
  246. XMONSTER:'d',"wolf",(56,05)
  247. XMONSTER:'@',"ronin",(57,05),hostile
  248. XMONSTER:'d',"wolf",(58,05)
  249. XMONSTER:'d',"wolf",(59,05)
  250. XMONSTER:'@',"ronin",(56,14),hostile
  251. XMONSTER:'d',"wolf",(57,14)
  252. XMONSTER:'@',"ronin",(58,14),hostile
  253. XMONSTER:'d',random,(59,14)
  254. XMONSTER:'d',"wolf",(60,14)
  255. XMONSTER:'I',random,random
  256. XMONSTER:'I',"stalker",random
  257. XMONSTER:'I',"stalker",random
  258. XMONSTER:'I',"stalker",random
  259. XMONSTER:'I',"stalker",random
  260. XMONSTER:'I',"stalker",random
  261. XMONSTER:'I',"stalker",random
  262. XMONSTER:'I',"stalker",random
  263. XMONSTER:'I',random,random
  264. X#    "guards" for the central courtyard.
  265. XMONSTER:'@',"samurai",(30,05),hostile
  266. XMONSTER:'@',"samurai",(31,05),hostile
  267. XMONSTER:'@',"samurai",(32,05),hostile
  268. XMONSTER:'@',"samurai",(32,14),hostile
  269. XMONSTER:'@',"samurai",(33,14),hostile
  270. XMONSTER:'@',"samurai",(34,14),hostile
  271. X
  272. X#
  273. X#    The "goal" level for the quest.
  274. X#
  275. X#    Here you meet Takauji, your nemesis monster.  You have to
  276. X#    defeat him in combat to gain the artifact you have been
  277. X#    assigned to retrieve.
  278. X#
  279. X
  280. XMAZE: "S-goal", ' '
  281. XFLAGS: noteleport
  282. XGEOMETRY:center,center
  283. XMAP
  284. X                                             
  285. X           .......................           
  286. X       ......---------.---------......       
  287. X    ......----.................----......    
  288. X   ....----.....-------------.....----....   
  289. X  ....--.....----...........----.....--....  
  290. X  ...||....---....---------....---....||...  
  291. X  ...|....--....---.......---....--....|...  
  292. X ....|...||...---...--+--...---...||...|.... 
  293. X ....|...|....|....|-...-|....|....|...|.... 
  294. X ....|...|....|....+.....+....|........|.... 
  295. X ....|...|....|....|-...-|....|....|...|.... 
  296. X ....|...||...---...--+--...---...||...|.... 
  297. X  ...|....--....---.......---....--....|...  
  298. X  ...||....---....----.----....---....||...  
  299. X  ....--.....----...........----.....--....  
  300. X   ....----.....-------------.....----....   
  301. X    ......----.................----......    
  302. X       ......-------------------......       
  303. X           .......................           
  304. XENDMAP
  305. X# Random Monsters
  306. XRANDOM_MONSTERS: 'd', 'I'
  307. X# Dungeon Description
  308. XREGION:(00,00,44,19),unlit,"ordinary"
  309. X# Stairs
  310. XSTAIR:(02,10),up
  311. X# Non diggable walls
  312. XNON_DIGGABLE:(00,00,44,19)
  313. X# Objects
  314. XOBJECT:')',"tsurugi",(22,10),blessed,0,"The Tsurugi of Muramasa"
  315. XOBJECT:random,random,random
  316. XOBJECT:random,random,random
  317. XOBJECT:random,random,random
  318. XOBJECT:random,random,random
  319. XOBJECT:random,random,random
  320. XOBJECT:random,random,random
  321. XOBJECT:random,random,random
  322. XOBJECT:random,random,random
  323. XOBJECT:random,random,random
  324. XOBJECT:random,random,random
  325. XOBJECT:random,random,random
  326. XOBJECT:random,random,random
  327. XOBJECT:random,random,random
  328. XOBJECT:random,random,random
  329. X#
  330. XTRAP:"board",(22,09)
  331. XTRAP:"board",(24,10)
  332. XTRAP:"board",(22,11)
  333. X# Random traps
  334. XTRAP:random,random
  335. XTRAP:random,random
  336. XTRAP:random,random
  337. XTRAP:random,random
  338. XTRAP:random,random
  339. XTRAP:random,random
  340. X# Random monsters.
  341. XMONSTER:'@',"Ashikaga Takauji",(22,10)
  342. XMONSTER:'@',"samurai",random,hostile
  343. XMONSTER:'@',"samurai",random,hostile
  344. XMONSTER:'@',"samurai",random,hostile
  345. XMONSTER:'@',"samurai",random,hostile
  346. XMONSTER:'@',"samurai",random,hostile
  347. XMONSTER:'@',"ronin",random,hostile
  348. XMONSTER:'@',"ronin",random,hostile
  349. XMONSTER:'@',"ronin",random,hostile
  350. XMONSTER:'@',"ronin",random,hostile
  351. XMONSTER:'@',"ronin",random,hostile
  352. XMONSTER:'d',"wolf",random
  353. XMONSTER:'d',"wolf",random
  354. XMONSTER:'d',"wolf",random
  355. XMONSTER:'d',"wolf",random
  356. XMONSTER:'d',random,random
  357. XMONSTER:'d',random,random
  358. XMONSTER:'I',"stalker",random
  359. XMONSTER:'I',"stalker",random
  360. XMONSTER:'I',"stalker",random
  361. XMONSTER:'I',"stalker",random
  362. XMONSTER:'I',"stalker",random
  363. XMONSTER:'I',"stalker",random
  364. XMONSTER:'I',"stalker",random
  365. XMONSTER:'I',"stalker",random
  366. XMONSTER:'I',random,random
  367. X
  368. X
  369. X#
  370. X#    The "fill" levels for the quest.
  371. X#
  372. X#    These levels are used to fill out any levels not occupied by specific
  373. X#    levels as defined above. "filla" is the upper filler, between the
  374. X#    start and locate levels, and "fillb" the lower between the locate
  375. X#    and goal levels.
  376. X#
  377. X
  378. XMAZE: "S-filla", ' '
  379. XINIT_MAP: '.' , 'P', true, true, random, true
  380. XNOMAP
  381. X# Random Monsters
  382. XRANDOM_MONSTERS: 'd', 'I'
  383. X#
  384. XSTAIR: random, up
  385. XSTAIR: random, down
  386. X#
  387. XOBJECT: random, random, random
  388. XOBJECT: random, random, random
  389. XOBJECT: random, random, random
  390. XOBJECT: random, random, random
  391. XOBJECT: random, random, random
  392. XOBJECT: random, random, random
  393. XOBJECT: random, random, random
  394. XOBJECT: random, random, random
  395. XOBJECT: random, random, random
  396. X#
  397. XMONSTER: 'd', random, random
  398. XMONSTER: 'd', "wolf", random
  399. XMONSTER: 'd', "wolf", random
  400. XMONSTER: 'd', "wolf", random
  401. XMONSTER: 'd', "wolf", random
  402. XMONSTER: 'd', "wolf", random
  403. XMONSTER: 'I', "stalker", random
  404. X#
  405. XTRAP: random, random
  406. XTRAP: random, random
  407. XTRAP: random, random
  408. XTRAP: random, random
  409. X
  410. XMAZE: "S-fillb", ' '
  411. XGEOMETRY:center,center
  412. XMAP
  413. X-------------                                  -------------
  414. X|...........|                                  |...........|
  415. X|...-----...|----------------------------------|...-----...|
  416. X|...|   |...|..................................|...|   |...|
  417. X|...-----..........................................-----...|
  418. X|...........|--S----------------------------S--|...........|
  419. X----...--------.|..........................|.--------...----
  420. X   |...|........+..........................+........|...|   
  421. X   |...|........+..........................+........|...|   
  422. X----...--------.|..........................|.--------...----
  423. X|...........|--S----------------------------S--|...........|
  424. X|...-----..........................................-----...|
  425. X|...|   |...|..................................|...|   |...|
  426. X|...-----...|----------------------------------|...-----...|
  427. X|...........|                                  |...........|
  428. X-------------                                  -------------
  429. XENDMAP
  430. XREGION:(00,00,59,15),unlit,"ordinary"
  431. X# Random Monsters
  432. X#RANDOM_MONSTERS: 'd', 'I'
  433. X#
  434. XSTAIR: random, up
  435. XSTAIR: random, down
  436. X#
  437. XOBJECT: random, random, random
  438. XOBJECT: random, random, random
  439. XOBJECT: random, random, random
  440. XOBJECT: random, random, random
  441. XOBJECT: random, random, random
  442. XOBJECT: random, random, random
  443. XOBJECT: random, random, random
  444. XOBJECT: random, random, random
  445. XOBJECT: random, random, random
  446. X#
  447. XMONSTER: 'd', random, random
  448. XMONSTER: 'd', "wolf", random
  449. XMONSTER: 'd', "wolf", random
  450. XMONSTER: 'd', "wolf", random
  451. XMONSTER: 'd', "wolf", random
  452. XMONSTER: 'I', "stalker", random
  453. XMONSTER: 'I', "stalker", random
  454. XMONSTER: 'I', "stalker", random
  455. X#
  456. XTRAP: random, random
  457. XTRAP: random, random
  458. XTRAP: random, random
  459. XTRAP: random, random
  460. END_OF_FILE
  461. if test 13527 -ne `wc -c <'dat/Samurai.des'`; then
  462.     echo shar: \"'dat/Samurai.des'\" unpacked with wrong size!
  463. fi
  464. # end of 'dat/Samurai.des'
  465. fi
  466. if test -f 'include/trap.h' -a "${1}" != "-c" ; then 
  467.   echo shar: Will not clobber existing file \"'include/trap.h'\"
  468. else
  469. echo shar: Extracting \"'include/trap.h'\" \(1140 characters\)
  470. sed "s/^X//" >'include/trap.h' <<'END_OF_FILE'
  471. X/*    SCCS Id: @(#)trap.h    3.1    92/09/28    */
  472. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  473. X/* NetHack may be freely redistributed.  See license for details. */
  474. X
  475. X/* note: no longer manipulated by 'makedefs' */
  476. X
  477. X#ifndef TRAP_H
  478. X#define TRAP_H
  479. X
  480. Xstruct trap {
  481. X    struct trap *ntrap;
  482. X    xchar tx,ty;
  483. X    Bitfield(ttyp,5);
  484. X    Bitfield(tseen,1);
  485. X    Bitfield(once,1);
  486. X    d_level dst;    /* destination for portals */
  487. X};
  488. X
  489. Xextern struct trap *ftrap;
  490. X#define newtrap()    (struct trap *) alloc(sizeof(struct trap))
  491. X#define dealloc_trap(trap) free((genericptr_t) (trap))
  492. X
  493. X/* unconditional traps */
  494. X#define NO_TRAP        0
  495. X#define ARROW_TRAP    1
  496. X#define DART_TRAP    2
  497. X#define ROCKTRAP    3
  498. X#define SQKY_BOARD    4
  499. X#define BEAR_TRAP    5
  500. X#define LANDMINE    6
  501. X#define SLP_GAS_TRAP    7
  502. X#define RUST_TRAP    8
  503. X#define FIRE_TRAP    9
  504. X#define PIT        10
  505. X#define SPIKED_PIT    11
  506. X#define TRAPDOOR    12
  507. X#define TELEP_TRAP    13
  508. X#define LEVEL_TELEP    14
  509. X#define MAGIC_PORTAL    15
  510. X#define WEB        16
  511. X#define STATUE_TRAP    17
  512. X#define MAGIC_TRAP    18
  513. X#define ANTI_MAGIC    19
  514. X
  515. X/* conditional feature traps */
  516. X#ifdef POLYSELF
  517. X#define POLY_TRAP    20
  518. X#define TRAPNUM    21
  519. X#else
  520. X#define TRAPNUM    20
  521. X#endif
  522. X
  523. X#endif /* TRAP_H */
  524. END_OF_FILE
  525. if test 1140 -ne `wc -c <'include/trap.h'`; then
  526.     echo shar: \"'include/trap.h'\" unpacked with wrong size!
  527. fi
  528. # end of 'include/trap.h'
  529. fi
  530. if test -f 'src/fountain.c' -a "${1}" != "-c" ; then 
  531.   echo shar: Will not clobber existing file \"'src/fountain.c'\"
  532. else
  533. echo shar: Extracting \"'src/fountain.c'\" \(13586 characters\)
  534. sed "s/^X//" >'src/fountain.c' <<'END_OF_FILE'
  535. X/*    SCCS Id: @(#)fountain.c    3.1    92/12/19    */
  536. X/*    Copyright Scott R. Turner, srt@ucla, 10/27/86 */
  537. X/* NetHack may be freely redistributed.  See license for details. */
  538. X
  539. X/* Code for drinking from fountains. */
  540. X
  541. X#include "hack.h"
  542. X
  543. Xstatic void NDECL(dowatersnakes);
  544. Xstatic void NDECL(dowaterdemon);
  545. Xstatic void NDECL(dowaternymph);
  546. XSTATIC_PTR void FDECL(gush, (int,int,genericptr_t));
  547. Xstatic void NDECL(dofindgem);
  548. X
  549. Xstatic void
  550. Xdowatersnakes() /* Fountain of snakes! */
  551. X{
  552. X    register int num = rn1(5,2);
  553. X    struct monst *mtmp;
  554. X
  555. X    if (!(mons[PM_WATER_MOCCASIN].geno & (G_GENOD | G_EXTINCT))) {
  556. X    if (!Blind)
  557. X        pline("An endless stream of %s pours forth!",
  558. X          Hallucination ? makeplural(rndmonnam()) : "snakes");
  559. X    else
  560. X        You("hear something hissing!");
  561. X    while(num-- > 0)
  562. X        if((mtmp = makemon(&mons[PM_WATER_MOCCASIN],u.ux,u.uy)) &&
  563. X           t_at(mtmp->mx, mtmp->my))
  564. X        (void) mintrap(mtmp);
  565. X    } else
  566. X    pline("The fountain bubbles furiously for a moment, then calms.");
  567. X}
  568. X
  569. Xstatic
  570. Xvoid
  571. Xdowaterdemon() /* Water demon */
  572. X{
  573. X    register struct monst *mtmp;
  574. X
  575. X    if(mons[PM_WATER_DEMON].geno & (G_GENOD | G_EXTINCT)) return;
  576. X    if((mtmp = makemon(&mons[PM_WATER_DEMON],u.ux,u.uy))) {
  577. X        if (!Blind)
  578. X        You("have unleashed %s!", a_monnam(mtmp));
  579. X        else
  580. X        You("feel the presence of evil.");
  581. X
  582. X    /* Give those on low levels a (slightly) better chance of survival */
  583. X        if ( rnd(100) > (80 + level_difficulty())) {
  584. X        pline("Grateful for %s release, %s grants you a wish!",
  585. X            Blind ? "its" : "his", Blind ? "it" : "he" );
  586. X        makewish();
  587. X        mongone(mtmp);
  588. X        } else if (t_at(mtmp->mx, mtmp->my))
  589. X        (void) mintrap(mtmp);
  590. X    }
  591. X}
  592. X
  593. Xstatic void
  594. Xdowaternymph() /* Water Nymph */
  595. X{
  596. X    register struct monst *mtmp;
  597. X
  598. X    if(mons[PM_WATER_NYMPH].geno & (G_GENOD | G_EXTINCT)) return;
  599. X    if((mtmp = makemon(&mons[PM_WATER_NYMPH],u.ux,u.uy))) {
  600. X        if (!Blind)
  601. X           You("have attracted %s!", a_monnam(mtmp));
  602. X        else
  603. X           You("hear a seductive voice.");
  604. X        mtmp->msleep = 0;
  605. X        if (t_at(mtmp->mx, mtmp->my))
  606. X            (void) mintrap(mtmp);
  607. X    } else
  608. X        if (!Blind)
  609. X           pline("A large bubble rises to the surface and pops.");
  610. X        else
  611. X           You("hear a loud pop.");
  612. X}
  613. X
  614. Xvoid
  615. Xdogushforth(drinking) /* Gushing forth along LOS from (u.ux, u.uy) */
  616. Xint drinking;
  617. X{
  618. X    int madepool = 0;
  619. X
  620. X    do_clear_area(u.ux, u.uy, 7, gush, (genericptr_t)&madepool);
  621. X    if (!madepool)
  622. X        if (drinking)
  623. X        Your("thirst is quenched.");
  624. X        else
  625. X        pline("Water sprays all over you.");
  626. X}
  627. X
  628. XSTATIC_PTR void
  629. Xgush(x, y, poolcnt)
  630. Xint x, y;
  631. Xgenericptr_t poolcnt;
  632. X{
  633. X    register struct monst *mtmp;
  634. X
  635. X    if (((x+y)%2) || (x == u.ux && y == u.uy) ||
  636. X        (rn2(1 + distmin(u.ux, u.uy, x, y)))  ||
  637. X        (levl[x][y].typ != ROOM) || t_at(x,y) ||
  638. X        (sobj_at(BOULDER, x, y)) || nexttodoor(x, y))
  639. X        return;
  640. X
  641. X    if (!((*(int *)poolcnt)++))
  642. X        pline("Water gushes forth from the overflowing fountain!");
  643. X
  644. X    /* Put a pool at x, y */
  645. X
  646. X    levl[x][y].typ = POOL;
  647. X
  648. X    if ((mtmp = m_at(x, y)) != 0)
  649. X        (void) minwater(mtmp);
  650. X    else
  651. X        newsym(x,y);
  652. X}
  653. X
  654. Xstatic void
  655. Xdofindgem() /* Find a gem in the sparkling waters. */
  656. X{
  657. X    if (!Blind) You("spot a gem in the sparkling waters!");
  658. X    (void) mksobj_at(rnd_class(DILITHIUM_CRYSTAL, LUCKSTONE-1),
  659. X                        u.ux, u.uy, FALSE);
  660. X    levl[u.ux][u.uy].looted |= F_LOOTED;
  661. X    newsym(u.ux, u.uy);
  662. X    exercise(A_WIS, TRUE);            /* a discovery! */
  663. X}
  664. X
  665. Xvoid
  666. Xdryup(x,y)
  667. Xxchar x, y;
  668. X{
  669. X    boolean isyou = (x == u.ux && y == u.uy);
  670. X
  671. X    if (IS_FOUNTAIN(levl[x][y].typ) &&
  672. X        (!rn2(3) || (levl[x][y].looted & F_WARNED))) {
  673. X        s_level *slev = Is_special(&u.uz);
  674. X        if(isyou && slev && slev->flags.town &&
  675. X           !(levl[x][y].looted & F_WARNED)) {
  676. X            struct monst *mtmp;
  677. X            levl[x][y].looted |= F_WARNED;
  678. X            /* Warn about future fountain use. */
  679. X            for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  680. X                if((mtmp->data == &mons[PM_WATCHMAN] ||
  681. X                mtmp->data == &mons[PM_WATCH_CAPTAIN]) &&
  682. X                   couldsee(mtmp->mx, mtmp->my) &&
  683. X                   mtmp->mpeaceful) {
  684. X                pline("%s yells:", Amonnam(mtmp));
  685. X                verbalize("Hey, stop using that fountain!");
  686. X                break;
  687. X                }
  688. X            }
  689. X            /* You can see or hear this effect */
  690. X            if(!mtmp) pline("The waterflow reduces to a trickle.");
  691. X            return;
  692. X        }
  693. X#ifdef WIZARD
  694. X        if (isyou && wizard) {
  695. X            if (yn("Dry up fountain?") == 'n')
  696. X                return;
  697. X        }
  698. X#endif
  699. X        if (cansee(x,y)) pline("The fountain dries up!");
  700. X        levl[x][y].typ = ROOM;
  701. X        levl[x][y].looted = 0;
  702. X        levl[x][y].blessedftn = 0;
  703. X        /* The location is seen if the hero/monster is invisible */
  704. X        /* or felt if the hero is blind.             */
  705. X        newsym(x, y);
  706. X        level.flags.nfountains--;
  707. X        if(isyou && slev && slev->flags.town)
  708. X            (void) angry_guards(FALSE);
  709. X    }
  710. X}
  711. X
  712. Xvoid
  713. Xdrinkfountain()
  714. X{
  715. X    /* What happens when you drink from a fountain? */
  716. X    register boolean mgkftn = (levl[u.ux][u.uy].blessedftn == 1);
  717. X    register int fate = rnd(30);
  718. X
  719. X    if (Levitation) {
  720. X        You("are floating high above the fountain.");
  721. X        return;
  722. X    }
  723. X
  724. X    if (mgkftn && u.uluck >= 0 && fate >= 10) {
  725. X        int i, ii, littleluck = (u.uluck < 4);
  726. X
  727. X        pline("Wow!  This makes you feel great!");
  728. X        /* blessed restore ability */
  729. X        for (ii = 0; ii < A_MAX; ii++)
  730. X            if (ABASE(ii) < AMAX(ii)) {
  731. X            ABASE(ii) = AMAX(ii);
  732. X            flags.botl = 1;
  733. X            }
  734. X        /* gain ability, blessed if "natural" luck is high */
  735. X        i = rn2(A_MAX);        /* start at a random attribute */
  736. X        for (ii = 0; ii < A_MAX; ii++) {
  737. X            if (adjattrib(i, 1, littleluck ? -1 : 0) && littleluck)
  738. X            break;
  739. X            if (++i >= A_MAX) i = 0;
  740. X        }
  741. X        display_nhwindow(WIN_MESSAGE, FALSE);
  742. X        pline("A wisp of vapor escapes the fountain....");
  743. X        exercise(A_WIS, TRUE);
  744. X        levl[u.ux][u.uy].blessedftn = 0;
  745. X        return;
  746. X    }
  747. X
  748. X    if (fate < 10) {
  749. X        pline("The cool draught refreshes you.");
  750. X        u.uhunger += rnd(10); /* don't choke on water */
  751. X        newuhs(FALSE);
  752. X        if(mgkftn) return;
  753. X    } else {
  754. X        switch (fate) {
  755. X
  756. X        case 19: /* Self-knowledge */
  757. X
  758. X            You("feel self-knowledgeable....");
  759. X            display_nhwindow(WIN_MESSAGE, FALSE);
  760. X            enlightenment(FALSE);
  761. X            exercise(A_WIS, TRUE);
  762. X            pline("The feeling subsides.");
  763. X            break;
  764. X
  765. X        case 20: /* Foul water */
  766. X
  767. X            pline("The water is foul!  You gag and vomit.");
  768. X            morehungry(rn1(20, 11));
  769. X            vomit();
  770. X            break;
  771. X
  772. X        case 21: /* Poisonous */
  773. X
  774. X            pline("The water is contaminated!");
  775. X            if (Poison_resistance) {
  776. X#ifdef TUTTI_FRUTTI
  777. X       pline("Perhaps it is runoff from the nearby %s farm.", pl_fruit);
  778. X#else
  779. X       pline("Perhaps it is runoff from the nearby orange farm.");
  780. X#endif
  781. X               losehp(rnd(4),"unrefrigerated sip of juice",
  782. X                KILLED_BY_AN);
  783. X               break;
  784. X            }
  785. X            losestr(rn1(4,3));
  786. X            losehp(rnd(10),"contaminated water", KILLED_BY);
  787. X            exercise(A_CON, FALSE);
  788. X            break;
  789. X
  790. X        case 22: /* Fountain of snakes! */
  791. X
  792. X            dowatersnakes();
  793. X            break;
  794. X
  795. X        case 23: /* Water demon */
  796. X            dowaterdemon();
  797. X            break;
  798. X
  799. X        case 24: /* Curse an item */ {
  800. X            register struct obj *obj;
  801. X
  802. X            pline("This water's no good!");
  803. X            morehungry(rn1(20, 11));
  804. X            exercise(A_CON, FALSE);
  805. X            for(obj = invent; obj ; obj = obj->nobj)
  806. X                if (!rn2(5))    curse(obj);
  807. X            break;
  808. X            }
  809. X
  810. X        case 25: /* See invisible */
  811. X
  812. X            You("see an image of someone stalking you.");
  813. X            pline("But it disappears.");
  814. X            HSee_invisible |= FROMOUTSIDE;
  815. X            newsym(u.ux,u.uy);
  816. X            exercise(A_WIS, TRUE);
  817. X            break;
  818. X
  819. X        case 26: /* See Monsters */
  820. X
  821. X            (void) monster_detect((struct obj *)0, 0);
  822. X            exercise(A_WIS, TRUE);
  823. X            break;
  824. X
  825. X        case 27: /* Find a gem in the sparkling waters. */
  826. X
  827. X            if (!levl[u.ux][u.uy].looted) {
  828. X                dofindgem();
  829. X                break;
  830. X            }
  831. X
  832. X        case 28: /* Water Nymph */
  833. X
  834. X            dowaternymph();
  835. X            break;
  836. X
  837. X        case 29: /* Scare */ {
  838. X            register struct monst *mtmp;
  839. X
  840. X            pline("This water gives you bad breath!");
  841. X            for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  842. X                mtmp->mflee = 1;
  843. X            }
  844. X            break;
  845. X
  846. X        case 30: /* Gushing forth in this room */
  847. X
  848. X            dogushforth(TRUE);
  849. X            break;
  850. X
  851. X        default:
  852. X
  853. X            pline("This tepid water is tasteless.");
  854. X            break;
  855. X        }
  856. X    }
  857. X    dryup(u.ux, u.uy);
  858. X}
  859. X
  860. Xvoid
  861. Xdipfountain(obj)
  862. Xregister struct obj *obj;
  863. X{
  864. X    if (Levitation) {
  865. X        You("are floating high above the fountain.");
  866. X        return;
  867. X    }
  868. X
  869. X    /* Don't grant Excalibur when there's more than one object.  */
  870. X    /* (quantity could be > 1 if merged daggers got polymorphed) */
  871. X    if (obj->otyp == LONG_SWORD && obj->quan == 1L
  872. X        && u.ulevel >= 5 && !rn2(6)
  873. X        && !obj->oartifact
  874. X        && !exist_artifact(LONG_SWORD, artiname(ART_EXCALIBUR))) {
  875. X        if (u.ualign.type != A_LAWFUL) {
  876. X            /* Ha!  Trying to cheat her. */
  877. X            pline("A freezing mist rises from the water and envelopes the sword.");
  878. X            pline("The fountain disappears!");
  879. X            curse(obj);
  880. X            if (obj->spe > -6 && !rn2(3)) obj->spe--;
  881. X            obj->oerodeproof = FALSE;
  882. X            exercise(A_WIS, FALSE);
  883. X        } else {
  884. X            /* The lady of the lake acts! - Eric Backus */
  885. X            /* Be *REAL* nice */
  886. X      pline("From the murky depths, a hand reaches up to bless the sword.");
  887. X            pline("As the hand retreats, the fountain disappears!");
  888. X            obj = oname(obj, artiname(ART_EXCALIBUR), 1);
  889. X            bless(obj);
  890. X            obj->oeroded = 0;
  891. X            obj->oerodeproof = TRUE;
  892. X            exercise(A_WIS, TRUE);
  893. X        }
  894. X        levl[u.ux][u.uy].typ = ROOM;
  895. X        levl[u.ux][u.uy].looted = 0;
  896. X        if(Invisible) newsym(u.ux, u.uy);
  897. X        level.flags.nfountains--;
  898. X        return;
  899. X    } else (void) get_wet(obj);
  900. X
  901. X    switch (rnd(30)) {
  902. X        case 16: /* Curse the item */
  903. X            curse(obj);
  904. X            break;
  905. X        case 17:
  906. X        case 18:
  907. X        case 19:
  908. X        case 20: /* Uncurse the item */
  909. X            if(obj->cursed) {
  910. X                if (!Blind)
  911. X                pline("The water glows for a moment.");
  912. X                uncurse(obj);
  913. X            } else {
  914. X                pline("A feeling of loss comes over you.");
  915. X            }
  916. X            break;
  917. X        case 21: /* Water Demon */
  918. X            dowaterdemon();
  919. X            break;
  920. X        case 22: /* Water Nymph */
  921. X            dowaternymph();
  922. X            break;
  923. X        case 23: /* an Endless Stream of Snakes */
  924. X            dowatersnakes();
  925. X            break;
  926. X        case 24: /* Find a gem */
  927. X            dofindgem();
  928. X            break;
  929. X        case 25: /* Water gushes forth */
  930. X            dogushforth(FALSE);
  931. X            break;
  932. X        case 26: /* Strange feeling */
  933. X            pline("A strange tingling runs up your %s.",
  934. X                            body_part(ARM));
  935. X            break;
  936. X        case 27: /* Strange feeling */
  937. X            You("feel a sudden chill.");
  938. X            break;
  939. X        case 28: /* Strange feeling */
  940. X            pline("An urge to take a bath overwhelms you.");
  941. X            if (u.ugold > 10) {
  942. X                u.ugold -= somegold() / 10;
  943. X                You("lost some of your gold in the fountain!");
  944. X                levl[u.ux][u.uy].looted &= ~F_LOOTED;
  945. X                exercise(A_WIS, FALSE);
  946. X            }
  947. X            break;
  948. X        case 29: /* You see coins */
  949. X
  950. X        /* We make fountains have more coins the closer you are to the
  951. X         * surface.  After all, there will have been more people going
  952. X         * by.    Just like a shopping mall!  Chris Woodbury  */
  953. X
  954. X            mkgold((long)
  955. X            (rnd((dunlevs_in_dungeon(&u.uz)-dunlev(&u.uz)+1)*2)+5),
  956. X            u.ux, u.uy);
  957. X            if (!Blind)
  958. X        pline("Far below you, you see coins glistening in the water.");
  959. X            exercise(A_WIS, TRUE);
  960. X            break;
  961. X    }
  962. X    dryup(u.ux, u.uy);
  963. X}
  964. X
  965. X#ifdef SINKS
  966. Xvoid
  967. Xbreaksink(x,y)
  968. Xint x, y;
  969. X{
  970. X    if(cansee(x,y) || (x == u.ux && y == u.uy))
  971. X    pline("The pipes break!  Water spurts out!");
  972. X    level.flags.nsinks--;
  973. X    levl[x][y].doormask = 0;
  974. X    levl[x][y].typ = FOUNTAIN;
  975. X    level.flags.nfountains++;
  976. X    newsym(x,y);
  977. X}
  978. X
  979. Xvoid
  980. Xdrinksink()
  981. X{
  982. X    if (Levitation) {
  983. X        You("are floating high above the sink.");
  984. X        return;
  985. X    }
  986. X    switch(rn2(20)) {
  987. X        static struct obj NEARDATA *otmp;
  988. X        case 0: You("take a sip of very cold water.");
  989. X            break;
  990. X        case 1: You("take a sip of very warm water.");
  991. X            break;
  992. X        case 2: You("take a sip of scalding hot water.");
  993. X            if (Fire_resistance)
  994. X                pline("It seems quite tasty.");
  995. X            else losehp(rnd(6), "sipping boiling water", KILLED_BY);
  996. X            break;
  997. X        case 3: if (mons[PM_SEWER_RAT].geno & (G_GENOD | G_EXTINCT))
  998. X                pline("The sink seems quite dirty.");
  999. X            else {
  1000. X                static struct monst NEARDATA *mtmp;
  1001. X
  1002. X                mtmp = makemon(&mons[PM_SEWER_RAT], u.ux, u.uy);
  1003. X                pline("Eek!  There's %s in the sink!",
  1004. X                    Blind ? "something squirmy" :
  1005. X                    a_monnam(mtmp));
  1006. X            }
  1007. X            break;
  1008. X        case 4: do {
  1009. X                otmp = mkobj(POTION_CLASS,FALSE);
  1010. X                if (otmp->otyp == POT_WATER) {
  1011. X                    obfree(otmp, (struct obj *)0);
  1012. X                    otmp = (struct obj *) 0;
  1013. X                }
  1014. X            } while(!otmp);
  1015. X            otmp->cursed = otmp->blessed = 0;
  1016. X            if (Blind)
  1017. X                pline("The sink emits some odd liquid.");
  1018. X            else
  1019. X                pline("The sink emits a stream of %s water.",
  1020. X                    Hallucination ? hcolor() :
  1021. X                    OBJ_DESCR(objects[otmp->otyp]));
  1022. X            otmp->dknown = !(Blind || Hallucination);
  1023. X            otmp->quan++; /* Avoid panic upon useup() */
  1024. X            otmp->corpsenm = 1; /* kludge for docall() */
  1025. X            (void) dopotion(otmp);
  1026. X            obfree(otmp, (struct obj *)0);
  1027. X            break;
  1028. X        case 5: if (!(levl[u.ux][u.uy].looted & S_LRING)) {
  1029. X                You("find a ring in the sink!");
  1030. X                (void) mkobj_at(RING_CLASS, u.ux, u.uy, TRUE);
  1031. X                levl[u.ux][u.uy].looted |= S_LRING;
  1032. X                exercise(A_WIS, TRUE);
  1033. X            } else pline("Some dirty water backs up in the drain.");
  1034. X            break;
  1035. X        case 6: breaksink(u.ux,u.uy);
  1036. X            break;
  1037. X        case 7: pline("The water moves as though of its own will!");
  1038. X            if ((mons[PM_WATER_ELEMENTAL].geno & (G_GENOD | G_EXTINCT))
  1039. X                || !makemon(&mons[PM_WATER_ELEMENTAL], u.ux, u.uy))
  1040. X                pline("But it quiets down.");
  1041. X            break;
  1042. X        case 8: pline("Yuk, this water tastes awful.");
  1043. X            more_experienced(1,0);
  1044. X            newexplevel();
  1045. X            break;
  1046. X        case 9: pline("Gaggg... this tastes like sewage!  You vomit.");
  1047. X            morehungry(rn1(30-ACURR(A_CON), 11));
  1048. X            vomit();
  1049. X            break;
  1050. X#ifdef POLYSELF
  1051. X        case 10: pline("This water contains toxic wastes!");
  1052. X            You("undergo a freakish metamorphosis!");
  1053. X            polyself();
  1054. X            break;
  1055. X#endif
  1056. X        /* more odd messages --JJB */
  1057. X        case 11: You("hear clanking from the pipes....");
  1058. X            break;
  1059. X        case 12: You("hear snatches of song from among the sewers....");
  1060. X            break;
  1061. X        case 19: if (Hallucination) {
  1062. X           pline("From the murky drain, a hand reaches up... --oops--");
  1063. X                break;
  1064. X            }
  1065. X        default: You("take a sip of %s water.",
  1066. X            rn2(3) ? (rn2(2) ? "cold" : "warm") : "hot");
  1067. X    }
  1068. X}
  1069. X#endif /* SINKS */
  1070. X
  1071. X/*fountain.c*/
  1072. END_OF_FILE
  1073. if test 13586 -ne `wc -c <'src/fountain.c'`; then
  1074.     echo shar: \"'src/fountain.c'\" unpacked with wrong size!
  1075. fi
  1076. # end of 'src/fountain.c'
  1077. fi
  1078. if test -f 'sys/msdos/exesmurf.c' -a "${1}" != "-c" ; then 
  1079.   echo shar: Will not clobber existing file \"'sys/msdos/exesmurf.c'\"
  1080. else
  1081. echo shar: Extracting \"'sys/msdos/exesmurf.c'\" \(13628 characters\)
  1082. sed "s/^X//" >'sys/msdos/exesmurf.c' <<'END_OF_FILE'
  1083. X/*    SCCS Id: @(#)exesmurf.c     3.1     91/01/29              */
  1084. X/* Copyright (c) Pierre Martineau and Stephen Spackman 1991, 1992, 1993.  */
  1085. X/* NetHack may be freely redistributed.  See license for details.      */
  1086. X
  1087. X/******************************************************************************
  1088. X*                                                                             *
  1089. X*                         EXE header list and modify                          *
  1090. X*                                                                             *
  1091. X*                        by Pierre Martineau, 91/01/29                        *
  1092. X*                                                                             *
  1093. X*                                Version 1.2                                  *
  1094. X*                                                                             *
  1095. X>*****************************************************************************<
  1096. X* Modified (stephen@estragon.uchicago.edu):                                   *
  1097. X* 1990oct23 sps Overlay splitter-outer first cut                              *
  1098. X*        31     Error handling; some #defines                                 *
  1099. X*     nov01     /l                                                            *
  1100. X*   91jan29     Changed default overlay file names to conform to ovlmgr 30a0  *
  1101. X******************************************************************************/
  1102. X
  1103. X#include <string.h>
  1104. X#include <stdlib.h>
  1105. X#include <stdio.h>
  1106. X#include <math.h>
  1107. X
  1108. X/** parameters ***************************************************************/
  1109. X#define MAXFILENAME 128   /* Probably overkill - theoretical limit is 80     */
  1110. X#define NPARTS        36      /* Maximum # of overlay files (excluding root .EXE)*/
  1111. X#define COPYBUFSIZE 32768 /* Fair sized buffer for file copy                 */
  1112. X#define BAKEXT      ".BAK"/* Extension for .exe backups                      */
  1113. X#define OVLEXT      ".OVL"/* Default extension for overlay files             */
  1114. X/* #define MANYZEROES */  /* Old style default: foo00001.ovl, not foo0.ovl   */
  1115. X/*****************************************************************************/
  1116. X
  1117. X#define BOOLEAN int
  1118. X#define TRUE    1
  1119. X#define FALSE   0
  1120. X
  1121. Xint sstrccnt(register char const *s, register char c)
  1122. X  { int n = 0;
  1123. X
  1124. X    while (*s) if (*s++ == c) n++;
  1125. X    return n;
  1126. X  }
  1127. X
  1128. XFILE *wrkfile, *outfile;
  1129. Xlong min, max, stk;
  1130. XBOOLEAN listflg = FALSE;
  1131. XBOOLEAN verbose = FALSE;
  1132. XBOOLEAN minflg = FALSE;
  1133. XBOOLEAN maxflg = FALSE;
  1134. XBOOLEAN stkflg = FALSE;
  1135. X
  1136. Xint column = 0;
  1137. X
  1138. Xstruct exehdr {
  1139. Xunsigned signature;
  1140. Xunsigned mod512;
  1141. Xunsigned pages;
  1142. Xunsigned relocitems;
  1143. Xunsigned headerparas;
  1144. Xunsigned minalloc;
  1145. Xunsigned maxalloc;
  1146. Xunsigned ss;
  1147. Xunsigned sp;
  1148. Xunsigned checksum;
  1149. Xunsigned ip;
  1150. Xunsigned cs;
  1151. Xunsigned relocptr;
  1152. Xunsigned ovlnum;
  1153. X} exehdr_area;
  1154. X
  1155. Xmain(argc, argv)
  1156. Xint argc;
  1157. Xchar *argv[];
  1158. X{
  1159. Xchar *dot, *slash;
  1160. Xchar fname[MAXFILENAME], oname[MAXFILENAME], zname[MAXFILENAME];
  1161. Xchar *jname = NULL;
  1162. Xchar *args;
  1163. Xint i;
  1164. Xlong offset, oldstk;
  1165. Xunsigned nparts = 0, part = 0, partstart[NPARTS + 2];
  1166. X
  1167. X    printf("EXE list and modify V1.1s, by Pierre Martineau, 90/05/20.\n");
  1168. X    printf("This program may be freely distributed.\n");
  1169. X
  1170. X    if ((argc < 2) || (argc > NPARTS + 2)) {
  1171. X        usage();
  1172. X        return;
  1173. X    }
  1174. X
  1175. X/*  Process any remaining arguments  */
  1176. X
  1177. X    if (argc == 2) {
  1178. X        listflg = TRUE;
  1179. X        verbose = TRUE; /* ??? */
  1180. X    }
  1181. X    else {
  1182. X        i = 2;
  1183. X        while (argc-- > 2) {
  1184. X            args = argv[i];
  1185. X        if ('0' <= args[0] && args[0] <= '9') { /* File split request */
  1186. X            if (nparts >= NPARTS) {
  1187. X            printf("\nToo many .OVL files requested (max. %d)\n", NPARTS);
  1188. X            usage();
  1189. X            return;
  1190. X        }
  1191. X        else if (!atoi(args)) {
  1192. X            printf("\nCan't relocate the root overlay (#0)\n");
  1193. X            usage();
  1194. X            return;
  1195. X        }
  1196. X        else if (nparts && partstart[nparts - 1] >= atoi(args)) {
  1197. X            printf("\nOverlay starts must be in ascending order\n");
  1198. X            usage();
  1199. X            return;
  1200. X        }
  1201. X        partstart[nparts++] = atoi(args);
  1202. X        } else {
  1203. X        if ((args[0] != '-') && (args[0] != '/')) {
  1204. X            printf("\nInvalid switch in paramater %s!\n", argv[i]);
  1205. X            usage();
  1206. X            return;
  1207. X        }
  1208. X        args++;
  1209. X        if (strnicmp(args, "min", 3) == 0) {
  1210. X            args += 3;
  1211. X            min = atol(args);
  1212. X            minflg = TRUE;
  1213. X        }
  1214. X        else if (strnicmp(args, "max", 3) == 0) {
  1215. X            args += 3;
  1216. X            max = atol(args);
  1217. X            maxflg = TRUE;
  1218. X        }
  1219. X        else if (strnicmp(args, "stk", 3) == 0) {
  1220. X            args += 3;
  1221. X            stk = atol(args);
  1222. X            stkflg = TRUE;
  1223. X        }
  1224. X        else if (strnicmp(args, "v", 1) == 0) {
  1225. X            listflg = TRUE;
  1226. X                    verbose = TRUE;
  1227. X                }
  1228. X                else if (strnicmp(args, "l", 1) == 0)
  1229. X                    listflg = TRUE;
  1230. X                else if (strnicmp(args, "p", 1) == 0) {
  1231. X                    args++;
  1232. X                    jname = args;
  1233. X                }
  1234. X        else {
  1235. X            printf("\nInvalid paramater %s!\n", argv[i]);
  1236. X            usage();
  1237. X            return;
  1238. X        }
  1239. X            }
  1240. X            i++;
  1241. X        }
  1242. X    }
  1243. X
  1244. X/*  Extract filename from first argumemt  */
  1245. X
  1246. X    strcpy(fname, argv[1]);
  1247. X    dot = strrchr(fname, '.');
  1248. X    slash = strrchr(fname, '\\');
  1249. X    if ((dot == NULL) || (slash > dot))
  1250. X        strcat(fname, ".exe");
  1251. X
  1252. X    if (nparts) {
  1253. X    strcpy(oname,fname);
  1254. X    *strrchr(fname, '.') = '\0';
  1255. X    strcat(fname,BAKEXT);
  1256. X    if (!stricmp(oname,fname)) {
  1257. X        printf(
  1258. X                "\nI refuse to split a file with extension "BAKEXT": %s\n",
  1259. X                oname
  1260. X            );
  1261. X        return;
  1262. X    }
  1263. X        if (!jname || nparts > 1 && !sstrccnt(jname, '?')) {
  1264. X            char ext[5];
  1265. X            char *t;
  1266. X
  1267. X            if (!jname) {
  1268. X                strcpy(zname, oname);
  1269. X                *strrchr(zname, '.') = '\0';
  1270. X                strcpy(ext, OVLEXT);
  1271. X            } else {
  1272. X                if (strrchr(jname, '.') &&
  1273. X                     (!strrchr(jname, '\\') ||
  1274. X                         strrchr(jname, '.') > strrchr(jname, '\\')
  1275. X                     )
  1276. X                ) {
  1277. X                    strncpy(ext, strrchr(jname, '.'), sizeof(ext));
  1278. X                    ext[sizeof(ext) - 1] = '\0';
  1279. X                    strncpy(zname, jname, strrchr(jname, '.') - jname);
  1280. X                    zname[strrchr(jname, '.') - jname] = '\0';
  1281. X                } else {
  1282. X                    strcpy(zname, jname);
  1283. X                    strcpy(ext, OVLEXT);
  1284. X                }
  1285. X            }
  1286. X            t = strrchr(zname, '\\') ? strrchr(zname, '\\') + 1:
  1287. X                strrchr(zname, ':') ? strrchr(zname, ':') + 1:
  1288. X                zname;
  1289. X            if (strlen(t) >= 8)
  1290. X                t[7] = '\0';
  1291. X#if defined(MANYZEROES)
  1292. X        while (strlen(t) < 8)
  1293. X#endif
  1294. X          strcat(t, "?");
  1295. X            strcat(zname, ext);
  1296. X            jname = zname;
  1297. X        }
  1298. X    if (rename(oname,fname)) { /* This assumes oldname, newname.
  1299. X                      There's some confusion. OK for TC2.0 */
  1300. X        printf("\nCouldn't rename (original) %s to %s\n", oname, fname);
  1301. X        return;
  1302. X    }
  1303. X    if ((outfile = fopen(oname, "wb")) == NULL) {
  1304. X            printf("\nCouldn't create file %s\n",oname);
  1305. X            return;
  1306. X        }
  1307. X    }
  1308. X
  1309. X    if ((wrkfile = fopen(fname, "r+b")) == NULL) {
  1310. X        printf("\nCouldn't open file %s\n", fname);
  1311. X        return;
  1312. X    }
  1313. X
  1314. X    fread(&exehdr_area, sizeof (struct exehdr), 1, wrkfile);
  1315. X    if (exehdr_area.signature != 0x5a4d) {
  1316. X        printf("\nNot an EXE file!\n");
  1317. X        return;
  1318. X    }
  1319. X
  1320. X    while(!feof(wrkfile)) {
  1321. X        if (nparts) {
  1322. X        if (exehdr_area.ovlnum == partstart[part]) {
  1323. X             fclose(outfile);
  1324. X                 {
  1325. X                     int p = part + 1;
  1326. X                     strcpy(oname, jname);
  1327. X                     while (sstrccnt(oname, '?') > 1) {
  1328. X                         *strrchr(oname, '?') = '0' + p % 10;
  1329. X                         p /= 10;
  1330. X                     }
  1331. X                     *strchr(oname, '?') = (p > 9 ? 'a' - 10 : '0') + p;
  1332. X                 }
  1333. X                 part++;
  1334. X         if ((outfile = fopen(oname, "wb")) == NULL) {
  1335. X                     printf("\nCan't open file %s\n", oname);
  1336. X                     return;
  1337. X                 }
  1338. X        }
  1339. X            fwrite(&exehdr_area, sizeof (struct exehdr), 1, outfile);
  1340. X            if (ferror(outfile)) {
  1341. X                printf("\nWrite error while moving overlay header in %s\n", oname);
  1342. X                return;
  1343. X            }
  1344. X    }
  1345. X        if (listflg)
  1346. X            show_hdr();
  1347. X        else if (nparts)
  1348. X            printf("[overlay %d]\r", exehdr_area.ovlnum); /* Keep talking... */
  1349. X        if ((minflg || maxflg || stkflg) && (exehdr_area.ovlnum == 0) && (exehdr_area.signature == 0x5a4d)) {
  1350. X            if (minflg)
  1351. X                exehdr_area.minalloc = min;
  1352. X            if (maxflg)
  1353. X                exehdr_area.maxalloc = max;
  1354. X            if (stkflg) {
  1355. X                oldstk = exehdr_area.sp;
  1356. X                exehdr_area.sp = stk;
  1357. X                if (!minflg) {
  1358. X                    exehdr_area.minalloc += ((stk - oldstk) / 16);
  1359. X                    printf("\nAdjusting size of minalloc!\n");
  1360. X                }
  1361. X            }
  1362. X            fseek(nparts ? outfile : wrkfile, ftell(wrkfile) - sizeof (struct exehdr), SEEK_SET);
  1363. X            fwrite(&exehdr_area, sizeof (struct exehdr), 1, nparts ? outfile : wrkfile);
  1364. X            if (ferror(nparts ? outfile : wrkfile)) {
  1365. X                printf("Write error while trying to update header!\n");
  1366. X                fclose(nparts ? outfile : wrkfile);
  1367. X                return;
  1368. X            }
  1369. X        }
  1370. X        offset = exehdr_area.pages;
  1371. X        offset *= 512L;
  1372. X        offset -= sizeof(struct exehdr);
  1373. X        if (nparts) { /* Copy the stuff across */
  1374. X        static char buffer[COPYBUFSIZE];
  1375. X        while (offset > sizeof(buffer)) {
  1376. X             fread(buffer, sizeof(buffer), 1, wrkfile);
  1377. X                 if (ferror(wrkfile)) {
  1378. X                     printf("\nRead error in overlay body\n");
  1379. X                     return;
  1380. X                 }
  1381. X         fwrite(buffer, sizeof(buffer), 1, outfile);
  1382. X                 if (ferror(outfile)) {
  1383. X                     printf("\nWrite error moving overlay body, file %s\n", oname);
  1384. X                     return;
  1385. X                 }
  1386. X         offset -= sizeof(buffer);
  1387. X        }
  1388. X        fread(buffer, (unsigned)offset, 1, wrkfile);
  1389. X            if (ferror(wrkfile)) {
  1390. X                printf("\nRead error in overlay body\n");
  1391. X                return;
  1392. X            }
  1393. X            fwrite(buffer, (unsigned)offset, 1, outfile);
  1394. X            if (ferror(outfile)) {
  1395. X                printf("\nWrite error moving overlay body, file %s\n", oname);
  1396. X                return;
  1397. X            }
  1398. X        } else fseek(wrkfile, offset, SEEK_CUR);
  1399. X        fread(&exehdr_area, sizeof (struct exehdr), 1, wrkfile);
  1400. X        if (ferror(wrkfile)) {
  1401. X            printf("Read error while trying to get a header!\n");
  1402. X            fclose(wrkfile);
  1403. X            return;
  1404. X        }
  1405. X    }
  1406. X    if (nparts) {
  1407. X        fclose(outfile);
  1408. X        if (!listflg) printf("                    \r");
  1409. X    }
  1410. X    fclose(wrkfile);
  1411. X    if (listflg && !verbose && column % 4) printf("\n");
  1412. X}
  1413. X
  1414. Xshow_hdr()
  1415. X{
  1416. Xlong lsize;
  1417. X
  1418. X    lsize = exehdr_area.pages;
  1419. X    if (exehdr_area.mod512 != 0)
  1420. X        lsize--;
  1421. X    lsize *= 512L;
  1422. X    lsize += exehdr_area.minalloc * 16;
  1423. X    lsize += exehdr_area.mod512;
  1424. X    lsize -= exehdr_area.headerparas * 16;
  1425. X
  1426. X    if (verbose) {
  1427. X        printf("\nOverlay: %d\n", exehdr_area.ovlnum);
  1428. X        printf("Size (512 byte pages)\t-%6x\t\t%6u\n", exehdr_area.pages, exehdr_area.pages);
  1429. X        printf("Remainder (last page)\t-%6x\t\t%6u\n", exehdr_area.mod512, exehdr_area.mod512);
  1430. X        printf("Header size (in paras)\t-%6x\t\t%6u\n", exehdr_area.headerparas, exehdr_area.headerparas);
  1431. X        printf("Minalloc (in paras)\t-%6x\t\t%6u\n", exehdr_area.minalloc, exehdr_area.minalloc);
  1432. X        printf("Maxalloc (in paras)\t-%6x\t\t%6u\n", exehdr_area.maxalloc, exehdr_area.maxalloc);
  1433. X        printf("Load size (in bytes)\t-%6lx\t\t%6lu\n", lsize, lsize);
  1434. X        printf("Relocation items\t-%6x\t\t%6u\n", exehdr_area.relocitems, exehdr_area.relocitems);
  1435. X        printf("Relocation table offset\t-%6x\t\t%6u\n", exehdr_area.relocptr, exehdr_area.relocptr);
  1436. X        printf("Checksum\t\t-%6x\t\t%6u\n", exehdr_area.checksum, exehdr_area.checksum);
  1437. X        printf("Initial CS:IP\t\t-  %04x:%04x\n", exehdr_area.cs, exehdr_area.ip);
  1438. X        printf("Initial SS:SP\t\t-  %04x:%04x\n", exehdr_area.ss, exehdr_area.sp);
  1439. X    } else {
  1440. X        if (!exehdr_area.ovlnum) {
  1441. X            printf("\nOverlay: %d\n", exehdr_area.ovlnum);
  1442. X            printf("Minalloc (in paras)\t-%6x\t\t%6u\n", exehdr_area.minalloc, exehdr_area.minalloc);
  1443. X            printf("Maxalloc (in paras)\t-%6x\t\t%6u\n", exehdr_area.maxalloc, exehdr_area.maxalloc);
  1444. X            printf("Stored size (in bytes)\t-%6lx\t\t%6lu\n", exehdr_area.pages * 512L, exehdr_area.pages * 512L);
  1445. X            printf("Load size (in bytes)\t-%6lx\t\t%6lu\n", lsize, lsize);
  1446. X            printf("Initial CS:IP, SS:SP\t-  %04x:%04x\t  %04x:%04x\n", exehdr_area.cs, exehdr_area.ip, exehdr_area.ss, exehdr_area.sp);
  1447. X    } else {
  1448. X        static bis = 0;
  1449. X        if (!bis++)
  1450. X                printf("\nOvl StrdSz LoadSz | Ovl StrdSz LoadSz | Ovl StrdSz LoadSz | Ovl StrdSz LoadSz\n");
  1451. X            printf("%3d:%6lu %6lu%s", exehdr_area.ovlnum, exehdr_area.pages * 512L, lsize, ++column % 4 ? " | " : "\n");
  1452. X        }
  1453. X    }
  1454. X}
  1455. X
  1456. Xusage()
  1457. X{
  1458. X    printf("\nUsage: exesmurf exe_file [/l] [/v] [/min#####] [/max#####] [/stk#####]\n");
  1459. X    printf("                [n1 n2...nn] [/p????????.???]\n");
  1460. X    printf("       where: min   = minalloc\n");
  1461. X    printf("              max   = maxalloc\n");
  1462. X    printf("              stk   = stack size\n");
  1463. X    printf("              ##### = decimal number of paragraphs\n");
  1464. X    printf("              ni    = overlay starting each new .OVL file, n1 < n2 <...< nn\n");
  1465. X    printf("              p     = DOS filename, maybe with ?s, for overlay files.\n");
  1466. X}
  1467. END_OF_FILE
  1468. if test 13628 -ne `wc -c <'sys/msdos/exesmurf.c'`; then
  1469.     echo shar: \"'sys/msdos/exesmurf.c'\" unpacked with wrong size!
  1470. fi
  1471. # end of 'sys/msdos/exesmurf.c'
  1472. fi
  1473. if test -f 'sys/vms/gnutparam.c' -a "${1}" != "-c" ; then 
  1474.   echo shar: Will not clobber existing file \"'sys/vms/gnutparam.c'\"
  1475. else
  1476. echo shar: Extracting \"'sys/vms/gnutparam.c'\" \(11344 characters\)
  1477. sed "s/^X//" >'sys/vms/gnutparam.c' <<'END_OF_FILE'
  1478. X/* Merge parameters into a termcap entry string.
  1479. X   Copyright (C) 1985, 1987 Free Software Foundation, Inc.
  1480. X
  1481. X
  1482. X               NO WARRANTY
  1483. X
  1484. X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  1485. XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  1486. XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  1487. XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  1488. XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  1489. XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1490. XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  1491. XAND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  1492. XDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  1493. XCORRECTION.
  1494. X
  1495. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  1496. XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  1497. XWHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  1498. XLIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  1499. XOTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  1500. XUSE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  1501. XDATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  1502. XA FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  1503. XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  1504. XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  1505. X
  1506. X        GENERAL PUBLIC LICENSE TO COPY
  1507. X
  1508. X  1. You may copy and distribute verbatim copies of this source file
  1509. Xas you receive it, in any medium, provided that you conspicuously and
  1510. Xappropriately publish on each copy a valid copyright notice "Copyright
  1511. X(C) 1986 Free Software Foundation, Inc."; and include following the
  1512. Xcopyright notice a verbatim copy of the above disclaimer of warranty
  1513. Xand of this License.  You may charge a distribution fee for the
  1514. Xphysical act of transferring a copy.
  1515. X
  1516. X  2. You may modify your copy or copies of this source file or
  1517. Xany portion of it, and copy and distribute such modifications under
  1518. Xthe terms of Paragraph 1 above, provided that you also do the following:
  1519. X
  1520. X    a) cause the modified files to carry prominent notices stating
  1521. X    that you changed the files and the date of any change; and
  1522. X
  1523. X    b) cause the whole of any work that you distribute or publish,
  1524. X    that in whole or in part contains or is a derivative of this
  1525. X    program or any part thereof, to be licensed at no charge to all
  1526. X    third parties on terms identical to those contained in this
  1527. X    License Agreement (except that you may choose to grant more extensive
  1528. X    warranty protection to some or all third parties, at your option).
  1529. X
  1530. X    c) You may charge a distribution fee for the physical act of
  1531. X    transferring a copy, and you may at your option offer warranty
  1532. X    protection in exchange for a fee.
  1533. X
  1534. XMere aggregation of another unrelated program with this program (or its
  1535. Xderivative) on a volume of a storage or distribution medium does not bring
  1536. Xthe other program under the scope of these terms.
  1537. X
  1538. X  3. You may copy and distribute this program (or a portion or derivative
  1539. Xof it, under Paragraph 2) in object code or executable form under the terms
  1540. Xof Paragraphs 1 and 2 above provided that you also do one of the following:
  1541. X
  1542. X    a) accompany it with the complete corresponding machine-readable
  1543. X    source code, which must be distributed under the terms of
  1544. X    Paragraphs 1 and 2 above; or,
  1545. X
  1546. X    b) accompany it with a written offer, valid for at least three
  1547. X    years, to give any third party free (except for a nominal
  1548. X    shipping charge) a complete machine-readable copy of the
  1549. X    corresponding source code, to be distributed under the terms of
  1550. X    Paragraphs 1 and 2 above; or,
  1551. X
  1552. X    c) accompany it with the information you received as to where the
  1553. X    corresponding source code may be obtained.  (This alternative is
  1554. X    allowed only for noncommercial distribution and only if you
  1555. X    received the program in object code or executable form alone.)
  1556. X
  1557. XFor an executable file, complete source code means all the source code for
  1558. Xall modules it contains; but, as a special exception, it need not include
  1559. Xsource code for modules which are standard libraries that accompany the
  1560. Xoperating system on which the executable file runs.
  1561. X
  1562. X  4. You may not copy, sublicense, distribute or transfer this program
  1563. Xexcept as expressly provided under this License Agreement.  Any attempt
  1564. Xotherwise to copy, sublicense, distribute or transfer this program is void and
  1565. Xyour rights to use the program under this License agreement shall be
  1566. Xautomatically terminated.  However, parties who have received computer
  1567. Xsoftware programs from you with this License Agreement will not have
  1568. Xtheir licenses terminated so long as such parties remain in full compliance.
  1569. X
  1570. X  5. If you wish to incorporate parts of this program into other free
  1571. Xprograms whose distribution conditions are different, write to the Free
  1572. XSoftware Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  1573. Xworked out a simple rule that can be stated here, but we will often permit
  1574. Xthis.  We will be guided by the two goals of preserving the free status of
  1575. Xall derivatives of our free software and of promoting the sharing and reuse of
  1576. Xsoftware.
  1577. X
  1578. X
  1579. XIn other words, you are welcome to use, share and improve this program.
  1580. XYou are forbidden to forbid anyone else to use, share and improve
  1581. Xwhat you give them.   Help stamp out software-hoarding!  */
  1582. X
  1583. X
  1584. X/* config.h may rename various library functions such as malloc.  */
  1585. X#ifdef emacs
  1586. X#include "config.h"
  1587. X#endif
  1588. X
  1589. X/* Assuming STRING is the value of a termcap string entry
  1590. X   containing `%' constructs to expand parameters,
  1591. X   merge in parameter values and store result in block OUTSTRING points to.
  1592. X   LEN is the length of OUTSTRING.  If more space is needed,
  1593. X   a block is allocated with `malloc'.
  1594. X
  1595. X   The value returned is the address of the resulting string.
  1596. X   This may be OUTSTRING or may be the address of a block got with `malloc'.
  1597. X   In the latter case, the caller must free the block.
  1598. X
  1599. X   The fourth and following args to tparam serve as the parameter values.  */
  1600. X
  1601. Xstatic char *tparam1 ();
  1602. X
  1603. X/* VARARGS 2 */
  1604. Xchar *
  1605. Xtparam (string, outstring, len, arg0, arg1, arg2, arg3)
  1606. X     char *string;
  1607. X     char *outstring;
  1608. X     int len;
  1609. X     int arg0, arg1, arg2, arg3;
  1610. X{
  1611. X#ifdef NO_ARG_ARRAY
  1612. X  int arg[4];
  1613. X  arg[0] = arg0;
  1614. X  arg[1] = arg1;
  1615. X  arg[2] = arg2;
  1616. X  arg[3] = arg3;
  1617. X  return tparam1 (string, outstring, len, 0, 0, arg);
  1618. X#else
  1619. X  return tparam1 (string, outstring, len, 0, 0, &arg0);
  1620. X#endif
  1621. X}
  1622. X
  1623. Xchar *BC;
  1624. Xchar *UP;
  1625. X
  1626. Xstatic char tgoto_buf[50];
  1627. X
  1628. Xchar *
  1629. Xtgoto (cm, hpos, vpos)
  1630. X     char *cm;
  1631. X     int hpos, vpos;
  1632. X{
  1633. X  int args[2];
  1634. X  if (!cm)
  1635. X    return 0;
  1636. X  args[0] = vpos;
  1637. X  args[1] = hpos;
  1638. X  return tparam1 (cm, tgoto_buf, 50, UP, BC, args);
  1639. X}
  1640. X
  1641. Xstatic char *
  1642. Xtparam1 (string, outstring, len, up, left, argp)
  1643. X     char *string;
  1644. X     char *outstring;
  1645. X     int len;
  1646. X     char *up, *left;
  1647. X     register int *argp;
  1648. X{
  1649. X  register int c;
  1650. X  register char *p = string;
  1651. X  register char *op = outstring;
  1652. X  char *outend;
  1653. X  int outlen = 0;
  1654. X
  1655. X  register int tem;
  1656. X  int *oargp = argp;
  1657. X  int doleft = 0;
  1658. X  int doup = 0;
  1659. X
  1660. X  outend = outstring + len;
  1661. X
  1662. X  while (1)
  1663. X    {
  1664. X      /* If the buffer might be too short, make it bigger.  */
  1665. X      if (op + 5 >= outend)
  1666. X    {
  1667. X      register char *new;
  1668. X      if (outlen == 0)
  1669. X        {
  1670. X          new = (char *) malloc (outlen = 40 + len);
  1671. X          outend += 40;
  1672. X        }
  1673. X      else
  1674. X        {
  1675. X          outend += outlen;
  1676. X          new = (char *) realloc (outstring, outlen *= 2);
  1677. X        }
  1678. X      op += new - outstring;
  1679. X      outend += new - outstring;
  1680. X      outstring = new;
  1681. X    }
  1682. X      if (!(c = *p++))
  1683. X    break;
  1684. X      if (c == '%')
  1685. X    {
  1686. X      c = *p++;
  1687. X      tem = *argp;
  1688. X      switch (c)
  1689. X        {
  1690. X        case 'd':        /* %d means output in decimal */
  1691. X          if (tem < 10)
  1692. X        goto onedigit;
  1693. X          if (tem < 100)
  1694. X        goto twodigit;
  1695. X        case '3':        /* %3 means output in decimal, 3 digits. */
  1696. X          if (tem > 999)
  1697. X        {
  1698. X          *op++ = tem / 1000 + '0';
  1699. X          tem %= 1000;
  1700. X        }
  1701. X          *op++ = tem / 100 + '0';
  1702. X        case '2':        /* %2 means output in decimal, 2 digits. */
  1703. X        twodigit:
  1704. X          tem %= 100;
  1705. X          *op++ = tem / 10 + '0';
  1706. X        onedigit:
  1707. X          *op++ = tem % 10 + '0';
  1708. X          argp++;
  1709. X          break;
  1710. X
  1711. X        case 'C':
  1712. X          /* For c-100: print quotient of value by 96, if nonzero,
  1713. X         then do like %+ */
  1714. X          if (tem >= 96)
  1715. X        {
  1716. X          *op++ = tem / 96;
  1717. X          tem %= 96;
  1718. X        }
  1719. X        case '+':        /* %+x means add character code of char x */
  1720. X          tem += *p++;
  1721. X        case '.':        /* %. means output as character */
  1722. X          if (left)
  1723. X        {
  1724. X          /* If want to forbid output of 0 and \n and \t,
  1725. X             and this is one of them, increment it.  */
  1726. X          while (tem == 0 || tem == '\n' || tem == '\t')
  1727. X            {
  1728. X              tem++;
  1729. X              if (argp == oargp)
  1730. X            doleft++, outend -= strlen (left);
  1731. X              else
  1732. X            doup++, outend -= strlen (up);
  1733. X            }
  1734. X        }
  1735. X          *op++ = tem | 0200;
  1736. X        case 'f':        /* %f means discard next arg */
  1737. X          argp++;
  1738. X          break;
  1739. X
  1740. X        case 'b':        /* %b means back up one arg (and re-use it) */
  1741. X          argp--;
  1742. X          break;
  1743. X
  1744. X        case 'r':        /* %r means interchange following two args */
  1745. X          argp[0] = argp[1];
  1746. X          argp[1] = tem;
  1747. X          oargp++;
  1748. X          break;
  1749. X
  1750. X        case '>':        /* %>xy means if arg is > char code of x, */
  1751. X          if (argp[0] > *p++) /* then add char code of y to the arg, */
  1752. X        argp[0] += *p;    /* and in any case don't output. */
  1753. X          p++;        /* Leave the arg to be output later. */
  1754. X          break;
  1755. X
  1756. X        case 'a':        /* %a means arithmetic */
  1757. X          /* Next character says what operation.
  1758. X         Add or subtract either a constant or some other arg */
  1759. X          /* First following character is + to add or - to subtract
  1760. X         or = to assign.  */
  1761. X          /* Next following char is 'p' and an arg spec
  1762. X         (0100 plus position of that arg relative to this one)
  1763. X         or 'c' and a constant stored in a character */
  1764. X          tem = p[2] & 0177;
  1765. X          if (p[1] == 'p')
  1766. X        tem = argp[tem - 0100];
  1767. X          if (p[0] == '-')
  1768. X        argp[0] -= tem;
  1769. X          else if (p[0] == '+')
  1770. X        argp[0] += tem;
  1771. X          else if (p[0] == '*')
  1772. X        argp[0] *= tem;
  1773. X          else if (p[0] == '/')
  1774. X        argp[0] /= tem;
  1775. X          else
  1776. X        argp[0] = tem;
  1777. X
  1778. X          p += 3;
  1779. X          break;
  1780. X
  1781. X        case 'i':        /* %i means add one to arg, */
  1782. X          argp[0] ++;    /* and leave it to be output later. */
  1783. X          argp[1] ++;    /* Increment the following arg, too!  */
  1784. X          break;
  1785. X
  1786. X        case '%':        /* %% means output %; no arg. */
  1787. X          goto ordinary;
  1788. X
  1789. X        case 'n':        /* %n means xor each of next two args with 140 */
  1790. X          argp[0] ^= 0140;
  1791. X          argp[1] ^= 0140;
  1792. X          break;
  1793. X
  1794. X        case 'm':        /* %m means xor each of next two args with 177 */
  1795. X          argp[0] ^= 0177;
  1796. X          argp[1] ^= 0177;
  1797. X          break;
  1798. X
  1799. X        case 'B':        /* %B means express arg as BCD char code. */
  1800. X          argp[0] += 6 * (tem / 10);
  1801. X          break;
  1802. X
  1803. X        case 'D':        /* %D means weird Delta Data transformation */
  1804. X          argp[0] -= 2 * (tem % 16);
  1805. X          break;
  1806. X        }
  1807. X    }
  1808. X      else
  1809. X    /* Ordinary character in the argument string.  */
  1810. X      ordinary:
  1811. X    *op++ = c;
  1812. X    }
  1813. X  *op = 0;
  1814. X  while (doleft-- > 0)
  1815. X    strcpy (op, left);
  1816. X  while (doup-- > 0)
  1817. X    strcpy (op, up);
  1818. X  return outstring;
  1819. X}
  1820. X
  1821. X#ifdef DEBUG
  1822. X
  1823. Xmain (argc, argv)
  1824. X     int argc;
  1825. X     char **argv;
  1826. X{
  1827. X  char buf[50];
  1828. X  int args[3];
  1829. X  args[0] = atoi (argv[2]);
  1830. X  args[1] = atoi (argv[3]);
  1831. X  args[2] = atoi (argv[4]);
  1832. X  tparam1 (argv[1], buf, "LEFT", "UP", args);
  1833. X  printf ("%s\n", buf);
  1834. X  return 0;
  1835. X}
  1836. X
  1837. X#endif /* DEBUG */
  1838. END_OF_FILE
  1839. if test 11344 -ne `wc -c <'sys/vms/gnutparam.c'`; then
  1840.     echo shar: \"'sys/vms/gnutparam.c'\" unpacked with wrong size!
  1841. fi
  1842. # end of 'sys/vms/gnutparam.c'
  1843. fi
  1844. echo shar: End of archive 89 \(of 108\).
  1845. cp /dev/null ark89isdone
  1846. MISSING=""
  1847. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  1848. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
  1849. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
  1850. 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
  1851. 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \
  1852. 101 102 103 104 105 106 107 108 ; do
  1853.     if test ! -f ark${I}isdone ; then
  1854.     MISSING="${MISSING} ${I}"
  1855.     fi
  1856. done
  1857. if test "${MISSING}" = "" ; then
  1858.     echo You have unpacked all 108 archives.
  1859.     echo "Now execute 'rebuild.sh'"
  1860.     rm -f ark10[0-8]isdone ark[1-9]isdone ark[1-9][0-9]isdone
  1861. else
  1862.     echo You still need to unpack the following archives:
  1863.     echo "        " ${MISSING}
  1864. fi
  1865. ##  End of shell archive.
  1866. exit 0
  1867.