home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume10 / nethack3p9 / part19 < prev    next >
Internet Message Format  |  1990-07-12  |  61KB

  1. Path: uunet!midway!ux1.cso.uiuc.edu!brutus.cs.uiuc.edu!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!uw-beaver!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v10i064:  nethack3p9 -  display oriented dungeons & dragons (Ver. 3.0i), Part19/56
  5. Message-ID: <5920@tekred.CNA.TEK.COM>
  6. Date: 12 Jul 90 00:36:10 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 2435
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Izchak Miller <izchak@linc.cis.upenn.edu>
  12. Posting-number: Volume 10, Issue 64
  13. Archive-name: nethack3p9/Part19
  14. Supersedes: NetHack3: Volume 7, Issue 56-93
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 19 (of 56)."
  25. # Contents:  src/do_wear.c src/panic.c vms/vmstermcap.c
  26. # Wrapped by billr@saab on Wed Jul 11 17:11:17 1990
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'src/do_wear.c' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'src/do_wear.c'\"
  30. else
  31. echo shar: Extracting \"'src/do_wear.c'\" \(36025 characters\)
  32. sed "s/^X//" >'src/do_wear.c' <<'END_OF_FILE'
  33. X/*    SCCS Id: @(#)do_wear.c    3.0    88/05/10
  34. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  35. X/* NetHack may be freely redistributed.  See license for details. */
  36. X
  37. X#include "hack.h"
  38. X
  39. X#ifdef OVLB
  40. X
  41. Xstatic int NEARDATA todelay;
  42. X
  43. X#endif /*OVLB */
  44. X
  45. X#ifndef OVLB
  46. X
  47. XSTATIC_DCL long takeoff_mask, taking_off;
  48. X
  49. X#else /* OVLB */
  50. X
  51. XSTATIC_OVL long NEARDATA takeoff_mask = 0L, NEARDATA taking_off = 0L;
  52. X
  53. Xstatic const long NEARDATA takeoff_order[] = { WORN_BLINDF, 1L, /* weapon */
  54. X    WORN_SHIELD, WORN_GLOVES, LEFT_RING, RIGHT_RING, WORN_CLOAK,
  55. X    WORN_HELMET, WORN_AMUL, WORN_ARMOR,
  56. X#ifdef SHIRT
  57. X    WORN_SHIRT,
  58. X#endif
  59. X    WORN_BOOTS, 0L };
  60. X
  61. Xstatic void FDECL(on_msg, (struct obj *));
  62. XSTATIC_PTR int NDECL(Armor_on);
  63. XSTATIC_PTR int NDECL(Boots_on);
  64. Xstatic int NDECL(Cloak_on);
  65. XSTATIC_PTR int NDECL(Helmet_on);
  66. XSTATIC_PTR int NDECL(Gloves_on);
  67. Xstatic void NDECL(Amulet_on);
  68. Xstatic void FDECL(Ring_off_or_gone, (struct obj *, BOOLEAN_P));
  69. XSTATIC_PTR int FDECL(select_off, (struct obj *));
  70. Xstatic struct obj *NDECL(do_takeoff);
  71. XSTATIC_PTR int NDECL(take_off);
  72. X
  73. Xvoid
  74. Xoff_msg(otmp) register struct obj *otmp; {
  75. X    if(flags.verbose)
  76. X        You("were wearing %s.", doname(otmp));
  77. X}
  78. X
  79. X/* for items that involve no delay */
  80. Xstatic void
  81. Xon_msg(otmp) register struct obj *otmp; {
  82. X    if(flags.verbose)
  83. X        You("are now wearing %s.", an(xname(otmp)));
  84. X}
  85. X
  86. X#endif /* OVLB */
  87. X#ifdef OVL2
  88. X
  89. Xboolean
  90. Xis_boots(otmp) register struct obj *otmp; {
  91. X    return(otmp->otyp >= LOW_BOOTS &&
  92. X           otmp->otyp <= LEVITATION_BOOTS);
  93. X}
  94. X
  95. Xboolean
  96. Xis_helmet(otmp) register struct obj *otmp; {
  97. X#ifdef TOLKIEN
  98. X    return(otmp->otyp >= ELVEN_LEATHER_HELM &&
  99. X        otmp->otyp <= HELM_OF_TELEPATHY);
  100. X#else
  101. X    return(otmp->otyp >= ORCISH_HELM &&
  102. X        otmp->otyp <= HELM_OF_TELEPATHY);
  103. X#endif
  104. X}
  105. X
  106. X#endif /* OVLB */
  107. X#ifdef OVL2
  108. X
  109. Xboolean
  110. Xis_gloves(otmp) register struct obj *otmp; {
  111. X    return(otmp->otyp >= LEATHER_GLOVES &&
  112. X           otmp->otyp <= GAUNTLETS_OF_DEXTERITY);
  113. X}
  114. X
  115. X#endif /* OVL2 */
  116. X#ifdef OVLB
  117. X
  118. Xboolean
  119. Xis_cloak(otmp) register struct obj *otmp; {
  120. X    return(otmp->otyp >= MUMMY_WRAPPING &&
  121. X        otmp->otyp <= CLOAK_OF_DISPLACEMENT);
  122. X}
  123. X
  124. Xboolean
  125. Xis_shield(otmp) register struct obj *otmp; {
  126. X    return(otmp->otyp >= SMALL_SHIELD &&
  127. X           otmp->otyp <= SHIELD_OF_REFLECTION);
  128. X}
  129. X
  130. X/*
  131. X * The Type_on() functions should be called *after* setworn().
  132. X * The Type_off() functions call setworn() themselves.
  133. X */
  134. X
  135. XSTATIC_PTR
  136. Xint
  137. XBoots_on() {
  138. X    long oldprop =
  139. X        u.uprops[objects[uarmf->otyp].oc_oprop].p_flgs & ~(WORN_BOOTS | TIMEOUT);
  140. X
  141. X    switch(uarmf->otyp) {
  142. X    case LOW_BOOTS:
  143. X    case IRON_SHOES:
  144. X    case HIGH_BOOTS:
  145. X    case WATER_WALKING_BOOTS:
  146. X    case JUMPING_BOOTS:
  147. X        break;
  148. X    case SPEED_BOOTS:
  149. X        if (!oldprop) {
  150. X            makeknown(uarmf->otyp);
  151. X            You("feel yourself speed up.");
  152. X        }
  153. X        break;
  154. X    case ELVEN_BOOTS:
  155. X        if (!oldprop) {
  156. X            makeknown(uarmf->otyp);
  157. X            You("walk very quietly.");
  158. X        }
  159. X        break;
  160. X    case FUMBLE_BOOTS:
  161. X        if (!oldprop)
  162. X            Fumbling += rnd(20);
  163. X        break;
  164. X    case LEVITATION_BOOTS:
  165. X        if (!oldprop) {
  166. X            makeknown(uarmf->otyp);
  167. X            float_up();
  168. X        }
  169. X        break;
  170. X    default: impossible("Unknown type of boots (%d)", uarmf->otyp);
  171. X    }
  172. X    return 0;
  173. X}
  174. X
  175. Xint
  176. XBoots_off() {
  177. X    register struct obj *obj = uarmf;
  178. X    /* For levitation, float_down() returns if Levitation, so we
  179. X     * must do a setworn() _before_ the levitation case.
  180. X     */
  181. X    long oldprop =
  182. X        u.uprops[objects[uarmf->otyp].oc_oprop].p_flgs & ~(WORN_BOOTS | TIMEOUT);
  183. X
  184. X    setworn((struct obj *)0, W_ARMF);
  185. X    switch(obj->otyp) {
  186. X    case SPEED_BOOTS:
  187. X        if (!oldprop) {
  188. X            makeknown(obj->otyp);
  189. X            You("feel yourself slow down.");
  190. X        }
  191. X        break;
  192. X    case WATER_WALKING_BOOTS:
  193. X        if(is_pool(u.ux,u.uy) && !Levitation
  194. X#ifdef POLYSELF
  195. X            && !is_flyer(uasmon)
  196. X#endif
  197. X            ) {
  198. X            makeknown(obj->otyp);
  199. X            /* make boots known in case you survive the drowning */
  200. X            drown();
  201. X        }
  202. X        break;
  203. X    case ELVEN_BOOTS:
  204. X        if (!oldprop) {
  205. X            makeknown(obj->otyp);
  206. X            You("sure are noisy.");
  207. X        }
  208. X        break;
  209. X    case FUMBLE_BOOTS:
  210. X        if (!oldprop)
  211. X            Fumbling = 0;
  212. X        break;
  213. X    case LEVITATION_BOOTS:
  214. X        if (!oldprop) {
  215. X            (void) float_down();
  216. X            makeknown(obj->otyp);
  217. X        }
  218. X        break;
  219. X    case LOW_BOOTS:
  220. X    case IRON_SHOES:
  221. X    case HIGH_BOOTS:
  222. X    case JUMPING_BOOTS:
  223. X        break;
  224. X    default: impossible("Unknown type of boots (%d)", obj->otyp);
  225. X    }
  226. X    return 0;
  227. X}
  228. X
  229. Xstatic int
  230. XCloak_on() {
  231. X    long oldprop = u.uprops[objects[uarmc->otyp].oc_oprop].p_flgs & ~WORN_CLOAK;
  232. X
  233. X    switch(uarmc->otyp) {
  234. X    case ELVEN_CLOAK:
  235. X    case CLOAK_OF_PROTECTION:
  236. X    case CLOAK_OF_DISPLACEMENT:
  237. X        makeknown(uarmc->otyp);
  238. X        break;
  239. X    case MUMMY_WRAPPING:
  240. X#ifdef TOLKIEN
  241. X    case ORCISH_CLOAK:
  242. X    case DWARVISH_CLOAK:
  243. X#endif
  244. X    case CLOAK_OF_MAGIC_RESISTANCE:
  245. X        break;
  246. X    case CLOAK_OF_INVISIBILITY:
  247. X        if (!oldprop && !See_invisible && !Blind) {
  248. X            makeknown(uarmc->otyp);
  249. X            pline("Suddenly you cannot see yourself.");
  250. X        }
  251. X        break;
  252. X    default: impossible("Unknown type of cloak (%d)", uarmc->otyp);
  253. X    }
  254. X    return 0;
  255. X}
  256. X
  257. Xint
  258. XCloak_off() {
  259. X    long oldprop = u.uprops[objects[uarmc->otyp].oc_oprop].p_flgs & ~WORN_CLOAK;
  260. X
  261. X    switch(uarmc->otyp) {
  262. X    case MUMMY_WRAPPING:
  263. X    case ELVEN_CLOAK:
  264. X#ifdef TOLKIEN
  265. X    case ORCISH_CLOAK:
  266. X    case DWARVISH_CLOAK:
  267. X#endif
  268. X    case CLOAK_OF_PROTECTION:
  269. X    case CLOAK_OF_MAGIC_RESISTANCE:
  270. X    case CLOAK_OF_DISPLACEMENT:
  271. X        break;
  272. X    case CLOAK_OF_INVISIBILITY:
  273. X        if (!oldprop && !See_invisible && !Blind) {
  274. X            makeknown(uarmc->otyp);
  275. X            pline("Suddenly you can see yourself.");
  276. X        }
  277. X        break;
  278. X    default: impossible("Unknown type of cloak (%d)", uarmc->otyp);
  279. X    }
  280. X    setworn((struct obj *)0, W_ARMC);
  281. X    return 0;
  282. X}
  283. X
  284. XSTATIC_PTR
  285. Xint
  286. XHelmet_on() {
  287. X    switch(uarmh->otyp) {
  288. X    case FEDORA:
  289. X    case HELMET:
  290. X#ifdef TOLKIEN
  291. X    case ELVEN_LEATHER_HELM:
  292. X    case DWARVISH_IRON_HELM:
  293. X#endif
  294. X    case ORCISH_HELM:
  295. X    case HELM_OF_TELEPATHY:
  296. X        break;
  297. X    case HELM_OF_BRILLIANCE:
  298. X        if (uarmh->spe) {
  299. X            ABON(A_INT) += uarmh->spe;
  300. X            ABON(A_WIS) += uarmh->spe;
  301. X            flags.botl = 1;
  302. X            makeknown(uarmh->otyp);
  303. X        }
  304. X        break;
  305. X    case HELM_OF_OPPOSITE_ALIGNMENT:
  306. X        if (u.ualigntyp == U_NEUTRAL) u.ualigntyp = rn2(2) ? -1 : 1;
  307. X        else u.ualigntyp = -(u.ualigntyp);
  308. X        makeknown(uarmh->otyp);
  309. X        flags.botl = 1;
  310. X        break;
  311. X    default: impossible("Unknown type of helm (%d)", uarmh->otyp);
  312. X    }
  313. X    return 0;
  314. X}
  315. X
  316. Xint
  317. XHelmet_off() {
  318. X    switch(uarmh->otyp) {
  319. X    case FEDORA:
  320. X    case HELMET:
  321. X#ifdef TOLKIEN
  322. X    case ELVEN_LEATHER_HELM:
  323. X    case DWARVISH_IRON_HELM:
  324. X#endif
  325. X    case ORCISH_HELM:
  326. X    case HELM_OF_TELEPATHY:
  327. X        break;
  328. X    case HELM_OF_BRILLIANCE:
  329. X        if (uarmh->spe) {
  330. X            ABON(A_INT) -= uarmh->spe;
  331. X            ABON(A_WIS) -= uarmh->spe;
  332. X            flags.botl = 1;
  333. X        }
  334. X        break;
  335. X    case HELM_OF_OPPOSITE_ALIGNMENT:
  336. X#ifdef THEOLOGY
  337. X        u.ualigntyp = u.ualignbase[0];
  338. X#else
  339. X        if (pl_character[0] == 'P' ||
  340. X            pl_character[0] == 'T' ||
  341. X            pl_character[0] == 'W')
  342. X            u.ualigntyp = U_NEUTRAL;
  343. X        else u.ualigntyp = -(u.ualigntyp);
  344. X#endif
  345. X        flags.botl = 1;
  346. X        break;
  347. X    default: impossible("Unknown type of helm (%d)", uarmh->otyp);
  348. X    }
  349. X    setworn((struct obj *)0, W_ARMH);
  350. X    return 0;
  351. X}
  352. X
  353. XSTATIC_PTR
  354. Xint
  355. XGloves_on() {
  356. X    long oldprop =
  357. X    u.uprops[objects[uarmg->otyp].oc_oprop].p_flgs & ~(WORN_GLOVES | TIMEOUT);
  358. X
  359. X    switch(uarmg->otyp) {
  360. X    case LEATHER_GLOVES:
  361. X        break;
  362. X    case GAUNTLETS_OF_FUMBLING:
  363. X        if (!oldprop)
  364. X            Fumbling += rnd(20);
  365. X        break;
  366. X    case GAUNTLETS_OF_POWER:
  367. X        makeknown(uarmg->otyp);
  368. X        flags.botl = 1; /* taken care of in attrib.c */
  369. X        break;
  370. X    case GAUNTLETS_OF_DEXTERITY:
  371. X        if (uarmg->spe) makeknown(uarmg->otyp);
  372. X        ABON(A_DEX) += uarmg->spe;
  373. X        flags.botl = 1;
  374. X        break;
  375. X    default: impossible("Unknown type of gloves (%d)", uarmg->otyp);
  376. X    }
  377. X    return 0;
  378. X}
  379. X
  380. Xint
  381. XGloves_off() {
  382. X    long oldprop =
  383. X    u.uprops[objects[uarmg->otyp].oc_oprop].p_flgs & ~(WORN_GLOVES | TIMEOUT);
  384. X
  385. X    switch(uarmg->otyp) {
  386. X    case LEATHER_GLOVES:
  387. X        break;
  388. X    case GAUNTLETS_OF_FUMBLING:
  389. X        if (!oldprop)
  390. X            Fumbling = 0;
  391. X        break;
  392. X    case GAUNTLETS_OF_POWER:
  393. X        makeknown(uarmg->otyp);
  394. X        flags.botl = 1; /* taken care of in attrib.c */
  395. X        break;
  396. X    case GAUNTLETS_OF_DEXTERITY:
  397. X        if (uarmg->spe) makeknown(uarmg->otyp);
  398. X        ABON(A_DEX) -= uarmg->spe;
  399. X        flags.botl = 1;
  400. X        break;
  401. X    default: impossible("Unknown type of gloves (%d)", uarmg->otyp);
  402. X    }
  403. X    setworn((struct obj *)0, W_ARMG);
  404. X    if (uwep && uwep->otyp == CORPSE && uwep->corpsenm == PM_COCKATRICE) {
  405. X    /* Prevent wielding cockatrice when not wearing gloves */
  406. X    You("wield the cockatrice corpse in your bare %s.",
  407. X        makeplural(body_part(HAND)));
  408. X    You("turn to stone...");
  409. X    killer_format = KILLED_BY_AN;
  410. X    killer = "cockatrice corpse";
  411. X    done(STONING);
  412. X    }
  413. X    return 0;
  414. X}
  415. X
  416. X/*
  417. Xstatic int
  418. XShield_on() {
  419. X    switch(uarms->otyp) {
  420. X    case SMALL_SHIELD:
  421. X#ifdef TOLKIEN
  422. X    case ELVEN_SHIELD:
  423. X    case URUK_HAI_SHIELD:
  424. X    case ORCISH_SHIELD:
  425. X    case DWARVISH_ROUNDSHIELD:
  426. X#endif
  427. X    case LARGE_SHIELD:
  428. X    case SHIELD_OF_REFLECTION:
  429. X        break;
  430. X    default: impossible("Unknown type of shield (%d)", uarms->otyp);
  431. X    }
  432. X    return 0;
  433. X}
  434. X*/
  435. X
  436. Xint
  437. XShield_off() {
  438. X/*
  439. X    switch(uarms->otyp) {
  440. X    case SMALL_SHIELD:
  441. X#ifdef TOLKIEN
  442. X    case ELVEN_SHIELD:
  443. X    case URUK_HAI_SHIELD:
  444. X    case ORCISH_SHIELD:
  445. X    case DWARVISH_ROUNDSHIELD:
  446. X#endif
  447. X    case LARGE_SHIELD:
  448. X    case SHIELD_OF_REFLECTION:
  449. X        break;
  450. X    default: impossible("Unknown type of shield (%d)", uarms->otyp);
  451. X    }
  452. X*/
  453. X    setworn((struct obj *)0, W_ARMS);
  454. X    return 0;
  455. X}
  456. X
  457. X/* This must be done in worn.c, because one of the possible intrinsics conferred
  458. X * is fire resistance, and we have to immediately set HFire_resistance in worn.c
  459. X * since worn.c will check it before returning.
  460. X */
  461. XSTATIC_PTR
  462. Xint
  463. XArmor_on()
  464. X{
  465. X    return 0;
  466. X}
  467. X
  468. Xint
  469. XArmor_off()
  470. X{
  471. X    setworn((struct obj *)0, W_ARM);
  472. X    return 0;
  473. X}
  474. X
  475. X/* The gone functions differ from the off functions in that if you die from
  476. X * taking it off and have life saving, you still die.
  477. X */
  478. Xint
  479. XArmor_gone()
  480. X{
  481. X    setnotworn(uarm);
  482. X    return 0;
  483. X}
  484. X
  485. Xstatic void
  486. XAmulet_on()
  487. X{
  488. X    char buf[BUFSZ];
  489. X
  490. X    switch(uamul->otyp) {
  491. X    case AMULET_OF_ESP:
  492. X    case AMULET_OF_LIFE_SAVING:
  493. X    case AMULET_VERSUS_POISON:
  494. X    case AMULET_OF_REFLECTION:
  495. X        break;
  496. X    case AMULET_OF_CHANGE:
  497. X        makeknown(AMULET_OF_CHANGE);
  498. X        flags.female = !flags.female;
  499. X        max_rank_sz();
  500. X        /* Don't use same message as polymorph */
  501. X        You("are suddenly very %s!", flags.female ? "feminine"
  502. X            : "masculine");
  503. X        if (pl_character[0]=='P')
  504. X            Strcpy(pl_character+6, flags.female? "ess":"");
  505. X        if (pl_character[0]=='C')
  506. X            Strcpy(pl_character+5, flags.female ? "woman" : "man");
  507. X#ifdef WIZARD
  508. X        if (!wizard) {
  509. X#endif
  510. Xnewname:    more();
  511. X        do {
  512. X            pline("What shall you be called, %s? ",
  513. X            flags.female ? "madam" : "sir");
  514. X            getlin(buf);
  515. X        } while (buf[0]=='\033' || buf[0]==0);
  516. X        if (!strcmp(plname,buf)) {
  517. X            pline("Sorry, that name no longer seems appropriate!");
  518. X            goto newname;
  519. X        }
  520. X        flags.botl = 1;
  521. X        (void)strncpy(plname, buf, sizeof(plname)-1);
  522. X#ifdef VMS
  523. X        Sprintf(SAVEF, "[.save]%d%s", getuid(), plname);
  524. X        regularize(SAVEF+7);
  525. X        Strcat(SAVEF, ";1");
  526. X#else
  527. X# ifdef MSDOS
  528. X        (void)strcpy(SAVEF, SAVEP);
  529. X        {
  530. X            int i = strlen(SAVEF);
  531. X            (void)strncat(SAVEF, plname, 8);
  532. X            regularize(SAVEF+i);
  533. X        }
  534. X        (void)strcat(SAVEF, ".sav");
  535. X# else
  536. X        Sprintf(SAVEF, "save/%d%s", getuid(), plname);
  537. X        regularize(SAVEF+5);        /* avoid . or / in name */
  538. X# endif
  539. X#endif
  540. X#ifdef WIZARD
  541. X        }
  542. X#endif
  543. X        pline("The amulet disintegrates!");
  544. X        useup(uamul);
  545. X        break;
  546. X    case AMULET_OF_STRANGULATION:
  547. X        makeknown(AMULET_OF_STRANGULATION);
  548. X        pline("It constricts your throat!");
  549. X        Strangled = 6;
  550. X        break;
  551. X    case AMULET_OF_RESTFUL_SLEEP:
  552. X        Sleeping = rnd(100);
  553. X        break;
  554. X    case AMULET_OF_YENDOR:
  555. X        break;
  556. X    }
  557. X}
  558. X
  559. Xvoid
  560. XAmulet_off()
  561. X{
  562. X    switch(uamul->otyp) {
  563. X    case AMULET_OF_ESP:
  564. X    case AMULET_OF_LIFE_SAVING:
  565. X    case AMULET_VERSUS_POISON:
  566. X    case AMULET_OF_REFLECTION:
  567. X        break;
  568. X    case AMULET_OF_CHANGE:
  569. X        impossible("Wearing an amulet of change?");
  570. X        break;
  571. X    case AMULET_OF_STRANGULATION:
  572. X        if (Strangled) {
  573. X            You("can breathe more easily!");
  574. X            Strangled = 0;
  575. X        }
  576. X        break;
  577. X    case AMULET_OF_RESTFUL_SLEEP:
  578. X        Sleeping = 0;
  579. X        break;
  580. X    case AMULET_OF_YENDOR:
  581. X        break;
  582. X    }
  583. X    setworn((struct obj *)0, W_AMUL);
  584. X}
  585. X
  586. Xvoid
  587. XRing_on(obj)
  588. Xregister struct obj *obj;
  589. X{
  590. X    long oldprop = u.uprops[objects[obj->otyp].oc_oprop].p_flgs & ~W_RING;
  591. X
  592. X    switch(obj->otyp){
  593. X    case RIN_TELEPORTATION:
  594. X    case RIN_REGENERATION:
  595. X    case RIN_SEARCHING:
  596. X    case RIN_STEALTH:
  597. X    case RIN_HUNGER:
  598. X    case RIN_AGGRAVATE_MONSTER:
  599. X    case RIN_POISON_RESISTANCE:
  600. X    case RIN_FIRE_RESISTANCE:
  601. X    case RIN_COLD_RESISTANCE:
  602. X    case RIN_SHOCK_RESISTANCE:
  603. X    case RIN_CONFLICT:
  604. X    case RIN_WARNING:
  605. X    case RIN_TELEPORT_CONTROL:
  606. X#ifdef POLYSELF
  607. X    case RIN_POLYMORPH:
  608. X    case RIN_POLYMORPH_CONTROL:
  609. X#endif
  610. X        break;
  611. X    case RIN_SEE_INVISIBLE:
  612. X        if (Invis && !oldprop
  613. X#ifdef POLYSELF
  614. X                && !perceives(uasmon)
  615. X#endif
  616. X                            && !Blind) {
  617. X            newsym(u.ux,u.uy);
  618. X            pline("Suddenly you can see yourself.");
  619. X            makeknown(RIN_SEE_INVISIBLE);
  620. X        }
  621. X        break;
  622. X    case RIN_INVISIBILITY:
  623. X        if (!oldprop && !See_invisible && !Blind) {
  624. X            makeknown(RIN_INVISIBILITY);
  625. X            Your("body takes on a %s transparency...",
  626. X                Hallucination ? "normal" : "strange");
  627. X        }
  628. X        break;
  629. X    case RIN_ADORNMENT:
  630. X        ABON(A_CHA) += obj->spe;
  631. X        flags.botl = 1;
  632. X        if (obj->spe || objects[RIN_ADORNMENT].oc_name_known) {
  633. X            makeknown(RIN_ADORNMENT);
  634. X            obj->known = 1;
  635. X        }
  636. X        break;
  637. X    case RIN_LEVITATION:
  638. X        if(!oldprop) {
  639. X            float_up();
  640. X            makeknown(RIN_LEVITATION);
  641. X            obj->known = 1;
  642. X        }
  643. X        break;
  644. X    case RIN_GAIN_STRENGTH:
  645. X        ABON(A_STR) += obj->spe;
  646. X        flags.botl = 1;
  647. X        if (obj->spe || objects[RIN_GAIN_STRENGTH].oc_name_known) {
  648. X            makeknown(RIN_GAIN_STRENGTH);
  649. X            obj->known = 1;
  650. X        }
  651. X        break;
  652. X    case RIN_INCREASE_DAMAGE:
  653. X        u.udaminc += obj->spe;
  654. X        break;
  655. X    case RIN_PROTECTION_FROM_SHAPE_CHAN:
  656. X        rescham();
  657. X        break;
  658. X    case RIN_PROTECTION:
  659. X        flags.botl = 1;
  660. X        if (obj->spe || objects[RIN_PROTECTION].oc_name_known) {
  661. X            makeknown(RIN_PROTECTION);
  662. X            obj->known = 1;
  663. X        }
  664. X        break;
  665. X    }
  666. X}
  667. X
  668. Xstatic void
  669. XRing_off_or_gone(obj,gone)
  670. Xregister struct obj *obj;
  671. Xboolean gone;
  672. X{
  673. X    register long mask = obj->owornmask & W_RING;
  674. X
  675. X    if(!(u.uprops[objects[obj->otyp].oc_oprop].p_flgs & mask))
  676. X    impossible("Strange... I didn't know you had that ring.");
  677. X    if(gone) setnotworn(obj);
  678. X    else setworn((struct obj *)0, obj->owornmask);
  679. X    switch(obj->otyp) {
  680. X    case RIN_TELEPORTATION:
  681. X    case RIN_REGENERATION:
  682. X    case RIN_SEARCHING:
  683. X    case RIN_STEALTH:
  684. X    case RIN_HUNGER:
  685. X    case RIN_AGGRAVATE_MONSTER:
  686. X    case RIN_POISON_RESISTANCE:
  687. X    case RIN_FIRE_RESISTANCE:
  688. X    case RIN_COLD_RESISTANCE:
  689. X    case RIN_SHOCK_RESISTANCE:
  690. X    case RIN_CONFLICT:
  691. X    case RIN_WARNING:
  692. X    case RIN_TELEPORT_CONTROL:
  693. X#ifdef POLYSELF
  694. X    case RIN_POLYMORPH:
  695. X    case RIN_POLYMORPH_CONTROL:
  696. X#endif
  697. X        break;
  698. X    case RIN_SEE_INVISIBLE:
  699. X        if (Invisible && !Blind) {
  700. X            pline("Suddenly you cannot see yourself.");
  701. X            makeknown(RIN_SEE_INVISIBLE);
  702. X        }
  703. X        break;
  704. X    case RIN_INVISIBILITY:
  705. X        if (!(Invisible & ~W_RING) && !See_invisible && !Blind) {
  706. X            Your("body seems to unfade...");
  707. X            makeknown(RIN_INVISIBILITY);
  708. X        }
  709. X        break;
  710. X    case RIN_ADORNMENT:
  711. X        ABON(A_CHA) -= obj->spe;
  712. X        flags.botl = 1;
  713. X        break;
  714. X    case RIN_LEVITATION:
  715. X        (void) float_down();
  716. X        if (!Levitation) makeknown(RIN_LEVITATION);
  717. X        break;
  718. X    case RIN_GAIN_STRENGTH:
  719. X        ABON(A_STR) -= obj->spe;
  720. X        flags.botl = 1;
  721. X        break;
  722. X    case RIN_INCREASE_DAMAGE:
  723. X        u.udaminc -= obj->spe;
  724. X        break;
  725. X    case RIN_PROTECTION_FROM_SHAPE_CHAN:
  726. X        /* If you're no longer protected, let the chameleons
  727. X         * change shape again -dgk
  728. X         */
  729. X        restartcham();
  730. X        break;
  731. X    }
  732. X}
  733. X
  734. Xvoid
  735. XRing_off(obj)
  736. Xstruct obj *obj;
  737. X{
  738. X    Ring_off_or_gone(obj,FALSE);
  739. X}
  740. X
  741. Xvoid
  742. XRing_gone(obj)
  743. Xstruct obj *obj;
  744. X{
  745. X    Ring_off_or_gone(obj,TRUE);
  746. X}
  747. X
  748. Xvoid
  749. XBlindf_on(otmp) 
  750. Xregister struct obj *otmp;
  751. X{
  752. X    setworn(otmp, W_TOOL);
  753. X    on_msg(otmp);
  754. X    seeoff(0);
  755. X}
  756. X
  757. Xvoid
  758. XBlindf_off(otmp) 
  759. Xregister struct obj *otmp;
  760. X{
  761. X    setworn((struct obj *)0, otmp->owornmask);
  762. X    off_msg(otmp);
  763. X    if (!Blinded)    make_blinded(1L,FALSE); /* See on next move */
  764. X    else        You("still cannot see.");
  765. X}
  766. X
  767. X/* called in main to set intrinsics of worn start-up items */
  768. Xvoid
  769. Xset_wear() {
  770. X    if (uarm)  (void) Armor_on();
  771. X    if (uarmc) (void) Cloak_on();
  772. X    if (uarmf) (void) Boots_on();
  773. X    if (uarmg) (void) Gloves_on();
  774. X    if (uarmh) (void) Helmet_on();
  775. X/*    if (uarms) (void) Shield_on(); */
  776. X}
  777. X
  778. Xboolean
  779. Xdonning(otmp)
  780. Xregister struct obj *otmp;
  781. X{
  782. X    return (otmp == uarmf && (afternmv == Boots_on || afternmv == Boots_off))
  783. X    || (otmp == uarmh && (afternmv == Helmet_on || afternmv == Helmet_off))
  784. X    || (otmp == uarmg && (afternmv == Gloves_on || afternmv == Gloves_off))
  785. X    || (otmp == uarm && (afternmv == Armor_on || afternmv == Armor_off));
  786. X}
  787. X
  788. Xvoid
  789. Xcancel_don()
  790. X{
  791. X    /* the piece of armor we were donning/doffing has vanished, so stop
  792. X     * wasting time on it (and don't dereference it when donning would
  793. X     * otherwise finish)
  794. X     */
  795. X    afternmv = 0;
  796. X    nomovemsg = NULL;
  797. X    multi = 0;
  798. X}
  799. X
  800. Xstatic const char NEARDATA clothes[] = {ARMOR_SYM, 0};
  801. Xstatic const char NEARDATA accessories[] = {RING_SYM, AMULET_SYM, TOOL_SYM, 0};
  802. X
  803. Xint
  804. Xdotakeoff() {
  805. X#ifdef __GNULINT__
  806. X    register struct obj *otmp = 0;
  807. X        /* suppress "may be used uninitialized" warning */
  808. X#else
  809. X    register struct obj *otmp;
  810. X#endif
  811. X    int armorpieces = 0;
  812. X
  813. X#define MOREARM(x) if (x) { armorpieces++; otmp = x; }
  814. X    MOREARM(uarmh);
  815. X    MOREARM(uarms);
  816. X    MOREARM(uarmg);
  817. X    MOREARM(uarmf);
  818. X    if (uarmc) {
  819. X        armorpieces++;
  820. X        otmp = uarmc;
  821. X    } else if (uarm) {
  822. X        armorpieces++;
  823. X        otmp = uarm;
  824. X#ifdef SHIRT
  825. X    } else if (uarmu) {
  826. X        armorpieces++;
  827. X        otmp = uarmu;
  828. X#endif
  829. X    }
  830. X    if (!armorpieces) {
  831. X        pline("Not wearing any armor.");
  832. X        return 0;
  833. X    }
  834. X    if (armorpieces > 1)
  835. X        otmp = getobj(clothes, "take off");
  836. X    if (otmp == 0) return(0);
  837. X    if (!(otmp->owornmask & W_ARMOR)) {
  838. X        You("are not wearing that.");
  839. X        return(0);
  840. X    }
  841. X    if (((otmp == uarm) && (uarmc))
  842. X#ifdef SHIRT
  843. X                || ((otmp == uarmu) && (uarmc || uarm))
  844. X#endif
  845. X                                ) {
  846. X        You("can't take that off.");
  847. X        return(0);
  848. X    }
  849. X    if(otmp == uarmg && welded(uwep)) {
  850. X    You("seem unable to take off the gloves while holding your %s.",
  851. X      is_sword(uwep) ? "sword" : "weapon");
  852. X        uwep->bknown = 1;
  853. X        return(0);
  854. X    }
  855. X    if(otmp == uarmg && Glib) {
  856. X    You("can't remove the slippery gloves with your slippery fingers.");
  857. X        return(0);
  858. X    }
  859. X    if(otmp == uarmf && u.utrap && u.utraptype == TT_BEARTRAP) {  /* -3. */
  860. X        pline("The bear trap prevents you from pulling your foot out.");
  861. X        return(0);
  862. X    }
  863. X    reset_remarm();            /* since you may change ordering */
  864. X    (void) armoroff(otmp);
  865. X    return(1);
  866. X}
  867. X
  868. Xint
  869. Xdoremring() {
  870. X#ifdef __GNULINT__
  871. X    register struct obj *otmp = 0;
  872. X        /* suppress "may be used uninitialized" warning */
  873. X#else
  874. X    register struct obj *otmp;
  875. X#endif
  876. X    int Accessories = 0;
  877. X
  878. X#define MOREACC(x) if (x) { Accessories++; otmp = x; }
  879. X    MOREACC(uleft);
  880. X    MOREACC(uright);
  881. X    MOREACC(uamul);
  882. X    MOREACC(ublindf);
  883. X
  884. X    if(!Accessories) {
  885. X        pline("Not wearing any accessories.");
  886. X        return(0);
  887. X    }
  888. X    if (Accessories != 1) otmp = getobj(accessories, "take off");
  889. X    if(!otmp) return(0);
  890. X    if(!(otmp->owornmask & (W_RING | W_AMUL | W_TOOL))) {
  891. X        You("are not wearing that.");
  892. X        return(0);
  893. X    }
  894. X    if(cursed(otmp)) return(0);
  895. X    if(otmp->olet == RING_SYM) {
  896. X#ifdef POLYSELF
  897. X        if (nolimbs(uasmon)) {
  898. X            pline("It seems to be stuck.");
  899. X            return(0);
  900. X        }
  901. X#endif
  902. X        if (uarmg && uarmg->cursed) {
  903. X            uarmg->bknown = 1;
  904. XYou("seem unable to remove your ring without taking off your gloves.");
  905. X            return(0);
  906. X        }
  907. X        if (welded(uwep) && bimanual(uwep)) {
  908. X            uwep->bknown = 1;
  909. XYou("seem unable to remove the ring while your hands hold your %s.",
  910. X                is_sword(uwep) ? "sword" : "weapon");
  911. X            return(0);
  912. X        }
  913. X        if (welded(uwep) && otmp==uright) {
  914. X            uwep->bknown = 1;
  915. XYou("seem unable to remove the ring while your right hand holds your %s.",
  916. X                is_sword(uwep) ? "sword" : "weapon");
  917. X            return(0);
  918. X        }
  919. X        /* Sometimes we want to give the off_msg before removing and
  920. X         * sometimes after; for instance, "you were wearing a moonstone
  921. X         * ring (on right hand)" is desired but "you were wearing a
  922. X         * square amulet (being worn)" is not because of the redundant
  923. X         * "being worn".
  924. X         */
  925. X        off_msg(otmp);
  926. X        Ring_off(otmp);
  927. X    } else if(otmp->olet == AMULET_SYM) {
  928. X        Amulet_off();
  929. X        off_msg(otmp);
  930. X    } else Blindf_off(otmp); /* does its own off_msg */
  931. X    return(1);
  932. X}
  933. X
  934. Xint
  935. Xcursed(otmp) register struct obj *otmp; {
  936. X    /* Curses, like chickens, come home to roost. */
  937. X    if(otmp->cursed){
  938. X        You("can't.  %s to be cursed.",
  939. X            (is_boots(otmp) || is_gloves(otmp) || otmp->quan > 1)
  940. X            ? "They seem" : "It seems");
  941. X        otmp->bknown = 1;
  942. X        return(1);
  943. X    }
  944. X    return(0);
  945. X}
  946. X
  947. Xint
  948. Xarmoroff(otmp) register struct obj *otmp; {
  949. X    register int delay = -objects[otmp->otyp].oc_delay;
  950. X
  951. X    if(cursed(otmp)) return(0);
  952. X    if(delay) {
  953. X        nomul(delay);
  954. X        if (is_helmet(otmp)) {
  955. X            nomovemsg = "You finish taking off your helmet.";
  956. X            afternmv = Helmet_off;
  957. X             }
  958. X        else if (is_gloves(otmp)) {
  959. X            nomovemsg = "You finish taking off your gloves.";
  960. X            afternmv = Gloves_off;
  961. X             }
  962. X        else if (is_boots(otmp)) {
  963. X            nomovemsg = "You finish taking off your boots.";
  964. X            afternmv = Boots_off;
  965. X             }
  966. X        else {
  967. X            nomovemsg = "You finish taking off your suit.";
  968. X            afternmv = Armor_off;
  969. X        }
  970. X    } else {
  971. X        /* Be warned!  We want off_msg after removing the item to
  972. X         * avoid "You were wearing ____ (being worn)."  However, an
  973. X         * item which grants fire resistance might cause some trouble
  974. X         * if removed in Hell and lifesaving puts it back on; in this
  975. X         * case the message will be printed at the wrong time (after
  976. X         * the messages saying you died and were lifesaved).  Luckily,
  977. X         * no cloak, shield, or fast-removable armor grants fire
  978. X         * resistance, so we can safely do the off_msg afterwards.
  979. X         * Rings do grant fire resistance, but for rings we want the
  980. X         * off_msg before removal anyway so there's no problem.  Take
  981. X         * care in adding armors granting fire resistance; this code
  982. X         * might need modification.
  983. X         */
  984. X        if(is_cloak(otmp))
  985. X            (void) Cloak_off();
  986. X        else if(is_shield(otmp))
  987. X            (void) Shield_off();
  988. X        else setworn((struct obj *)0, otmp->owornmask & W_ARMOR);
  989. X        off_msg(otmp);
  990. X    }
  991. X    takeoff_mask = taking_off = 0L;
  992. X    return(1);
  993. X}
  994. X
  995. Xint
  996. Xdowear() {
  997. X    register struct obj *otmp;
  998. X    register int delay;
  999. X    register int err = 0;
  1000. X    long mask = 0;
  1001. X
  1002. X#ifdef POLYSELF
  1003. X    /* cantweararm checks for suits of armor */
  1004. X    /* verysmall or nohands checks for shields, gloves, etc... */
  1005. X    if ((verysmall(uasmon) || nohands(uasmon))) {
  1006. X        pline("Don't even bother.");
  1007. X        return(0);
  1008. X    }
  1009. X#endif
  1010. X    otmp = getobj(clothes, "wear");
  1011. X    if(!otmp) return(0);
  1012. X#ifdef POLYSELF
  1013. X    if (cantweararm(uasmon) && !is_shield(otmp) &&
  1014. X            !is_helmet(otmp) && !is_gloves(otmp) &&
  1015. X            !is_boots(otmp)) {
  1016. X        pline("The %s will not fit on your body.",
  1017. X            is_cloak(otmp) ? "cloak" :
  1018. X# ifdef SHIRT
  1019. X            otmp->otyp == HAWAIIAN_SHIRT ? "shirt" :
  1020. X# endif
  1021. X            "suit");
  1022. X        return(0);
  1023. X    }
  1024. X#endif
  1025. X    if(otmp->owornmask & W_ARMOR) {
  1026. X        You("are already wearing that!");
  1027. X        return(0);
  1028. X    }
  1029. X    if(is_helmet(otmp)) {
  1030. X        if(uarmh) {
  1031. X            You("are already wearing a helmet.");
  1032. X            err++;
  1033. X        } else
  1034. X            mask = W_ARMH;
  1035. X    } else if(is_shield(otmp)){
  1036. X        if(uarms) {
  1037. X            You("are already wearing a shield.");
  1038. X            err++;
  1039. X        }
  1040. X        if(uwep && bimanual(uwep)) {
  1041. X        You("cannot hold a shield and wield a two-handed %s.",
  1042. X              is_sword(uwep) ? "sword" : "weapon");
  1043. X            err++;
  1044. X        }
  1045. X        if(!err) mask = W_ARMS;
  1046. X    } else if(is_boots(otmp)) {
  1047. X           if(uarmf) {
  1048. X            You("are already wearing boots.");
  1049. X            err++;
  1050. X           } else
  1051. X            mask = W_ARMF;
  1052. X    } else if(is_gloves(otmp)) {
  1053. X        if(uarmg) {
  1054. X            You("are already wearing gloves.");
  1055. X            err++;
  1056. X        } else
  1057. X        if(uwep && uwep->cursed) {
  1058. X            You("cannot wear gloves over your %s.",
  1059. X                  is_sword(uwep) ? "sword" : "weapon");
  1060. X            err++;
  1061. X        } else
  1062. X            mask = W_ARMG;
  1063. X#ifdef SHIRT
  1064. X    } else if( otmp->otyp == HAWAIIAN_SHIRT ) {
  1065. X        if (uarm || uarmc || uarmu) {
  1066. X            if(!uarm && !uarmc) /* then uarmu */
  1067. X               You("are already wearing a shirt.");
  1068. X            else
  1069. X               You("can't wear that over your %s.",
  1070. X                 (uarm && !uarmc) ? "armor" : "cloak");
  1071. X            err++;
  1072. X        } else
  1073. X            mask = W_ARMU;
  1074. X#endif
  1075. X    } else if(is_cloak(otmp)) {
  1076. X        if(uarmc) {
  1077. X            You("are already wearing a cloak.");
  1078. X            err++;
  1079. X        } else
  1080. X            mask = W_ARMC;
  1081. X    } else {
  1082. X        if(uarmc) {
  1083. X            You("cannot wear armor over a cloak.");
  1084. X            err++;
  1085. X        } else if(uarm) {
  1086. X            You("are already wearing some armor.");
  1087. X            err++;
  1088. X        }
  1089. X        if(!err) mask = W_ARM;
  1090. X    }
  1091. X/* Unnecessary since now only weapons and special items like pick-axes get
  1092. X * welded to your hand, not armor
  1093. X    if(welded(otmp)) {
  1094. X        if(!err++)
  1095. X            weldmsg(otmp, FALSE);
  1096. X    }
  1097. X */
  1098. X    if(err) return(0);
  1099. X
  1100. X    otmp->known = 1;
  1101. X    if(otmp == uwep)
  1102. X        setuwep((struct obj *)0);
  1103. X    setworn(otmp, mask);
  1104. X    delay = -objects[otmp->otyp].oc_delay;
  1105. X    if(delay){
  1106. X        nomul(delay);
  1107. X        if(is_boots(otmp)) afternmv = Boots_on;
  1108. X        if(is_helmet(otmp)) afternmv = Helmet_on;
  1109. X        if(is_gloves(otmp)) afternmv = Gloves_on;
  1110. X        if(otmp == uarm) afternmv = Armor_on;
  1111. X        nomovemsg = "You finish your dressing maneuver.";
  1112. X    } else {
  1113. X        if(is_cloak(otmp)) (void) Cloak_on();
  1114. X/*        if(is_shield(otmp)) (void) Shield_on(); */
  1115. X        on_msg(otmp);
  1116. X    }
  1117. X    takeoff_mask = taking_off = 0L;
  1118. X    return(1);
  1119. X}
  1120. X
  1121. Xint
  1122. Xdoputon() {
  1123. X    register struct obj *otmp;
  1124. X    long mask = 0;
  1125. X
  1126. X    if(uleft && uright && uamul && ublindf) {
  1127. X#ifdef POLYSELF
  1128. X        Your("%s%s are full, and you're already wearing an amulet and a blindfold.",
  1129. X            (humanoid(uasmon) || u.usym==S_CENTAUR) ? "ring-" : "",
  1130. X            makeplural(body_part(FINGER)));
  1131. X#else
  1132. X        Your("ring-fingers are full, and you're already wearing an amulet and a blindfold.");
  1133. X#endif
  1134. X        return(0);
  1135. X    }
  1136. X    otmp = getobj(accessories, "wear");
  1137. X    if(!otmp) return(0);
  1138. X    if(otmp->owornmask & (W_RING | W_AMUL | W_TOOL)) {
  1139. X        You("are already wearing that!");
  1140. X        return(0);
  1141. X    }
  1142. X    if(welded(otmp)) {
  1143. X        weldmsg(otmp, TRUE);
  1144. X        return(0);
  1145. X    }
  1146. X    if(otmp == uwep)
  1147. X        setuwep((struct obj *)0);
  1148. X    if(otmp->olet == RING_SYM) {
  1149. X#ifdef POLYSELF
  1150. X        if(nolimbs(uasmon)) {
  1151. X            You("cannot make the ring stick to your body.");
  1152. X            return(0);
  1153. X        }
  1154. X#endif
  1155. X        if(uleft && uright){
  1156. X#ifdef POLYSELF
  1157. X            pline("There are no more %s%s to fill.",
  1158. X                (humanoid(uasmon) || u.usym==S_CENTAUR)
  1159. X                    ? "ring-" : "",
  1160. X                makeplural(body_part(FINGER)));
  1161. X#else
  1162. X            pline("There are no more ring-fingers to fill.");
  1163. X#endif
  1164. X            return(0);
  1165. X        }
  1166. X        if(uleft) mask = RIGHT_RING;
  1167. X        else if(uright) mask = LEFT_RING;
  1168. X        else do {
  1169. X            char answer;
  1170. X
  1171. X#ifdef POLYSELF
  1172. X            pline("What %s%s, Right or Left? ",
  1173. X                (humanoid(uasmon) || u.usym==S_CENTAUR)
  1174. X                    ? "ring-" : "",
  1175. X                body_part(FINGER));
  1176. X#else
  1177. X            pline("What ring-finger, Right or Left? ");
  1178. X#endif
  1179. X            if(index(quitchars, (answer = readchar())))
  1180. X                return(0);
  1181. X            switch(answer){
  1182. X            case 'l':
  1183. X            case 'L':
  1184. X                mask = LEFT_RING;
  1185. X                break;
  1186. X            case 'r':
  1187. X            case 'R':
  1188. X                mask = RIGHT_RING;
  1189. X                break;
  1190. X            }
  1191. X        } while(!mask);
  1192. X        if (uarmg && uarmg->cursed) {
  1193. X            uarmg->bknown = 1;
  1194. X            You("cannot remove your gloves to put on the ring.");
  1195. X            return(0);
  1196. X        }
  1197. X        if (welded(uwep) && bimanual(uwep)) {
  1198. X            /* welded will set bknown */
  1199. X        You("cannot free your weapon hands to put on the ring.");
  1200. X            return(0);
  1201. X        }
  1202. X        if (welded(uwep) && mask==RIGHT_RING) {
  1203. X            /* welded will set bknown */
  1204. X        You("cannot free your weapon hand to put on the ring.");
  1205. X            return(0);
  1206. X        }
  1207. X        setworn(otmp, mask);
  1208. X        Ring_on(otmp);
  1209. X    } else if (otmp->olet == AMULET_SYM) {
  1210. X        if(uamul) {
  1211. X            You("are already wearing an amulet.");
  1212. X            return(0);
  1213. X        }
  1214. X        setworn(otmp, W_AMUL);
  1215. X        if (otmp->otyp == AMULET_OF_CHANGE) {
  1216. X            Amulet_on();
  1217. X            /* Don't do a prinv() since the amulet is now gone */
  1218. X            return(1);
  1219. X        }
  1220. X        Amulet_on();
  1221. X    } else {    /* it's a blindfold */
  1222. X        if (ublindf) {
  1223. X            You("are already wearing a blindfold.");
  1224. X            return(0);
  1225. X        }
  1226. X        if (otmp->otyp != BLINDFOLD) {
  1227. X            You("can't wear that!");
  1228. X            return(0);
  1229. X        }
  1230. X        Blindf_on(otmp);
  1231. X        return(1);
  1232. X    }
  1233. X    prinv(otmp);
  1234. X    return(1);
  1235. X}
  1236. X
  1237. X#endif /* OVLB */
  1238. X
  1239. X#define ARM_BONUS(obj)    ((10 - objects[obj->otyp].a_ac) + obj->spe)
  1240. X
  1241. X#ifdef OVL0
  1242. X
  1243. Xvoid
  1244. Xfind_ac() {
  1245. X    register int uac = 10;
  1246. X#ifdef POLYSELF
  1247. X    if (u.mtimedone) uac = mons[u.umonnum].ac;
  1248. X#endif
  1249. X    if(uarm) uac -= ARM_BONUS(uarm);
  1250. X    if(uarmc) uac -= ARM_BONUS(uarmc);
  1251. X    if(uarmh) uac -= ARM_BONUS(uarmh);
  1252. X    if(uarmf) uac -= ARM_BONUS(uarmf);
  1253. X    if(uarms) uac -= ARM_BONUS(uarms);
  1254. X    if(uarmg) uac -= ARM_BONUS(uarmg);
  1255. X#ifdef SHIRT
  1256. X    if(uarmu) uac -= ARM_BONUS(uarmu);
  1257. X#endif
  1258. X    if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe;
  1259. X    if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe;
  1260. X#ifdef THEOLOGY
  1261. X    if (Protection & INTRINSIC) uac -= u.ublessed;
  1262. X#endif
  1263. X    if(uac != u.uac){
  1264. X        u.uac = uac;
  1265. X        flags.botl = 1;
  1266. X    }
  1267. X}
  1268. X
  1269. X#endif /* OVL0 */
  1270. X#ifdef OVLB
  1271. X
  1272. Xvoid
  1273. Xglibr()
  1274. X{
  1275. X    register struct obj *otmp;
  1276. X    int xfl = 0;
  1277. X#ifdef HARD
  1278. X    boolean leftfall, rightfall;
  1279. X
  1280. X    leftfall = (uleft && !uleft->cursed && (!uwep || !uwep->cursed
  1281. X        || !bimanual(uwep)));
  1282. X    rightfall = (uright && !uright->cursed && (!uwep || !uwep->cursed));
  1283. X#else
  1284. X#define leftfall uleft
  1285. X#define rightfall uright
  1286. X#endif
  1287. X    if(!uarmg) if(leftfall || rightfall)
  1288. X#ifdef POLYSELF
  1289. X                if(!nolimbs(uasmon))
  1290. X#endif
  1291. X                        {
  1292. X        /* Note: at present also cursed rings fall off */
  1293. X        /* changed 10/30/86 by GAN */
  1294. X        Your("%s off your %s.",
  1295. X            (leftfall && rightfall) ? "rings slip" : "ring slips",
  1296. X            makeplural(body_part(FINGER)));
  1297. X        xfl++;
  1298. X        if(leftfall) {
  1299. X            otmp = uleft;
  1300. X            Ring_off(uleft);
  1301. X            dropx(otmp);
  1302. X        }
  1303. X        if(rightfall) {
  1304. X            otmp = uright;
  1305. X            Ring_off(uright);
  1306. X            dropx(otmp);
  1307. X        }
  1308. X    }
  1309. X    if(((otmp = uwep) != (struct obj *)0)
  1310. X#ifdef HARD
  1311. X       && !otmp->cursed
  1312. X#endif
  1313. X    ) {
  1314. X        /* Note: at present also cursed weapons fall */
  1315. X        /* changed 10/30/86 by GAN */
  1316. X        Your("%s %sslips from your %s.",
  1317. X            is_sword(uwep) ? "sword" : "weapon",
  1318. X            xfl ? "also " : "",
  1319. X            makeplural(body_part(HAND)));
  1320. X        setuwep((struct obj *)0);
  1321. X        dropx(otmp);
  1322. X    }
  1323. X}
  1324. X
  1325. Xstruct obj *
  1326. Xsome_armor(){
  1327. Xregister struct obj *otmph = (uarmc ? uarmc : uarm);
  1328. X    if(uarmh && (!otmph || !rn2(4))) otmph = uarmh;
  1329. X    if(uarmg && (!otmph || !rn2(4))) otmph = uarmg;
  1330. X    if(uarmf && (!otmph || !rn2(4))) otmph = uarmf;
  1331. X    if(uarms && (!otmph || !rn2(4))) otmph = uarms;
  1332. X#ifdef SHIRT
  1333. X    if(!uarm && !uarmc && uarmu && (!otmph || !rn2(4))) otmph = uarmu;
  1334. X#endif
  1335. X    return(otmph);
  1336. X}
  1337. X
  1338. Xvoid
  1339. Xcorrode_armor(){
  1340. Xregister struct obj *otmph = some_armor();
  1341. X
  1342. X    if (otmph && otmph != uarmf) {
  1343. X        if (otmph->rustfree || objects[otmph->otyp].oc_material != METAL ||
  1344. X        otmph->otyp >= LEATHER_ARMOR) {
  1345. X            Your("%s not affected!",
  1346. X                aobjnam(otmph, "are"));
  1347. X            return;
  1348. X        }
  1349. X        Your("%s!", aobjnam(otmph, "corrode"));
  1350. X        otmph->spe--;
  1351. X        adj_abon(otmph, -1);
  1352. X    }
  1353. X}
  1354. X
  1355. XSTATIC_PTR
  1356. Xint
  1357. Xselect_off(otmp)
  1358. Xregister struct obj *otmp;
  1359. X{
  1360. X    if(!otmp) return(0);
  1361. X    if(cursed(otmp)) return(0);
  1362. X#ifdef POLYSELF
  1363. X    if(otmp->olet==RING_SYM && nolimbs(uasmon)) return(0);
  1364. X#endif
  1365. X    if(welded(uwep) && (otmp==uarmg || otmp==uright || (otmp==uleft
  1366. X            && bimanual(uwep))))
  1367. X        return(0);
  1368. X    if(uarmg && uarmg->cursed && (otmp==uright || otmp==uleft)) {
  1369. X        uarmg->bknown = 1;
  1370. X        return(0);
  1371. X    }
  1372. X    if((otmp==uarm 
  1373. X#ifdef SHIRT
  1374. X            || otmp==uarmu
  1375. X#endif
  1376. X                    ) && uarmc && uarmc->cursed) {
  1377. X        uarmc->bknown = 1;
  1378. X        return(0);
  1379. X    }
  1380. X#ifdef SHIRT
  1381. X    if(otmp==uarmu && uarm && uarm->cursed) {
  1382. X        uarm->bknown = 1;
  1383. X        return(0);
  1384. X    }
  1385. X#endif
  1386. X
  1387. X    if(otmp == uarm) takeoff_mask |= WORN_ARMOR;
  1388. X    else if(otmp == uarmc) takeoff_mask |= WORN_CLOAK;
  1389. X    else if(otmp == uarmf) takeoff_mask |= WORN_BOOTS;
  1390. X    else if(otmp == uarmg) takeoff_mask |= WORN_GLOVES;
  1391. X    else if(otmp == uarmh) takeoff_mask |= WORN_HELMET;
  1392. X    else if(otmp == uarms) takeoff_mask |= WORN_SHIELD;
  1393. X#ifdef SHIRT
  1394. X    else if(otmp == uarmu) takeoff_mask |= WORN_SHIRT;
  1395. X#endif
  1396. X    else if(otmp == uleft) takeoff_mask |= LEFT_RING;
  1397. X    else if(otmp == uright) takeoff_mask |= RIGHT_RING;
  1398. X    else if(otmp == uamul) takeoff_mask |= WORN_AMUL;
  1399. X    else if(otmp == ublindf) takeoff_mask |= WORN_BLINDF;
  1400. X    else if(otmp == uwep) takeoff_mask |= 1L;    /* WIELDED_WEAPON */
  1401. X
  1402. X    else impossible("select_off: %s???", doname(otmp));
  1403. X
  1404. X    return(0);
  1405. X}
  1406. X
  1407. Xstatic struct obj *
  1408. Xdo_takeoff() {
  1409. X
  1410. X    register struct obj *otmp = 0;
  1411. X
  1412. X    if (taking_off == 1L) { /* weapon */
  1413. X      if(!cursed(uwep)) {
  1414. X        setuwep((struct obj *) 0);
  1415. X        You("are empty %s.", body_part(HANDED));
  1416. X      }
  1417. X    } else if (taking_off ==  WORN_ARMOR) {
  1418. X      otmp = uarm;
  1419. X      if(!cursed(otmp)) (void) Armor_off();
  1420. X    } else if (taking_off == WORN_CLOAK) {
  1421. X      otmp = uarmc;
  1422. X      if(!cursed(otmp)) (void) Cloak_off();
  1423. X    } else if (taking_off == WORN_BOOTS) {
  1424. X      otmp = uarmf;
  1425. X      if(!cursed(otmp)) (void) Boots_off();
  1426. X    } else if (taking_off == WORN_GLOVES) {
  1427. X      otmp = uarmg;
  1428. X      if(!cursed(otmp)) (void) Gloves_off();
  1429. X    } else if (taking_off == WORN_HELMET) {
  1430. X      otmp = uarmh;
  1431. X      if(!cursed(otmp)) (void) Helmet_off();
  1432. X    } else if (taking_off == WORN_SHIELD) {
  1433. X      otmp = uarms;
  1434. X      if(!cursed(otmp)) (void) Shield_off();
  1435. X#ifdef SHIRT
  1436. X    } else if (taking_off == WORN_SHIRT) {
  1437. X      otmp = uarmu;
  1438. X      if(!cursed(otmp))
  1439. X        setworn((struct obj *)0, uarmu->owornmask & W_ARMOR);
  1440. X#endif
  1441. X    } else if (taking_off == WORN_AMUL) {
  1442. X      otmp = uamul;
  1443. X      if(!cursed(otmp)) Amulet_off();
  1444. X    } else if (taking_off == LEFT_RING) {
  1445. X      otmp = uleft;
  1446. X      if(!cursed(otmp)) Ring_off(uleft);
  1447. X    } else if (taking_off == RIGHT_RING) {
  1448. X      otmp = uright;
  1449. X      if(!cursed(otmp)) Ring_off(uright);
  1450. X    } else if (taking_off == WORN_BLINDF) {
  1451. X      if(!cursed(ublindf)) {
  1452. X        setworn((struct obj *)0, ublindf->owornmask);
  1453. X        if(!Blinded) make_blinded(1L,FALSE); /* See on next move */
  1454. X        else     You("still cannot see.");
  1455. X      }
  1456. X    } else impossible("do_takeoff: taking off %lx", taking_off);
  1457. X
  1458. X    return(otmp);
  1459. X}
  1460. X
  1461. XSTATIC_PTR
  1462. Xint
  1463. Xtake_off() {
  1464. X
  1465. X    register int i;
  1466. X    register struct obj *otmp;
  1467. X
  1468. X    if(taking_off) {
  1469. X        if(todelay > 0) {
  1470. X
  1471. X        todelay--;
  1472. X        return(1);    /* still busy */
  1473. X        } else if((otmp = do_takeoff())) off_msg(otmp);
  1474. X
  1475. X        takeoff_mask &= ~taking_off;
  1476. X        taking_off = 0L;
  1477. X    }
  1478. X
  1479. X    for(i = 0; takeoff_order[i]; i++)
  1480. X        if(takeoff_mask & takeoff_order[i]) {
  1481. X
  1482. X        taking_off = takeoff_order[i];
  1483. X        break;
  1484. X        }
  1485. X
  1486. X    otmp = (struct obj *) 0;
  1487. X
  1488. X    if (taking_off == 0L) {
  1489. X      You("finish disrobing.");
  1490. X      return 0;
  1491. X    } else if (taking_off == 1L) {
  1492. X      todelay = 1;
  1493. X    } else if (taking_off == WORN_ARMOR) {
  1494. X      otmp = uarm;
  1495. X    } else if (taking_off == WORN_CLOAK) {
  1496. X      otmp = uarmc;
  1497. X    } else if (taking_off == WORN_BOOTS) {
  1498. X      otmp = uarmf;
  1499. X    } else if (taking_off == WORN_GLOVES) {
  1500. X      otmp = uarmg;
  1501. X    } else if (taking_off == WORN_HELMET) {
  1502. X      otmp = uarmh;
  1503. X    } else if (taking_off == WORN_SHIELD) {
  1504. X      otmp = uarms;
  1505. X#ifdef SHIRT
  1506. X    } else if (taking_off == WORN_SHIRT) {
  1507. X      otmp = uarmu;
  1508. X#endif
  1509. X    } else if (taking_off == WORN_AMUL) {
  1510. X      todelay = 1;
  1511. X    } else if (taking_off == LEFT_RING) {
  1512. X      todelay = 1;
  1513. X    } else if (taking_off == RIGHT_RING) {
  1514. X      todelay = 1;
  1515. X    } else if (taking_off == WORN_BLINDF) {
  1516. X      todelay = 2;
  1517. X    } else {
  1518. X      impossible("take_off: taking off %lx", taking_off);
  1519. X      return 0;    /* force done */
  1520. X    }
  1521. X
  1522. X    if(otmp) todelay = objects[otmp->otyp].oc_delay;
  1523. X    set_occupation(take_off, "disrobing", 0);
  1524. X    return(1);        /* get busy */
  1525. X}
  1526. X
  1527. X#endif /* OVLB */
  1528. X#ifdef OVL1
  1529. X
  1530. Xvoid
  1531. Xreset_remarm() { taking_off = takeoff_mask =0L; }
  1532. X
  1533. X#endif /* OVL1 */
  1534. X#ifdef OVLB
  1535. X
  1536. Xint
  1537. Xdoddoremarm() {
  1538. X
  1539. X    if(taking_off || takeoff_mask) {
  1540. X
  1541. X        You("continue disrobing.");
  1542. X        set_occupation(take_off, "disrobing", 0);
  1543. X        return(take_off());
  1544. X    }
  1545. X
  1546. X    (void) ggetobj("take off", select_off, 0);
  1547. X    if(takeoff_mask) return(take_off());
  1548. X    else         return(0);
  1549. X}
  1550. X
  1551. Xint
  1552. Xdestroy_arm(atmp)
  1553. Xregister struct obj *atmp;
  1554. X{
  1555. X    register struct obj *otmp;
  1556. X
  1557. X    if((otmp = uarmc) && (!atmp || atmp == uarmc)) {
  1558. X        Your("cloak crumbles and turns to dust!");
  1559. X        (void) Cloak_off();
  1560. X        useup(otmp);
  1561. X    } else if((otmp = uarm) && (!atmp || atmp == uarm)) {
  1562. X        /* may be disintegrated by spell or dragon breath... */
  1563. X        if (donning(otmp)) cancel_don();
  1564. X        Your("armor turns to dust and falls to the floor!");
  1565. X        (void) Armor_gone();
  1566. X        useup(otmp);
  1567. X#ifdef SHIRT
  1568. X    } else if((otmp = uarmu) && (!atmp || atmp == uarmu)) {
  1569. X        Your("shirt crumbles into tiny threads and falls apart!");
  1570. X        useup(otmp);
  1571. X#endif
  1572. X    } else if((otmp = uarmh) && (!atmp || atmp == uarmh)) {
  1573. X        if (donning(otmp)) cancel_don();
  1574. X        Your("helmet turns to dust and is blown away!");
  1575. X        (void) Helmet_off();
  1576. X        useup(otmp);
  1577. X    } else if((otmp = uarmg) && (!atmp || atmp == uarmg)) {
  1578. X        if (donning(otmp)) cancel_don();
  1579. X        Your("gloves vanish!");
  1580. X        (void) Gloves_off();
  1581. X        useup(otmp);
  1582. X        selftouch("You");
  1583. X    } else if((otmp = uarmf) && (!atmp || atmp == uarmf)) {
  1584. X        if (donning(otmp)) cancel_don();
  1585. X        Your("boots disintegrate!");
  1586. X        (void) Boots_off();
  1587. X        useup(otmp);
  1588. X    } else if((otmp =uarms) && (!atmp || atmp == uarms)) {
  1589. X        Your("shield crumbles away!");
  1590. X        (void) Shield_off();
  1591. X        useup(otmp);
  1592. X    } else     return(0);        /* could not destroy anything */
  1593. X
  1594. X    return(1);
  1595. X}
  1596. X
  1597. Xvoid
  1598. Xadj_abon(otmp, delta)
  1599. Xregister struct obj *otmp;
  1600. Xregister schar delta;
  1601. X{
  1602. X    if (uarmg && otmp->otyp == GAUNTLETS_OF_DEXTERITY) {
  1603. X        ABON(A_DEX) += (delta);
  1604. X        flags.botl = 1;
  1605. X    }
  1606. X    if (uarmh && otmp->otyp == HELM_OF_BRILLIANCE) {
  1607. X        ABON(A_INT) += (delta);
  1608. X        ABON(A_WIS) += (delta);
  1609. X        flags.botl = 1;
  1610. X    }
  1611. X}
  1612. X
  1613. X#endif /* OVLB */
  1614. END_OF_FILE
  1615. if test 36025 -ne `wc -c <'src/do_wear.c'`; then
  1616.     echo shar: \"'src/do_wear.c'\" unpacked with wrong size!
  1617. fi
  1618. # end of 'src/do_wear.c'
  1619. fi
  1620. if test -f 'src/panic.c' -a "${1}" != "-c" ; then 
  1621.   echo shar: Will not clobber existing file \"'src/panic.c'\"
  1622. else
  1623. echo shar: Extracting \"'src/panic.c'\" \(892 characters\)
  1624. sed "s/^X//" >'src/panic.c' <<'END_OF_FILE'
  1625. X/*    SCCS Id: @(#)panic.c    3.0    89/11/15
  1626. X * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
  1627. X *
  1628. X *    This code was adapted from the code in end.c to run in a standalone
  1629. X *    mode for the makedefs / drg code.
  1630. X */
  1631. X/* NetHack may be freely redistributed.  See license for details. */
  1632. X
  1633. X#define NEED_VARARGS
  1634. X#include    "config.h"
  1635. X
  1636. X#ifdef MSDOS
  1637. X#undef exit
  1638. Xextern void FDECL(exit, (int));
  1639. X#endif
  1640. X#ifdef AZTEC
  1641. X#define abort() exit()
  1642. X#endif
  1643. X/*VARARGS1*/
  1644. Xboolean panicking;
  1645. X
  1646. Xvoid
  1647. Xpanic VA_DECL(char *,str)
  1648. X    VA_START(str);
  1649. X    VA_INIT(str, char *);
  1650. X    if(panicking++)
  1651. X#ifdef SYSV
  1652. X        (void)
  1653. X#endif
  1654. X        abort();    /* avoid loops - this should never happen*/
  1655. X
  1656. X    (void) fputs(" ERROR:  ", stderr);
  1657. X    Vprintf(str,VA_ARGS);
  1658. X    (void) fflush(stderr);
  1659. X#if defined(UNIX) || defined(VMS)
  1660. X# ifdef SYSV
  1661. X        (void)
  1662. X# endif
  1663. X            abort();    /* generate core dump */
  1664. X#endif
  1665. X    VA_END();
  1666. X    exit(1);        /* redundant */
  1667. X    return;
  1668. X}
  1669. END_OF_FILE
  1670. if test 892 -ne `wc -c <'src/panic.c'`; then
  1671.     echo shar: \"'src/panic.c'\" unpacked with wrong size!
  1672. fi
  1673. # end of 'src/panic.c'
  1674. fi
  1675. if test -f 'vms/vmstermcap.c' -a "${1}" != "-c" ; then 
  1676.   echo shar: Will not clobber existing file \"'vms/vmstermcap.c'\"
  1677. else
  1678. echo shar: Extracting \"'vms/vmstermcap.c'\" \(18405 characters\)
  1679. sed "s/^X//" >'vms/vmstermcap.c' <<'END_OF_FILE'
  1680. X/* Work-alike for termcap, plus extra features.
  1681. X   Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  1682. X
  1683. X               NO WARRANTY
  1684. X
  1685. X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  1686. XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  1687. XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  1688. XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  1689. XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  1690. XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1691. XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  1692. XAND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  1693. XDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  1694. XCORRECTION.
  1695. X
  1696. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  1697. XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  1698. XWHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  1699. XLIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  1700. XOTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  1701. XUSE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  1702. XDATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  1703. XA FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  1704. XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  1705. XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  1706. X
  1707. X        GENERAL PUBLIC LICENSE TO COPY
  1708. X
  1709. X  1. You may copy and distribute verbatim copies of this source file
  1710. Xas you receive it, in any medium, provided that you conspicuously and
  1711. Xappropriately publish on each copy a valid copyright notice "Copyright
  1712. X(C) 1986 Free Software Foundation, Inc."; and include following the
  1713. Xcopyright notice a verbatim copy of the above disclaimer of warranty
  1714. Xand of this License.  You may charge a distribution fee for the
  1715. Xphysical act of transferring a copy.
  1716. X
  1717. X  2. You may modify your copy or copies of this source file or
  1718. Xany portion of it, and copy and distribute such modifications under
  1719. Xthe terms of Paragraph 1 above, provided that you also do the following:
  1720. X
  1721. X    a) cause the modified files to carry prominent notices stating
  1722. X    that you changed the files and the date of any change; and
  1723. X
  1724. X    b) cause the whole of any work that you distribute or publish,
  1725. X    that in whole or in part contains or is a derivative of this
  1726. X    program or any part thereof, to be licensed at no charge to all
  1727. X    third parties on terms identical to those contained in this
  1728. X    License Agreement (except that you may choose to grant more extensive
  1729. X    warranty protection to some or all third parties, at your option).
  1730. X
  1731. X    c) You may charge a distribution fee for the physical act of
  1732. X    transferring a copy, and you may at your option offer warranty
  1733. X    protection in exchange for a fee.
  1734. X
  1735. XMere aggregation of another unrelated program with this program (or its
  1736. Xderivative) on a volume of a storage or distribution medium does not bring
  1737. Xthe other program under the scope of these terms.
  1738. X
  1739. X  3. You may copy and distribute this program (or a portion or derivative
  1740. Xof it, under Paragraph 2) in object code or executable form under the terms
  1741. Xof Paragraphs 1 and 2 above provided that you also do one of the following:
  1742. X
  1743. X    a) accompany it with the complete corresponding machine-readable
  1744. X    source code, which must be distributed under the terms of
  1745. X    Paragraphs 1 and 2 above; or,
  1746. X
  1747. X    b) accompany it with a written offer, valid for at least three
  1748. X    years, to give any third party free (except for a nominal
  1749. X    shipping charge) a complete machine-readable copy of the
  1750. X    corresponding source code, to be distributed under the terms of
  1751. X    Paragraphs 1 and 2 above; or,
  1752. X
  1753. X    c) accompany it with the information you received as to where the
  1754. X    corresponding source code may be obtained.  (This alternative is
  1755. X    allowed only for noncommercial distribution and only if you
  1756. X    received the program in object code or executable form alone.)
  1757. X
  1758. XFor an executable file, complete source code means all the source code for
  1759. Xall modules it contains; but, as a special exception, it need not include
  1760. Xsource code for modules which are standard libraries that accompany the
  1761. Xoperating system on which the executable file runs.
  1762. X
  1763. X  4. You may not copy, sublicense, distribute or transfer this program
  1764. Xexcept as expressly provided under this License Agreement.  Any attempt
  1765. Xotherwise to copy, sublicense, distribute or transfer this program is void and
  1766. Xyour rights to use the program under this License agreement shall be
  1767. Xautomatically terminated.  However, parties who have received computer
  1768. Xsoftware programs from you with this License Agreement will not have
  1769. Xtheir licenses terminated so long as such parties remain in full compliance.
  1770. X
  1771. X  5. If you wish to incorporate parts of this program into other free
  1772. Xprograms whose distribution conditions are different, write to the Free
  1773. XSoftware Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  1774. Xworked out a simple rule that can be stated here, but we will often permit
  1775. Xthis.  We will be guided by the two goals of preserving the free status of
  1776. Xall derivatives of our free software and of promoting the sharing and reuse of
  1777. Xsoftware.
  1778. X
  1779. X
  1780. XIn other words, you are welcome to use, share and improve this program.
  1781. XYou are forbidden to forbid anyone else to use, share and improve
  1782. Xwhat you give them.   Help stamp out software-hoarding!  */
  1783. X
  1784. X
  1785. X
  1786. X/* BUFSIZE is the initial size allocated for the buffer
  1787. X   for reading the termcap file.
  1788. X   It is not a limit.
  1789. X   Make it large normally for speed.
  1790. X   Make it variable when debugging, so can exercise
  1791. X   increasing the space dynamically.  */
  1792. X
  1793. X#ifdef emacs
  1794. X#include "config.h"
  1795. X#endif
  1796. X
  1797. X#ifndef BUFSIZE
  1798. X#ifdef DEBUG
  1799. X#define BUFSIZE bufsize
  1800. X
  1801. Xint bufsize = 128;
  1802. X#else
  1803. X#define BUFSIZE 2048
  1804. X#endif
  1805. X#endif
  1806. X
  1807. X#ifndef emacs
  1808. Xstatic
  1809. Xmemory_out ()
  1810. X{
  1811. X  write (2, "Virtual memory exhausted\n", 25);
  1812. X  exit (1);
  1813. X}
  1814. X
  1815. Xstatic int
  1816. Xxmalloc (size)
  1817. X     int size;
  1818. X{
  1819. X  register tem = malloc (size);
  1820. X  if (!tem)
  1821. X    memory_out ();
  1822. X  return tem;
  1823. X}
  1824. X
  1825. Xstatic int
  1826. Xxrealloc (ptr, size)
  1827. X     int ptr;
  1828. X     int size;
  1829. X{
  1830. X  register tem = realloc (ptr, size);
  1831. X  if (!tem)
  1832. X    memory_out ();
  1833. X  return tem;
  1834. X}
  1835. X#endif /* not emacs */
  1836. X
  1837. X/* Looking up capabilities in the entry already found */
  1838. X
  1839. X/* The pointer to the data made by tgetent is left here
  1840. X   for tgetnum, tgetflag and tgetstr to find.  */
  1841. X
  1842. Xstatic char *term_entry;
  1843. X
  1844. Xstatic char *tgetst1 ();
  1845. X
  1846. X/* This is the main subroutine that is used to search
  1847. X   an entry for a particular capability */
  1848. X
  1849. Xstatic char *
  1850. Xfind_capability (bp, cap)
  1851. X     register char *bp, *cap;
  1852. X{
  1853. X  for (; *bp; bp++)
  1854. X    if (bp[0] == ':'
  1855. X    && bp[1] == cap[0]
  1856. X    && bp[2] == cap[1])
  1857. X      return &bp[4];
  1858. X  return 0;
  1859. X}
  1860. X
  1861. Xint
  1862. Xtgetnum (cap)
  1863. X     char *cap;
  1864. X{
  1865. X  register char *ptr = find_capability (term_entry, cap);
  1866. X  if (!ptr || ptr[-1] != '#')
  1867. X    return -1;
  1868. X  return atoi (ptr);
  1869. X}
  1870. X
  1871. Xint
  1872. Xtgetflag (cap)
  1873. X     char *cap;
  1874. X{
  1875. X  register char *ptr = find_capability (term_entry, cap);
  1876. X  return 0 != ptr && ptr[-1] == ':';
  1877. X}
  1878. X
  1879. X/* Look up a string-valued capability `cap'.
  1880. X   If `area' is nonzero, it points to a pointer to a block in which
  1881. X   to store the string.  That pointer is advanced over the space used.
  1882. X   If `area' is zero, space is allocated with `malloc'.  */
  1883. X
  1884. Xchar *
  1885. Xtgetstr (cap, area)
  1886. X     char *cap;
  1887. X     char **area;
  1888. X{
  1889. X  register char *ptr = find_capability (term_entry, cap);
  1890. X  if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~'))
  1891. X    return 0;
  1892. X  return tgetst1 (ptr, area);
  1893. X}
  1894. X
  1895. X/* Table, indexed by a character in range 0100 to 0140 with 0100 subtracted,
  1896. X   gives meaning of character following \, or a space if no special meaning.
  1897. X   Eight characters per line within the string.  */
  1898. X
  1899. Xstatic char esctab[]
  1900. X  = " \007\010  \033\014 \
  1901. X      \012 \
  1902. X  \015 \011 \013 \
  1903. X        ";
  1904. X
  1905. X/* Given a pointer to a string value inside a termcap entry (`ptr'),
  1906. X   copy the value and process \ and ^ abbreviations.
  1907. X   Copy into block that *area points to,
  1908. X   or to newly allocated storage if area is 0.  */
  1909. X
  1910. Xstatic char *
  1911. Xtgetst1 (ptr, area)
  1912. X     char *ptr;
  1913. X     char **area;
  1914. X{
  1915. X  register char *p, *r;
  1916. X  register int c;
  1917. X  register int size;
  1918. X  char *ret;
  1919. X  register int c1;
  1920. X
  1921. X  if (!ptr)
  1922. X    return 0;
  1923. X
  1924. X  /* `ret' gets address of where to store the string */
  1925. X  if (!area)
  1926. X    {
  1927. X      /* Compute size of block needed (may overestimate) */
  1928. X      p = ptr;
  1929. X      while ((c = *p++) && c != ':' && c != '\n');
  1930. X      ret = (char *) xmalloc (p - ptr + 1);
  1931. X    }
  1932. X  else
  1933. X    ret = *area;
  1934. X
  1935. X  /* Copy the string value, stopping at null or colon.  */
  1936. X  /* Also process ^ and \ abbreviations.  */
  1937. X  p = ptr;
  1938. X  r = ret;
  1939. X  while ((c = *p++) && c != ':' && c != '\n')
  1940. X    {
  1941. X      if (c == '^')
  1942. X    c = *p++ & 037;
  1943. X      else if (c == '\\')
  1944. X    {
  1945. X      c = *p++;
  1946. X      if (c >= '0' && c <= '7')
  1947. X        {
  1948. X          c -= '0';
  1949. X          size = 0;
  1950. X
  1951. X          while (++size < 3 && (c1 = *p) >= '0' && c1 <= '7')
  1952. X        {
  1953. X          c *= 8;
  1954. X          c += c1 - '0';
  1955. X          p++;
  1956. X        }
  1957. X        }
  1958. X      else if (c >= 0100 && c < 0200)
  1959. X        {
  1960. X          c1 = esctab[(c & ~040) - 0100];
  1961. X          if (c1 != ' ')
  1962. X        c = c1;
  1963. X        }
  1964. X    }
  1965. X      *r++ = c;
  1966. X    }
  1967. X  *r = 0;
  1968. X  /* Update *area */
  1969. X  if (area)
  1970. X    *area = r + 1;
  1971. X  return ret;
  1972. X}
  1973. X
  1974. X/* Outputting a string with padding */
  1975. X
  1976. Xshort ospeed;
  1977. Xchar PC;
  1978. X
  1979. X/* Actual baud rate if positive;
  1980. X   - baud rate / 100 if negative.  */
  1981. X
  1982. Xstatic short speeds[] =
  1983. X  {
  1984. X#ifdef VMS
  1985. X    0, 50, 75, 110, 134, 150, -3, -6, -12, -18,
  1986. X    -20, -24, -36, -48, -72, -96, -192
  1987. X#else /* not VMS */
  1988. X    0, 50, 75, 110, 135, 150, -2, -3, -6, -12,
  1989. X    -18, -24, -48, -96, -192, -384
  1990. X#endif /* not VMS */
  1991. X  };
  1992. X
  1993. Xtputs (string, nlines, outfun)
  1994. X     register char *string;
  1995. X     int nlines;
  1996. X     register int (*outfun) ();
  1997. X{
  1998. X  register int padcount = 0;
  1999. X
  2000. X  if (string == (char *) 0)
  2001. X    return;
  2002. X  while (*string >= '0' && *string <= '9')
  2003. X    {
  2004. X      padcount += *string++ - '0';
  2005. X      padcount *= 10;
  2006. X    }
  2007. X  if (*string == '.')
  2008. X    {
  2009. X      string++;
  2010. X      padcount += *string++ - '0';
  2011. X    }
  2012. X  if (*string == '*')
  2013. X    {
  2014. X      string++;
  2015. X      padcount *= nlines;
  2016. X    }
  2017. X  while (*string)
  2018. X    (*outfun) (*string++);
  2019. X
  2020. X  /* padcount is now in units of tenths of msec.  */
  2021. X  padcount *= speeds[ospeed];
  2022. X  padcount += 500;
  2023. X  padcount /= 1000;
  2024. X  if (speeds[ospeed] < 0)
  2025. X    padcount = -padcount;
  2026. X  else
  2027. X    {
  2028. X      padcount += 50;
  2029. X      padcount /= 100;
  2030. X    }
  2031. X
  2032. X  while (padcount-- > 0)
  2033. X    (*outfun) (PC);
  2034. X}
  2035. X
  2036. X/* Finding the termcap entry in the termcap data base */
  2037. X
  2038. Xstruct buffer
  2039. X  {
  2040. X    char *beg;
  2041. X    int size;
  2042. X    char *ptr;
  2043. X    int ateof;
  2044. X    int full;
  2045. X  };
  2046. X
  2047. X/* Forward declarations of static functions */
  2048. X
  2049. Xstatic int scan_file ();
  2050. Xstatic char *gobble_line ();
  2051. Xstatic int compare_contin ();
  2052. Xstatic int name_match ();
  2053. X
  2054. X#ifdef VMS
  2055. X
  2056. X#include <rmsdef.h>
  2057. X#include <fab.h>
  2058. X#include <nam.h>
  2059. X
  2060. Xstatic int
  2061. Xlegal_filename_p (fn)
  2062. X     char *fn;
  2063. X{
  2064. X  struct FAB fab = cc$rms_fab;
  2065. X  struct NAM nam = cc$rms_nam;
  2066. X  char esa[NAM$C_MAXRSS];
  2067. X
  2068. X  fab.fab$l_fna = fn;
  2069. X  fab.fab$b_fns = strlen(fn);
  2070. X  fab.fab$l_nam = &nam;
  2071. X  fab.fab$l_fop = FAB$M_NAM;
  2072. X
  2073. X  nam.nam$l_esa = esa;
  2074. X  nam.nam$b_ess = sizeof esa;
  2075. X
  2076. X  return SYS$PARSE(&fab, 0, 0) == RMS$_NORMAL;
  2077. X}
  2078. X
  2079. X#endif /* VMS */
  2080. X
  2081. X/* Find the termcap entry data for terminal type `name'
  2082. X   and store it in the block that `bp' points to.
  2083. X   Record its address for future use.
  2084. X
  2085. X   If `bp' is zero, space is dynamically allocated.  */
  2086. X
  2087. Xint
  2088. Xtgetent (bp, name)
  2089. X     char *bp, *name;
  2090. X{
  2091. X  register char *tem;
  2092. X  register int fd;
  2093. X  struct buffer buf;
  2094. X  register char *bp1;
  2095. X  char *bp2;
  2096. X  char *term;
  2097. X  int malloc_size = 0;
  2098. X  register int c;
  2099. X  char *tcenv;            /* TERMCAP value, if it contais :tc=.  */
  2100. X  char *indirect = 0;        /* Terminal type in :tc= in TERMCAP value.  */
  2101. X  int filep;
  2102. X
  2103. X  tem = (char *) getenv ("TERMCAP");
  2104. X  if (tem && *tem == 0) tem = 0;
  2105. X
  2106. X#ifdef VMS
  2107. X  filep = tem && legal_filename_p (tem);
  2108. X#else
  2109. X  filep = tem && (*tem == '/');
  2110. X#endif /* VMS */
  2111. X
  2112. X  /* If tem is non-null and starts with / (in the un*x case, that is),
  2113. X     it is a file name to use instead of /etc/termcap.
  2114. X     If it is non-null and does not start with /,
  2115. X     it is the entry itself, but only if
  2116. X     the name the caller requested matches the TERM variable.  */
  2117. X
  2118. X  if (tem && !filep && !strcmp (name, getenv ("TERM")))
  2119. X    {
  2120. X      indirect = tgetst1 (find_capability (tem, "tc"), 0);
  2121. X      if (!indirect)
  2122. X    {
  2123. X      if (!bp)
  2124. X        bp = tem;
  2125. X      else
  2126. X        strcpy (bp, tem);
  2127. X      goto ret;
  2128. X    }
  2129. X      else
  2130. X    {            /* we will need to read /etc/termcap */
  2131. X      tcenv = tem;
  2132. X       tem = 0;
  2133. X    }
  2134. X    }
  2135. X  else
  2136. X    indirect = (char *) 0;
  2137. X
  2138. X  if (!tem)
  2139. X#ifdef VMS
  2140. X    tem = "emacs_library:[etc]termcap.dat";
  2141. X#else
  2142. X    tem = "/etc/termcap";
  2143. X#endif
  2144. X
  2145. X  /* Here we know we must search a file and tem has its name.  */
  2146. X
  2147. X  fd = open (tem, 0, 0);
  2148. X  if (fd < 0)
  2149. X    return -1;
  2150. X
  2151. X  buf.size = BUFSIZE;
  2152. X  buf.beg = (char *) xmalloc (buf.size);
  2153. X  term = indirect ? indirect : name;
  2154. X
  2155. X  if (!bp)
  2156. X    {
  2157. X      malloc_size = indirect ? strlen (tcenv) + 1 : buf.size;
  2158. X      bp = (char *) xmalloc (malloc_size);
  2159. X    }
  2160. X  bp1 = bp;
  2161. X
  2162. X  if (indirect)            /* copy the data from the environment variable */
  2163. X    {
  2164. X      strcpy (bp, tcenv);
  2165. X      bp1 += strlen (tcenv);
  2166. X    }
  2167. X
  2168. X  while (term)
  2169. X    {
  2170. X      /* Scan file, reading it via buf, till find start of main entry */
  2171. X      if (scan_file (term, fd, &buf) == 0)
  2172. X    return 0;
  2173. X
  2174. X      /* Free old `term' if appropriate.  */
  2175. X      if (term != name)
  2176. X    free (term);
  2177. X
  2178. X      /* If `bp' is malloc'd by us, make sure it is big enough.  */
  2179. X      if (malloc_size)
  2180. X    {
  2181. X      malloc_size = bp1 - bp + buf.size;
  2182. X      tem = (char *) xrealloc (bp, malloc_size);
  2183. X      bp1 += tem - bp;
  2184. X      bp = tem;
  2185. X    }
  2186. X
  2187. X      bp2 = bp1;
  2188. X
  2189. X      /* Copy the line of the entry from buf into bp.  */
  2190. X      tem = buf.ptr;
  2191. X      while ((*bp1++ = c = *tem++) && c != '\n')
  2192. X    /* Drop out any \ newline sequence. */
  2193. X    if (c == '\\' && *tem == '\n')
  2194. X      {
  2195. X        bp1--;
  2196. X        tem++;
  2197. X      }
  2198. X      *bp1 = 0;
  2199. X
  2200. X      /* Does this entry refer to another terminal type's entry?  */
  2201. X      /* If something is found, copy it into heap and null-terminate it */
  2202. X      term = tgetst1 (find_capability (bp2, "tc"), 0);
  2203. X    }
  2204. X
  2205. X  close (fd);
  2206. X  free (buf.beg);
  2207. X
  2208. X  if (malloc_size)
  2209. X    {
  2210. X      bp = (char *) xrealloc (bp, bp1 - bp + 1);
  2211. X    }
  2212. X
  2213. X ret:
  2214. X  term_entry = bp;
  2215. X  if (malloc_size)
  2216. X    return (int) bp;
  2217. X  return 1;
  2218. X}
  2219. X
  2220. X/* Given file open on `fd' and buffer `bufp',
  2221. X   scan the file from the beginning until a line is found
  2222. X   that starts the entry for terminal type `string'.
  2223. X   Returns 1 if successful, with that line in `bufp',
  2224. X   or returns 0 if no entry found in the file.  */
  2225. X
  2226. Xstatic int
  2227. Xscan_file (string, fd, bufp)
  2228. X     char *string;
  2229. X     int fd;
  2230. X     register struct buffer *bufp;
  2231. X{
  2232. X  register char *tem;
  2233. X  register char *end;
  2234. X
  2235. X  bufp->ptr = bufp->beg;
  2236. X  bufp->full = 0;
  2237. X  bufp->ateof = 0;
  2238. X  *bufp->ptr = 0;
  2239. X
  2240. X  lseek (fd, 0L, 0);
  2241. X
  2242. X  while (!bufp->ateof)
  2243. X    {
  2244. X      /* Read a line into the buffer */
  2245. X      end = 0;
  2246. X      do
  2247. X    {
  2248. X      /* if it is continued, append another line to it,
  2249. X         until a non-continued line ends */
  2250. X      end = gobble_line (fd, bufp, end);
  2251. X    }
  2252. X      while (!bufp->ateof && end[-2] == '\\');
  2253. X
  2254. X      if (*bufp->ptr != '#'
  2255. X      && name_match (bufp->ptr, string))
  2256. X    return 1;
  2257. X
  2258. X      /* Discard the line just processed */
  2259. X      bufp->ptr = end;
  2260. X    }
  2261. X  return 0;
  2262. X}
  2263. X
  2264. X/* Return nonzero if NAME is one of the names specified
  2265. X   by termcap entry LINE.  */
  2266. X
  2267. Xstatic int
  2268. Xname_match (line, name)
  2269. X     char *line, *name;
  2270. X{
  2271. X  register char *tem;
  2272. X
  2273. X  if (!compare_contin (line, name))
  2274. X    return 1;
  2275. X  /* This line starts an entry.  Is it the right one?  */
  2276. X  for (tem = line; *tem && *tem != '\n' && *tem != ':'; tem++)
  2277. X    if (*tem == '|' && !compare_contin (tem + 1, name))
  2278. X      return 1;
  2279. X
  2280. X  return 0;
  2281. X}
  2282. X
  2283. Xstatic int
  2284. Xcompare_contin (str1, str2)
  2285. X     register char *str1, *str2;
  2286. X{
  2287. X  register int c1, c2;
  2288. X  while (1)
  2289. X    {
  2290. X      c1 = *str1++;
  2291. X      c2 = *str2++;
  2292. X      while (c1 == '\\' && *str1 == '\n')
  2293. X    {
  2294. X      str1++;
  2295. X      while ((c1 = *str1++) == ' ' || c1 == '\t');
  2296. X    }
  2297. X      if (c2 == '\0')        /* end of type being looked up */
  2298. X    {
  2299. X      if (c1 == '|' || c1 == ':') /* If end of name in data base, */
  2300. X        return 0;        /* we win. */
  2301. X      else
  2302. X        return 1;
  2303. X        }
  2304. X      else if (c1 != c2)
  2305. X    return 1;
  2306. X    }
  2307. X}
  2308. X
  2309. X/* Make sure that the buffer <- `bufp' contains a full line
  2310. X   of the file open on `fd', starting at the place `bufp->ptr'
  2311. X   points to.  Can read more of the file, discard stuff before
  2312. X   `bufp->ptr', or make the buffer bigger.
  2313. X
  2314. X   Returns the pointer to after the newline ending the line,
  2315. X   or to the end of the file, if there is no newline to end it.
  2316. X
  2317. X   Can also merge on continuation lines.  If `append_end' is
  2318. X   nonzero, it points past the newline of a line that is
  2319. X   continued; we add another line onto it and regard the whole
  2320. X   thing as one line.  The caller decides when a line is continued.  */
  2321. X
  2322. Xstatic char *
  2323. Xgobble_line (fd, bufp, append_end)
  2324. X     int fd;
  2325. X     register struct buffer *bufp;
  2326. X     char *append_end;
  2327. X{
  2328. X  register char *end;
  2329. X  register int nread;
  2330. X  register char *buf = bufp->beg;
  2331. X  register char *tem;
  2332. X
  2333. X  if (append_end == 0)
  2334. X    append_end = bufp->ptr;
  2335. X
  2336. X  while (1)
  2337. X    {
  2338. X      end = append_end;
  2339. X      while (*end && *end != '\n') end++;
  2340. X      if (*end)
  2341. X        break;
  2342. X      if (bufp->ateof)
  2343. X    return buf + bufp->full;
  2344. X      if (bufp->ptr == buf)
  2345. X    {
  2346. X      if (bufp->full == bufp->size)
  2347. X        {
  2348. X          bufp->size *= 2;
  2349. X          tem = (char *) xrealloc (buf, bufp->size);
  2350. X          bufp->ptr += tem - buf;
  2351. X          append_end += tem - buf;
  2352. X          bufp->beg = buf = tem;
  2353. X        }
  2354. X    }
  2355. X      else
  2356. X    {
  2357. X      append_end -= bufp->ptr - buf;
  2358. X      bcopy (bufp->ptr, buf, bufp->full -= bufp->ptr - buf);
  2359. X      bufp->ptr = buf;
  2360. X    }
  2361. X      if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full)))
  2362. X    bufp->ateof = 1;
  2363. X      bufp->full += nread;
  2364. X      if (bufp->full != bufp->size)
  2365. X    buf[bufp->full] = 0;
  2366. X    }
  2367. X  return end + 1;
  2368. X}
  2369. X
  2370. X#ifdef TEST
  2371. X
  2372. X#include <stdio.h>
  2373. X
  2374. Xmain (argc, argv)
  2375. X     int argc;
  2376. X     char **argv;
  2377. X{
  2378. X  char *term;
  2379. X  char *buf;
  2380. X
  2381. X  term = argv[1];
  2382. X  printf ("TERM: %s\n", term);
  2383. X
  2384. X  buf = (char *) tgetent (0, term);
  2385. X  if ((int) buf <= 0)
  2386. X    {
  2387. X      printf ("No entry.\n");
  2388. X      return 0;
  2389. X    }
  2390. X
  2391. X  printf ("Entry: %s\n", buf);
  2392. X
  2393. X  tprint ("cm");
  2394. X  tprint ("AL");
  2395. X
  2396. X  printf ("co: %d\n", tgetnum ("co"));
  2397. X  printf ("am: %d\n", tgetflag ("am"));
  2398. X}
  2399. X
  2400. Xtprint (cap)
  2401. X     char *cap;
  2402. X{
  2403. X  char *x = tgetstr (cap, 0);
  2404. X  register char *y;
  2405. X
  2406. X  printf ("%s: ", cap);
  2407. X  if (x)
  2408. X    {
  2409. X      for (y = x; *y; y++)
  2410. X    if (*y <= ' ' || *y == 0177)
  2411. X      printf ("\\%0o", *y);
  2412. X    else
  2413. X      putchar (*y);
  2414. X      free (x);
  2415. X    }
  2416. X  else
  2417. X    printf ("none");
  2418. X  putchar ('\n');
  2419. X}
  2420. X
  2421. X#endif /* TEST */
  2422. END_OF_FILE
  2423. if test 18405 -ne `wc -c <'vms/vmstermcap.c'`; then
  2424.     echo shar: \"'vms/vmstermcap.c'\" unpacked with wrong size!
  2425. fi
  2426. # end of 'vms/vmstermcap.c'
  2427. fi
  2428. echo shar: End of archive 19 \(of 56\).
  2429. cp /dev/null ark19isdone
  2430. MISSING=""
  2431. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 ; do
  2432.     if test ! -f ark${I}isdone ; then
  2433.     MISSING="${MISSING} ${I}"
  2434.     fi
  2435. done
  2436. if test "${MISSING}" = "" ; then
  2437.     echo You have unpacked all 56 archives.
  2438.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2439. else
  2440.     echo You still need to unpack the following archives:
  2441.     echo "        " ${MISSING}
  2442. fi
  2443. ##  End of shell archive.
  2444. exit 0
  2445.