home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume23 / lome / part07 < prev    next >
Encoding:
Internet Message Format  |  1991-01-08  |  46.7 KB

  1. Path: j.cc.purdue.edu!mentor.cc.purdue.edu!purdue!bu.edu!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!papaya.bbn.com!rsalz
  2. From: rsalz@bbn.com (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v23i057:  Line oriented macro processor, Part07/09
  5. Message-ID: <3032@litchi.bbn.com>
  6. Date: 29 Nov 90 17:44:15 GMT
  7. Organization: BBN Systems and Technologies, Cambridge MA
  8. Lines: 1836
  9. Approved: rsalz@uunet.UU.NET
  10.  
  11. Submitted-by: Darren New <new@ee.udel.edu>
  12. Posting-number: Volume 23, Issue 57
  13. Archive-name: lome/part07
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 6 (of 9)."
  22. # Contents:  LOME/LOME.scm LOME/SCMTestP.scm PPL/PPL.doc TFS/TFSUnix.c
  23. # Wrapped by new@estelle.ee.udel.edu on Tue Aug 14 16:10:01 1990
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'LOME/LOME.scm' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'LOME/LOME.scm'\"
  27. else
  28. echo shar: Extracting \"'LOME/LOME.scm'\" \(9447 characters\)
  29. sed "s/^X//" >'LOME/LOME.scm' <<'END_OF_FILE'
  30. XFILE: LOME.scm
  31. XThis is the SCM source file for the LOME program.
  32. X    THIS IS NOT COMPLETE AND PROBABLY WON'T BE FOR SOME TIME!
  33. X    I'LL PROBABLY FINISH THIS ONLY WHEN I FIND A MACHINE WHERE I NEED LOME
  34. X    WHICH DOESN'T HAVE A REASONABLE C COMPILER.  AND PROBABLY NOT THEN
  35. X    EITHER.
  36. X
  37. XBEGIN PROGRAM
  38. XBEGIN MAIN ROUTINE
  39. X
  40. X. The following parameters may be changed to allow larger or smaller progs.
  41. X
  42. XNUMDATA 01 0 00 30.  Allow up to thirty pushes on the user stack.
  43. XNUMDATA 02 0 00 15.  Allow up to fifteen nested macros.
  44. XNUMDATA 10 0 03 00.  Start output on stream 3.
  45. X
  46. X. The data near the bottom of the cell-space is organised thus:
  47. X. PTR[01] = number of pushes to user stack
  48. X. PTR[02] = number of nested macros
  49. X. PTR[05] = bottom of user-managed stack
  50. X. PTR[06] = first address past user-managed stack
  51. X.      = bottom of macro call stack.
  52. X. PTR[07] = first address past macro call stack
  53. X.      = address of first macro.
  54. X. PTR[08] = first address past last macro
  55. X.      = beginning of dynamically allocated memory
  56. X. PTR[10] = root of dictionary tree.
  57. X. VAL[10] = current output stream
  58. X. VAL[11] = macro input stream
  59. X. PTR[11] = head of free space chain
  60. X. PTR[12] = head of input stream stack (stream #'s in VAL's)
  61. X. VAL[20] to VAL[49] = parameter line.
  62. X
  63. X
  64. X
  65. X
  66. X. Here we read the initial macro definition file until we get a
  67. X. blank line or an EOF
  68. X
  69. XLABEL 01.        Read next line of MDef file
  70. XVAL A = 1 + 0.
  71. XGET BUFF A.
  72. XTO 03 IF FLG A EQ 0.
  73. XLABEL 02.        Many places go to here to issue error
  74. XPTR B = 6 + 0.        really 10
  75. XGET B = MEM B.        get current output stream
  76. XMESSAGE UEOF TO B.
  77. XSTOP A.
  78. XLABEL 03.        See if empty line
  79. XVAL A = INPUT.
  80. XTO 01 IF VAL A NE 0.
  81. X
  82. X. Here we have found the first blank line. Read the next line and
  83. X. store its contents in the val fields at offsets 20 thru 49
  84. X
  85. XVAL A = 1 + 0.
  86. XGET BUFF A.
  87. XTO 02 IF FLG A NE 0.
  88. XPTR B = 3 * 6.        We expect 30 characters.
  89. XVAL B = PTR B.        We need PTR B below.
  90. XPTR A = 2 * 6.        Which is really 20.
  91. XPTR B = 8 + 0.        Which is mem[0].
  92. XMOV PTR B BY A.     Which is mem[20].
  93. XLABEL 04.        read next char of parameter line
  94. XVAL A = INPUT.
  95. XTO 05 IF VAL A EQ 0.
  96. XPTR A = 0 + 0.
  97. XFLG A = 0.
  98. XPUT MEM B = A.
  99. XMOV PTR B BY 1.
  100. XVAL B = B - 1.
  101. XTO 04.
  102. XLABEL 05.        found end of parameter line
  103. XTO 02 IF VAL B NE 0.    Issue UEOF for parameter line wrong length
  104. XFLG B = 0.
  105. XPTR A = 8 + 0.        Which is mem[0]
  106. XMOV PTR A BY 5.     See start of code
  107. XMOV PTR A BY 2.     Pointing at mem[7]
  108. XPUT MEM A = B.        Store pointer to start of macros
  109. X
  110. X
  111. X
  112. X. At this point, we are ready to start reading macro bodies.
  113. X. The macros are stored in contiguous memory locations.
  114. X. At this point in the code, PTR B points to the place to start
  115. X. storing the macro definitions.
  116. X. The first cell of each macro contains:
  117. X. VAL = number of chars in the header minus placeholders and EOL
  118. X.     = minimum length of line which will match this header.
  119. X. PTR = address of this cell in the next macro.
  120. X. ??? FLG = 0 if more macros after this, 1 if not (PTR not valid).
  121. X. This is followed by the text of the header line, processed.
  122. X. The escape characters have been removed and any BEOL and comment have
  123. X. been removed. Each FLG field is one of
  124. X. FLG = 0 for a normal or escaped character,
  125. X. FLG = 1 for a placeholder character, or
  126. X. FLG = 2 for end-of-line (BEOL or real EOL).
  127. X. PTR = ??????????????
  128. X. The header line is followed by the macro body lines.
  129. X. FLG = 0 if the VAL should be inserted into the constructed line
  130. X. FLG = 1 if the VAL contains 0 - 9 as a function number and PTR
  131. X.      contains 0 - 11 (0-9,C,F).
  132. X. FLG = 2 if the VAL contains 0 for EOL.
  133. X. FLG = 3 if the FLG=2 cell immediately before this was the last line
  134. X.      of this macro body.
  135. X. PTR = ??????????????
  136. X
  137. XPTR A = 2 * 6.
  138. XPTR C = 8 + 0.
  139. XMOV PTR C BY A.     Point to parameter line
  140. XGET E = MEM C.        VAL E = escape character
  141. XMOV PTR C BY 1.
  142. XGET F = MEM C.        VAL F = placeholder character
  143. XMOV PTR C BY 1.
  144. XGET G = MEM C.        VAL G = HEOL character
  145. XMOV PTR C BY 3.
  146. XGET H = MEM C.        VAL H = digit zero
  147. XMOV PTR C BY 6.     C points to param[16]
  148. XMOV PTR C BY 4.     C points to param[20]
  149. XGET I = MEM C.        VAL I = space character
  150. XMOV PTR C BY 2.
  151. XGET J = MEM C.
  152. XVAL J = J - H.        VAL J = 0 discard blank lines, = 1 keep blank lines
  153. XMOV PTR C BY 1.
  154. XGET K = MEM C.
  155. XVAL K = K - H.        VAL K = 0 discard leading space, = 1 keep leading space
  156. X
  157. XPTR A = 2 * 6.
  158. XPTR C = 8 + 0.
  159. XMOV PTR C BY A.     Point to parameter line
  160. XMOV PTR C BY 3.
  161. XGET L = MEM C.        VAL L = substitution character
  162. XMOV PTR C BY 1.
  163. XGET M = MEM C.        VAL M = BEOL character
  164. XMOV PTR C BY 5.
  165. XGET N = MEM C.        VAL N = file operation character
  166. XMOV PTR C BY 1.
  167. XGET O = MEM C.        VAL O = control operation character
  168. X
  169. X. Here we use
  170. X. PTR B to point to the start of the macro header,
  171. X. VAL B to hold the min length of matching line,
  172. X. VAL C to hold number of chars added to line so far,
  173. X. PTR C to point to the current location,
  174. X. VAL A to hold input character,
  175. X. REG D to hold built cell to be stored,
  176. X
  177. XLABEL 06.        Read next macro header line
  178. XDEBUG.
  179. XPTR C = B + 0.
  180. XVAL B = 0 + 0.
  181. XVAL C = 0 + 0.
  182. XVAL A = 1 + 0.
  183. XGET BUFF A.
  184. XTO 22 IF FLG A NE 0.        @$@$ CHANGE THIS TO READ SOURCES
  185. XVAL D = 0 + 0.
  186. XFLG D = 0.
  187. XPTR D = 0 + 0.
  188. XPUT MEM C = D.
  189. XMOV PTR C BY 1.
  190. XTO 98 IF PTR C EQ 9.    full memory?
  191. X
  192. XLABEL 07.        process next char of macro header
  193. XVAL A = INPUT.
  194. XTO 08 IF VAL K NE 0.    if leading space not being discarded
  195. XTO 08 IF VAL A NE I.    if char read was not space
  196. XTO 08 IF VAL C NE 0.    if other characters are on the line
  197. XTO 07.            skip this character
  198. XLABEL 08.        not a leading space to be discarded
  199. XTO 10 IF VAL A NE E.    if input not an escape character
  200. XVAL A = INPUT.        it was an escape, so read next char
  201. XTO 11 IF VAL A EQ 0.    but at end of line, so ignore it
  202. XLABEL 09.        go here to add a regular character
  203. XVAL D = A + 0.        set up cell to match normal character
  204. XFLG D = 0.        normal char
  205. XPTR D = B + 0.        point back to beginning of header
  206. XPUT MEM C = D.        store it
  207. XMOV PTR C BY 1.     bump pointer
  208. XTO 98 IF PTR C EQ 9.    full memory?
  209. XVAL B = B + 1.        need to match it
  210. XVAL C = C + 1.        stored it.
  211. XTO 07.
  212. XLABEL 10.        input not an escape char
  213. XTO 11 IF VAL A EQ G.    if HEOL found
  214. XTO 11 IF VAL A EQ 0.    if EOL found
  215. XTO 09 IF VAL A NE F.    jump if not placeholder char
  216. XVAL D = A + 0.
  217. XFLG D = 1.        placeholder character
  218. XPTR D = B + 0.        point back to header
  219. XPUT MEM C = D.        store it
  220. XMOV PTR C BY 1.     bump pointer
  221. XTO 98 IF PTR C EQ 9.    full memory?
  222. XVAL C = C + 1.        stored it.
  223. XTO 07.
  224. XLABEL 11.        end of macro header line found.
  225. XVAL D = 0 + 0.
  226. XFLG D = 2.
  227. XPTR D = B + 0.
  228. XPUT MEM C = D.
  229. XMOV PTR C BY 1.
  230. XTO 98 IF PTR C EQ 9.    full memory?
  231. X
  232. X. Now we must read in the macro body, stoping when we get two BEOLs at
  233. X. the start of a line.
  234. X
  235. XLABEL 12.        to here to read macro body line.
  236. X.            PTR B still header, PTR C still next free
  237. XVAL A = 1 + 0.
  238. XGET BUFF A.
  239. XTO 02 IF FLG A NE 0.
  240. XVAL C = 0 + 0.        to count chars on line
  241. XLABEL 13.        to here for each char of macro body line
  242. XVAL A = INPUT.
  243. XFLG D = 0.        assume normal char until known otherwise
  244. XVAL D = A + 0.
  245. XPTR D = 0 + 0.
  246. XTO 20 IF VAL A EQ 0.    if end of line
  247. XTO 19 IF VAL A EQ M.    if BEOL
  248. XTO 15 IF VAL A NE E.    if not escape
  249. XVAL A = INPUT.
  250. XVAL D = A + 0.
  251. XTO 20 IF VAL A EQ 0.    escape, then EOL
  252. XLABEL 14.        insert D into macro body line
  253. XPUT MEM C = D.
  254. XMOV PTR C BY 1.
  255. XTO 98 IF PTR C EQ 9.    full memory?
  256. XVAL C = C + 1.
  257. XTO 13.
  258. XLABEL 15.        not escape or EOL or BEOL
  259. XTO 14 IF VAL A NE L.    if not substitution char, insert it
  260. XVAL A = INPUT.        get next char
  261. XTO 16 IF VAL A NE O.    if not control operation character
  262. XVAL D = 9 + 2.        11 means control operation
  263. XTO 18.
  264. XLABEL 16.        substitution, but not control op
  265. XTO 17 IF VAL A NE N.    if not file operation character
  266. XVAL D = 9 + 1.        10 means file operation
  267. XTO 18.
  268. XLABEL 17.        substitution, but not control op or file op
  269. XVAL D = A - H.        D = 0..9 (H is '0')
  270. XLABEL 18.        finish building substitution cell
  271. XPTR D = VAL D.        so we can do LT comparisons
  272. XTO 97 IF PTR D LT 0.    issue SUBS error if too small
  273. XPTR A = 6 + 1.        set PTR A to 11
  274. XTO 97 IF PTR A LT D.    issue SUBS error if too big
  275. XVAL A = INPUT.        read individual code
  276. XVAL D = A - H.        convert individual code to 0..9
  277. XFLG D = 1.        substitution flag
  278. XTO 14.            go insert it
  279. XLABEL 19.        found an unescaped BEOL
  280. XTO 20 IF VAL C NE 0.    not at start of line, so treat as normal EOL
  281. XVAL A = INPUT.        see if followed by another BEOL
  282. XTO 20 IF VAL A NE M.    nope, handle as normal EOL
  283. XFLG D = 3.        mark end of macro (for skip -1)
  284. XPUT MEM C = D.
  285. XMOV PTR C BY 1.
  286. XTO 98 IF PTR C EQ 9.    full memory?
  287. XFLG D = 0.
  288. XVAL D = 0 + 0.
  289. XPTR D = C + 0.
  290. XPUT MEM B = D.        store forward pointer
  291. XPTR B = C + 0.        and skip forward
  292. XPTR C = 8 + 0.        point C at mem[7].
  293. XMOV PTR C BY 5.
  294. XMOV PTR C BY 2.
  295. XVAL B = 0 + 0.
  296. XFLG B = 0.
  297. XPUT MEM C = B.        point end-of-macro pointer here.
  298. XTO 06.            read next macro header
  299. X
  300. XLABEL 20.        insert end-of-line marker if appropriate
  301. XTO 21 IF VAL C NE 0.    if anything on line,
  302. XTO 21 IF VAL J EQ 1.    or we want to keep blank lines
  303. XTO 12.            otherwise forget it.
  304. XLABEL 21.        insert end-of-line marker
  305. XFLG D = 2.        insert EOL character
  306. XVAL D = 0 + 0.
  307. XPTR D = 0 + 0.
  308. XPUT MEM C = D.
  309. XMOV PTR C BY 1.
  310. XVAL C = C + 1.        keep track of chars on line
  311. XTO 98 IF PTR C EQ 9.    full memory?
  312. XTO 12.            read next line
  313. X
  314. XLABEL 22.        go here to read and translate source file.
  315. XDEBUG.            dump memory for inspection
  316. XTO 99.
  317. X
  318. XLABEL 97.        output a SUBS message to current output stream
  319. XPTR A = 6 + 0.
  320. XGET A = MEM A.
  321. XMESSAGE SUBS TO A.
  322. XSTOP A.
  323. X
  324. XLABEL 98.        output a FULL message to current output stream
  325. XPTR A = 6 + 0.        really 10
  326. XGET A = MEM A.        get current output stream
  327. XMESSAGE FULL TO A.
  328. XSTOP A.
  329. X
  330. XLABEL 99.
  331. X
  332. XEND MAIN ROUTINE
  333. XEND PROGRAM
  334. X
  335. X
  336. END_OF_FILE
  337. if test 9447 -ne `wc -c <'LOME/LOME.scm'`; then
  338.     echo shar: \"'LOME/LOME.scm'\" unpacked with wrong size!
  339. fi
  340. # end of 'LOME/LOME.scm'
  341. fi
  342. if test -f 'LOME/SCMTestP.scm' -a "${1}" != "-c" ; then 
  343.   echo shar: Will not clobber existing file \"'LOME/SCMTestP.scm'\"
  344. else
  345. echo shar: Extracting \"'LOME/SCMTestP.scm'\" \(9624 characters\)
  346. sed "s/^X//" >'LOME/SCMTestP.scm' <<'END_OF_FILE'
  347. XThis is a test program to make sure that your SCM macros are correct. It
  348. Xshould be compiled and executed. Execute it with SCMTestD on stream one.
  349. XOutput to stream two will consist of error messages and explainations. It
  350. Xuses a brute-force approach to testing the macros: it reads a line from the
  351. Xinput file that contains an error message, it checks that an operation had
  352. Xan intended effect, and if it does, it skips past code that outputs the
  353. Xline that was read. You should make sure that the I/O routines work first.
  354. XAlso, check manually that BEGIN PROGRAM, BEGIN MAIN ROUTINE, END PROGRAM,
  355. Xand END MAIN ROUTINE do what you want. Also, BEGIN SUBROUTINE and END
  356. XSUBROUTINE should be checked manually.
  357. X
  358. XBEGIN PROGRAM.
  359. X
  360. XBEGIN SUBROUTINE F.
  361. XVAL B = 1 + 0.
  362. XGET BUFF B.        4
  363. XVAL W = 2 + 0.
  364. XPUT BUFF W.
  365. XEND SUBROUTINE F.
  366. X
  367. XBEGIN SUBROUTINE S.
  368. X
  369. XVAL B = 1 + 0.
  370. XGET BUFF B.        X 002
  371. XTO 03 IF FLG 1 EQ 1.
  372. XVAL W = 2 + 0.
  373. XPUT BUFF W.
  374. XLABEL 03.
  375. X
  376. XVAL B = 1 + 0.
  377. XGET BUFF B.        X 003
  378. XTO 05 IF FLG 1 EQ 2.
  379. XTO 04.
  380. XLABEL 05.
  381. XVAL W = 2 + 0.
  382. XPUT BUFF W.
  383. XLABEL 04.
  384. X
  385. XVAL B = 1 + 0.
  386. XGET BUFF B.        X 004
  387. XTO 06 IF FLG 1 NE 1.
  388. XTO 07.
  389. XLABEL 06.
  390. XVAL W = 2 + 0.
  391. XPUT BUFF W.
  392. XLABEL 07.
  393. X
  394. XVAL B = 1 + 0.
  395. XGET BUFF B.        X 005
  396. XTO 08 IF FLG 1 NE 2.
  397. XVAL W = 2 + 0.
  398. XPUT BUFF W.
  399. XLABEL 08.
  400. X
  401. XVAL B = 1 + 0.
  402. XGET BUFF B.        X 006
  403. XTO 09 IF VAL 1 EQ 1.
  404. XVAL W = 2 + 0.
  405. XPUT BUFF W.
  406. XLABEL 09.
  407. X
  408. XVAL B = 1 + 0.
  409. XGET BUFF B.        X 007
  410. XTO 10 IF VAL 1 EQ 2.
  411. XTO 11.
  412. XLABEL 10.
  413. XVAL W = 2 + 0.
  414. XPUT BUFF W.
  415. XLABEL 11.
  416. X
  417. XVAL B = 1 + 0.
  418. XGET BUFF B.        X 008
  419. XTO 12 IF VAL 1 NE 1.
  420. XTO 13.
  421. XLABEL 12.
  422. XVAL W = 2 + 0.
  423. XPUT BUFF W.
  424. XLABEL 13.
  425. X
  426. XVAL B = 1 + 0.
  427. XGET BUFF B.        X 009
  428. XTO 14 IF VAL 1 NE 2.
  429. XVAL W = 2 + 0.
  430. XPUT BUFF W.
  431. XLABEL 14.
  432. X
  433. XVAL B = 1 + 0.
  434. XGET BUFF B.        X 010
  435. XTO 15 IF PTR 1 EQ 1.
  436. XVAL W = 2 + 0.
  437. XPUT BUFF W.
  438. XLABEL 15.
  439. X
  440. XVAL B = 1 + 0.
  441. XGET BUFF B.        X 011
  442. XTO 16 IF PTR 1 EQ 2.
  443. XTO 17.
  444. XLABEL 16.
  445. XVAL W = 2 + 0.
  446. XPUT BUFF W.
  447. XLABEL 17.
  448. X
  449. XVAL B = 1 + 0.
  450. XGET BUFF B.        X 012
  451. XTO 18 IF PTR 1 NE 1.
  452. XTO 19.
  453. XLABEL 18.
  454. XVAL W = 2 + 0.
  455. XPUT BUFF W.
  456. XLABEL 19.
  457. X
  458. XVAL B = 1 + 0.
  459. XGET BUFF B.        X 013
  460. XTO 20 IF PTR 1 NE 2.
  461. XVAL W = 2 + 0.
  462. XPUT BUFF W.
  463. XLABEL 20.
  464. X
  465. XVAL B = 1 + 0.
  466. XGET BUFF B.        X 014
  467. XTO 21 IF PTR 1 LT 2.
  468. XVAL W = 2 + 0.
  469. XPUT BUFF W.
  470. XLABEL 21.
  471. X
  472. XVAL B = 1 + 0.
  473. XGET BUFF B.        X 015
  474. XTO 22 IF PTR 2 LT 1.
  475. XTO 23.
  476. XLABEL 22.
  477. XVAL W = 2 + 0.
  478. XPUT BUFF W.
  479. XLABEL 23.
  480. X
  481. XVAL B = 1 + 0.
  482. XGET BUFF B.        X 016
  483. XTO 24 IF PTR 1 LT 1.
  484. XTO 25.
  485. XLABEL 24.
  486. XVAL W = 2 + 0.
  487. XPUT BUFF W.
  488. XLABEL 25.
  489. X
  490. XVAL B = 1 + 0.
  491. XGET BUFF B.        X 017
  492. XFLG A = 1.
  493. XTO 26 IF FLG A EQ 1.
  494. XVAL W = 2 + 0.
  495. XPUT BUFF W.
  496. XLABEL 26.
  497. X
  498. XVAL B = 1 + 0.
  499. XGET BUFF B.        X 018
  500. XVAL A = PTR 3.
  501. XTO 27 IF VAL A EQ 3.
  502. XVAL W = 2 + 0.
  503. XPUT BUFF W.
  504. XLABEL 27.
  505. X
  506. XVAL B = 1 + 0.
  507. XGET BUFF B.        X 019
  508. XPTR A = VAL 2.
  509. XTO 28 IF PTR A EQ 2.
  510. XVAL W = 2 + 0.
  511. XPUT BUFF W.
  512. XLABEL 28.
  513. X
  514. XVAL B = 1 + 0.
  515. XGET BUFF B.        X 020
  516. XFLG A = 1.
  517. XVAL A = 2 + 0.
  518. XPTR A = VAL 3.
  519. XTO 29 IF FLG A EQ 1.
  520. XVAL W = 2 + 0.
  521. XPUT BUFF W.
  522. XLABEL 29.
  523. X
  524. XVAL B = 1 + 0.
  525. XGET BUFF B.        X 021
  526. XTO 30 IF VAL A EQ 2.
  527. XVAL W = 2 + 0.
  528. XPUT BUFF W.
  529. XLABEL 30.
  530. X
  531. XVAL B = 1 + 0.
  532. XGET BUFF B.        X 022
  533. XFLG A = 1.
  534. XPTR A = 2 + 0.
  535. XVAL A = PTR 3.
  536. XTO 31 IF FLG A EQ 1.
  537. XVAL W = 2 + 0.
  538. XPUT BUFF W.
  539. XLABEL 31.
  540. X
  541. XVAL B = 1 + 0.
  542. XGET BUFF B.        X 023
  543. XTO 32 IF PTR A EQ 2.
  544. XVAL W = 2 + 0.
  545. XPUT BUFF W.
  546. XLABEL 32.
  547. X
  548. XVAL B = 1 + 0.
  549. XGET BUFF B.        X 024
  550. XFLG A = 1.
  551. XPTR A = 3 + 0.
  552. XVAL A = 2 + 0.
  553. XFLG A = 0.
  554. XTO 33 IF VAL A EQ 2.
  555. XVAL W = 2 + 0.
  556. XPUT BUFF W.
  557. XLABEL 33.
  558. X
  559. XVAL B = 1 + 0.
  560. XGET BUFF B.        X 025
  561. XTO 34 IF PTR A EQ 3.
  562. XVAL W = 2 + 0.
  563. XPUT BUFF W.
  564. XLABEL 34.
  565. X
  566. XVAL B = 1 + 0.
  567. XGET BUFF B.        X 026
  568. XFLG E = 0.
  569. XPTR E = VAL 0.
  570. XVAL E = 1 + 3.
  571. XTO 35 IF VAL E EQ 4.
  572. XVAL W = 2 + 0.
  573. XPUT BUFF W.
  574. XLABEL 35.
  575. X
  576. XVAL B = 1 + 0.
  577. XGET BUFF B.        X 027
  578. XTO 36 IF PTR E EQ 0.
  579. XVAL W = 2 + 0.
  580. XPUT BUFF W.
  581. XLABEL 36.
  582. X
  583. XVAL B = 1 + 0.
  584. XGET BUFF B.        X 028
  585. XTO 37 IF FLG E EQ 0.
  586. XVAL W = 2 + 0.
  587. XPUT BUFF W.
  588. XLABEL 37.
  589. X
  590. XEND SUBROUTINE S.
  591. X
  592. XBEGIN SUBROUTINE Q.
  593. XVAL B = 1 + 0.
  594. XGET BUFF B.        X 032
  595. XFLG A = 0.
  596. XVAL A = 0 + 0.
  597. XPTR A = 1 + 2.
  598. XTO 41 IF FLG A EQ 0.
  599. XVAL W = 2 + 0.
  600. XPUT BUFF W.
  601. XLABEL 41.
  602. X
  603. XVAL B = 1 + 0.
  604. XGET BUFF B.        X 033
  605. XTO 42 IF VAL A EQ 0.
  606. XVAL W = 2 + 0.
  607. XPUT BUFF W.
  608. XLABEL 42.
  609. X
  610. XVAL B = 1 + 0.
  611. XGET BUFF B.        X 034
  612. XTO 43 IF PTR A EQ 3.
  613. XVAL W = 2 + 0.
  614. XPUT BUFF W.
  615. XLABEL 43.
  616. X
  617. XVAL B = 1 + 0.
  618. XGET BUFF B.        X 035
  619. XVAL A = 0 + 0.
  620. XFLG A = 0.
  621. XPTR A = 1 - 3.
  622. XTO 44 IF FLG A EQ 0.
  623. XVAL W = 2 + 0.
  624. XPUT BUFF W.
  625. XLABEL 44.
  626. X
  627. XVAL B = 1 + 0.
  628. XGET BUFF B.        X 036
  629. XTO 45 IF VAL A EQ 0.
  630. XVAL W = 2 + 0.
  631. XPUT BUFF W.
  632. XLABEL 45.
  633. X
  634. XVAL B = 1 + 0.
  635. XGET BUFF B.        X 037
  636. XPTR A = A + 3.
  637. XTO 46 IF PTR A EQ 1.
  638. XVAL W = 2 + 0.
  639. XPUT BUFF W.
  640. XLABEL 46.
  641. X
  642. XVAL B = 1 + 0.
  643. XGET BUFF B.        X 038
  644. XPTR A = 0 + 0.
  645. XFLG A = 0.
  646. XVAL A = 1 - 3.
  647. XTO 47 IF FLG A EQ 0.
  648. XVAL W = 2 + 0.
  649. XPUT BUFF W.
  650. XLABEL 47.
  651. X
  652. XVAL B = 1 + 0.
  653. XGET BUFF B.        X 039
  654. XTO 48 IF PTR A EQ 0.
  655. XVAL W = 2 + 0.
  656. XPUT BUFF W.
  657. XLABEL 48.
  658. X
  659. XVAL B = 1 + 0.
  660. XGET BUFF B.        X 040
  661. XVAL A = A + 3.
  662. XTO 49 IF VAL A EQ 1.
  663. XVAL W = 2 + 0.
  664. XPUT BUFF W.
  665. XLABEL 49.
  666. X
  667. XVAL B = 1 + 0.
  668. XGET BUFF B.        X 041
  669. XVAL A = 0 + 0.
  670. XFLG A = 0.
  671. XPTR A = 3 * 3.
  672. XPTR D = VAL 9.
  673. XTO 50 IF PTR A EQ D.
  674. XVAL W = 2 + 0.
  675. XPUT BUFF W.
  676. XLABEL 50.
  677. X
  678. XVAL B = 1 + 0.
  679. XGET BUFF B.        X 042
  680. XTO 51 IF VAL A EQ 0.
  681. XVAL W = 2 + 0.
  682. XPUT BUFF W.
  683. XLABEL 51.
  684. X
  685. XVAL B = 1 + 0.
  686. XGET BUFF B.        X 043
  687. XTO 52 IF FLG A EQ 0.
  688. XVAL W = 2 + 0.
  689. XPUT BUFF W.
  690. XLABEL 52.
  691. X
  692. XVAL B = 1 + 0.
  693. XGET BUFF B.        X 044
  694. XVAL C = 0 + 0.
  695. XFLG C = 0.
  696. XPTR A = VAL 6.
  697. XPTR C = A / 2.
  698. XTO 53 IF PTR C EQ 3.
  699. XVAL W = 2 + 0.
  700. XPUT BUFF W.
  701. XLABEL 53.
  702. X
  703. XEND SUBROUTINE Q.
  704. X
  705. XBEGIN SUBROUTINE R.
  706. X
  707. XCALL Q. make sure nested calls work
  708. X
  709. XVAL B = 1 + 0.
  710. XGET BUFF B.        X 045
  711. XTO 54 IF VAL C EQ 0.
  712. XVAL W = 2 + 0.
  713. XPUT BUFF W.
  714. XLABEL 54.
  715. X
  716. XVAL B = 1 + 0.
  717. XGET BUFF B.        X 046
  718. XTO 55 IF VAL C EQ 0.
  719. XVAL W = 2 + 0.
  720. XPUT BUFF W.
  721. XLABEL 55.
  722. X
  723. XVAL B = 1 + 0.
  724. XGET BUFF B.        X 047
  725. XPTR A = VAL 7.
  726. XPTR C = A / 2.
  727. XTO 56 IF PTR C EQ 3.
  728. XVAL W = 2 + 0.
  729. XPUT BUFF W.
  730. XLABEL 56.
  731. X
  732. XVAL B = 1 + 0.
  733. XGET BUFF B.        X 048
  734. XPTR A = VAL 7.
  735. XPTR A = 0 - A.
  736. XPTR C = A / 2.
  737. XPTR C = 0 - C.
  738. XTO 57 IF PTR C EQ 3.
  739. XVAL W = 2 + 0.
  740. XPUT BUFF W.
  741. XLABEL 57.
  742. X
  743. XVAL B = 1 + 0.
  744. XGET BUFF B.        X 049
  745. XPTR A = VAL 7.
  746. XPTR D = 0 - 2.
  747. XPTR C = A / D.
  748. XPTR C = 0 - C.
  749. XTO 58 IF PTR C EQ 3.
  750. XVAL W = 2 + 0.
  751. XPUT BUFF W.
  752. XLABEL 58.
  753. X
  754. XVAL B = 1 + 0.
  755. XGET BUFF B.        X 050
  756. XPTR A = VAL 7.
  757. XPTR A = 0 - A.
  758. XPTR D = 0 - 2.
  759. XPTR C = A / D.
  760. XTO 59 IF PTR C EQ 3.
  761. XVAL W = 2 + 0.
  762. XPUT BUFF W.
  763. XLABEL 59.
  764. X
  765. XVAL B = 1 + 0.
  766. XGET BUFF B.        X 051
  767. XPTR D = VAL 4.
  768. XPTR A = 0 - 2.
  769. XPTR C = 2 * A.
  770. XPTR C = 0 - C.
  771. XTO 60 IF PTR C EQ D.
  772. XVAL W = 2 + 0.
  773. XPUT BUFF W.
  774. XLABEL 60.
  775. X
  776. XVAL B = 1 + 0.
  777. XGET BUFF B.        X 052
  778. XPTR D = VAL 4.
  779. XPTR A = 0 - 2.
  780. XPTR C = A * 2.
  781. XPTR C = 0 - C.
  782. XTO 61 IF PTR C EQ D.
  783. XVAL W = 2 + 0.
  784. XPUT BUFF W.
  785. XLABEL 61.
  786. X
  787. XVAL B = 1 + 0.
  788. XGET BUFF B.        X 053
  789. XPTR D = VAL 4.
  790. XPTR A = 0 - 2.
  791. XPTR C = A * A.
  792. XTO 62 IF PTR C EQ D.
  793. XVAL W = 2 + 0.
  794. XPUT BUFF W.
  795. XLABEL 62.
  796. X
  797. XVAL B = 1 + 0.
  798. XGET BUFF B.        X 054
  799. XVAL C = 0 - 6.
  800. XTO 63 IF VAL C EQ 6.
  801. XTO 64.
  802. XLABEL 63.
  803. XVAL W = 2 + 0.
  804. XPUT BUFF W.
  805. XLABEL 64.
  806. X
  807. XVAL B = 1 + 0.
  808. XGET BUFF B.        X 055
  809. XTO 65 IF VAL C NE 6.
  810. XVAL W = 2 + 0.
  811. XPUT BUFF W.
  812. XLABEL 65.
  813. X
  814. XVAL B = 1 + 0.
  815. XGET BUFF B.        X 056
  816. XPTR C = 0 - 3.
  817. XTO 66 IF PTR C EQ 3.
  818. XTO 67.
  819. XLABEL 66.
  820. XVAL W = 2 + 0.
  821. XPUT BUFF W.
  822. XLABEL 67.
  823. X
  824. XVAL B = 1 + 0.
  825. XGET BUFF B.        X 057
  826. XTO 68 IF PTR C NE 3.
  827. XVAL W = 2 + 0.
  828. XPUT BUFF W.
  829. XLABEL 68.
  830. X
  831. XVAL B = 1 + 0.
  832. XGET BUFF B.        X 058
  833. XTO 69 IF PTR C LT 3.
  834. XVAL W = 2 + 0.
  835. XPUT BUFF W.
  836. XLABEL 69.
  837. X
  838. XVAL B = 1 + 0.
  839. XGET BUFF B.        X 059
  840. XTO 70 IF PTR 3 LT C.
  841. XTO 71.
  842. XLABEL 70.
  843. XVAL W = 2 + 0.
  844. XPUT BUFF W.
  845. XLABEL 71.
  846. X
  847. XEND SUBROUTINE R.
  848. X
  849. X
  850. XBEGIN MAIN ROUTINE.
  851. XVAL B = 1 + 0.
  852. XGET BUFF B.        1
  853. XVAL W = 2 + 0.
  854. XPUT BUFF W.
  855. XVAL B = 1 + 0.
  856. XGET BUFF B.        2
  857. XVAL W = 2 + 0.
  858. XPUT BUFF W.
  859. XVAL B = 1 + 0.
  860. XGET BUFF B.        3
  861. XVAL W = 2 + 0.
  862. XPUT BUFF W.
  863. X
  864. XCALL F.
  865. X
  866. XVAL B = 1 + 0.
  867. XGET BUFF B.        X 001
  868. XTO 02.
  869. XLABEL 01.
  870. XVAL W = 2 + 0.
  871. XPUT BUFF W.
  872. XLABEL 02.
  873. X
  874. XCALL S.
  875. X
  876. XVAL B = 1 + 0.
  877. XGET BUFF B.        5
  878. XVAL W = 2 + 0.
  879. XPUT BUFF W.
  880. X
  881. XVAL B = 1 + 0.
  882. XGET BUFF B.        6
  883. XVAL D = INPUT.    '6'
  884. XVAL E = INPUT.    '.'
  885. XVAL F = INPUT.    ' '
  886. XVAL G = INPUT.    'D'
  887. XVAL H = INPUT.    'O'
  888. XVAL I = INPUT.    'G'
  889. XVAL J = INPUT.    eol
  890. XVAL B = 1 + 0.
  891. XGET BUFF B.        X 029
  892. XTO 38 IF VAL J EQ 0.
  893. XVAL W = 2 + 0.
  894. XPUT BUFF W.
  895. XLABEL 38.
  896. X
  897. XOUTPUT = VAL D. '6'
  898. XOUTPUT = VAL E. '.'
  899. XOUTPUT = VAL F. ' '
  900. XOUTPUT = VAL I. 'G'
  901. XOUTPUT = VAL H. 'O'
  902. XOUTPUT = VAL H. 'O'
  903. XOUTPUT = VAL G. 'D'
  904. XOUTPUT = VAL J. eol
  905. XVAL W = 2 + 0.
  906. XPUT BUFF W.
  907. X
  908. XVAL B = 1 + 0.
  909. XGET BUFF B.        7
  910. XVAL W = 2 + 0.
  911. XPUT BUFF W.
  912. X
  913. XVAL B = 1 + 0.
  914. XGET BUFF B.        8
  915. XVAL D = INPUT.    '7'
  916. XVAL E = INPUT.    '.'
  917. XVAL F = INPUT.    ' '
  918. XVAL G = INPUT.    '0'
  919. XVAL H = INPUT.    eol
  920. XVAL B = 1 + 0.
  921. XGET BUFF B.        X 030
  922. XTO 39 IF VAL H EQ 0.
  923. XVAL W = 2 + 0.
  924. XPUT BUFF W.
  925. XLABEL 39.
  926. X
  927. XOUTPUT = VAL D. '7'
  928. XOUTPUT = VAL E. '.'
  929. XOUTPUT = VAL F. ' '
  930. XVAL J = G + 0.
  931. XOUTPUT = VAL J. '0'
  932. XOUTPUT = VAL F. ' '
  933. XVAL J = G + 1.
  934. XOUTPUT = VAL J. '1'
  935. XOUTPUT = VAL F.
  936. XVAL J = G + 2.
  937. XOUTPUT = VAL J. '2'
  938. XOUTPUT = VAL F.
  939. XVAL J = G + 3.
  940. XOUTPUT = VAL J. '3'
  941. XOUTPUT = VAL F.
  942. XVAL J = G + 4.
  943. XOUTPUT = VAL J. '4'
  944. XOUTPUT = VAL F.
  945. XVAL J = G + 5.
  946. XOUTPUT = VAL J. '5'
  947. XOUTPUT = VAL F.
  948. XVAL J = G + 6.
  949. XOUTPUT = VAL J. '6'
  950. XOUTPUT = VAL F.
  951. XVAL J = G + 7.
  952. XOUTPUT = VAL J. '7'
  953. XOUTPUT = VAL F.
  954. XVAL J = G + 8.
  955. XOUTPUT = VAL J. '8'
  956. XOUTPUT = VAL F.
  957. XVAL J = G + 9.
  958. XOUTPUT = VAL J. '9'
  959. XOUTPUT = VAL F.
  960. XOUTPUT = VAL H.
  961. XVAL W = 2 + 0.
  962. XPUT BUFF W.
  963. X
  964. XVAL B = 1 + 0.
  965. XGET BUFF B.        9
  966. XVAL W = 2 + 0.
  967. XPUT BUFF W.
  968. X
  969. XVAL B = 1 + 0.
  970. XGET BUFF B.        10
  971. XVAL D = INPUT.    '1'
  972. XVAL G = INPUT.    '0'
  973. XVAL E = INPUT.    '.'
  974. XVAL F = INPUT.    ' '
  975. XVAL G = INPUT.    '0'
  976. XVAL H = INPUT.    eol
  977. XVAL B = 1 + 0.
  978. XGET BUFF B.        X 031
  979. XTO 40 IF VAL H EQ 0.
  980. XVAL W = 2 + 0.
  981. XPUT BUFF W.
  982. XLABEL 40.
  983. X
  984. XOUTPUT = VAL D. '1'
  985. XOUTPUT = VAL G. '0'
  986. XOUTPUT = VAL E. '.'
  987. XOUTPUT = VAL F. ' '
  988. XVAL I = PTR 0.
  989. XVAL J = G + I.
  990. XOUTPUT = VAL J. '0'
  991. XOUTPUT = VAL F. ' '
  992. XVAL I = PTR 1.
  993. XVAL J = G + I.
  994. XOUTPUT = VAL J. '1'
  995. XOUTPUT = VAL F.
  996. XVAL I = PTR 2.
  997. XVAL J = G + I
  998. XOUTPUT = VAL J. '2'
  999. XOUTPUT = VAL F.
  1000. XVAL I = PTR 3.
  1001. XVAL J = G + I
  1002. XOUTPUT = VAL J. '3'
  1003. XOUTPUT = VAL H.
  1004. XVAL W = 2 + 0.
  1005. XPUT BUFF W.
  1006. X
  1007. XCALL R.
  1008. X
  1009. XVAL B = 1 + 0.
  1010. XGET BUFF B.        99
  1011. XVAL W = 2 + 0.
  1012. XPUT BUFF W.
  1013. X
  1014. XEND MAIN ROUTINE.
  1015. XEND PROGRAM.
  1016. X
  1017. END_OF_FILE
  1018. if test 9624 -ne `wc -c <'LOME/SCMTestP.scm'`; then
  1019.     echo shar: \"'LOME/SCMTestP.scm'\" unpacked with wrong size!
  1020. fi
  1021. # end of 'LOME/SCMTestP.scm'
  1022. fi
  1023. if test -f 'PPL/PPL.doc' -a "${1}" != "-c" ; then 
  1024.   echo shar: Will not clobber existing file \"'PPL/PPL.doc'\"
  1025. else
  1026. echo shar: Extracting \"'PPL/PPL.doc'\" \(13126 characters\)
  1027. sed "s/^X//" >'PPL/PPL.doc' <<'END_OF_FILE'
  1028. X.rm 75
  1029. X.rm 70
  1030. X.po 2
  1031. X.he 'PPL.Doc'Portability Library Specs'Darren New'
  1032. X.fo '    Page #' 'Printed %    '
  1033. X.pl 63
  1034. X.nj
  1035. X.ce 4
  1036. XThis documentation and all accompanying files
  1037. XCopyright 1986, 1990 Darren New.
  1038. XAll Rights Reserved.
  1039. XSee README for distribution permissions.
  1040. X
  1041. XThis file documents the proposed "Portable Programmer's Library",
  1042. Xhereinafter referred to as "PPL" or "PL".
  1043. X
  1044. XThe Portable Programmer's Library is a set of functions written in portable
  1045. XC intended to allow programmers to port their utilities and applications
  1046. Xbetween different machines with no changes to their source. The PPL
  1047. Xacheives this goal by relying on a small number of programmer-supplied
  1048. Xfunctions that must be rewritten for each type of "host" computer. At the
  1049. Xlowest level, these functions handle such tasks as memory allocation, error
  1050. Xrecovery, I/O to "standard input" and "standard output", and command-line
  1051. Xargument parsing. At the next higher level, these functions provide such
  1052. Xservices as screen updates and file and directory access. All other
  1053. Xfunctions are built on top of these low-level routines. Many of the more
  1054. Xsophisticated routines (e.g., file requesters, menus) have equivalent
  1055. Xroutines in the PPL implemented in terms of lower-level routines. These can
  1056. Xbe overwridden by the host implementation to allow conformance with
  1057. Xalready-existant host capabilities.
  1058. X
  1059. XThe PPL includes several subsystems which are sorted according to
  1060. Xfunctionality. Each subsystem has its own header file, named after the
  1061. Xsubsystem, which includes all of the other header files for that subsystem.
  1062. XSince the syntax for subdirectories may vary, these header files are
  1063. Xassumed to be somewhere accessable without subdirectories, and the
  1064. Xindividual header files lie in subdirectories; thus, the programmer need
  1065. Xonly edit one header file for each subsystem. The subsystems, which are
  1066. Xdocumented in more detail in their own documentation file, include the
  1067. Xfollowing:
  1068. X
  1069. X.nf
  1070. XHOST    -   The lowest level routines. These change between machines. These
  1071. Xare actually several of these, one for each subsystem and one for all
  1072. Xsubsystems combined. The basic routines are stored in a subdirectory called
  1073. XPPL.
  1074. X
  1075. XUTIL    -   The Utility Subsystem. These parse command-line templates and
  1076. Xdo other utility-oriented processing. These also handle date and time
  1077. Xarithmetic, list processing, sorting, and regular expression matching.
  1078. X
  1079. XUIS     -   The User Interface Subsystem. This includes windowing, menus,
  1080. Xand special key handling.
  1081. X
  1082. XTFS     -   The Text File Subsystem. This includes routines to handle
  1083. Xopening, closing, creating, destroying, reading, and writing of ASCII
  1084. Xformat files. Files created by the TFS of one host should be readable by
  1085. Xthe TFS of other hosts.
  1086. X
  1087. XBFS     -   The Binary File Subsystem. This includes routines to handle
  1088. Xopening, closing, creating, destroying, reading, and writing of binary
  1089. X(non_ASCII) files. These files are byte-addressable and dynamically sized
  1090. X(esentially like UNIX files).
  1091. X
  1092. XKFS     -   The Keyed File Subsystem. This includes routines to handle
  1093. Xopening, closing, creating, destroying, reading, and writing of
  1094. XKey/Sequential files. These files can have records inserted, deleted, and
  1095. Xsorted on several keys, and can also be accessed sequentially. Most of what
  1096. Xyou need for the file interface to a simple database is here.
  1097. X
  1098. XFNS     - File Name Subsystem. This includes routines for HOST-specific
  1099. Xfilenames, directory access, protection changing, and so on. Use of
  1100. Xthis library will not make your program non-portable if care is used, but
  1101. Xthe user of you application will be aware of the syntax of host file names
  1102. Xand so on.
  1103. X
  1104. XHIS     - Host Interface Subsystem. This includes routines for date and
  1105. Xtime handling, host-syntax "system" calls, and other miscellaneous routines
  1106. Xthat may need to be changed from machine to machine. Check the header file
  1107. Xto determine which routines are portable and which are not.
  1108. X
  1109. XPNS     - Portable Name Subsystem. This includes routines for allowing
  1110. Xportable filenames and "system" functions such as starting other commands
  1111. Xand changing access permissions on files. It includes essentially
  1112. Xeverything that the FNS and HIS do; however, it is more difficult for the
  1113. Xprogrammer to use. It is designed to prevent the user from needing to learn
  1114. Xabout the host filename syntax, how to copy or rename files on the host,
  1115. Xand so on. It essentially gives the functionality of a small shell by using
  1116. Xmenu-driven utilities. It also includes routines for translating host-style
  1117. Xfilenames to portable filenames and back again, as well as routines for
  1118. Xgiving the user a choice of filenames and returning which filename the user
  1119. Xchose.
  1120. X
  1121. XTLS     - Threaded Language Subsystem. This implements the threaded
  1122. Xlanguage called "2OL", which stands for "Second Order Language".
  1123. X
  1124. XMXS     -   The Mutual Exclusion Subsystem. This includes routines for
  1125. Xcommunicating between concurrent tasks, especially locking other concurrent
  1126. Xtasks out of critical sections. This also contains simple routines for
  1127. Xasynchronous user-generated interrupt handling.
  1128. X
  1129. XACS     -   The Application Configuration Subsystem. This includes routines
  1130. Xfor creating and saving configuration information in a portable and
  1131. Xextendable way.
  1132. X
  1133. XTIS     -   The Telecommunication Interface Subsystem. This includes
  1134. Xroutines for portable access to computers other than the one the program is
  1135. Xrunning on. Note this Subsystem works best if the computer being contacted
  1136. Xis also running an application based on the TIS.
  1137. X
  1138. X.fi
  1139. X.ce
  1140. X***************************************************************
  1141. X
  1142. XNote that only shorts and longs are actually used by PortLib routines.
  1143. XShorts are pretty much assumed to be at least 16 bits long. Chars are
  1144. Xpretty much assumed to be 8 bits long, and longs are pretty much assumed to
  1145. Xbe long enough to reference anything in the system. Where parameters are
  1146. Xdeclared int, it is assumed that only arguments that could fit in a short
  1147. Xare passed. These parameters are declared int instead of short simply to
  1148. Xease the burden of the caller by allowing uncast integers to be passed. In
  1149. Xmost cases (I hope all), parameters are declared as short and only shorts
  1150. Xare passed.
  1151. X
  1152. XAlso, the naming conventions for external data are as follows: constant
  1153. Xvalues such as NULL, TRUE, and so on are all caps. Constant values that are
  1154. Xused as flags to individual routines are all small letters prefixed by the
  1155. Xinitials of the subsystem in which they appear (e.g., PLsev_normal,
  1156. XUIScolor_notice). Routine names (functions or macros that look like
  1157. Xfunctions) are mixed upper/lower case and are prefixed by their subsystem
  1158. Xinitials in all caps (e.g., PLClrErr, UISMakeWindow). General typedefs
  1159. X(like bool, str, etc.) are all lower case. Specific typedefs (UISwindow)
  1160. Xshould be lower case with the subsystem initials prepended in upper case.
  1161. XFor compatibility, assert(), fault(), and bomb() are all lower case.
  1162. X
  1163. X.fi
  1164. X.ce
  1165. X***************************************************************
  1166. X
  1167. XThe HOST Subsystem includes routines to allow easy implementation of each
  1168. Xof the above subsystems. There are, however, a set of HOST routines that
  1169. Xwould be required for every application using the PPL. The organization of
  1170. Xthis subsystem is described here. The functionality required is divided as
  1171. Xfollows:
  1172. X
  1173. XMachine Parameters  -   In PPL.h is a set of parameters that should be
  1174. Xset to match the host computer before the first compilation of the rest of
  1175. Xthe PPL. These parameters include such things as the maximum amount of
  1176. Xmemory that can be allocated contiguously (for segmented machines), the
  1177. Xmaximum size a single I/O, the most efficient declaration for array
  1178. Xindicies, and so on.
  1179. X
  1180. XMemory Functions    -   Functions to allocate and deallocate dynamic
  1181. Xmemory, similarly to malloc() and free().
  1182. X
  1183. XStandard I/O Functions  -   Functions to read and write "standard I/O"
  1184. Xstreams for utilities; these are normally not found in user-level
  1185. Xapplications, but rather only in programs which a programmer would be
  1186. Xusing. Interfacing to the user is the task of the UIS.
  1187. X
  1188. XError Functions -   Functions to diagnose and correct errors detected by
  1189. Xother HOST subsystems. This allows for portable error handling.
  1190. X
  1191. XCommand Argument Functions  -   These access command-line arguments in a
  1192. Xportable way. Note that in order to implement this, the HOST subsystem
  1193. Xactually contains the main() function, which must eventually call DoIt();
  1194. XDoIt() is the "main program" of all PPL-based programs.
  1195. X
  1196. XDebug Functions -   These allow for portable debugging statements, not
  1197. Xnecessarily for portable debugging. In the worst case (the host implements
  1198. Xnone of these), all these statements are designed to be macro'ed out.
  1199. X
  1200. XStatus Functions    -   These allow the programmer to post status messages
  1201. Xfor debugging purposes or for keeping the user awake. These also include
  1202. Xfunctions for delaying and for beeping or flashing.
  1203. X
  1204. XFor more explicit documentation of these routines, please see the
  1205. XHOST subsystem header files.
  1206. X
  1207. X
  1208. X.fi
  1209. X.ce
  1210. X***************************************************************
  1211. X.ce
  1212. XINSTALLATION ON YOUR COMMODORE AMIGA COMPUTER
  1213. X
  1214. XThe organization of the development system is as follows. The root for
  1215. Xall directories is "PPLDIR:" on the Amiga. Upon installation on your
  1216. Xparticular machine, you should make the directory that is to be the
  1217. Xroot and then add to your Startup-Sequence a command to assign this
  1218. Xdirectory to PPLDIR:. You should also assign "INCLUDE:" to be the
  1219. Xdirectory where you want compressed header files to go and "CH:" to be
  1220. Xthe directory where you want uncompressed header files to go. You
  1221. Xshould then unpack the zoo files using the `x//' parameter to cause
  1222. Xthe files to go into the correct directories. Edit the MakeHead.Amiga
  1223. Xfiles to set the first couple of lines correctly for your machine.
  1224. XExecute the FixMake.Amiga script in each subdirectory in order to
  1225. Xrebuild the Makefile.Amiga and Makefile.Unix files. Note that you may
  1226. Xneed to change ld.Amiga to set the correct flags or whatever. On my
  1227. XAmiga, I have renamed `lmk' to be `make' and have written the
  1228. Xfollowing script and put it in s:lmk:
  1229. X
  1230. X.nf
  1231. X    .key name
  1232. X    .bra {
  1233. X    .ket }
  1234. X    if exists Makefile
  1235. X        make {name}
  1236. X    else
  1237. X        if exists FixMake.Amiga
  1238. X            execute FixMake.Amiga
  1239. X            make -f Makefile.Amiga {name}
  1240. X        endif
  1241. X    endif
  1242. X
  1243. X.fi
  1244. X
  1245. XBy doing this, the command `lmk' will recreate the Makefile and then
  1246. Xmake the program. In each subsystem, the default target will build the
  1247. Xsubsystem. The target `clean' will remove most of the leftovers, while
  1248. X`zap' will remove everything about the subsystem except the source.
  1249. XThe target `test' (if available) will run regression tests on the
  1250. Xsubsystem. If the regression tests fail, check the output: you may
  1251. Xjust have a different encoding of characters or a byte-order
  1252. Xdifference or something like that.
  1253. X
  1254. X.nf
  1255. XThe correct order for making these programs is as follows:
  1256. X    1)  PPL
  1257. X    2)  BFS, TFS
  1258. X    3)  VMS, LOME, UIS
  1259. X
  1260. X.fi
  1261. X.ce
  1262. X***************************************************************
  1263. X.ce
  1264. XINSTALLATION ON YOUR UNIX-BASED COMPUTER
  1265. X
  1266. XThe organization of the development system is as follows. The root for
  1267. Xall directories is "$PPLDIR" under Unix. The current sources assume
  1268. Xthe use of GCC under SunOS 4.x. Upon installation on your particular
  1269. Xmachine, you should make the directory that is to be the root and then
  1270. Xadd to your .cshrc file a command to setenv PPLDIR to the full path of
  1271. Xthat directory. You should then unpack the zoo files using the `x//'
  1272. Xparameter to cause the files to go into the correct directories. You
  1273. Xshould also create directories called "$PPLDIR/CH" and
  1274. X"$PPLDIR/Headers" to hold header files. Edit the MakeHead.Unix file to
  1275. Xset the first couple of lines correctly for your machine. Execute the
  1276. XFixMake.Unix script in each subdirectory in order to rebuild the
  1277. XMakefile.Amiga and Makefile.Unix files. Note that you may need to
  1278. Xchange ld.Unix to set the correct flags or whatever.
  1279. X
  1280. XUnder Unix, I have the following lines in my .cshrc:
  1281. X
  1282. X.nf
  1283. Xsetenv PPLDIR ~/PPLstuff
  1284. Xalias lmk 'source FixMake.Unix && make -f Makefile.Unix \!* |& \
  1285. X    tee make.err'
  1286. X
  1287. X.fi
  1288. X
  1289. XBy doing this, the command `lmk' will recreate the Makefile and then
  1290. Xmake the program. In each subsystem, the default target will build the
  1291. Xsubsystem. The target `clean' will remove most of the leftovers, while
  1292. X`zap' will remove everything about the subsystem except the source.
  1293. XThe target `test' (if available) will run regression tests on the
  1294. Xsubsystem. If the regression tests fail, check the output: you may
  1295. Xjust have a different encoding of characters or a byte-order
  1296. Xdifference or something like that.
  1297. X
  1298. X.nf
  1299. XThe correct order for making these programs is as follows:
  1300. X    1)  PPL
  1301. X    2)  BFS, TFS
  1302. X    3)  VMS, LOME, UIS
  1303. X
  1304. X.fi
  1305. X.ce
  1306. X***************************************************************
  1307. X.ce
  1308. XINSTALLATION ON A CURRENTLY-UNSUPPORTED PLATFORM
  1309. X
  1310. XUnpack as above. If you don't have `make,' go buy it. Otherwise, you
  1311. Xwill have to build everything by hand, which is not impossible but is
  1312. Xinconvenient. Look at all the files that have `Amiga' or `Unix' in
  1313. Xtheir name and modify them to work under your machine and OS. Package
  1314. Xup the changes and send them to me.  Thank you!
  1315. X
  1316. X
  1317. END_OF_FILE
  1318. if test 13126 -ne `wc -c <'PPL/PPL.doc'`; then
  1319.     echo shar: \"'PPL/PPL.doc'\" unpacked with wrong size!
  1320. fi
  1321. # end of 'PPL/PPL.doc'
  1322. fi
  1323. if test -f 'TFS/TFSUnix.c' -a "${1}" != "-c" ; then 
  1324.   echo shar: Will not clobber existing file \"'TFS/TFSUnix.c'\"
  1325. else
  1326. echo shar: Extracting \"'TFS/TFSUnix.c'\" \(10504 characters\)
  1327. sed "s/^X//" >'TFS/TFSUnix.c' <<'END_OF_FILE'
  1328. X/* :ts=4:
  1329. X * TFSUnix.c
  1330. X * Portable Programmer's Library Text File Subsystem Code File
  1331. X * Copyright 1988 Darren New.  All Rights Reserved.
  1332. X *
  1333. X * Started: 26-Feb-88 DHN
  1334. X * LastMod: 13-Jul-90 DHN
  1335. X *
  1336. X * Version One for Unix -- Simple, just to get running
  1337. X *   This uses access() because it's simple and there, even
  1338. X *   tho I know this is wrong under SUID programs.
  1339. X *
  1340. X */
  1341. X
  1342. X#include "PPL.h"
  1343. X#include "TFS.h"
  1344. X
  1345. X#include "stdio.h"
  1346. X#include "fcntl.h"
  1347. X
  1348. X/* Why this isn't in stdio.h I'll never understand */
  1349. Xextern int fclose(FILE *);
  1350. Xextern long tell(int);
  1351. Xextern long ftell(FILE *);
  1352. Xextern long fseek(FILE *, long, int);
  1353. Xextern int fgetc(FILE *);
  1354. Xextern int fwrite(char *, int, int, FILE *);
  1355. X
  1356. X#define MAXTFS 15            /* max # TFSfiles open at once */
  1357. X
  1358. XHIDDEN struct {             /* one open file */
  1359. X    str name;
  1360. X    FILE * fhand;
  1361. X    str modes;
  1362. X    } ftab[MAXTFS];
  1363. X
  1364. XHIDDEN bool TFShbi = FALSE;        /* has been init */
  1365. XHIDDEN short TFSfree;            /* number of free ftab entries */
  1366. X
  1367. X
  1368. X#define HND (handle - 1)            /* for convenience */
  1369. X
  1370. X
  1371. Xvoid TFSInit()
  1372. X{
  1373. X    inx i;
  1374. X    assert(TFShbi == FALSE);
  1375. X    TFShbi = TRUE;
  1376. X    for (i = 0; i < MAXTFS; i++)
  1377. X    ftab[i].name = ftab[i].modes = NULL;
  1378. X    TFSfree = MAXTFS;
  1379. X    PLErrClr();
  1380. X    }
  1381. X
  1382. Xbool TFSHasBeenInit()
  1383. X{
  1384. X    return TFShbi;
  1385. X    }
  1386. X
  1387. Xvoid TFSTerm()
  1388. X{
  1389. X    int i;
  1390. X    assert(TFShbi);
  1391. X    for (i = 0; i < MAXTFS; i++) {
  1392. X    if (ftab[i].modes != NULL) {
  1393. X        fclose(ftab[i].fhand);
  1394. X        PLFreeMem(ftab[i].modes);
  1395. X        PLFreeMem(ftab[i].name);
  1396. X        }
  1397. X    }
  1398. X    TFSfree = 0;
  1399. X    TFShbi = FALSE;
  1400. X    PLErrClr();
  1401. X    }
  1402. X
  1403. X
  1404. XTFSfile TFSOpen(fname, mode)
  1405. X    str fname;
  1406. X    str mode;
  1407. X{
  1408. X
  1409. X    /**** NOTE THIS MUST BE CHANGED TO REMEMBER NAMES IN FULL LENGTH
  1410. X      OR RELATIVE TO A LOCK OR DIRECTORY! ****/
  1411. X
  1412. X    /**** Also note that this takes advantage of some of the restrictions
  1413. X      on mode combinations; e.g., R excludes W, W excludes P, ... ****/
  1414. X
  1415. X    long flock, fhand;
  1416. X    bool mL, mC, mT, mA, mR, mW, mP, mD;
  1417. X    long t; /* temp value */
  1418. X    inx i;
  1419. X
  1420. X#define setup(a,b) {a = (NULL != strchr(mode, b));}
  1421. X
  1422. X    assert(TFShbi);
  1423. X#if CHKARGS
  1424. X    if (fname == NULL || mode == NULL || *fname == EOS || *mode == EOS ||
  1425. X        BIGFNAME <= strlen(fname) ) {
  1426. X    PLErrSet(PLerr_badarg);
  1427. X    return 0;
  1428. X    }
  1429. X#endif
  1430. X
  1431. X    setup(mL, 'L'); setup(mC, 'C'); setup(mT, 'T');
  1432. X    setup(mA, 'A'); setup(mR, 'R'); setup(mW, 'W');
  1433. X    setup(mP, 'P'); setup(mD, 'D');
  1434. X
  1435. X#if CHKARGS
  1436. X    if ( (mR && mW) || (mP && !mR && !mC) || (mW && !mA && !mT) ||
  1437. X        (mA && mT) || (mA && !mW) || (mT && !mW) ) {
  1438. X    PLErrSet(PLerr_badarg);
  1439. X    return 0;
  1440. X    }
  1441. X#endif
  1442. X
  1443. X    if (TFSfree == 0 && ! mL) {
  1444. X    PLErrSet(PLerr_oores);
  1445. X    return 0;
  1446. X    }
  1447. X
  1448. X    if (mL) {           /* just check for access */
  1449. X    if (!mC) {      /* not creating */
  1450. X        flock = access(fname, F_OK);
  1451. X        if (flock == -1) {  /* directories inaccessible */
  1452. X        OSerr = errno;
  1453. X        if (OSerr == EACCES || OSerr == EISDIR || OSerr == ENOTDIR ||
  1454. X            OSerr == EPERM || OSerr == ETXTBSY)
  1455. X            PLErrSet(PLerr_permit);
  1456. X        else
  1457. X            PLErrSet(PLerr_exist);
  1458. X        return 0;
  1459. X        }
  1460. X        flock = access(fname, F_OK + mR ? R_OK : W_OK);
  1461. X        if (flock == -1) {  /* file inaccessible */
  1462. X        OSerr = errno;
  1463. X        if (OSerr == EACCES || OSerr == EISDIR || OSerr == ENOTDIR ||
  1464. X            OSerr == EPERM || OSerr == ETXTBSY)
  1465. X            PLErrSet(PLerr_permit);
  1466. X        else
  1467. X            PLErrSet(PLerr_exist);
  1468. X        return 0;
  1469. X        }
  1470. X        }
  1471. X    else {    /* creating */
  1472. X        char * dirname;
  1473. X        char * slash;
  1474. X            /* check simple case first */
  1475. X        if (-1 != access(fname, F_OK + W_OK))
  1476. X        return 1;
  1477. X            /* Difficult case: build name of parent dir */
  1478. X        dirname = PLStrDup(fname);
  1479. X        slash = dirname + 1;
  1480. X        if (NULL == strchr(dirname, '/'))
  1481. X        strcpy(dirname, ".");
  1482. X        else {
  1483. X        while (NULL != strchr(slash, '/'))
  1484. X            slash = strchr(slash, '/');
  1485. X        *(slash+1) = '\0';
  1486. X        }
  1487. X        flock = access(dirname, F_OK);
  1488. X        if (flock == -1) {  /* see if dest dir exists */
  1489. X        OSerr = errno;
  1490. X        PLErrSet(PLerr_exist);
  1491. X        PLFreeMem(dirname);
  1492. X        return 0;
  1493. X        }
  1494. X        flock = access(dirname, F_OK + W_OK);
  1495. X        if (flock == -1) {  /* see if dest dir is writable */
  1496. X        OSerr = errno;
  1497. X        PLErrSet(PLerr_permit);
  1498. X        PLFreeMem(dirname);
  1499. X        return 0;
  1500. X        }
  1501. X        flock = access(fname, F_OK + W_OK);
  1502. X        if (flock == -1 && errno != ENOENT) {
  1503. X                /* see if dest file exists and writable */
  1504. X        OSerr = errno;
  1505. X        PLErrSet(PLerr_permit);
  1506. X        PLFreeMem(dirname);
  1507. X        return 0;
  1508. X        }
  1509. X        else {
  1510. X        /* otherwise, must be good */
  1511. X        errno = 0;
  1512. X        PLFreeMem(dirname);
  1513. X        return 1;
  1514. X        }
  1515. X        }
  1516. X    }
  1517. X
  1518. X    /* Here, we are not just looking. In this case, it is easiest to
  1519. X       simply try to do the operation and see if it fails. */
  1520. X
  1521. X    t  = mR ? O_RDONLY : O_WRONLY;
  1522. X    t += mC ? O_CREAT : 0;
  1523. X    t += mT ? O_TRUNC : 0;
  1524. X    t += mA ? O_APPEND : 0;
  1525. X
  1526. X    fhand = open(fname, t, 0666);
  1527. X    if (fhand < 0) {
  1528. X    OSerr = errno;
  1529. X    switch (errno) {
  1530. X        default:
  1531. X        PLErrSet(PLerr_opsysF); break;
  1532. X        case EACCES:
  1533. X        case EEXIST:
  1534. X        case EISDIR:
  1535. X        case ENOTDIR:
  1536. X        case EROFS:
  1537. X        PLErrSet(PLerr_permit); break;
  1538. X        case EDQUOT:
  1539. X        case EMFILE:
  1540. X        case ENFILE:
  1541. X        case ENOSPC:
  1542. X        case ENOSR:
  1543. X        PLErrSet(PLerr_oores); break;
  1544. X        case EFAULT:
  1545. X        case ENAMETOOLONG:
  1546. X        PLErrSet(PLerr_param); break;
  1547. X        case EOPNOTSUPP:
  1548. X        PLErrSet(PLerr_unsup); break;
  1549. X        case ENOENT:
  1550. X        PLErrSet(PLerr_exist); break;
  1551. X        }
  1552. X    return 0;
  1553. X    }
  1554. X    if (mP && tell(fhand) < 0) {
  1555. X    close(fhand);
  1556. X    PLErrSet(PLerr_unsup);
  1557. X    return 0;
  1558. X    }
  1559. X    for (i = 0; i < MAXTFS && ftab[i].modes; i++)
  1560. X    ;
  1561. X    ftab[i].fhand = fdopen(fhand, mR ? "rt" : (mA ? "at" : "wt"));
  1562. X    if (ftab[i].fhand == NULL) {
  1563. X    close(fhand);
  1564. X    PLErrSet(PLerr_oores);
  1565. X    return 0;
  1566. X    }
  1567. X    ftab[i].modes = PLStrDup(mode);
  1568. X    ftab[i].name = PLStrDup(fname);
  1569. X
  1570. X    return (TFSfile) (i + 1);
  1571. X    }
  1572. X
  1573. Xbool TFSClose(handle)
  1574. X    TFSfile handle;
  1575. X{
  1576. X    int err;
  1577. X    assert(TFShbi);
  1578. X#if CHKARGS
  1579. X    if (HND < 0 || MAXTFS <= HND || ftab[HND].modes == NULL) {
  1580. X    PLErrSet(PLerr_badarg);
  1581. X    return FALSE;
  1582. X    }
  1583. X#endif
  1584. X    assert(ftab[HND].fhand != NULL);
  1585. X    assert(ftab[HND].name  != NULL);
  1586. X    assert(ftab[HND].modes != NULL);
  1587. X
  1588. X    err = fclose(ftab[HND].fhand);
  1589. X    PLFreeMem((ptr) ftab[HND].modes);
  1590. X    PLFreeMem((ptr) ftab[HND].name);
  1591. X    ftab[HND].name = ftab[HND].modes = NULL;
  1592. X    if (err == 0) {
  1593. X    PLErrClr();
  1594. X    return TRUE;
  1595. X    }
  1596. X    else {
  1597. X    PLErrSet(PLerr_opsysF);
  1598. X    return FALSE;
  1599. X    }
  1600. X    }
  1601. X
  1602. Xbool TFSDestroy(handle)
  1603. X    TFSfile handle;
  1604. X{
  1605. X    char fn[BIGFNAME];
  1606. X    bool flag;
  1607. X    int err;
  1608. X
  1609. X    assert(TFShbi);
  1610. X#if CHKARGS
  1611. X    if (HND < 0 || MAXTFS <= HND || ftab[HND].modes == NULL) {
  1612. X    PLErrSet(PLerr_badarg);
  1613. X    return FALSE;
  1614. X    }
  1615. X#endif
  1616. X    strcpy(fn, ftab[HND].name);
  1617. X    flag = (NULL != strchr(ftab[HND].modes, 'D'));
  1618. X
  1619. X    fclose(ftab[HND].fhand);
  1620. X    PLFreeMem(ftab[HND].name);
  1621. X    PLFreeMem(ftab[HND].modes);
  1622. X    ftab[HND].modes = NULL;
  1623. X
  1624. X    if (flag) {
  1625. X    err = unlink(fn);  /* permission checked during open */
  1626. X    if (err == -1) {
  1627. X        OSerr = errno;
  1628. X        PLErrSet(PLerr_permit);
  1629. X        return FALSE;
  1630. X        }
  1631. X    else {
  1632. X        PLErrClr();
  1633. X        return TRUE;
  1634. X        }
  1635. X    }
  1636. X    else {
  1637. X    PLErrSet(PLerr_badarg);
  1638. X    return FALSE;
  1639. X    }
  1640. X    }
  1641. X
  1642. X/*  @$@$
  1643. XTFSInfo()       - Determine file parameters. This may return various
  1644. Xparameters about the given file. The description of the information
  1645. Xreturned is given in the TFS.h file.
  1646. X*/
  1647. X
  1648. X
  1649. Xshort TFSRead(handle, buf)
  1650. X    TFSfile handle;
  1651. X    str buf;
  1652. X{
  1653. X    inx i;    /* index into buffer */
  1654. X    int c;    /* read character */
  1655. X    long l;    /* length of record read */
  1656. X
  1657. X    assert(TFShbi);
  1658. X    assert(buf != NULL);
  1659. X#if CHKARGS
  1660. X    if (HND < 0 || MAXTFS <= HND || ftab[HND].modes == NULL) {
  1661. X    PLErrSet(PLerr_badarg);
  1662. X    return S -1;
  1663. X    }
  1664. X    if (NULL == strchr(ftab[HND].modes, 'R')) {
  1665. X    PLErrSet(PLerr_badarg);
  1666. X    return S -1;
  1667. X    }
  1668. X#endif
  1669. X    i = 0;
  1670. X    do {
  1671. X    errno = 0;
  1672. X    c = fgetc(ftab[HND].fhand);
  1673. X    l = (c == EOF) ? (ferror(ftab[HND].fhand) ? -1 : 0) : 1;
  1674. X        /* l is what read() would have returned */
  1675. X    if (0 < l)
  1676. X        buf[i++] = c;
  1677. X    } while (0 < l && i < BIGLINE && c != '\n');
  1678. X
  1679. X    /* printf("l=%d, i=%d, c=%d, buf[0]=%c\n", l, i, c, buf[0]); */
  1680. X    if (l == -1) {
  1681. X    OSerr = errno;
  1682. X    PLErrSet(PLerr_opsysF);
  1683. X    buf[0] = EOS;
  1684. X    return S -1;
  1685. X    }
  1686. X    if (i == BIGLINE && c != '\n') {     /* line overflow */
  1687. X    buf[--i] = EOS;
  1688. X    while (0 < i && isspace(buf[i-1]))
  1689. X        buf[--i] = EOS;
  1690. X    while (EOF != (c = fgetc(ftab[HND].fhand)) && c != '\n')
  1691. X        /* flush rest of line */;
  1692. X    PLErrSet(PLerr_overflow);
  1693. X    assert(strlen(buf) < BIGLINE);
  1694. X    return S -1;
  1695. X    }
  1696. X    if (l == 0) {           /* end of file */
  1697. X    if (i == 0) {
  1698. X        buf[0] = EOS;
  1699. X        PLErrSet(PLerr_eod);
  1700. X        return S -1;
  1701. X        }
  1702. X    else {
  1703. X        buf[i++] = c = '\n';
  1704. X        /* and fall thru */
  1705. X        }
  1706. X    }
  1707. X    if (c == '\n') {        /* end of line */
  1708. X    if (i == BIGLINE) 
  1709. X        i -= 1;
  1710. X    buf[i] = EOS;
  1711. X    while (0 < i && isspace(buf[i-1]))
  1712. X        buf[--i] = EOS;
  1713. X    PLErrClr();
  1714. X    assert(strlen(buf) < BIGLINE);
  1715. X    return S i;
  1716. X    }
  1717. X
  1718. X    assert(0);  /* you can't get here */
  1719. X    return 0;
  1720. X    }
  1721. X
  1722. X
  1723. Xbool TFSWrite(handle, buf)
  1724. X    TFSfile handle;
  1725. X    str buf;
  1726. X{
  1727. X    int i;  /* must be able to handle negative numbers */
  1728. X
  1729. X    assert(buf != NULL);
  1730. X#if CHKARGS
  1731. X    if (HND < 0 || MAXTFS <= HND || ftab[HND].modes == NULL) {
  1732. X    PLErrSet(PLerr_badarg);
  1733. X    return FALSE;
  1734. X    }
  1735. X    if (NULL == strchr(ftab[HND].modes, 'W')) {
  1736. X    PLErrSet(PLerr_badarg);
  1737. X    return FALSE;
  1738. X    }
  1739. X    if (BIGIO <= strlen(buf)) {
  1740. X    PLErrSet(PLerr_badarg);
  1741. X    return FALSE;
  1742. X    }
  1743. X#endif
  1744. X
  1745. X    clearerr(ftab[HND].fhand);
  1746. X    i = strlen(buf);
  1747. X    while (0 < i && isspace(buf[i - 1]))
  1748. X    i -= 1;
  1749. X    if ( ( (0 < i) && (i != fwrite(buf, 1, i, ftab[HND].fhand)) ) ||
  1750. X        1 != fwrite("\n", 1, 1, ftab[HND].fhand)) {
  1751. X    OSerr = errno;
  1752. X    PLErrSet(PLerr_opsysF);
  1753. X    return FALSE;
  1754. X    }
  1755. X    PLErrClr();
  1756. X    return TRUE;
  1757. X    }
  1758. X
  1759. Xlong TFSNote(handle)
  1760. X    TFSfile handle;
  1761. X{
  1762. X    long retval;
  1763. X#if CHKARGS
  1764. X    if (HND < 0 || MAXTFS <= HND || ftab[HND].modes == NULL) {
  1765. X    PLErrSet(PLerr_badarg);
  1766. X    return -1L;
  1767. X    }
  1768. X    if (NULL == strchr(ftab[HND].modes, 'P') ||
  1769. X        NULL == strchr(ftab[HND].modes, 'R')) {
  1770. X    PLErrSet(PLerr_badarg);
  1771. X    return -1L;
  1772. X    }
  1773. X#endif
  1774. X
  1775. X    retval = ftell(ftab[HND].fhand);
  1776. X    if (retval == -1) {
  1777. X    OSerr = errno;
  1778. X    PLErrSet(PLerr_opsysF);
  1779. X    return 0L;
  1780. X    }
  1781. X    else {
  1782. X    PLErrClr();
  1783. X    return retval + 1L;
  1784. X    }
  1785. X    }
  1786. X
  1787. Xbool TFSPoint(handle, pos)
  1788. X    TFSfile handle;
  1789. X    TFSnote pos;
  1790. X{
  1791. X    long newpos;
  1792. X#if CHKARGS
  1793. X    if (HND < 0 || MAXTFS <= HND || ftab[HND].modes == NULL) {
  1794. X    PLErrSet(PLerr_badarg);
  1795. X    return -1L;
  1796. X    }
  1797. X    if (pos <= 0L || NULL == strchr(ftab[HND].modes, 'P') ||
  1798. X        NULL == strchr(ftab[HND].modes, 'R')) {
  1799. X    PLErrSet(PLerr_badarg);
  1800. X    return -1L;
  1801. X    }
  1802. X#endif
  1803. X
  1804. X    newpos = fseek(ftab[HND].fhand, pos - 1L, 0);
  1805. X    if (newpos == -1L) {
  1806. X    OSerr = errno;
  1807. X    PLErrSet(PLerr_opsysF);
  1808. X    return FALSE;
  1809. X    }
  1810. X    else {
  1811. X    PLErrClr();
  1812. X    return TRUE;
  1813. X    }
  1814. X    }
  1815. X
  1816. X
  1817. END_OF_FILE
  1818. if test 10504 -ne `wc -c <'TFS/TFSUnix.c'`; then
  1819.     echo shar: \"'TFS/TFSUnix.c'\" unpacked with wrong size!
  1820. fi
  1821. # end of 'TFS/TFSUnix.c'
  1822. fi
  1823. echo shar: End of archive 6 \(of 9\).
  1824. cp /dev/null ark6isdone
  1825. MISSING=""
  1826. for I in 1 2 3 4 5 6 7 8 9 ; do
  1827.     if test ! -f ark${I}isdone ; then
  1828.     MISSING="${MISSING} ${I}"
  1829.     fi
  1830. done
  1831. if test "${MISSING}" = "" ; then
  1832.     echo You have unpacked all 9 archives.
  1833.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1834. else
  1835.     echo You still need to unpack the following archives:
  1836.     echo "        " ${MISSING}
  1837. fi
  1838. ##  End of shell archive.
  1839. exit 0
  1840. -- 
  1841. --- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
  1842.  
  1843. exit 0 # Just in case...
  1844. -- 
  1845. Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
  1846. Use a domain-based address or give alternate paths, or you may lose out.
  1847.