home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2388 < prev    next >
Internet Message Format  |  1990-12-28  |  20KB

  1. From: goer@ellis.uchicago.edu (Richard L. Goerwitz)
  2. Newsgroups: alt.sources
  3. Subject: itlib part 2 of 3
  4. Message-ID: <1990Dec21.055654.22566@midway.uchicago.edu>
  5. Date: 21 Dec 90 05:56:54 GMT
  6.  
  7.  
  8. ---- Cut Here and feed the following to sh ----
  9. #!/bin/sh
  10. # this is itlib.02 (part 2 of a multipart archive)
  11. # do not concatenate these parts, unpack them in order with /bin/sh
  12. # file itlib.icn continued
  13. #
  14. if test ! -r _shar_seq_.tmp; then
  15.     echo 'Please unpack part 1 first!'
  16.     exit 1
  17. fi
  18. (read Scheck
  19.  if test "$Scheck" != 2; then
  20.     echo Please unpack part "$Scheck" next!
  21.     exit 1
  22.  else
  23.     exit 0
  24.  fi
  25. ) < _shar_seq_.tmp || exit 1
  26. if test ! -f _shar_wnt_.tmp; then
  27.     echo 'x - still skipping itlib.icn'
  28. else
  29. echo 'x - continuing file itlib.icn'
  30. sed 's/^X//' << 'SHAR_EOF' >> 'itlib.icn' &&
  31. X
  32. Xend
  33. X
  34. X
  35. X
  36. Xprocedure Decode(s)
  37. X
  38. X    # Does things like turn ^ plus a letter into a genuine control
  39. X    # character.
  40. X
  41. X    new_s := ""
  42. X
  43. X    s ? {
  44. X
  45. X    while new_s ||:= tab(upto('\\^')) do {
  46. X        chr := move(1)
  47. X        if chr == "\\" then {
  48. X        new_s ||:= {
  49. X            case chr2 := move(1) of {
  50. X            "\\" : "\\"
  51. X            "^"  : "^"
  52. X            "E"  : "\e"
  53. X            "b"  : "\b"
  54. X            "f"  : "\f"
  55. X            "n"  : "\n"
  56. X            "r"  : "\r"
  57. X            "t"  : "\t"
  58. X            default : {
  59. X                if any(&digits,chr2) then {
  60. X                char(integer("8r"||chr2||move(2 to 0 by -1))) |
  61. X                    er("Decode","bad termcap entry",3)
  62. X                }
  63. X               else chr2
  64. X            }
  65. X            }
  66. X        }
  67. X        }
  68. X        else new_s ||:= char(ord(map(move(1),&lcase,&ucase)) - 64)
  69. X    }
  70. X    new_s ||:= tab(0)
  71. X    }
  72. X
  73. X    return new_s
  74. X
  75. Xend
  76. X
  77. X
  78. X
  79. Xprocedure igoto(cm,col,line)
  80. X
  81. X    local colline, range, increment, str, outstr, chr, x, y
  82. X
  83. X    if col > (tc_table["co"]) | line > (tc_table["li"]) then {
  84. X    colline := string(\col) || "," || string(\line) | string(\col|line)
  85. X    range := "(" || tc_table["co"]-1 || "," || tc_table["li"]-1 || ")"
  86. X    er("igoto",colline || " out of range " || (\range|""),9)
  87. X    } 
  88. X
  89. X    # Use the Iconish 1;1 upper left corner & not the C-ish 0 offsets
  90. X    increment := -1
  91. X    outstr := ""
  92. X    
  93. X    cm ? {
  94. X    while outstr ||:= tab(find("%")) do {
  95. X        tab(match("%"))
  96. X        chr := move(1)
  97. X        if case chr of {
  98. X        "." :  outstr ||:= char(line + increment)
  99. X        "+" :  outstr ||:= char(line + ord(move(1)) + increment)
  100. X        "d" :  {
  101. X            str := string(line + increment)
  102. X            outstr ||:= right(str, integer(tab(any('23'))), "0") | str
  103. X        }
  104. X        }
  105. X        then line :=: col
  106. X        else {
  107. X        case chr of {
  108. X            "n" :  line := ixor(line,96) & col := ixor(col,96)
  109. X            "i" :  increment := 0
  110. X            "r" :  line :=: col
  111. X            "%" :  outstr ||:= "%"
  112. X            "B" :  line := ior(ishift(line / 10, 4), line % 10)
  113. X            ">" :  {
  114. X            x := move(1); y := move(1)
  115. X            line > ord(x) & line +:= ord(y)
  116. X            &null
  117. X            }
  118. X        } | er("goto","bad termcap entry",5)
  119. X        }
  120. X    }
  121. X    return outstr || tab(0)
  122. X    }
  123. X
  124. Xend
  125. X
  126. X
  127. X
  128. Xprocedure iputs(cp, affcnt)
  129. X
  130. X    local baud_rates, char_rates, i, delay, PC
  131. X    static num_chars, char_times
  132. X    # global tty_speed
  133. X
  134. X    initial {
  135. X    num_chars := &digits ++ '.'
  136. X    char_times := table()
  137. X    # Baud rates in decimal, not octal (as in termio.h)
  138. X    baud_rates := [0,7,8,9,10,11,12,13,14,15]
  139. X    char_rates := [0,333,166,83,55,41,20,10,10,10]
  140. X    every i := 1 to *baud_rates do {
  141. X        char_times[baud_rates[i]] := char_rates[i]
  142. X    }
  143. X    }
  144. X
  145. X    type(cp) == "string" |
  146. X    er("iputs","you can't iputs() a non-string value!",10)
  147. X
  148. X    cp ? {
  149. X    delay := tab(many(num_chars))
  150. X    if ="*" then {
  151. X        delay *:= \affcnt |
  152. X        er("iputs","affected line count missing",6)
  153. X    }
  154. X    writes(tab(0))
  155. X    }
  156. X
  157. X    if (\delay, tty_speed ~= 0) then {
  158. X    PC := tc_table["pc"] | "\000"
  159. X    char_time := char_times[tty_speed] | (return "speed error")
  160. X    delay := (delay * char_time) + (char_time / 2)
  161. X    every 1 to delay by 10
  162. X    do writes(PC)
  163. X    }
  164. X
  165. X    return
  166. X
  167. Xend
  168. X
  169. X
  170. X
  171. Xprocedure getspeed()
  172. X
  173. X    local stty_g, stty_output, c_cflag, o_speed
  174. X
  175. X    stty_g := open("/bin/stty -g 2>&1","pr") |
  176. X    er("getspeed","Can't access your stty command.",4)
  177. X    stty_output := !stty_g
  178. X    close(stty_g)
  179. X
  180. X    \stty_output ? {
  181. X    # tab to the third field of the output of the stty -g cmd
  182. X        tab(find(":")+1) & tab(find(":")+1) &
  183. X    c_cflag := integer("16r"||tab(find(":")))
  184. X    } | er("getspeed","Unable to unwind your stty -g output.",4)
  185. X
  186. X    o_speed := iand(15,c_cflag)
  187. X    return o_speed
  188. X
  189. Xend
  190. SHAR_EOF
  191. echo 'File itlib.icn is complete' &&
  192. true || echo 'restore of itlib.icn failed'
  193. rm -f _shar_wnt_.tmp
  194. fi
  195. # ============= iscreen.icn ==============
  196. if test -f 'iscreen.icn' -a X"$1" != X"-c"; then
  197.     echo 'x - skipping iscreen.icn (File already exists)'
  198.     rm -f _shar_wnt_.tmp
  199. else
  200. > _shar_wnt_.tmp
  201. echo 'x - extracting iscreen.icn (Text)'
  202. sed 's/^X//' << 'SHAR_EOF' > 'iscreen.icn' &&
  203. X############################################################################
  204. X#
  205. X#    Name:     iscreen.icn
  206. X#
  207. X#    Title:     Icon screen functions
  208. X#
  209. X#    Author:     Richard L. Goerwitz
  210. X#
  211. X#    Version: 1.12
  212. X#
  213. X############################################################################
  214. X#
  215. X#  This and future version of iscreen are placed in the public domain - RLG
  216. X#
  217. X############################################################################
  218. X#  
  219. X#      This file contains some rudimentary screen functions for use with
  220. X#  itlib.icn (termlib-like routines for Icon).
  221. X#
  222. X#      clear()              - clears the screen (tries several methods)
  223. X#      emphasize()          - initiates emphasized mode
  224. X#      normal(mode)         - resets to normal mode; if mode is null,
  225. X#        or "b," normal() assumes you were in emphasize mode,
  226. X#        otherwise you are assumed to have been in underline mode
  227. X#      message(s)           - displays message s on 2nd-to-last line
  228. X#      underline()          - initiates underline mode
  229. X#      status_line(s,s2,p)  - draws status line s on the 3rd-to-last
  230. X#        screen line; if s is too short for the terminal, s2 is used;
  231. X#        if p is nonnull then it either centers, left-, or right-justi-
  232. X#        fies, depending on the value, "c," "l," or "r."
  233. X#
  234. X############################################################################
  235. X#
  236. X#  Requires: UNIX
  237. X#
  238. X#  Links: itlib.icn (or your OS-specific port of itlib)
  239. X#
  240. X#  See also: boldface.icn
  241. X#
  242. X############################################################################
  243. X
  244. X
  245. Xprocedure clear()
  246. X
  247. X    # Clears the screen.  Tries several methods.
  248. X
  249. X    if not iputs(getval("cl"))
  250. X    then iputs(igoto(getval("cm"),1,1))
  251. X    if not iputs(getval("cd"))
  252. X    then {
  253. X    every i := 1 to getval("li") do {
  254. X        iputs(igoto(getval("cm"),1,i))
  255. X        iputs(getval("ce"))
  256. X    }
  257. X    iputs(igoto(getval("cm"),1,1))
  258. X    }
  259. X    return
  260. X
  261. Xend
  262. X
  263. X
  264. X
  265. Xprocedure emphasize()
  266. X    
  267. X    static bold_str, cookie_str
  268. X    initial {
  269. X    if bold_str := getval("so")
  270. X    then cookie_str := repl(getval("bc") | "\b", getval("sg"))
  271. X    else {
  272. X        if bold_str := getval("us")
  273. X        then cookie_str := repl(getval("bc") | "\b", getval("ug"))
  274. X    }
  275. X    }        
  276. X    
  277. X    iputs(\bold_str)
  278. X    iputs(\cookie_str)
  279. X    return
  280. X
  281. Xend
  282. X
  283. X
  284. X
  285. Xprocedure underline()
  286. X    
  287. X    static underline_str, cookie_str
  288. X    initial {
  289. X    if underline_str := getval("us")
  290. X    then cookie_str := repl(getval("bc") | "\b", getval("sg"))
  291. X    }        
  292. X    
  293. X    iputs(\underline_str)
  294. X    iputs(\cookie_str)
  295. X    return
  296. X
  297. Xend
  298. X
  299. X
  300. X
  301. Xprocedure normal(mode)
  302. X
  303. X    static UN_bold_str, bold_cookie_str,
  304. X    UN_underline_str, underline_cookie_str
  305. X    initial {
  306. X
  307. X    if UN_bold_str := getval("se") then
  308. X        bold_cookie_str := repl(getval("bc") | "\b", getval("sg"))
  309. X    else {
  310. X        UN_bold_str := getval("ue")
  311. X        bold_cookie_str := repl(getval("bc")|"\b", getval("ug"))
  312. X    }
  313. X    if UN_underline_str := getval("ue") then
  314. X        underline_cookie_str := repl(getval("bc")|"\b", getval("ug"))
  315. X    }        
  316. X    
  317. X    if /mode | (mode == "b") then {
  318. X    iputs(\UN_bold_str)
  319. X    iputs(\bold_cookie_str)
  320. X    return
  321. X    }
  322. X
  323. X    iputs(\UN_underline_str)
  324. X    iputs(\underline_cookie_str)
  325. X    return
  326. X
  327. Xend
  328. X
  329. X
  330. X
  331. Xprocedure status_line(s,s2,p)
  332. X
  333. X    # Writes a status line on the terminal's third-to-last line
  334. X    # The only necessary argument is s.  S2 (optional) is used
  335. X    # for extra narrow screens.  In other words, by specifying
  336. X    # s2 you give status_line an alternate, shorter status string
  337. X    # to display, in case the terminal isn't wide enough to sup-
  338. X    # port s.  If p is nonnull, then the status line is either
  339. X    # centered (if equal to "c"), left justified ("l"), or right
  340. X    # justified ("r").
  341. X
  342. X    local width
  343. X
  344. X    /s := ""
  345. X    width := getval("co")
  346. X    if *s > width then {
  347. X    (*s2 < width, s := \s2) |
  348. X        er("status_line","Your terminal is too narrow.",4)
  349. X    }
  350. X    case \p of {
  351. X    "c"    : s := center(s,width-1)
  352. X    "l"    : s := left(s,width-1)
  353. X    "r"    : s := right(s,width-1)
  354. X    default: stop("status_line:  Unknown option "||string(p),4)
  355. X    }
  356. X
  357. X    iputs(igoto(getval("cm"), 1, getval("li")-2))
  358. X    emphasize(); writes(s); iputs(getval("ce"))
  359. X    normal()
  360. X    return
  361. X
  362. Xend
  363. X
  364. X
  365. X
  366. Xprocedure message(s)
  367. X
  368. X    # Display prompt s on the second-to-last line of the screen.
  369. X    # I hate to use the last line, due to all the problems with
  370. X    # automatic scrolling.
  371. X
  372. X    /s := ""
  373. X    normal()
  374. X    iputs(igoto(getval("cm"), 1, getval("li")-1))
  375. X    writes(s[1:getval("co")] | s)
  376. X    iputs(getval("ce"))
  377. X    return
  378. X
  379. Xend
  380. SHAR_EOF
  381. true || echo 'restore of iscreen.icn failed'
  382. rm -f _shar_wnt_.tmp
  383. fi
  384. # ============= itlibdos.icn ==============
  385. if test -f 'itlibdos.icn' -a X"$1" != X"-c"; then
  386.     echo 'x - skipping itlibdos.icn (File already exists)'
  387.     rm -f _shar_wnt_.tmp
  388. else
  389. > _shar_wnt_.tmp
  390. echo 'x - extracting itlibdos.icn (Text)'
  391. sed 's/^X//' << 'SHAR_EOF' > 'itlibdos.icn' &&
  392. X##########################################################################
  393. X#    
  394. X#    Name:    itlibdos.icn
  395. X#    
  396. X#    Title:    Icon termlib-type tools (MS-DOS version)
  397. X#    
  398. X#    Author:    Richard L. Goerwitz
  399. X#
  400. X#    Version: 1.12
  401. X#
  402. X###########################################################################
  403. X#
  404. X#  I place this and future versions of itlibdos in the public domain - RLG
  405. X#
  406. X###########################################################################
  407. X#
  408. X#  The following library represents a series of rough functional
  409. X#  equivalents to the standard Unix low-level termcap routines.  They
  410. X#  are not meant as exact termlib clones.  Nor are they enhanced to
  411. X#  take care of magic cookie terminals, terminals that use \D in their
  412. X#  termcap entries, or, in short, anything I felt would not affect my
  413. X#  normal, day-to-day work with ANSI and vt100 terminals.
  414. X#
  415. X#  Requires:  An MS-DOS platform & co-expressions.  The MS-DOS version
  416. X#  is a port of the Unix version.  Software you write for this library
  417. X#  can be made to run under Unix simply by substituting the Unix ver-
  418. X#  sion of this library.  See below for additional notes on how to use
  419. X#  this MS-DOS port.
  420. X#
  421. X#  setname(term)
  422. X#    Use only if you wish to initialize itermlib for a terminal
  423. X#  other than what your current environment specifies.  "Term" is the
  424. X#  name of the termcap entry to use.  Normally this initialization is
  425. X#  done automatically, and need not concern the user.
  426. X#
  427. X#  getval(id)
  428. X#    Works something like tgetnum, tgetflag, and tgetstr.  In the
  429. X#  spirit of Icon, all three have been collapsed into one routine.
  430. X#  Integer valued caps are returned as integers, strings as strings,
  431. X#  and flags as records (if a flag is set, then type(flag) will return
  432. X#  "true").  Absence of a given capability is signalled by procedure
  433. X#  failure.
  434. X#
  435. X#  igoto(cm,destcol,destline) - NB:  default 1 offset (*not* zero)!
  436. X#    Analogous to tgoto.  "Cm" is the cursor movement command for
  437. X#  the current terminal, as obtained via getval("cm").  Igoto()
  438. X#  returns a string which, when output via iputs, will cause the
  439. X#  cursor to move to column "destcol" and line "destline."  Column and
  440. X#  line are always calculated using a *one* offset.  This is far more
  441. X#  Iconish than the normal zero offset used by tgoto.  If you want to
  442. X#  go to the first square on your screen, then include in your program
  443. X#  "iputs(igoto(getval("cm"),1,1))."
  444. X#
  445. X#  iputs(cp,affcnt)
  446. X#    Equivalent to tputs.  "Cp" is a string obtained via getval(),
  447. X#  or, in the case of "cm," via igoto(getval("cm"),x,y).  Affcnt is a
  448. X#  count of affected lines.  It is only relevant for terminals which
  449. X#  specify proportional (starred) delays in their termcap entries.
  450. X#
  451. X#  Notes on the MS-DOS version:
  452. X#    There are two basic reasons for using the I/O routines
  453. X#  contained in this package.  First, by using a set of generalized
  454. X#  routines, your code will become much more readable.  Secondly, by
  455. X#  using a high level interface, you can avoid the cardinal
  456. X#  programming error of hard coding things like screen length and
  457. X#  escape codes into your programs.
  458. X#    To use this collection of programs, you must do two things.
  459. X#  First, you must add the line "device=ansi.sys" (or the name of some
  460. X#  other driver, like zansi.sys, nansi.sys, or nnansi.sys [=new
  461. X#  nansi.sys]) to your config.sys file.  Secondly, you must add two
  462. X#  lines to your autoexec.bat file:  1) "set TERM=ansi-mono" and 2)
  463. X#  "set TERMCAP=\location\termcap."  The purpose of setting the TERM
  464. X#  variable is to tell this program what driver you are using.  If you
  465. X#  have a color system, use "ansi-color" instead of "ansi-mono," and
  466. X#  if you are using nansi or zansi instead of vanilla ansi, use one of
  467. X#  these names instead of the "ansi" (e.g. "zansi-mono").  The purpose
  468. X#  of setting TERMCAP is to make it possible to determine where the
  469. X#  termcap file is located.  The termcap file (which should have been
  470. X#  packed with this library as termcap.dos) is a short database of all
  471. X#  the escape sequences used by the various terminal drivers.  Set
  472. X#  TERMCAP so that it reflects the location of this file (which should
  473. X#  be renamed as termcap, for the sake of consistency with the Unix
  474. X#  version).  Naturally, you must change "\location\" above to reflect
  475. X#  the correct path on your system.
  476. X#    Although I make no pretense here of providing here a complete
  477. X#  introduction to the format of the termcap database file, it will be
  478. X#  useful, I think, to explain a few basic facts about how to use this
  479. X#  program in conjunction with it.  If, say, you want to clear the
  480. X#  screen, add the line,
  481. X#
  482. X#    iputs(getval("cl"))
  483. X#
  484. X#  to your program.  The function iputs() outputs screen control
  485. X#  sequences.  Getval retrieves a specific sequence from the termcap
  486. X#  file.  The string "cl" is the symbol used in the termcap file to
  487. X#  mark the code used to clear the screen.  By executing the
  488. X#  expression "iputs(getval("cl"))," you are 1) looking up the "cl"
  489. X#  (clear) code in the termcap database entry for your terminal, and
  490. X#  the 2) outputting that sequence to the screen.
  491. X#    Some other useful termcap symbols are "ce" (clear to end of
  492. X#  line), "ho" (go to the top left square on the screen), "so" (begin
  493. X#  standout mode), and "se" (end standout mode).  To output a
  494. X#  boldfaced string, str, to the screen, you would write -
  495. X#
  496. X#    iputs(getval("so"))
  497. X#    writes(str)
  498. X#    iputs(getval("se"))
  499. X#
  500. X#  You could write "iputs(getval("so") || str || getval("se")), but
  501. X#  this would only work for DOS.  Some Unix terminals require padding,
  502. X#  and iputs() handles them specially.  Normally you should not worry
  503. X#  about Unix quirks under DOS.  It is in general wise, though, to
  504. X#  separate out screen control sequences, and output them via iputs().
  505. X#    It is also heartily to be recommended that MS-DOS programmers
  506. X#  try not to assume that everyone will be using a 25-line screen.
  507. X#  Some terminals are 24-line.  Some 43.  Some have variable window
  508. X#  sizes.  If you want to put a status line on, say, the 2nd-to-last
  509. X#  line of the screen, then determine what that line is by executing
  510. X#  "getval("li")."  The termcap database holds not only string-valued
  511. X#  sequences, but numeric ones as well.  The value of "li" tells you
  512. X#  how many lines the terminal has (compare "co," which will tell you
  513. X#  how many columns).  To go to the beginning of the second-to-last
  514. X#  line on the screen, type in:
  515. X#
  516. X#    iputs(igoto(getval("cm"), 1, getval("li")-1))
  517. X#
  518. X#  The "cm" capability is a special capability, and needs to be output
  519. X#  via igoto(cm,x,y), where cm is the sequence telling your computer
  520. X#  to move the cursor to a specified spot, x is the column, and y is
  521. X#  the row.  The expression "getval("li")-1" will return the number of
  522. X#  the second-to-last line on your screen.
  523. X#
  524. X##########################################################################
  525. X#
  526. X#  Requires: MS-DOS, coexpressions
  527. X#
  528. X#  See also: iscreen.icn (a set of companion utilities) 
  529. X#
  530. X##########################################################################
  531. X
  532. X
  533. Xglobal tc_table
  534. Xrecord true()
  535. X
  536. X
  537. Xprocedure check_features()
  538. X
  539. X    local in_params, line
  540. X
  541. X    initial {
  542. X    find("ms-dos",map(&features)) |
  543. X        er("check_features","MS-DOS system required",1)
  544. X    find("o-expres",&features) |
  545. X        er("check_features","co-expressions not implemented - &$#!",1)
  546. X    }
  547. X
  548. X    return
  549. X
  550. Xend
  551. X
  552. X
  553. X
  554. Xprocedure setname(name)
  555. X
  556. X    # Sets current terminal type to "name" and builds a new termcap
  557. X    # capability database (residing in tc_table).  Fails if unable to
  558. X    # find a termcap entry for terminal type "name."  If you want it
  559. X    # to terminate with an error message under these circumstances,
  560. X    # comment out "| fail" below, and uncomment the er() line.
  561. X
  562. X    #tc_table is global
  563. X    
  564. X    check_features()
  565. X
  566. X    tc_table := maketc_table(getentry(name)) | fail
  567. X    # er("setname","no termcap entry found for "||name,3)
  568. X    return
  569. X
  570. Xend
  571. X
  572. X
  573. X
  574. Xprocedure getname()
  575. X
  576. X    # Getname() first checks to be sure we're running under DOS, and,
  577. X    # if so, tries to figure out what the current terminal type is,
  578. X    # checking the value of the environment variable TERM, and if this
  579. X    # is unsuccessful, defaulting to "mono."
  580. X
  581. X    local term, tset_output
  582. X
  583. X    check_features()
  584. X    term := getenv("TERM") | "mono"
  585. X    
  586. X    return \term |
  587. X    er("getname","can't seem to determine your terminal type",1)
  588. X
  589. Xend
  590. X
  591. X
  592. X
  593. Xprocedure er(func,msg,errnum)
  594. X
  595. X    # short error processing utility
  596. X    write(&errout,func,":  ",msg)
  597. X    exit(errnum)
  598. X
  599. Xend
  600. X
  601. X
  602. X
  603. Xprocedure getentry(name, termcap_string)
  604. X
  605. X    # "Name" designates the current terminal type.  Getentry() scans
  606. X    # the current environment for the variable TERMCAP.  If the
  607. X    # TERMCAP string represents a termcap entry for a terminal of type
  608. X    # "name," then getentry() returns the TERMCAP string.  Otherwise,
  609. X    # getentry() will check to see if TERMCAP is a file name.  If so,
  610. X    # getentry() will scan that file for an entry corresponding to
  611. X    # "name."  If the TERMCAP string does not designate a filename,
  612. X    # getentry() will look through ./termcap for the correct entry.
  613. X    # Whatever the input file, if an entry for terminal "name" is
  614. X    # found, getentry() returns that entry.  Otherwise, getentry()
  615. X    # fails.
  616. X
  617. X    local f, getline, line, nm, ent1, ent2
  618. X
  619. X    /termcap_string := getenv("TERMCAP")
  620. X
  621. X    if \termcap_string ? (not match("\\"), pos(0) | tab(find("|")+1), =name)
  622. X    then return termcap_string
  623. X    else {
  624. X
  625. X    # The logic here probably isn't clear.  The idea is to try to use
  626. X    # the termcap environment variable successively as 1) a termcap en-
  627. X    # try and then 2) as a termcap file.  If neither works, 3) go to
  628. X    # the ./termcap file.  The else clause here does 2 and, if ne-
  629. X    # cessary, 3.  The "\termcap_string ? (not match..." expression
  630. X    # handles 1.
  631. X
  632. X    if find("\\",\termcap_string)
  633. X    then f := open(termcap_string)
  634. X    /f := open("termcap") |
  635. X        er("getentry","I can't access your termcap file",1)
  636. X
  637. X    getline := create read_file(f)
  638. X    
  639. X    while line := @getline do {
  640. X        if line ? (pos(1) | tab(find("|")+1), =name, any(':|')) then {
  641. X        entry := ""
  642. X        while (\line | @getline) ? {
  643. X            if entry ||:= 1(tab(find(":")+1), pos(0))
  644. SHAR_EOF
  645. true || echo 'restore of itlibdos.icn failed'
  646. fi
  647. echo 'End of  part 2'
  648. echo 'File itlibdos.icn is continued in part 3'
  649. echo 3 > _shar_seq_.tmp
  650. exit 0
  651.