home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ibm370 / ik0por.txt < prev    next >
Text File  |  2020-01-01  |  43KB  |  972 lines

  1. IK0POR.HLP                                               1991 Sept
  2.  
  3. Notes on porting Kermit-370 to other operating systems.  This document
  4. consists of three parts: a general specification of functionality, a
  5. detailed guide to some of the more arcane sections of system-specific
  6. code in Kermit-370, and a summary of all the modules within Kermit-CMS.
  7.  
  8. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  9. A. Feasibility.
  10.  
  11. The following is a list of system-specific operations that must (or
  12. should) be performed by Kermit-370.  Each item is labeled with its
  13. degree of importance and with the name(s) of the macro and/or routine(s)
  14. that perform the function.  The importance level is marked with ">>" and
  15. the program components with "<<".  Names of macros are further marked
  16. with asterisks; routines are usually coupled with function codes.  The
  17. presence of both a macro and a routine indicates that the macro serves
  18. only to invoke the routine.
  19.  
  20.        TERMINAL FUNCTIONS
  21.  
  22.  1. Read from the terminal with possible prompt.  Return length read.
  23.     Leave text in specified buffer (unedited, if possible).  Should
  24.     follow techniques of utility programs, if any, such that command
  25.     procedures can issue Kermit subcommands (if possible).
  26.     >> Essential.
  27.     << * RTEXT
  28.  
  29.  2. Display text at the terminal.  Ok if system supplies a CRLF.
  30.     >> Essential.
  31.     << * WTEXT
  32.  
  33.  3. Test for stacked lines of terminal (or pseudo-terminal) input.
  34.     >> Cosmetic.  Avoids extra prompts and synchronizes "banner" display
  35.        at startup.
  36.     << SUPFNC,7
  37.  
  38.  4. Set up a new prompt string, if necessary, for subsequent terminal
  39.     read requests.
  40.     >> Only if needed for #1.
  41.     << SUPFNC,11
  42.  
  43.  5. Clear the screen (if possible).
  44.     >> Cosmetic.
  45.     << SCRNIO,0
  46.  
  47.        SYSTEM FUNCTIONS
  48.  
  49.  6. Analyze user environment at startup and determine if suitable.  Save
  50.     any quantities needed and condition the line for entering commands.
  51.     Determine, if possible, the terminal controller type insofar as that
  52.     is necessary for establishing the method of file transfer.
  53.     >> Essential.
  54.     << SETMSG,1
  55.  
  56.  7. Reperform system-dependent initialization after SET LINE command
  57.     selects a new communication line.
  58.     >> Needed for SET LINE subcommand.
  59.     << SETMSG,5 + SCRNIO,3
  60.  
  61.  8. Reverse any setup performed in #6 and clean up before returning to
  62.     system.
  63.     >> Essential.
  64.     << SETMSG,4
  65.  
  66.  9. Obtain free storage block of specified length.  Return error code,
  67.     if possible, when enough storage is not available.  Method should
  68.     be re-entrant if possible and must preserve registers 2-13 without
  69.     recourse to the save area pointed to by R13.
  70.     >> Essential.
  71.     << * DMSFREE
  72.  
  73. 10. Release free storage block of specified address and length.
  74.     >> Essential.
  75.     << * DMSFRET
  76.  
  77. 11. Invoke the system HELP facility with optional operand string.
  78.     >> Cosmetic, but very useful.
  79.     << KHELP
  80.  
  81. 12. Start typeout interception.  If possible, this should include all
  82.     possible terminal output regardless of source.  At a minimum, it
  83.     must result in messages from Kermit itself being saved in a buffer
  84.     instead of displayed.  The intercepted output may be stored wherever
  85.     convenient.
  86.     >> Needed for REMOTE operations in server mode.
  87.     << SUPFNC,1
  88.  
  89. 13. Stop interception and restore normal terminal functions.
  90.     >> Needed for REMOTE operations in server mode.
  91.     << SUPFNC,5
  92.  
  93. 14. Retrieve intercepted messages and copy them, if necessary, to the
  94.     Kermit disk buffer.
  95.     >> Needed for REMOTE operations in server mode.
  96.     << SUPFNC,2
  97.  
  98. 15. Execute a host command (with or without interception).  Generally,
  99.     the command text may be of two different forms: either a text
  100.     string extracted from a text buffer or a canonical, internal
  101.     representation requiring perhaps less system overhead.  Commands
  102.     invoked by Kermit for purely internal purposes should be of the
  103.     latter form.  If possible, detect whether the command is legal
  104.     before invoking it.  Detect in any case whether the command is legal
  105.     sooner or later.
  106.     >> Cosmetic, but very useful.  If necessary, a minimal set of host
  107.        commands can be emulated.
  108.     << SUPFNC,3
  109.  
  110. 16. Retrieve original command string by which Kermit was invoked.  This
  111.     need not be done more than once (at startup).
  112.     >> Needed for specifying a subcommand in original command line.
  113.     << SUPFNC,6
  114.  
  115. 17. Log off the current session.
  116.     >> Needed for honoring BYE command.
  117.     << SUPFNC,8
  118.  
  119. 18. Wait for a specified time (in seconds).
  120.     >> Needed for DELAY parameter and possibly for screen synchronizing.
  121.     << SUPFNC,9
  122.  
  123. 19. Return the current clock time (in centiseconds).  The code is fully
  124.     generic, even though the function is done in SUPFNC.
  125.     >> Needed for statistics and long-packet optimizing.
  126.     << SUPFNC,10
  127.  
  128.        DISK/FILE-SYSTEM FUNCTIONS
  129.  
  130. 20. Select a "working directory" specified by a string extracted from
  131.     a text buffer.  The directory is, of course, a concept defined
  132.     within the context of the operating system.  Subsequent files are
  133.     preferentially read from and written to the directory.
  134.     >> Needed if the directory concept is implemented: CWD subcommand.
  135.     << CWDSET
  136.  
  137. 21. Show space available in the "working directory" or other area.
  138.     >> Needed for the SPACE subcommand.
  139.     << DSPACE
  140.  
  141. 22. Open a disk file by name for input (or return a non-zero code in
  142.     case of failure).  If necessary, refer to default file attributes
  143.     specified to Kermit to aid in locating the file.  Return a data area
  144.     filled with the file attributes and a pointer to a storage block
  145.     reserved for controlling the I/O (a "ticket").  OPENF is a generic
  146.     macro.
  147.     >> Essential.
  148.     << * OPENF I + DISKIO,1
  149.  
  150. 23. Open a disk file by name for output (or return a non-zero code in
  151.     case of failure).  If the file already exists, prepare to either
  152.     overwrite it or append to it as the occasion requires.  If the file
  153.     is to be extended, be sure its attributes are not altered.  Return
  154.     a data area and "ticket" as with opening for input.
  155.     >> Essential.
  156.     << * OPENF O + DISKIO,2
  157.  
  158. 24. Test for the existence of a file by name.  Return a data area with
  159.     the file attributes if found.
  160.     >> Essential.
  161.     << * OPENF T + DISKIO,3
  162.  
  163. 25. Close the file specified by a "ticket".  The ticket should then be
  164.     "blank", so that reclosing would have no ill effects.  CLOSF is
  165.     generic.
  166.     >> Essential.
  167.     << * CLOSF + DISKIO,4
  168.  
  169. 26. Write a record out to a disk file specified by a "ticket".  The data
  170.     address and length must be subject to change with each invocation,
  171.     but must be retained if not explicitly changed.  A completion code
  172.     of 13 must be returned if the write encounters a full disk.  Any
  173.     other I/O error must return some other non-zero code.
  174.     >> Essential.
  175.     << * WRITF + DISKIO,10
  176.  
  177. 27. Read a record in from a disk file specified by a "ticket".  The
  178.     buffer address and length must be subject to change with each
  179.     invocation, but must be retained if not explicitly changed.  If line
  180.     numbers are kept in predictable locations within each record, there
  181.     must be an option to remove them before returning the length of data
  182.     read.  If the end of the file is reached, a completion code of 12
  183.     must be returned.  An error must return some other non-zero code.
  184.     >> Essential.
  185.     << * READF + DISKIO,9 or DISKIO,0
  186.  
  187. 28. Update the disk directory for given file (specified by a "ticket")
  188.     such that the file is still open for output.
  189.     >> Needed for SET DEBUG SAVE subcommand.
  190.     << * SAVEF + DISKIO,21
  191.  
  192. 29. Set up disk directory search for files matching a given pattern
  193.     name.  This may entail as little as saving the pattern or as much
  194.     as creating a file with the complete list of matches.  Note: the
  195.     former is dangerous in a multi-user system if the name space to be
  196.     searched can be altered while Kermit is searching, especially if
  197.     control blocks can be unchained.  The latter approach also has a
  198.     drawback, in that files can still be created or deleted after the
  199.     "complete" list is made.  NXTFSET is a generic macro.
  200.     >> Needed for wildcard filespecs.
  201.     << * NXTFSET + DISKIO,5
  202.  
  203. 30. Fetch the next filespec from a directory search and get a pointer to
  204.     a list of its file attributes.  Must return a non-zero code if no
  205.     more files (and must persist even if called repeatedly).  NXTF is
  206.     a generic macro.
  207.     >> Needed for wildcard filespecs.
  208.     << * NXTF + DISKIO,6
  209.  
  210. 31. Clean up after a disk directory search.
  211.     >> Needed for wildcard filespecs.
  212.     << * NXTFSET END + DISKIO,7
  213.  
  214. 32. Check candidate name of a directory for validity and accessibility.
  215.     >> Needed for CWD subcommand.
  216.     << * NXTFSET CWD + DISKIO,8
  217.  
  218. 33. Test current directory (or environment) for sufficient disk space.
  219.     >> Cosmetic, used for processing A-packets.
  220.     << DISKIO,11
  221.  
  222. 34. Analyze disk I/O error; set up error message and code.  ERRF is a
  223.     generic macro.
  224.     >> Cosmetic, but useful.
  225.     << * ERRF + DISKIO,12
  226.  
  227. 35. Display directory information about specified file (possibly with
  228.     wildcard notation).
  229.     >> Needed for DIR subcommand.  Cosmetic, but very useful.
  230.     << DISKIO,13
  231.  
  232. 36. Delete a specified file.  ERASF is a generic macro.
  233.     >> Cosmetic, but useful, especially for REMOTE server functions.
  234.     << * ERASF + DISKIO,14
  235.  
  236. 37. Rename a specified file.
  237.     >> Cosmetic, but useful, especially for REMOTE server functions.
  238.     << DISKIO,15
  239.  
  240. 38. Copy a specified file.
  241.     >> Cosmetic, but useful, especially for REMOTE server functions.
  242.     << DISKIO,16
  243.  
  244. 39. Parse input string for a filespec under a variety of circumstances.
  245.     The name must be converted to a uniform internal format suitable for
  246.     Kermit I/O routines.
  247.       a) Native file for input (possible wild-card notation).
  248.       b) Native file for output.
  249.       c) Foreign filespec.
  250.       d) TAKE file (input or output).
  251.       e) Native file for utility operations.
  252.     >> Essential.
  253.     << FSPEC (q.v.)
  254.  
  255. 40. Check a given filespec for uniqueness and either generate a unique
  256.     new name if possible or return an error indication if necessary.
  257.     Possibly query the user for permission to overwrite a file that
  258.     already exists, provided the filespec was entered by hand.
  259.     >> Essential.
  260.     << FSPEC (q.v.)
  261.  
  262. 41. Convert an internal filespec to the form for transmission.
  263.     >> Essential.
  264.     << FSPEC (q.v.)
  265.  
  266. 42. Convert an internal filespec to the display form.
  267.     >> Needed for STATUS display and transaction log.
  268.     << FSPEC (q.v.)
  269.  
  270. 43. Open a library *per se* for purposes other than transferring its
  271.     members.  OPENF is a generic macro.
  272.     >> Useful if the concept of libraries is important.
  273.     << * OPENF L + DISKIO,22
  274.  
  275. 44. Skip over the first "n" records of a newly-opened input file.
  276.     POINTF is a generic macro.
  277.     >> Useful for SEND with line range.
  278.     << * POINTF + DISKIO,23
  279.  
  280.        COMMUNICATION FUNCTIONS
  281.  
  282. 45. Open a specified communication line for I/O (default to the terminal
  283.     connection).  Set parameters needed for transparent operation.  The
  284.     procedure may depend on the type of terminal (or line) controller
  285.     and should include both linemode and fullscreen types.  After the
  286.     line is open, if it is the terminal, no display messages will be
  287.     issued by Kermit, and messages from other sources should also be
  288.     suppressed, if possible.  These opening functions are to be divided
  289.     into controller-specific (of which there may be different variants)
  290.     and general.
  291.     >> Essential.
  292.     << TERMIO/SCRNIO,1 + SETMSG,2
  293.  
  294. 46. Close the current communication line.  Restore normal operation.
  295.     The same division of functions obtains as in #45.
  296.     >> Essential.
  297.     << TERMIO/SCRNIO,2 + SETMSG,3
  298.  
  299. 47. Write a packet to the communication line.  If possible, control the
  300.     entire contents, including terminators.  Also, if possible and if
  301.     Kermit will immediately be requesting a read, begin the following
  302.     read operation so that there is no delay between the completion of
  303.     the write and the readiness of the system to read -- this may be
  304.     important in a heavily loaded time-sharing environment.
  305.     >> Essential.
  306.     << TERMIO/SCRNIO,4
  307.  
  308. 48. Read a packet from the communication line.  If possible, suppress
  309.     any prompts the system might normally supply.  If possible, arrange
  310.     for a timer interrupt after a specified wait such that the I/O
  311.     request can be cancelled.
  312.     >> Essential.
  313.     << TERMIO/SCRNIO,5
  314.  
  315. 49. For fullscreen lines, write a message to the screen despite the line
  316.     having been opened.
  317.     >> Cosmetic, but useful.
  318.     << SCRNIO,6
  319.  
  320. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  321. B. Hints.
  322.  
  323. In general, the operation of porting Kermit-370 entails starting from
  324. one or more existing versions of the system-specific code (IKxMAC.ASM
  325. and IKxUTL.ASM) and replacing one set of system-specific code with
  326. another.  Each subroutine has comments documenting the interface with
  327. the rest of the program, and a fair amount of the code itself deals with
  328. such bookkeeping details and can be carried over.  Similarly, each macro
  329. begins with a brief function/syntax description.  In one example
  330. (porting Kermit-370 to the MUSIC O.S.), about 2/3 of the final macro
  331. definition code had been carried across from CMS as well as about 2/5 of
  332. the final MUSIC-specific subroutine code.  In all, only about 850 lines
  333. of non-comment code had to be written.  In another example (porting to
  334. CICS), only about 1/2 of the macro definition code had been carried
  335. across, along with about 1/4 of the subroutine code.
  336.  
  337. In some cases, particularly when the operating system is supplied in
  338. source form, it may be useful to examine the system code and macro
  339. definitions for helpful hints on the techniques of invoking system
  340. functions, manipulating filespecs, and the like.  Care should be taken,
  341. of course, not to violate copyright restrictions.
  342.  
  343. ------------------------------------------------------------------------
  344. Parameters.
  345.  
  346. It is necessary to define the symbols in the SSYMS macro.  A useful
  347. technique is to compare two existing variants to determine which
  348. symbols are always present.  Items in the KSYSTF macro are also system-
  349. specific, and many of them are required in all variants; some are not
  350. required, but are generally useful (again, compare existing variants
  351. for tips).
  352.  
  353. ------------------------------------------------------------------------
  354. Entry and exit conditions.
  355.  
  356. Kermit at entry should have R13 -> 72-byte save area and R15 -> Kermit,
  357. and there must be a macro SAVE similar to that of MVS.  If there is no
  358. system macro SAVE, Kermit must supply one itself.  If necessary, that
  359. macro can distinguish between internal linkages (in which R13, R14, and
  360. R15 *must* follow type-I conventions) and the initial call from the
  361. system (which may be anything at all).  The entry conditions for Kermit
  362. consist of two macro calls:
  363.          SAVE  (14,12),,&LABEL
  364.          KMAIN ENTER
  365. plus code appropriate to internal linkages.  &LABEL will be either GUPI
  366. or KERMIT.  For internal linkages, that parameter is always "*".  After
  367. the invocation of KMAIN, R13 must point to the original save area, of
  368. which the first 12 bytes must be unused, and if the values originally in
  369. R0 and R1 were important, they must be saved in bytes 20-27.  KMAIN
  370. ENTER must assign free storage and zero-fill it; point register KWRKBASE
  371. at the storage, register KSUBBASE at Kermit, and R10 at COMMON; and set
  372. up pointers to the stack.  KMAIN RETURN must release the storage,
  373. restore any registers necessary, and return to the system with the
  374. proper condition code (initially in R15).
  375.  
  376. ------------------------------------------------------------------------
  377. FSPEC.  Notes from source code:
  378.  
  379. * Entry: R1->name field, R0=flags selecting operation (see below)
  380. *        For parse operations, SCANPTR defines the input string.
  381. *        For getting foreign or display filespec, R7->output buffer
  382. * Exit: if not FFNEW, then R15=0 if ok, 1 if ?, 2 if bad.
  383. *        For R15=1 or 2 R3,R4 give message.  ERRNUM may be leftover.
  384. *
  385. *                                 Flags:                  Notes:
  386. *   Tasks:               FFRCF FFSND FFGET FFNEW
  387. * Parse RECV               X                     set ROVR properly
  388. * Parse SEND 1st                 X
  389. * Parse SEND 2nd           X     X
  390. * Parse GET 1st                        X
  391. * Parse GET 2nd            X           X         set ROVR properly
  392. * Parse F-packet   (FFHDR) X     X     X
  393. * Parse for Generic(FFUTL)       X     X         FFWLD: allow partial
  394. * Parse TAKE
  395. *
  396. * Get unique name                            X     R15: 0=>ok, 1=>bad
  397. * Interactive name check               X     X     R15: 0=>ok, 1=>bad
  398. * Get foreign name (FFENC) X                 X     R15->end of string
  399. * Get display form (FFDSP)       X           X     R15->end of string
  400.  
  401. Further explanation of entry conditions -
  402. "name field" is a fixed-length string of length LFID to be filled with
  403. the internal representation of a file name.  SCANPTR is a pair of
  404. pointers (LEN, ADR) of a character string to be parsed, typically a
  405. string typed by the user, possibly in lower case.  Note: Kermit assumes
  406. that a file specification will fit into a string of no more than 256
  407. bytes, i.e., LFID must be <257.
  408.  
  409. FSPEC parses out one filename at a time.  There is, of course, the
  410. alternate command syntax for SEND that allows the user to specify a list
  411. of files.  The only contribution of FSPEC to the parsing is to note the
  412. delimiter it finds after the name; the list control is managed by the
  413. generic code.
  414.  
  415. SEND takes one or two parameters, namely, the native filename and,
  416. optionally, a different filename to send to the other Kermit.  A
  417. reversed pair of parameters is taken for the GET subcommand: a required
  418. "foreign" filename and an optional overriding "native" one.  Foreign
  419. filenames, since they depend on the system of the other Kermit, might be
  420. thought of as independent of the IBM/370 operating system, but
  421. Kermit-CMS offers a special syntax extension that isn't implemented in
  422. Kermit-TSO.  Anyway, that is the meaning of SEND 1st, etc.  The foreign
  423. filename, by the way, is stored in JFSPEC, which is a varying-length
  424. string in COMMON (one-byte length indicator, followed by a maximum of 47
  425. bytes).  "Parse RECV", in case that's not clear, means grab the
  426. filename, if any, entered on the RECEIVE subcommand, and (as the Note
  427. says), set flag ROVR in FL1, if a filename is actually found.  I also
  428. note that the code clears flag NMOK in FL4 (in the CMS version), but
  429. that happens to be part of the internal logic of FSPEC to avoid
  430. duplicate efforts in filename collision testing.  "Parse F-packet" means
  431. grab a (valid) filename from the file header sent from the other Kermit.
  432. "Parse for Generic" means grab a filename from the text string sent by
  433. the other Kermit for one of the Generic Server mode commands.  The
  434. corresponding Note says that FFWLD set in the input flags means that
  435. part or all of the filename can be omitted to indicate all matching
  436. files, as in the DIRECTORY command.  "Parse TAKE" means grab a file name
  437. from the text of a TAKE subcommand.
  438.  
  439. The difference between "Get unique name" and "Interactive name check" is
  440. that the latter is permitted to type out a message and query the user
  441. for further instructions if necessary (as might be the case when the
  442. user types RECEIVE DUP.FILE), while the former must either find a unique
  443. name, or return an error condition.  "Get foreign name" means putting
  444. the foreign filespec into a buffer (in ASCII) with JFSPEC taking
  445. precedence over whatever is found at (R1).  Finally, "Get display form"
  446. is just the reverse of the various parse operations: the internal
  447. representation is converted to conventional external representation
  448. (with excess blanks, if any, removed according to whatever convention
  449. holds).
  450.  
  451. ------------------------------------------------------------------------
  452. FDB.  File Descriptor Block + File Access Block:
  453.  
  454. In IKxMAC.ASM, the FDBD macro has two parts, an FAB and FDB.  The FAB is
  455. intended to map the operating system's macro, whereas the FDB is
  456. Kermit's local variables.  Some of the variables in the FDB are used
  457. throughout the generic Kermit code.  The common part begins at FDBD and
  458. includes everything mapped by FDBPAT macro, and also includes FABLRTR,
  459. which is a recent addition giving the maximum record length for output
  460. to a file (which may in CMS, for example, differ from the current
  461. largest record length).
  462.  
  463. ------------------------------------------------------------------------
  464. Host command execution.
  465.  
  466. Not all operating systems make it possible for one application program
  467. (such as Kermit) to invoke another.  When that is not possible, Kermit
  468. should make an effort to emulate the basic file-management commands
  469. corresponding to DISKIO functions 13-16 plus the appropriate commands
  470. (even if the system doesn't have them) to invoke on-line help and to
  471. display a file at the terminal.  For an example of how such emulation
  472. can be done, see function 3 of SUPFNC in the MUSIC version of Kermit.
  473. Some calls to SUPFNC are generated internally by Kermit-370 itself
  474. (these are identified by *not* having flag UCMD set in FL4).  Such calls
  475. should not require any syntax checking and may, in fact, be already
  476. converted to a special "system" format, if any, suitable for passing
  477. directly to the command processor.  The details of formatting and syntax
  478. check will, of course, be highly system-specific.
  479.  
  480. ------------------------------------------------------------------------
  481. SCRNIO.  Fullscreen packet I/O.  See part C for calling sequence info.
  482.  
  483. For the Series/1 interface (and whenever else possible), Kermit-370
  484. takes advantage of a Read chained to a Write to speed up the I/O.
  485. Actually, the operation is chained by the Series/1, so Kermit issues
  486. both a write and a read synchronized by a hardware interrupt from the
  487. Series/1.
  488.  
  489. Fullscreen buffer limits are defined by symbols MAXWS and MAXRS set in
  490. macro SSYMS.
  491.  
  492. In principle, all you need to know is the sequence of calls to SCRNIO.
  493. You can handle the system interface in any convenient manner.  The
  494. sequence is (by R0 code): 1, 6 (with greetings message), 4, 5, 4, 5, ...
  495. 4, 5, 2.  The value of WRRD determines whether a "4" means Write/Read
  496. (value is 5) or just Write (value is 0) -- that value will always be 5
  497. except possibly the last time.  Even if WRRD is 0 on the last call with
  498. R0=4, there will still be a call with R0=5 just afterwards, followed by
  499. a call to release control of the screen.
  500.  
  501. The difference between "4" and "6" is just that no read is required
  502. following a "6".  Also, "6" is intended for displaying messages to the
  503. user, in case he's watching, but "4" is for sending to the micro Kermit.
  504.  
  505. ------------------------------------------------------------------------
  506. TERMIO.  Similar to SCRNIO in many respects.
  507.  
  508. TTY buffer limits are defined by symbols MAXWT and MAXRT set in the
  509. macro SSYMS.
  510.  
  511. The way to signal a timeout from TERMIO is to return a packet of exactly
  512. one character: an ASCII 'T'.  You can see an example by looking at the
  513. TSO version.
  514.  
  515. There is a potential problem for Kermit transfers that arises if the
  516. user has a printable character for any editing functions used in the
  517. interpretation by the system of terminal input.  Examples of such
  518. functions include character-delete and line-end (both normally found
  519. only on line-mode terminals).  If such a character appears in a packet
  520. sent to the 370, the packet will be mangled unless Kermit takes special
  521. precautions.  CMS Kermit deals with the problem by noting the LINEDIT
  522. setting when it starts up, turning off LINEDIT during a protocol
  523. transfer, and restoring LINEDIT afterwards.  TSO Kermit, on the other
  524. hand, simply suppresses the user's line and character deletes during a
  525. transfer (and simultaneously saves the current values) and then restores
  526. them afterwards.  The functions of saving, changing, and restoring the
  527. edit characters would be performed under variants 1, 2, and 3,
  528. respectively, of SETMSG.
  529.  
  530. ------------------------------------------------------------------------
  531. Type-out interception.
  532.  
  533. Intercepting host command output depends on the operating system
  534. facilities.  In any case, the info would go directly to the screen
  535. unless you first call SUPFNC,1 to start typeout interception.  For
  536. example, under CMS that means intercepting all SVC's (and BALR's to the
  537. system typeout entry point) and copying the corresponding info into a
  538. buffer as it's generated (leaving x'15' separators).  That sort of
  539. operation is self-pacing, so that the cleanup consists of nothing more
  540. than copying the end-of-buffer pointer into a global variable.  Under
  541. TSO, the setup call creates a STACK entry such that the TSO-type
  542. utilities will write to a pre-allocated dataset.  Cleanup in that case
  543. consists of closing the file and then reading the file into the buffer,
  544. again with X'15' (Newline) characters separating lines, and finally
  545. copying out the end-of-buffer pointer.
  546.  
  547. If there's no general way to save the output of a class of utility
  548. programs, then you would just have to do what you can: put any
  549. preliminaries in SUPFNC,1 and the nitty-gritty (for, say, DIR) in
  550. DISKIO,13 with the buffer-read-back in SUPFNC,2/SUPFNC,5.  You might
  551. want to get a copy of TSO Kermit to see how it does things.
  552.  
  553. The expansion for WTEXT in the TSO version generates a call to a
  554. subroutine in COMMON which checks the interception flags and then either
  555. issues a TPUT or copies the info into the output buffer.
  556.  
  557. ------------------------------------------------------------------------
  558. GUPI.
  559.  
  560. Updates for Kermit-370 are in the same format as in CMS, except that the
  561. multi-level updates are applied from a single, concatenated file, rather
  562. than a flock of separate updates listed by an AUX.  You should take a
  563. look at implementing the generic update program GUPI for your operating
  564. system.
  565.  
  566. Bear in mind that there are almost always some updates to the base
  567. generic source, so the "package" for installation must include a means
  568. of applying those, and it would also be nice if subsequent changes,
  569. particularly generic changes, could be transmitted to all systems in the
  570. same form.  In any case, instructions for applying updates should be
  571. included in the IKxKER.BWR file (see IKCKER.BWR for a pattern).  It is
  572. pretty easy to make a GUPI, once you've got Kermit: just take subroutine
  573. DISKIO (functions 1, 2, 3, 4, 9, and 10) plus any associated data
  574. structures and tack on a command interface.  GUPI uses the same macros
  575. as Kermit.  You can see a working example by getting IKTGUP.ASM +
  576. IK0GUP.ASM from Columbia.  The only complication is that you'll need to
  577. make a macro library consisting of the macros in IK0MAC.ASM, IKxMAC.ASM,
  578. and IKxGUP.ASM.  The awkward (but workable) alternative would be to
  579. convert all the COPY blocks in GUPI into macros as the MUSIC version
  580. does.  Making a macro libary is simplified by the structure of the code:
  581.  
  582.  a) All the pieces have *COPY cards imbedded appropriately (the source
  583.     components have each macro preceded by a card of the form
  584.     *COPY                                              macro-name
  585.     to improve legibility).
  586.  
  587.  b) The builder may concatenate all the pieces in any order, both for
  588.     Kermit itself and GUPI, then change the *COPY cards into the
  589.     appropriate member-separators, and finally run the result through a
  590.     PDS (library) generator.
  591.  
  592.  c) The "real" source for Kermit or GUPI can then be a small skeleton
  593.     which consists of comments and COPY instructions (which refer to
  594.     members of the macro+source library).
  595.  
  596. ------------------------------------------------------------------------
  597. Reentrancy.
  598.  
  599. Kermit-370 is fully re-entrant in the generic sections, and provides a
  600. simple means for any system-specific code to be re-entrant as well.  The
  601. ENTER, LOCALS, and EXIT macros can (and should) be used to begin a new
  602. routine, end the static code, and end the routine, respectively.
  603. Storage locations defined between the LOCALS and EXIT macros are
  604. allocated as temporary variables and initialized to zeroes for each
  605. invocation of the subroutine (and may be allocated recursively, if
  606. necessary).  Sufficient stack space must be reserved for Kermit by
  607. setting the symbol STKDWDS in the SSYMS macro.  The requirement is 18
  608. doublewords per subroutine call plus the sum of all temporaries (rounded
  609. up to doublewords) for the subroutines in the longest path.  There is
  610. automatic overflow checking at each subroutine call performed by COMMON
  611. code routine named SUBENT.  The result of overflow is an immediate
  612. return with an error code from the subroutine, but that may still lead
  613. to unpredictable consequences, and STKDWDS should be given generous
  614. proportions.  When TEST is set on in Kermit-370, the STATUS subcommand
  615. displays the maximum extent of stack space used (in doublewords).
  616.  
  617. ------------------------------------------------------------------------
  618. Miscellaneous notes.
  619.  
  620. 1. Does your O.S. have a LINEND character facility like VM?  If not, it
  621.    might pay to copy the implementation of that from TSO Kermit.  This
  622.    will, of course, mean some changes to IKxMAC.
  623. 2. Would TAKE files generated by Kermit users tend to have line
  624.    numbers imbedded?  If so, it would pay to copy/adapt the stripping
  625.    facility of TSO or CMS Kermit.
  626. 3. Does your O.S. have a way of timing out on a line-mode terminal read?
  627.    The way to signal a timeout from TERMIO is to return a packet of
  628.    exactly one character: an ASCII 'T'.  You can see an example by
  629.    looking at the TSO variant.
  630. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  631. C. Module summary
  632.  
  633. This summary was produced for Kermit-CMS 4.2.2.  The system-specific
  634. modules vary (of course), but all should be quite similar to the
  635. CMS variant.  Some of the differences lie in whether a particular
  636. entry point is treated as a separate routine or not.
  637.  
  638.           ALPHABETIC LIST OF SUBROUTINES
  639. Each item begins with a one-line description, possibly followed by more
  640. details, including entry and exit conditions and function.  If any
  641. alternate entry points exist, each one is similarly described.  Finally,
  642. all common references, callers, and calls are lists -- these are joint
  643. lists in the cases of routines with alternate entries.
  644.  
  645. ACCTNG: save statistics for a transfer in the transaction log
  646.      ENTRY ACCTST
  647.  * add a new entry (name only) to the transaction log
  648.      CALLERS- RECEIV  SEND
  649.  
  650. COMMON: Kermit-370 common routines/data areas
  651.        CALLS- CWDSET  DECODE  DISKIO  DUMP    ENCODE  FSPEC   INTINI
  652.               RIO     RPACK   RPAR    SET     SPACK   SPAR    STATUS
  653.               SUPFNC
  654.  
  655. CRCCLC: calculates crc
  656.  * Calculate the CRC and return it in R15.  Expects R5 to point to the
  657.  * start of the data on which the CRC is calculated, and R6 to the
  658.  * char after the last one.
  659.      CALLERS- RPACK   SPACK
  660.  
  661. CWDSET (system-specific): set working directory
  662.  * Set new 'working directory', i.e., filemode letter
  663.  * Entry: SCANPTR string has option
  664.  * Exit: R15=0 if ok, R15=1 if error or help needed. ERRNUM unchanged.
  665.      ENTRY DSPACE
  666.  * Show space in 'working directory' or other minidisk
  667.  * Entry: SCANPTR string has option (none => working directory)
  668.  * Exit: R15=0 if ok, R15=1 if error or help needed. ERRNUM unchanged
  669.      COMMONS- COMMON
  670.      CALLERS- COMMON  SERVER  SET
  671.        CALLS- DISKIO
  672.  
  673. DECODE: decode pkts from RDATA to WBUF
  674.  * Exit: ERRNUM left unchanged unless there is an error.
  675.      CALLERS- COMMON  GENCMD  RECEIV
  676.        CALLS- OUTBUF
  677.  
  678. DISKIO (system-specific): performs disk I/O functions
  679.  * ERRNUM unchanged unless there is a disk error.
  680.  * Function selected on entry by R0:
  681.  * 0=> unnum: R1->FAB.  Return R1->buffer,R0=# and remove the sequence
  682.  *     number (if any) from the buffer (used for TAKE files)
  683.  * 1=> open (in): R1->pattern FDB, R2->name.  Returns R0->FAB, R1->FDB
  684.  * 2=> open (out): (same)
  685.  * 3=> test name: R2->name.  Returns R1->FDB if found (else R15=1)
  686.  * 4=> close file: R1->adr(FAB).
  687.  * 5=> set up search: R1->pattern name.
  688.  * 6=> return next file in list:  Returns R1->FDB + sets up FILNAM
  689.  * 7=> close search (if any).
  690.  * 8=> test CWD string: R1->string.  Returns R15=0 if ok, else =1.
  691.  * 9=> read: R1->FAB.  Returns R15=12 if EOF, 0 if ok; R0=# data
  692.  * 10=> write: R1->FAB.  Returns R15=13 if disk full, 0 if ok.
  693.  * 11=> test space: R1->pattern FDB (has size in Kbytes),
  694.  *   R2->name (used if FAB not found), R6->adr(FAB). Return R15=0 if ok.
  695.  * 12=> analyze R/W error, set ERRNUM, make EMSG: R1->FAB, TMPDW=code
  696.  *      always returns R15=1
  697.  * 13=> directory info on file: R1->name.  Returns R15=0 if ok.
  698.  * 14=> delete file: R1->name.  Returns R15=0 if ok.
  699.  * 15=> rename file: R1->name, R2->new name.  Returns R15=0 if ok.
  700.  * 16=> copy file: R1->name, R2->new name.  Returns R15=0 if ok.
  701.  * 21=> save file status in directory: R1->FAB. (not used)
  702.  * 22=> open library (in): R2->DDNAME.  Return R15=0 if ok.
  703.  * 23=> point for next read, R1->adr(FDB), R2=records to skip.
  704.  *      Return R15=0 if ok.
  705.      CALLERS- COMMON  CWDSET  DUMP    FSPEC   GENCMD  INBUF   KERMIT
  706.               OUTBUF  RECEIV  RIO     SEND    SERVER  SET     USNTRF
  707.        CALLS- SUPFNC
  708.  
  709. DUMP: show translation table or transaction log
  710.  * Display current contents of table or log
  711.  * Entry: SCANPTR string has option
  712.  * Exit: R15=0 if ok, R15=1 if error or help needed. ERRNUM unchanged.
  713.      ENTRY DUMPTOD
  714.  * Extra entry point for dumping TOD (in sec) from R0 into buf
  715.  * at R1 and return updated buffer ptr in R15
  716.      ENTRY GIVTAB
  717.  * Save current translation table in STORAG into a TAKE file on disk
  718.  * Entry: SCANPTR string has option
  719.  * Exit: R15=0 if ok, R15=1 if error or help needed.  ERRNUM set
  720.  *       appropriately as long as command syntax is ok, else unchanged.
  721.      COMMONS- ERRTAB
  722.      CALLERS- COMMON  SCRNIO
  723.        CALLS- DISKIO  FSPEC   STATUS  TBLSET
  724.  
  725. ENCODE: encode from RBUF into SDATA buffer
  726.      CALLERS- COMMON  SEND
  727.        CALLS- INBUF
  728.  
  729. ERPACK: send error packet based on ERRNUM
  730.      COMMONS- ERRTAB
  731.      CALLERS- GENCMD  RECEIV  SEND    SERVER
  732.        CALLS- SPACK   STATUS
  733.  
  734. FOPSTR: test string for file options
  735.  * Entry: R1->Address of option field, R6->string, R7=length - 1
  736.  * Exit: R15=0 + R6,R7 fixed if ok, R15=1 if error (msg ptrs set up)
  737.      CALLERS- FSPEC
  738.  
  739. FSPEC (system-specific): extract filespec from scan string
  740.  * Entry: R1->name field, R0=flags selecting operation (see below)
  741.  *        For parse operations, SCANPTR defines the input string.
  742.  *        For getting foreign or display filespec, R7->output buffer
  743.  * Exit: if not FFNEW, then R15=0 if ok, 1 if ?, 2 if bad.
  744.  *        For R15=1 or 2 R3,R4 give message.  ERRNUM may be leftover.
  745.  * See part B for calling flags.
  746.      CALLERS- COMMON  DUMP    GENCMD  RECEIV  SERVER  SET     USNTRF
  747.        CALLS- DISKIO  FOPSTR
  748.  
  749. GENCMD: send a Generic command
  750.  * Entry: SCANPTR has string
  751.  * Exit: R15=0 if ok, 1 if help needed, 2 if bad parameter
  752.  *       ERRNUM set appropriately
  753.      CALLERS- USNTRF
  754.        CALLS- DECODE  DISKIO  ERPACK  FSPEC   INTINI  OUTBUF  RECEIV
  755.               SEND
  756.  
  757. INBUF: read next disk record into RBUF
  758.  * Exit: R15=0 if ok, -1 if EOF, 1 if read error (ERRNUM set)
  759.      CALLERS- ENCODE  NPREAD
  760.        CALLS- DISKIO
  761.  
  762. INTINI: Initialize/reset terminal for protocol
  763.  * If R1 is 0, reset for interactive unless in Server mode.
  764.  * If R1 is positive, set up for protocol:
  765.  *  1 for SERVER, 2 for SEND, 3 for RECEIVE, 4 for short msg
  766.  * R15 = 0 on return if ok
  767.      CALLERS- COMMON  GENCMD  SEND    SERVER  USNTRF
  768.        CALLS- SCRNIO  SUPFNC  TERMIO
  769.  
  770. KERMIT: main entry point
  771.  * Assign buffers, initialize STORAG section; do Kermit; return.
  772.      COMMONS- COMMON  KSYSNIT
  773.        CALLS- DISKIO  SCRNIO  SPAR    TBLSET  USNTRF
  774.  
  775. KHDMP: dump storage to log file (not generated unless &KTRACE is YES)
  776.  * Dump area to log
  777.  * Entry: R1->area, R0=length, R2-> 8-byte title for area
  778.  * Exit: R15=0 if ok
  779.  
  780. KHELP (system-specific): perform HELP command
  781.  * Handle HELP command, rest of string given by SCANPTR.
  782.      COMMONS- SETCMDS
  783.      CALLERS- USNTRF
  784.        CALLS- SUPFNC
  785.  
  786. NPREAD: copy from RBUF to SDATA buffer (no encoding)
  787.      CALLERS- SEND
  788.        CALLS- INBUF
  789.  
  790. OPTPKT: compute optimum packet size
  791.  * Entry: TINSV contains stack of data
  792.  * Exit: R15=0 if no limit, else optimum packet size (per algorithm)
  793.      CALLERS- SEND    STATUS
  794.  
  795. OUTBUF: write record from WBUF to a disk file
  796.  * Entry: R1=length of buffer (which starts where WBUF points)
  797.  * Exit: R15=0 if ok, other if error (ERRNUM set)
  798.      CALLERS- DECODE  GENCMD  RECEIV
  799.        CALLS- DISKIO
  800.  
  801. RECEIV: receives a file
  802.  * Receive file(s) and set ERRNUM appropriately
  803.  * Entry: filespec in FILNAM if ROVR is set, latest received packet
  804.           in buffer
  805.      COMMONS- COMMON
  806.      CALLERS- GENCMD  SERVER  USNTRF
  807.        CALLS- ACCTNG  DECODE  DISKIO  ERPACK  FSPEC   OUTBUF  RPACK
  808.               RPAR    SPAR    SUPFNC  TBLSET
  809.  
  810. RIO: Read packet into receive packet buffer
  811.      ENTRY SIO
  812.  * Send packet in SNDPKT
  813.      CALLERS- COMMON  RPACK   SEND    SPACK
  814.        CALLS- DISKIO  SCRNIO  TERMIO
  815.  
  816. RPACK: Read and validate a packet
  817.  * ERRNUM set if error found, unchanged otherwise
  818.      CALLERS- COMMON  RECEIV
  819.        CALLS- CRCCLC  RIO
  820.  
  821. RPAR: sets up parms to send to other host
  822.      ENTRY RPARSET
  823.  * set up for exchange (RPAR to be called 1st)
  824.      CALLERS- COMMON  RECEIV  SEND    SERVER
  825.        CALLS- SCRNIO  TERMIO
  826.  
  827. SCRNIO (system-specific): Handle screen I/O via protocol converter
  828.  * R1 points to a pair of (adr,len) for read or write.  If I/O is
  829.  * successfull, R15 returns transferred byte count (else returns -1).
  830.  *               Command code is in R0:
  831.  * 0 => Clear screen on console (not comm line)
  832.  * 1 => Open screen for I/O            4 => Write packet
  833.  * 2 => Close screen                   5 => Read packet
  834.  * 3 => Reset screen status after      6 => Write message (no ATTN)
  835.  *      environment changes            7 => Read screen buffer
  836.      ENTRY SETMSG
  837.  * Entry: R1 selects operation
  838.  * Exit: R15=0 if ok
  839.  * 1-> Analyze user environment, determine if suitable.
  840.  *     Save quantities needed and condition line for entering commands.
  841.  *     Perform any system-dependent initialization.
  842.  * 2-> Condition line for protocol transfers.
  843.  * 3-> Decondition line at end of transfer.
  844.  * 4-> System-dependent clean-up at exit.
  845.  * 5-> Reperform system-dependent initialization after SET LINE.
  846.      COMMONS- KSYSNIT
  847.      CALLERS- INTINI  KERMIT  RIO     RPAR    SET     SUPFNC
  848.        CALLS- DUMP    USNTRF
  849.  
  850. SEND: sends a file
  851.  * Send file(s) and set ERRNUM appropriately
  852.  * Entry: filespec pattern in IFILE, Disp code (if any) in R1
  853.      CALLERS- GENCMD  SERVER  USNTRF
  854.        CALLS- ACCTNG  DISKIO  ENCODE  ERPACK  INTINI  NPREAD  OPTPKT
  855.               RIO     RPAR    SPAR    SUPFNC
  856.  
  857. SERVER: performs Server mode functions
  858.  * Exit: ERRNUM set appropriately.
  859.      CALLERS- USNTRF
  860.        CALLS- CWDSET  DISKIO  ERPACK  FSPEC   INTINI  RECEIV  RPAR
  861.               SEND    SPAR    SUPFNC  USNTRF
  862.  
  863. SET: perform SET command options
  864.  * Set/change values in STORAG.
  865.  * Entry: SCANPTR string has option
  866.  * Exit: R15=0 if ok, 1 if help needed, 2 if bad parameter name
  867.  *       ERRNUM unchanged
  868.      ENTRY SHOW
  869.  * Display current values in STORAG.
  870.  * Entry: SCANPTR string has option
  871.  * Exit: R15=0 if ok, 1 if help needed, 2 if bad parameter name
  872.  *       ERRNUM unchanged
  873.      COMMONS- SETCMDS ETCETERA
  874.      CALLERS- COMMON
  875.        CALLS- CWDSET  DISKIO  FSPEC   SCRNIO  SETCMDS SUPFNC  TBLSET
  876.  
  877. SPACK: fill sending packet buffer and send it
  878.      CALLERS- COMMON  ERPACK  USNTRF
  879.        CALLS- CRCCLC  RIO
  880.  
  881. SPAR: use parms from other host in RDATA
  882.      ENTRY SPARSET
  883.  * set up for exchange (SPAR to be called 1st)
  884.      CALLERS- COMMON  KERMIT  RECEIV  SEND    SERVER
  885.  
  886. STATUS: display latest error (if any), transfer statistics, etc.
  887.  * Exit: R15=0.  ERRNUM unchanged.
  888.      ENTRY PEMSG
  889.  * Display just error message and its backup explanations.
  890.      COMMONS- ERRTAB
  891.      CALLERS- COMMON  DUMP    ERPACK  USNTRF
  892.        CALLS- OPTPKT
  893.  
  894. SUPFNC (system-specific): various supervisor functions
  895.  *  On entry, R1 = operation code, R0 = possible ptr
  896.  * Exit: R15 set (0 => ok, <0 => illegal cmd, >0 => depends)
  897.  *       ERRNUM set appropriately (R1=1,3,4) or unchanged (2,5-11)
  898.  * 1 -> Start typeout interception.  N.B.  &MAXLR >> 2048 for this
  899.  * 2 -> Clean up afterwards and stop interception
  900.  * 3 -> Execute host command with or without interception
  901.  *      If UCMD set, SCANPTR gives text, else R0->text,R6=len
  902.  * 4 -> Execute CP command with or without interception
  903.  *      R0->text, R6=len
  904.  * 5 -> Stop interception if going
  905.  * 6 -> Retrieve original cmd parm string into CBUF (R15=1 if null)
  906.  * 7 -> Test for stacked lines, return number in R15
  907.  * 8 -> Log off (doesn't return!)
  908.  * 9 -> Wait specified time
  909.  * 10-> Return clock time in R15 (centisec)
  910.  * 11-> Setup up new prompt string at (R0)
  911.      CALLERS- COMMON  DISKIO  INTINI  KHELP   RECEIV  SEND    SERVER
  912.               SET     USNTRF
  913.        CALLS- SCRNIO
  914.  
  915. TBLSET: set up character set
  916.  * Define new translation tables
  917.  * Entry: Names of table in TRNALF and FILALF, R1->tables
  918.  *        R0->item just changed, if any (else, 0)
  919.  *        Tables should be a pair with ATOE first
  920.  * Exit: R15=0 if ok, R15=1 if error ERRNUM unchanged.
  921.      ENTRY TBLATT
  922.  * Entry: R6->Designator string, R7=length
  923.  * Exit:  Correct table set up and R15=0 if ok, else 1
  924.      COMMONS- COMMON  TRNTBLD
  925.      CALLERS- DUMP    KERMIT  RECEIV  SET
  926.  
  927. TERMIO (system-specific): Handle terminal I/O
  928.  * R1 points to a pair of (adr,len) for read or write.  If I/O is
  929.  * successfull, R15 returns transferred byte count (else returns -1).
  930.  *               Command code is in R0:
  931.  * 1 => Open line for I/O            4 => Write packet
  932.  * 2 => Close line                   5 => Read packet
  933.  * 3 => Reset line status after    ( 6 => Write message ) not used
  934.  *      environment changes        ( 7 => Read buffer ) not used
  935.      COMMONS- COMMON
  936.      CALLERS- INTINI  RIO     RPAR
  937.  
  938. USNTRF: execute main loop
  939.  * Execute Kermit commands (beginning with default TAKE files)
  940.  * Entry: environment already set up
  941.  * Exit: R15=0, ERRNUM set appropriately
  942.      COMMONS- COMMON
  943.      CALLERS- KERMIT  KHELP   SCRNIO  SERVER
  944.        CALLS- DISKIO  FSPEC   GENCMD  INTINI  KHELP   RECEIV  SEND
  945.               SERVER  SPACK   STATUS  SUPFNC
  946.  
  947. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  948.  
  949.           ALPHABETIC LIST OF COMMON BLOCKS
  950.  
  951. COMMON: Kermit-370 common data areas
  952.      USED BY- CWDSET  KERMIT  KSYSNIT RECEIV  TBLSET  TERMIO  USNTRF
  953.  
  954. ERRMSGS: text of error messages
  955.      USED BY- ERRTAB
  956.  
  957. ERRTAB: List of error messages
  958.      COMMONS- ERRMSGS
  959.      USED BY- DUMP    ERPACK  STATUS
  960.  
  961. ETCETERA: overflow from COMMON
  962.      USED BY- SET
  963.  
  964. KSYSNIT: initial parameter values
  965.      USED BY- KERMIT  SCRNIO
  966.  
  967. SETCMDS: tables of command keywords
  968.      USED BY- KHELP   SET
  969.  
  970. TRNTBLD: translation tables and variations thereon
  971.      USED BY- TBLSET
  972.