home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / trs80model4 / m4file.asm < prev    next >
Assembly Source File  |  1986-10-21  |  4KB  |  174 lines

  1. ;        m4file/asm
  2. ;
  3. ;    The close command.  At present, only SESSION is valid
  4. ;
  5. CLSFLS    CALL    GETLOGF        ;Get the logfile descriptor
  6.     IFNZ    CLSF10        ;Skip if not SESSION LOG FILE
  7.     LD    A,(LOGFLG)    ;Check to see if session log open
  8.     IFZ    CLSF07        ;If already closed, then jump to message
  9.     XOR    A        ;Reset the FILE OPEN flag
  10.     LD    (LOGFLG),A
  11.     LD    DE,LFCB        ;Get the FCB for the CLOSE
  12.     CALL    XCLOSE        ;Close the file if possible
  13.     CALL    NZ,XERROR0    ;Print a message if file not closed right
  14.     JR    CLSF08        ;Back for another command
  15. CLSF07    STROUT    NOLOGF        ;Print LOG FILE NOT OPEN message
  16. CLSF08    JP    KERMIT        ;Back for another command
  17. ;
  18. ;    Check the debug logfile
  19. ;
  20. CLSF10    IFANOT    1,CLSF30    ;If not debug then try transaction
  21.     LD    A,(DEBLOG)    ;Check if logging in effect
  22.     IFZ    CLSF07
  23.     XOR    A        ;Zap the open flag
  24.     LD    (DEBLOG),A
  25.     LD    DE,DFCB        ;Get the FCB
  26.     CALL    XCLOSE
  27.     CALL    NZ,XERROR0
  28.     JR    CLSF08
  29. ;
  30. ;    Check the transaction logfile
  31. ;
  32. CLSF30    LD    A,(TRANLOG)    ;Check if it is open
  33.     IFZ    CLSF07
  34.     XOR    A        ;Zap the open flag
  35.     LD    (TRANLOG),A    ;Reset it
  36.     LD    DE,TRFCB        ;Get the transaction FCB
  37.     CALL    XCLOSE        ;Close the file
  38.     CALL    NZ,XERROR0    ;Print system message if error
  39.     JR    CLSF08        ;Back for another command
  40. ;
  41. ;    THIS IS THE LOG COMMAND.
  42. ;
  43. LOG    EQU    $
  44.     CALL    GETLOGF        ;Get the logfile descriptor
  45.     OR    A
  46.     JP    Z,LOGSES    ;If zero then session logging
  47.     CP    2
  48.     JP    Z,LOGTRAN    ;Go do transaction logging
  49. ;
  50. ;    Debug logging
  51. ;
  52.     LD    A,(DEBLOG)    ;See if logging already in effect
  53.     IFZ    LOG_3
  54. LOG_1    STROUT    LOGOPN        ;Print LOG OPEN message
  55.     JP    KERMIT        ;RETURN TO COMMAND PARSER
  56. LOG_3    LD    DE,DFCB
  57.     PUSH    DE        ;Save it for later
  58.     LD    A,CMIFI        ;Get a file spec
  59.     CALL    COMND        ;Parse it
  60.     JP    KERMT3        ;Exit if not confirmed
  61.     IFNZ    LOG_3A
  62.     LD    HL,DEFDEBLOG    ;Get the default name
  63.     LD    DE,DFCB
  64.     LD    BC,32
  65.     LDIR            ;Move it into place
  66. LOG_3A    POP    DE        ;Get the FCB back
  67.     LD    HL,DBUFF    ;Get the buffer
  68.     LD    B,0        ;Use 256 LRL
  69.     CALL    XINIT        ;Create the output file
  70.     JR    Z,LOG_5
  71.     IFA    42,LOG_5    ;Ignore a LRL error
  72. LOG_4    CALL    XERROR0
  73.     JP    KERMIT
  74. LOG_5    LD    A,1
  75.     LD    (DEBLOG),A    ;Set the log file open flag
  76.     JP    KERMIT
  77. ;
  78. ;    Session logging
  79. ;
  80. LOGSES    LD    A,(LOGFLG)    ;Check if session log open
  81.     IFZ    LOG_6
  82.     JP    LOG_1        ;Oops, log already open
  83. LOG_6    LD    A,CMIFI        ;PARSE AN INPUT FILE SPEC.
  84.     LD    DE,LFCB        ;Get the session log FCB
  85.     PUSH    DE        ;Save it for later
  86.     CALL    COMND        ;Parse it
  87.     JP    KERMT3
  88.     IFNZ    LOG_6A        ;Jump if text was given
  89.     LD    HL,DEFSESLOG    ;Get the default name
  90.     LD    DE,LFCB        ;Get the FCB
  91.     LD    BC,32        ;Get the count
  92.     LDIR            ;Move the block
  93. LOG_6A    LD    HL,LBUFF    ;Get the buffer
  94.     POP    DE        ;Get the session log FCB
  95.     LD    B,0        ;Select 256 byte records
  96.     CALL    XINIT        ;Create a new file
  97.     JR    Z,LOG_8        ;Continue on a no error return
  98.     IFANOT    42,LOG_4    ;If not LRL error, then abort
  99. LOG_8    XOR    A
  100.     LD    (PREVLCHR),A    ;Reset the previous character
  101.     LD    A,2
  102.     LD    (LOGFLG),A    ;Turn logging on
  103.     JP    KERMIT        ;Jump to get a new command
  104. ;
  105. ;    Transaction logging
  106. ;
  107. LOGTRAN    LD    A,(TRANLOG)    ;Get the flag
  108.     IFZ    LOG_9
  109.     JP    LOG_1        ;Oops log already open
  110. LOG_9    LD    A,CMIFI        ;Get a file spec
  111.     LD    DE,TRFCB
  112.     PUSH    DE        ;Save it for later
  113.     CALL    COMND        ;Parse a file name
  114.     JP    KERMT3        ;Abort if no confirm
  115.     IFNZ    LOG_9A        ;Jump if text given
  116.     LD    HL,DEFTRLOG    ;Get the default
  117.     LD    DE,TRFCB
  118.     LD    BC,32
  119.     LDIR            ;Move it
  120. LOG_9A    POP    DE
  121.     LD    HL,TBUFF    ;Get the buffer
  122.     LD    B,0        ;Select 256 LRL
  123.     CALL    XINIT        ;Create the output file
  124.     JR    Z,LOG_10
  125.     IFANOT    42,LOG_4
  126. LOG_10    LD    A,1        ;Set the flag to ON
  127.     LD    (TRANLOG),A
  128.     JP    KERMIT        ;Back for another command
  129. ;
  130. ;    Get a logfile identifier
  131. ;
  132. GETLOGF    LD    A,CMKEY        ;PARSE A KEYWORD
  133.     LD    DE,CLSTAB    ;GET THE PARSE TABLE
  134.     CALL    COMND        ;GET A KEYWORD
  135.     JP    KERMT2        ;ABORT ON AN ERROR
  136.     RET            ;Return to caller
  137. ;
  138. ;    Output a normal string terminated by EOS.
  139. ;
  140. OUTLOG    LD    A,EOS
  141.     JP    OUTLOGCH
  142. ;
  143. ;    Output a message to a log file
  144. ;    HL=message, DE=FCB, A=terminator character
  145. ;
  146. OUTLOGCH    EQU    $
  147.     PUSH    HL        ;Save the registers
  148.     PUSH    DE
  149.     LD    (ENDCH),A    ;Store the terminator
  150. OUTL_1    LD    A,(HL)        ;Get a character
  151.     CP    EOS
  152. ENDCH    EQU    $-1        ;Address of terminator character
  153.     JR    Z,OUTL_2
  154.     PUSH    HL        ;Save the string address, and the FCB
  155.     PUSH    DE
  156.     CALL    XPUT        ;@PUT the character
  157.     POP    DE        ;Restore the addresses
  158.     POP    HL
  159.     JR    NZ,OUTL_3    ;On error, abort
  160.     INC    HL        ;Point to next character
  161.     JR    OUTL_1        ;Loop on
  162. OUTL_2    POP    DE        ;Restore stack
  163.     POP    HL
  164.     JP    RSKP        ;Return normal
  165. ;
  166. ;    Log file error
  167. ;
  168. OUTL_3    CALL    XERROR0        ;Print system message
  169.     STROUT    LOGERROR    ;Print a message on the console
  170.     POP    DE        ;Restore the stack
  171.     POP    HL
  172.     RET            ;Return error
  173. ;end of file
  174.