home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / vmstt.bli < prev    next >
Text File  |  2020-01-01  |  9KB  |  563 lines

  1. MODULE KERTT (IDENT = '2.0.004'
  2.         ) =
  3. BEGIN
  4.  
  5. SWITCHES LANGUAGE (COMMON);
  6.  
  7. !<BLF/WIDTH:100>
  8.  
  9. !++
  10. ! FACILITY:
  11. !
  12. !    KERMIT text processing
  13. !
  14. ! ABSTRACT:
  15. !
  16. !    This module contains all of the text processing required for
  17. !    KERMSG.
  18. !
  19. ! ENVIRONMENT:
  20. !
  21. !    TOPS-10, P/OS, VAX/VMS
  22. !
  23. ! AUTHOR: Robert C. McQueen, CREATION DATE: 29-August-1983
  24. !--
  25.  
  26. %SBTTL 'Table of Contents'
  27. !
  28. ! TABLE OF CONTENTS:
  29. !
  30. %SBTTL 'Revision History'
  31.  
  32. !++
  33. !
  34. ! Create this module for PRO/Kermit 1.0, Kermit-10 2(100) and Kermit-32 1.2
  35. !
  36. ! 1.2.000    By: Robert C. McQueen            On: 29-August-1983
  37. !        Create this module.
  38. !
  39. ! 1.2.001    By: Robert C. McQueen        On: 9-Sept-1983
  40. !        Make the string passed to TERM_DUMP a counted ASCIZ string,
  41. !        not a counted ASCII string.
  42. !
  43. ! 1.2.002    By: Robert C. McQueen        On: 16-September-1983
  44. !        Make TT_OUTPUT a global routine, so we can force information
  45. !        output a various points in time.
  46. !
  47. ! 2.0.003    Release for TOPS-10 KERMIT-10 version 2.
  48. !        Release for VAX/VMS KERMIT-32 version 2.
  49. !
  50. ! 2.0.004    By: Nick Bush            On: 22-December-1983
  51. !        Add TT_HOLD to indicate that output should not be dumped
  52. !        when LF's are seen, only when buffer is full.
  53. !--
  54.  
  55. %SBTTL 'Library files'
  56. !
  57. ! INCLUDE FILES:
  58. !
  59. !
  60. ! KERMIT common definitions
  61. !
  62.  
  63. REQUIRE 'KERCOM';
  64.  
  65. %SBTTL 'Symbol definitions'
  66. !
  67. ! EQUATED SYMBOLS:
  68. !
  69.  
  70. LITERAL
  71.     TEXT_BFR_LENGTH = 256;            ! Length of the text buffer
  72.  
  73. %SBTTL 'Storage'
  74. !
  75. ! OWN STORAGE:
  76. !
  77. !
  78. ! TT_xxxxx routine storage
  79. !
  80.  
  81. OWN
  82.     HOLD_FLAG,                    ! Output should be held even if CRLF seen
  83.     DUMP_ROUTINE,                ! Address of routine to dump text
  84.     TEXT_COUNT,                    ! Count of the characters
  85.     TEXT_POINTER,                ! Pointer to store characters
  86.     TEXT_BUFFER : VECTOR [CH$ALLOCATION (TEXT_BFR_LENGTH)];    ! Buffer of characters
  87.  
  88. %SBTTL 'External storage'
  89.  
  90. !++
  91. ! The following is the various external storage locations that are
  92. ! referenced from this module.
  93. !--
  94.  
  95. !
  96. ! KERMSG storage
  97. !
  98.  
  99. EXTERNAL
  100.     CONNECT_FLAG;                ! Flag if communications line is TT:
  101.  
  102. !++
  103. ! The following is the only external routine used by this module.  This
  104. ! routine will cause the terminal buffer that we have been building to be
  105. ! output on the terminal
  106. !--
  107.  
  108. EXTERNAL ROUTINE
  109.     TERM_DUMP : NOVALUE;            ! Output the terminal buffer
  110.  
  111. %SBTTL 'Terminal routines -- TT_INIT - Initialize this module'
  112.  
  113. GLOBAL ROUTINE TT_INIT : NOVALUE =
  114.  
  115. !++
  116. ! FUNCTIONAL DESCRIPTION:
  117. !
  118. !    This routine will initialize the terminal processing module.  It will
  119. !    initialize the various data locations in this module.
  120. !
  121. ! CALLING SEQUENCE:
  122. !
  123. !    TT_INIT();
  124. !
  125. ! INPUT PARAMETERS:
  126. !
  127. !    None.
  128. !
  129. ! IMPLICIT INPUTS:
  130. !
  131. !    None.
  132. !
  133. ! OUTPUT PARAMETERS:
  134. !
  135. !    None.
  136. !
  137. ! IMPLICIT OUTPUTS:
  138. !
  139. !    None.
  140. !
  141. ! COMPLETION CODES:
  142. !
  143. !    None.
  144. !
  145. ! SIDE EFFECTS:
  146. !
  147. !    None.
  148. !
  149. !--
  150.  
  151.     BEGIN
  152. !
  153. ! Now initialize the various pointers
  154. !
  155.     TEXT_COUNT = 0;
  156.     TEXT_POINTER = CH$PTR (TEXT_BUFFER);
  157.     DUMP_ROUTINE = TERM_DUMP;            ! Initial output routine is to terminal
  158.     HOLD_FLAG = FALSE;                ! Dump output on CRLF's
  159.     END;                    ! End of TT_INIT
  160.  
  161. %SBTTL 'TT_SET_OUTPUT - Set output routine to use'
  162.  
  163. GLOBAL ROUTINE TT_SET_OUTPUT (OUT_RTN) =
  164.  
  165. !++
  166. ! FUNCTIONAL DESCRIPTION:
  167. !
  168. ! This routine will set the output routine to use for the TT_xxx routines.
  169. !The argument is a routine address which will output a counted ASCIZ string.
  170. !It will return the address of the previous output routine.
  171. !
  172. ! CALLING SEQUENCE:
  173. !
  174. !    OLD_RTN = TT_SET_OUTPUT (OUT_RTN);
  175. !
  176. ! INPUT PARAMETERS:
  177. !
  178. !    OUT_RTN - Address of routine to output a counted ASCIZ string
  179. !        called as OUT_RTN (Address of string, length of string)
  180. !
  181. ! IMPLICIT INPUTS:
  182. !
  183. !    DUMP_ROUTINE - Previous output routine
  184. !
  185. ! OUPTUT PARAMETERS:
  186. !
  187. !    The value of the routine is the previous output routine address.
  188. !
  189. ! IMPLICIT OUTPUTS:
  190. !
  191. !    DUMP_ROUTINE - New output routine
  192. !
  193. ! COMPLETION CODES:
  194. !
  195. !    None.
  196. !
  197. ! SIDE EFFECTS:
  198. !
  199. !    None.
  200. !
  201. !--
  202.  
  203.     BEGIN
  204.  
  205.     LOCAL
  206.     OLD_RTN;                ! Old routine address
  207.  
  208.     OLD_RTN = .DUMP_ROUTINE;            ! Remember the old address
  209.     DUMP_ROUTINE = .OUT_RTN;            ! Save the new
  210.     RETURN .OLD_RTN;                ! And return the old value
  211.     END;                    ! End of TT_SET_OUTPUT
  212.  
  213. %SBTTL 'TT_HOLD - Start holding text until TT_OUTPUT call'
  214.  
  215. GLOBAL ROUTINE TT_HOLD (FLAG) : NOVALUE =
  216.  
  217. !++
  218. ! FUNCTIONAL DESCRIPTION:
  219. !
  220. !    This routine is called to start buffering an amount of data
  221. !    which should not be output until TT_OUTPUT is called.  It
  222. !    sets a flag to indicate that output should not be done on
  223. !    CRLF's.
  224. !
  225. ! CALLING SEQUENCE:
  226. !
  227. !    TT_HOLD (TRUE or FALSE);
  228. !
  229. ! INPUT PARAMETERS:
  230. !
  231. !    FLAG - True if output should be held past LF's.  False if output
  232. !           should be dumped on each LF.
  233. !
  234. ! IMPLICIT INPUTS:
  235. !
  236. !    None.
  237. !
  238. ! OUPTUT PARAMETERS:
  239. !
  240. !    None.
  241. !
  242. ! IMPLICIT OUTPUTS:
  243. !
  244. !    HOLD_FLAG is set to true.
  245. !
  246. ! COMPLETION CODES:
  247. !
  248. !    None.
  249. !
  250. ! SIDE EFFECTS:
  251. !
  252. !    None.
  253. !
  254. !--
  255.  
  256.     BEGIN
  257.     HOLD_FLAG = .FLAG;
  258.     END;                    ! End of TT_HOLD
  259.  
  260. %SBTTL 'Terminal routines -- TT_OUTPUT - Output the buffer'
  261.  
  262. GLOBAL ROUTINE TT_OUTPUT : NOVALUE =
  263.  
  264. !++
  265. ! FUNCTIONAL DESCRIPTION:
  266. !
  267. !    This routine will dump the text buffer on the output device.
  268. !
  269. ! CALLING SEQUENCE:
  270. !
  271. !    TT_OUTPUT();
  272. !
  273. ! INPUT PARAMETERS:
  274. !
  275. !    None.
  276. !
  277. ! IMPLICIT INPUTS:
  278. !
  279. !    None.
  280. !
  281. ! OUTPUT PARAMETERS:
  282. !
  283. !    None.
  284. !
  285. ! IMPLICIT OUTPUTS:
  286. !
  287. !    None.
  288. !
  289. ! COMPLETION CODES:
  290. !
  291. !    None.
  292. !
  293. ! SIDE EFFECTS:
  294. !
  295. !    None.
  296. !
  297. !--
  298.  
  299.     BEGIN
  300.  
  301.     LOCAL
  302.     STATUS;                    ! Status returned by the library routine
  303.  
  304. !
  305. ! Output the text
  306. !
  307.     CH$WCHAR_A (CHR_NUL, TEXT_POINTER);
  308.     (.DUMP_ROUTINE) (TEXT_BUFFER, .TEXT_COUNT);    ! Output the buffer to the correct place
  309. !
  310. ! Now reset the descriptor and the pointer to a virgin state
  311. !
  312.     TEXT_COUNT = 0;
  313.     TEXT_POINTER = CH$PTR (TEXT_BUFFER);
  314. !
  315.     END;                    ! End of TT_OUTPUT
  316.  
  317. %SBTTL 'Terminal routines -- TT_CHAR - Output a single character'
  318.  
  319. GLOBAL ROUTINE TT_CHAR (CHARACTER) : NOVALUE =
  320.  
  321. !++
  322. ! FUNCTIONAL DESCRIPTION:
  323. !
  324. !    This routine will store a character into the text buffer.  It will
  325. !    cause the text to be output if the character is a line terminator.
  326. !
  327. ! CALLING SEQUENCE:
  328. !
  329. !    TT_CHAR(Character);
  330. !
  331. ! INPUT PARAMETERS:
  332. !
  333. !    Character - Character to store into the text buffer.
  334. !
  335. ! IMPLICIT INPUTS:
  336. !
  337. !    None.
  338. !
  339. ! OUTPUT PARAMETERS:
  340. !
  341. !    None.
  342. !
  343. ! IMPLICIT OUTPUTS:
  344. !
  345. !    None.
  346. !
  347. ! COMPLETION CODES:
  348. !
  349. !    None.
  350. !
  351. ! SIDE EFFECTS:
  352. !
  353. !    None.
  354. !
  355. !--
  356.  
  357.     BEGIN
  358. !
  359. ! Increment the count of the characters
  360. !
  361.     TEXT_COUNT = .TEXT_COUNT + 1;
  362. !
  363. ! And store the character
  364. !
  365.     CH$WCHAR_A (.CHARACTER, TEXT_POINTER);
  366. !
  367. ! If this is a line feed then just output the text string
  368. !
  369.  
  370.     IF (.CHARACTER EQL CHR_LFD) AND NOT .HOLD_FLAG THEN TT_OUTPUT ();
  371.  
  372. !
  373. ! Check to make sure we are not exceeding the limit of the buffer
  374. !
  375.  
  376.     IF .TEXT_COUNT EQL TEXT_BFR_LENGTH - 1 THEN TT_OUTPUT ();
  377.  
  378. !
  379.     END;                    ! End of TT_CHAR
  380.  
  381. %SBTTL 'Terminal routines -- TT_TEXT - Output a text string'
  382.  
  383. GLOBAL ROUTINE TT_TEXT (ADDRESS) : NOVALUE =
  384.  
  385. !++
  386. ! FUNCTIONAL DESCRIPTION:
  387. !
  388. !    This routine will output text on the user's terminal.  It will
  389. !    assume that it must check to determine if it can output the text
  390. !    or not.
  391. !
  392. ! CALLING SEQUENCE:
  393. !
  394. !    TT_TEXT(TEXT_ADDRESS);
  395. !
  396. ! INPUT PARAMETERS:
  397. !
  398. !    None.
  399. !
  400. ! IMPLICIT INPUTS:
  401. !
  402. !    None.
  403. !
  404. ! OUTPUT PARAMETERS:
  405. !
  406. !    None.
  407. !
  408. ! IMPLICIT OUTPUTS:
  409. !
  410. !    None.
  411. !
  412. ! COMPLETION CODES:
  413. !
  414. !    None.
  415. !
  416. ! SIDE EFFECTS:
  417. !
  418. !    None.
  419. !
  420. !--
  421.  
  422.     BEGIN
  423.  
  424.     LOCAL
  425.     CHARACTER,                ! Character being processed
  426.     ARG_POINTER;                ! Pointer to the argument's text
  427.  
  428. !
  429. ! Construct a pointer to the argument.
  430. !
  431.     ARG_POINTER = CH$PTR (.ADDRESS);
  432. !
  433. ! Get the first character that was passed.
  434. !
  435.     CHARACTER = CH$RCHAR_A (ARG_POINTER);
  436. !
  437. ! Loop reading characters and calling the output routine to process
  438. ! them
  439. !
  440.  
  441.     WHILE .CHARACTER NEQ CHR_NUL DO
  442.     BEGIN
  443.     TT_CHAR (.CHARACTER);
  444.     CHARACTER = CH$RCHAR_A (ARG_POINTER);
  445.     END;
  446.  
  447.     END;                    ! End of TT_TEXT
  448.  
  449. %SBTTL 'Terminal routines -- TT_NUMBER - Output a three digit number'
  450.  
  451. GLOBAL ROUTINE TT_NUMBER (NUMBER) : NOVALUE =
  452.  
  453. !++
  454. ! FUNCTIONAL DESCRIPTION:
  455. !
  456. !    This routine will store a three digit number into the text buffer.
  457. !    It will just return if the number is greater than 999.
  458. !
  459. ! CALLING SEQUENCE:
  460. !
  461. !    TT_NUMBER(Value);
  462. !
  463. ! INPUT PARAMETERS:
  464. !
  465. !    Value - Value to output.
  466. !
  467. ! IMPLICIT INPUTS:
  468. !
  469. !    None.
  470. !
  471. ! OUTPUT PARAMETERS:
  472. !
  473. !    None.
  474. !
  475. ! IMPLICIT OUTPUTS:
  476. !
  477. !    None.
  478. !
  479. ! COMPLETION CODES:
  480. !
  481. !    None.
  482. !
  483. ! SIDE EFFECTS:
  484. !
  485. !    None.
  486. !
  487. !--
  488.  
  489.     BEGIN
  490.     ROUTINE TT_NUM_WORKER (VALUE) : NOVALUE =
  491.     BEGIN
  492.  
  493.     IF .VALUE LEQ 9
  494.     THEN
  495.         TT_CHAR (.VALUE + %C'0')
  496.     ELSE
  497.         BEGIN
  498.         TT_NUM_WORKER (.VALUE/10);
  499.         TT_CHAR ((.VALUE MOD 10) + %C'0');
  500.         END;
  501.  
  502.     END;
  503.  
  504.     IF .NUMBER LSS 0
  505.     THEN
  506.     BEGIN
  507.     TT_CHAR (%C'-');
  508.     NUMBER = -.NUMBER;
  509.     END;
  510.  
  511.     TT_NUM_WORKER (.NUMBER);
  512.     END;                    ! End of TT_NUMBER
  513.  
  514. %SBTTL 'Terminal routines -- TT_CRLF - Output a CRLF'
  515.  
  516. GLOBAL ROUTINE TT_CRLF : NOVALUE =
  517.  
  518. !++
  519. ! FUNCTIONAL DESCRIPTION:
  520. !
  521. !    This routine will cause the contents of the terminal buffer to be
  522. !    output to SYS$OUTPUT:.
  523. !
  524. ! CALLING SEQUENCE:
  525. !
  526. !    TT_CRLF();
  527. !
  528. ! INPUT PARAMETERS:
  529. !
  530. !    None.
  531. !
  532. ! IMPLICIT INPUTS:
  533. !
  534. !    None.
  535. !
  536. ! OUTPUT PARAMETERS:
  537. !
  538. !    None.
  539. !
  540. ! IMPLICIT OUTPUTS:
  541. !
  542. !    None.
  543. !
  544. ! COMPLETION CODES:
  545. !
  546. !    None.
  547. !
  548. ! SIDE EFFECTS:
  549. !
  550. !    None.
  551. !
  552. !--
  553.  
  554.     BEGIN
  555.     TT_CHAR (CHR_CRT);
  556.     TT_CHAR (CHR_LFD);
  557.     END;                    ! End of TT_CRLF
  558.  
  559. %SBTTL 'End of KERTRM'
  560. END                        ! End of module
  561.  
  562. ELUDOM
  563.