home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / msr313src.zip / mssset.asm < prev    next >
Assembly Source File  |  1993-07-12  |  107KB  |  3,482 lines

  1.     NAME    mssset
  2. ; File MSSSET.ASM
  3.     include mssdef.h
  4. ;  Copyright (C) 1985, 1993, Trustees of Columbia University in the 
  5. ;  City of New York.  Permission is granted to any individual or institution
  6. ;  to use this software as long as it is not sold for profit.  This copyright
  7. ;  notice must be retained.  This software may not be included in commercial
  8. ;  products without written permission of Columbia University.
  9. ;
  10. ; edit history:
  11. ; 27 August 1992 version 3.13
  12. ; 6 Sept 1991 version 3.11
  13. ; Last edit 13 Feb 1992
  14.  
  15.     public setcom, prmptr, dodef, setcpt, docom, stkadr, rdbuf
  16.     public setrx, rxtable, srvdsa, srvena, mcctab, takopen, takclos, ask
  17.     public askq, assign, initibm, mccptr, setinpbuf, setrollb, npages
  18.     public    xfchtab, xftyptab, com1port, com2port, com3port, com4port
  19.     public    flotab, popcmd, domacptr, warntab, portirq, dodecom
  20.     public    tcpdata, tcphost, xfertab1, xfertab2, rollwidth, setwidth
  21.     public    getok
  22.  
  23. braceop    equ    7bh        ; opening curly brace
  24. bracecl    equ    7dh        ; closing curly brace
  25.  
  26. maketab    MACRO            ; Assembler Macro to make rxtable [jrd]
  27. cnt = 0
  28.     rept 256
  29.     db    cnt        ; initialize table to 0 .. 255
  30. cnt = cnt + 1
  31.     endm
  32.     db    0        ; table off (0) or on (1) indicator
  33. ENDM
  34.  
  35. data     segment
  36.     extrn    comand:byte, flags:byte, trans:byte, takadr:word, taklev:byte
  37.     extrn    portval:word, dtrans:byte, spause:word, machnam:byte
  38.     extrn    filtst:byte, maxtry:byte, script:byte, denyflg:word
  39.     extrn    sloghnd:word, ploghnd:word, tloghnd:word
  40.     extrn    decbuf:byte, kstatus:word, errlev:byte, srvtmo:byte
  41.     extrn    luser:byte, lpass:byte, partab:byte, destab:byte, blktab:byte
  42.     extrn    seoftab:byte, dmpname:byte, lsesnam:byte, lpktnam:byte
  43.     extrn    ltranam:byte, incstb:byte, inactb:byte, rxoffmsg:byte
  44.     extrn    rxonmsg:byte, scpbuflen:word, oldtak:byte, setchtab:byte
  45.     extrn    prnname:byte, prnhand:word, outpace:word, apctrap:byte
  46.     extrn    protlist:byte
  47.  
  48. rxtable    equ THIS BYTE        ; build 256 byte Translation Input table
  49.     maketab            ; table rxtable is used by Connect mode
  50.  
  51. kerm    db    'MS-Kermit>',0        ; default asciiz prompt
  52. prm    db    60 dup (0)        ; buffer for new prompt
  53. rdbuf    db    cmdblen dup (?)        ; work space; room for macro def
  54.                     ;  and for Status display line
  55.  
  56. stflg    db    0        ; Says if setting SEND or RECEIVE parameter
  57. defkind    db    0        ; 0 for ASSIGN, 1 for DEFINE
  58. ermes1    db    cr,lf,'?Too many macro names$'
  59. ermes2    db    cr,lf,bell,'?No room for Take file buffer or Macro definition'
  60.     db    cr,lf,bell,'$'
  61. ermes4    db    cr,lf,'?Too many active Take files and Macros',cr,lf, bell,'$'
  62. ermes5    db    cr,lf,'?Not implemented$'
  63. ermes6    db    cr,lf,'?More parameters are needed$'
  64. ermes7    db    cr,lf,'?Cannot use RTS/CTS on non-UART ports$'
  65. errcap    db    cr,lf,'?Unable to open that file$'
  66. erropn    db    cr,lf,'?Log file is already open$'
  67. askhlp1    db    'Variable name  then  prompt string$'
  68. askhlp2    db    'Prompt string$'
  69. askhlp3    db    'Enter a line of text$'
  70. getokhlp db    'Optional prompt string$'
  71. getdef    db    'Please respond Yes or No ',0    ; ASCII, used as prompt
  72. filhlp    db    ' Output filename for the log$'
  73. dishlp    db    cr,lf,' Quiet (no screen writing), Regular (normal),'
  74.     db    ' Serial (non-formatted screen)'
  75.     db    cr,lf,' and/or 7-BIT (default) or 8-BIT wide characters.$'
  76. remhlp    db    cr,lf,' OFF to show file transfer display,'
  77.     db    ' ON for quiet screen$'
  78. macmsg    db    ' Specify macro name followed by body of macro, on same line$'
  79. prmmsg    db    cr,lf
  80.     db    ' Enter new prompt string or nothing to regain regular prompt.'
  81.     db    cr,lf,' Use \123 notation for special chars (Escape is \27)$'
  82.  
  83. srxhlp1    db    cr,lf,' Enter   code for received byte   code for'
  84.     db    ' local byte ',cr,lf,' use ascii characters themselves or'
  85.     db    cr,lf,' numerical equivalents of  \nnn  decimal'
  86.     db    ' or \Onnn  octal or \Xnnn  hexadecimal',cr,lf
  87.     db    ' or keywords  ON  or  OFF  (translation is initially off)'
  88.     db    cr,lf,'$'
  89. badrx    db    cr,lf,'?Expected ON, OFF, or \nnn$'
  90.  
  91. takchlp    db    cr,lf,'Value 0 to 65535 for COUNT in script IF COUNT command$'
  92. takcerr    db    cr,lf,'?Note: command is valid only in Take files and Macros$'
  93.  
  94. dmpdefnam db    'Kermit.scn',0        ; asciiz default screen dump filename
  95. prndefnam db    'PRN',0            ; asciiz default printer name
  96. nummsg1 db    cr,lf,'?Use a number between $'
  97. nummsg2    db    ' and $'
  98. srvthlp    db    'seconds, 0-255, waiting for a transaction$'
  99. unkchhlp db    cr,lf,' Disposition of files arriving with unknown'
  100.     db    ' character sets:',cr,lf,'  Keep (default), Cancel$'
  101. winhelp    db    cr,lf,'Number of sliding window slots 1 (no windowing) to 31$'
  102. eophlp    db    ' Decimal number between 0 and 31$'
  103. ctlhlp    db    ' Decimal number between 0 and 31, 128 and 159$'
  104. cntlhlp db    cr,lf,' PREFIXED <0..31, 128..159> protectively quotes this'
  105.     db    ' control code',cr,lf
  106.     db    ' UNPREFIXED <0..31, 128..159> sends control code as-is'
  107.     db    cr,lf,' Use ALL to change all codes at once.$'
  108. badcntlmsg db    cr,lf,'?Number is not in range of 0..31, 128..159',cr,lf,'$'
  109. sohhlp    db    ' Decimal number between 0 and 31.',cr,lf,' Special case:'
  110.     db    ' up to 126, but reduces strength of the protocol.$'
  111. dmphlp    db    ' Filename to hold screen dumps$'
  112. prnhlp    db    ' Filename for printer output (default is PRN)$'
  113. prnerr    db    cr,lf,' Cannot open that name. Using default of PRN$'
  114. erlhlp    db    ' Decimal number between 0 and 255$'
  115. pakerr    db    cr,lf,'?Choose a decimal number '
  116.     db    'from 20 to 94 (normal) or to 9024 (long)$'
  117. pakhlp    db    cr,lf,'Decimal number between 20 and 94 (normal) or '
  118.     db    '9024 (long)$'
  119. padhlp    db    cr,lf,' Decimal number between 0 and 31 or 127$'
  120. pauhlp    db    ' Decimal number between 0 and 65383 milliseconds$'
  121. quohlp    db    ' Decimal number between 33 and 126$'
  122. retryhlp db    ' Decimal number between 1 and 63$'
  123. rollhlp    db    ' Decimal number between 0 and 8000$'
  124. dblhlp    db    ' Decimal number between 0 and 255$'
  125. luserh    db    cr,lf,'Username Password from remote Kermit (0-16 chars each)$'
  126. lpassh    db    cr,lf,'Password from remote Kermit (0-16 chars,'
  127.     db    ' spaces allowed)$'
  128. timhlp    db    ' Decimal number between 0 and 94$'
  129. delyhlp    db    ' Delay seconds before sending file (0-63)$'
  130. eschlp    db    cr,lf,'Press literal control keys (ex: Control ]) or'
  131.     db    ' enter in \nnn numerical form$'
  132. escerr    db    cr,lf,'?Not a control code$'
  133. hnd1hlp    db    cr,lf,'XON (\17), XOFF (\19), CR (\13), LF (\10), BELL (\7),'
  134.     DB    ' ESC (\27), NONE (\0)'
  135.     db    cr,lf,' or "CODE" followed by decimal number$' 
  136. intoms    db    'number of seconds to wait before timeout',cr,lf,'$'
  137. loghlp    db    cr,lf
  138.     db    ' PACKETS - during file transfers  (to default file PACKET.LOG)'
  139.     db    cr,lf
  140.     db    ' SESSION - during Connect mode   (to default file SESSION.LOG)'
  141.     db    cr,lf
  142.     db    ' TRANSACTIONS - files transfers (to default file TRANSACT.LOG)'
  143.     db    cr,lf,'  followed by an optional filename for the log.$'
  144. comhlp    db    cr,lf,' Address of the COM1 - COM4 port (ex: COM3 \x02f8 or'
  145.     db    ' COM4 \x02e8)$'
  146. irqhlp    db    cr,lf,' Enter, or IRQ of port (ex: \3)$'
  147. debhlp    db    cr,lf,' PACKETS - during file transfers'    ; Debugging
  148.     db    cr,lf,' SESSION - during Connect mode'
  149.     db    cr,lf,' ON - both packets and session'
  150.     db    cr,lf,' OFF - turns off all debugging$'
  151. dohlp    db    cr,lf,'definitions of variables (\%n), or press ENTER key$'
  152.  
  153. sdshlp    db    cr,lf,'DISABLE or ENABLE access to selected Server commands:'
  154.     db    cr,lf
  155.     db    ' CD/CWD, DEL, DIR, FINISH (includes BYE & LOGOUT), GET,'
  156.     db    ' HOST, KERMIT, LOGIN,',cr,lf
  157.     db    ' PRINT, SEND, SPACE, TYPE, and ALL.$'
  158.  
  159. xfchhlp    db    cr,lf,' Which character set to put on the wire during file'
  160.     db    ' transfers:',cr,lf
  161.     db    '  TRANSPARENT (regular PC codes)',cr,lf
  162.     db    '  LATIN1   (ISO 8859-1)',cr,lf
  163.     db    '  LATIN2   (ISO 8859-2)',cr,lf
  164.     db    '  HEBREW   (ISO 8859-8)',cr,lf
  165.     db    '  CYRILLIC (ISO 8859-5)',cr,lf
  166.     db    '  JAPANESE-EUC$'
  167. xferhlp1 db    cr,lf,' OFF: disable feature, ON: enable (default), FORCE:'
  168.     db    ' forced on$'
  169. xfchhlp2 db    cr,lf,' READABLE: translate some/many characters to/from'
  170.     db    ' locally readable form (def).'
  171.     db    cr,lf,' INVERTIBLE: use codes which can be copied back to the'
  172.     db    ' host in its form.$'
  173. xfchbad    db    cr,lf,'Warning: forcing FILE CHARACTER-SET to CP866$'
  174. xfchbad2 db    cr,lf,'Warning: forcing FILE CHARACTER-SET to Shift-JIS$'
  175. xfchbad3 db    cr,lf,'Warning: forcing FILE CHARACTER-SET to CP862$'
  176. setchmsg db   cr,lf,'Warning: forcing TRANSFER CHARACTER-SET to CYRILLIC$'
  177. setchmsg2 db  cr,lf,'Warning: forcing TRANSFER CHARACTER-SET to'
  178.     db    ' Japanese-EUC$'
  179. setchmsg3 db  cr,lf,'Warning: forcing TRANSFER CHARACTER-SET to HEBREW-ISO$'
  180. xfilhlp    db    'NONE, SPACE, or filler character$'
  181. xpmthlp db    'Host echo char acting as prompt, \1-\255$'
  182. xpauhlp    db    'Millisec to pause between lines, 1 - 65000$'
  183. opacehlp db    'Millisec to pause between OUTPUT bytes, 0 - 65000$'
  184. pophlp    db    'Status value to be returned  msg, nothing if no new value$'
  185. crlf    db    cr,lf,'$'
  186.  
  187. srvtab    db    2            ; SET SERVER table
  188.     mkeyw    'Login',1
  189.     mkeyw    'Timeout',2
  190.  
  191. sethlp    db    cr,lf
  192.     db    '  Alarm    sec from now or HH:MM:SS  '
  193.     db    '  Local-echo        on/off           '
  194.     db    cr,lf
  195.     db    '  Attributes packets on/off          '
  196.     db    '  Mode-line         on/off'
  197.     db    cr,lf
  198.     db    '  Bell    on/off    at end of xfers  '
  199.     db    '  NetBios-name      (our local name)'
  200.     db    cr,lf
  201.     db    '  Block-check-type  checksum/CRC     '
  202.     db    '  Output pacing (ms between bytes)  '
  203.     db    cr,lf
  204.     db    '  COM1 - COM4 port-address irq       '
  205.     db    '  Parity    even/odd/mark/space/none'
  206.     db    cr,lf
  207.     db    '  Control prefixed/unprefixed  code  '
  208.     db    '  Port (or Line)    1/2/COM1/COM2/etc'
  209.     db    cr,lf
  210.     db    '  Count   number    a loop counter   '
  211.     db    '  Printer filespec   for Connect mode'
  212.     db    cr,lf
  213.     db    '  Debug   on/off    display packets  '
  214.     db    '  Prompt  string   (new Kermit prompt)'
  215.     db    cr,lf
  216.     db    '  Default-disk                       '
  217.     db    '  Receive parameter  many things'
  218.     db    cr,lf
  219.     db    '  Delay   secs  before Sending file  '
  220.     db    '  Retry limit for packet send/receive'
  221.     db    cr,lf
  222.     db    '  Destination   Disk/Screen/Printer  '
  223.     db    '  Rollback, terminal screens'
  224.     db    cr,lf
  225.     db    '  Display quiet/reg/serial show cnts?'
  226.     db    '  Send parameter    many things'
  227.     db    cr,lf
  228.     db    '  Dump filespec     screen to disk   '
  229.     db    '  Server parameter'
  230.     db    cr,lf
  231.     db    '  Duplex            half or full     '
  232.     db      '  Speed or Baud     many speeds'    
  233.     db    cr,lf
  234.     db    '  EOF Ctrl-Z/NoCtrl-Z  ^Z ends file? '
  235.     db    '  Take-echo on/off  display commands?' 
  236.     db    cr,lf
  237.     db     '  End-of-line char  cr or whatever   '
  238.     db    '  Terminal type and parameters'
  239.     db    cr,lf
  240.     db    '  Errorlevel number   for DOS Batch  '
  241.     db    '  TCP/IP address,mask,nameserver etc'
  242.     db    cr,lf
  243.     db      '  Escape-char  ^]   or whatever      '
  244.     db    '  Timer     on/off  time packet waiting'
  245.     db    cr,lf
  246.     db    '  File (Character-set, Type, Warning)'
  247.     db    '  Translation IN  Connect mode rcv''d char'
  248.     db    cr,lf
  249.     db    '  Flow-control  none xon/xoff rts/cts'
  250.     db    '  Transfer Character-set (on wire) '
  251.     db    cr,lf
  252.     db    '  Handshake xon/xoff/cr/lf/bell/esc..'
  253.     db    '  Transmit  parameters, for scripts'
  254.     db    cr,lf
  255.     db    '  Incomplete file   keep/discard     '
  256.     db    '  Unknown-character-set (keep/cancel)'
  257.     db    cr,lf
  258.     db    '  Input timeout, etc  (for scripts)  '
  259.     db    '  Warning   on/off  if file renamed'
  260.     db    cr,lf
  261.     db    '  Key         key-ident   definition '
  262.     db    '  Windows  number of sliding window slots'
  263.     db    '$'
  264.  
  265. settab     db    55                    ; Set table
  266.     mkeyw    'Alarm',setalrm
  267.     mkeyw    'Attributes',setatt
  268.     mkeyw    'Baud',baudst
  269.     mkeyw    'Bell',bellst
  270.     mkeyw    'Block-check-type',blkset
  271.     mkeyw    'COM1',com1port
  272.     mkeyw    'COM2',com2port
  273.     mkeyw    'COM3',com3port
  274.     mkeyw    'COM4',com4port
  275.     mkeyw    'Control-character',cntlset
  276.     mkeyw    'Count',takectr
  277.     mkeyw    'Debug',debst
  278.     mkeyw    'Default-disk',cwdir
  279.     mkeyw    'Delay',setdely
  280.     mkeyw    'Destination',desset
  281.     mkeyw    'Display',disply
  282.     mkeyw    'Dump',setdmp
  283.     mkeyw    'Duplex',setdup
  284.     mkeyw    'End-of-Line',eolset
  285.     mkeyw    'EOF',seteof
  286.     mkeyw    'Errorlevel',seterl
  287.     mkeyw    'Escape-character',escset
  288.     mkeyw    'File',setfile
  289.     mkeyw    'Flow-control',floset
  290.     mkeyw    'Handshake',hndset
  291.     mkeyw    'Incomplete',abfset
  292.     mkeyw    'Input',inpset
  293.     mkeyw    'Key',setkey
  294.     mkeyw    'Line',coms
  295.     mkeyw    'Local-echo',lcal
  296.     mkeyw    'Mode-line',modl
  297.     mkeyw    'NetBios-name',setnbios
  298.     mkeyw    'Output',setoutput
  299.     mkeyw    'Parity',setpar
  300.     mkeyw    'Port',coms
  301.     mkeyw    'Printer',setprn
  302.     mkeyw    'Prompt',promset
  303.     mkeyw    'Receive',recset
  304.     mkeyw    'Remote',remset
  305.     mkeyw    'Retry',retryset
  306.     mkeyw    'Rollback',setrollb
  307.     mkeyw    'Send',sendset
  308.     mkeyw    'Server',setsrv
  309.     mkeyw    'Speed',baudst
  310.     mkeyw    'Take-echo',takset
  311.     mkeyw    'TCP/IP',tcpipset
  312.     mkeyw    'Terminal',vts
  313.     mkeyw    'Timer',timset
  314.     mkeyw    'Transfer',sxfer
  315.     mkeyw    'xfer',sxfer        ; hidden synonym
  316.     mkeyw    'Translation',setrx
  317.     mkeyw    'Transmit',setxmit
  318.     mkeyw    'Unknown-character-set',unkchset
  319.     mkeyw    'Warning',filwar
  320.     mkeyw    'Windows',winset
  321.  
  322. setfitab db    5            ; Set File command table
  323.     mkeyw    'Character-Set',1
  324.     mkeyw    'Collision',0
  325.     mkeyw    'Display',3
  326.     mkeyw    'Type',2
  327.     mkeyw    'Warning',0
  328.  
  329. xfertab    db    3            ; SET TRANSFER table
  330.     mkeyw    'Character-set',0
  331.     mkeyw    'Locking-shift',1
  332.     mkeyw    'Translation',2
  333.  
  334. xfertab1 db    3            ; SET TRANSFER LOCKING-SHIFT
  335.     mkeyw    'Off',lock_disable
  336.     mkeyw    'On',lock_enable
  337.     mkeyw    'Forced',lock_force
  338.  
  339. xfertab2 db    2            ; SET TRANSFER TRANSLATION
  340.     mkeyw    'Readable',0
  341.     mkeyw    'Invertible',1
  342.  
  343. xfchtab    db    6            ; SET TRANSFER CHARACTER-SET
  344.     mkeyw    'Transparent',xfr_xparent    ; no translation
  345.     mkeyw    'Latin1 ISO 8859-1',xfr_latin1    ; ISO 8859-1, Latin-1
  346.     mkeyw    'Latin2 ISO 8859-2',xfr_latin2    ; ISO 8859-2, Latin-2
  347.     mkeyw    'Hebrew ISO 8859-8',xfr_hebiso    ; ISO 8859-8 Hebrew-ISO
  348.     mkeyw    'Cyrillic ISO 8859-5',xfr_cyrillic; ISO 8859-5/Cyrillic, CP866
  349.     mkeyw    'Japanese-EUC',xfr_japanese    ; Japanese-EUC
  350.  
  351. xftyptab db    2            ; SET FILE TYPE table
  352.     mkeyw    'Binary',1        ; Binary = as-is
  353.     mkeyw    'Text',0        ; Text = can change char sets
  354.  
  355. warntab    db    6            ; File Warning table
  356.     mkeyw    'Overwrite',1        ; overwrite
  357.     mkeyw    'Rename',0        ; rename
  358.     mkeyw    'Discard',4         ; discard
  359.     mkeyw    'No-supersede',4    ; discard
  360.     mkeyw    'on (rename)',0        ; old form
  361.     mkeyw    'off (overwrite)',1    ; old form
  362.  
  363. unkctab db    2            ; unknown character-set disposition
  364.     mkeyw    'Keep',0
  365.     mkeyw    'Cancel',1
  366.  
  367. atttab    db    6            ; SET ATTRIBUTES table
  368.     mkeyw    'Off',00ffh        ; all off
  369.     mkeyw    'On',10ffh        ; all on (high byte is on/off)
  370.     mkeyw    'Character-set',attchr    ; Character set
  371.     mkeyw    'Date-Time',attdate    ; Date and Time
  372.     mkeyw    'Length',attlen        ; Length
  373.     mkeyw    'Type',atttype        ; Type
  374.  
  375. comtab    db    2            ; table of COM ports
  376.     mkeyw    'COM3',4        ; offset of COM3 address
  377.     mkeyw    'COM4',6        ; offset of COM4 address
  378.  
  379. cntltab    db    2            ; SET CONTROL table
  380.     mkeyw    'Prefixed',0        ; 0 = send with prefix
  381.     mkeyw    'Unprefixed',1        ; 1 = send as-is
  382.  
  383. stsrtb    db    10            ; Number of options
  384.     mkeyw    'Packet-length',srpack
  385.     mkeyw    'Padchar',srpad
  386.     mkeyw    'Padding',srnpd
  387.     mkeyw    'Pause',srpaus
  388.     mkeyw    'Start-of-packet',srsoh
  389.     mkeyw    'Quote',srquo
  390.     mkeyw    'End-of-packet',sreol
  391.     mkeyw    'Timeout',srtim
  392.     mkeyw    'Double-char',srdbl
  393.     mkeyw    'Ignore-char',srign
  394.  
  395. ontab    db    2
  396.     mkeyw    'off',0
  397.     mkeyw    'on',1
  398.  
  399. outputtab db    1            ; Set OUTPUT
  400.     mkeyw    'PACING',setopace
  401.  
  402. distab    db    5             ; Set Display mode
  403.     mkeyw    '7-bit',7        ; controls bit d8bit in flags.remflg
  404.     mkeyw    '8-bit',8        ; sets d8bit
  405.     mkeyw    'Quiet',dquiet        ; values defined in header file
  406.     mkeyw    'Regular',dregular
  407.     mkeyw    'Serial',dserial
  408.  
  409. distab2    db    3            ; for SET FILE DISPLAY
  410.     mkeyw    'Quiet',dquiet        ; values defined in header file
  411.     mkeyw    'Regular',dregular
  412.     mkeyw    'Serial',dserial
  413.  
  414. ; If abort when receiving files, can keep what we have or discard
  415. abftab    db    2
  416.     mkeyw    'Discard',1
  417.     mkeyw    'Keep',0
  418.  
  419. flotab    db    5
  420.     mkeyw    'none',0
  421.     mkeyw    'xon/xoff',1+2        ; both directions
  422.     mkeyw    'incoming-xon/xoff',2
  423.     mkeyw    'outgoing-xon/xoff',1
  424.     mkeyw    'RTS/CTS',4
  425.  
  426. hndtab    db    8
  427.     mkeyw    'none',0
  428.     mkeyw    'bell',bell
  429.     mkeyw    'cr',cr
  430.     mkeyw    'esc',escape
  431.     mkeyw    'lf',lf
  432.     mkeyw    'xoff',xoff
  433.     mkeyw    'xon',xon
  434.     mkeyw    'code',0ffh        ; allow general numerial code
  435.  
  436. duptab    db    2            ; SET DUPLEX table
  437.     mkeyw    'full',0
  438.     mkeyw    'half',1
  439.  
  440. gettab    db    3            ; GETOK dispatch table
  441.     mkeyw    'Yes',kssuc        ; success = yes
  442.     mkeyw    'OK',kssuc        ; ditto
  443.     mkeyw    'No',ksgen        ; general failure
  444.  
  445. inptab    db    4                ; Scripts. Set Input
  446.     mkeyw    'Case',inpcas            ;[jrs]
  447.     mkeyw    'Default-timeout',inptmo    ;[jrs]
  448.     mkeyw    'Echo',inpeco            ;[jrs]
  449.     mkeyw    'Timeout-action',inpact        ;[jrs]
  450.  
  451. xmitab    db    4            ; SET TRANSMIT table
  452.     mkeyw    'Fill-empty-line',0
  453.     mkeyw    'Line-Feeds-sent',1
  454.     mkeyw    'Pause',3
  455.     mkeyw    'Prompt',2
  456.  
  457. debtab    db    4            ; Set Debug command
  458.     mkeyw    'Off',0
  459.     mkeyw    'On',logpkt+logses
  460.     mkeyw    'Packets',logpkt
  461.     mkeyw    'Session',logses
  462.  
  463. logtab    db    3            ; LOG command
  464.     mkeyw    'Packets',logpkt
  465.     mkeyw    'Session',logses
  466.     mkeyw    'Transactions',logtrn
  467.  
  468. srvdetab db    14            ; Server Enable/Disable list
  469.     mkeyw    'All',0fffh
  470.     mkeyw    'CD',cwdflg
  471.     mkeyw    'CWD',cwdflg
  472.     mkeyw    'Delete',delflg
  473.     mkeyw    'Dir',dirflg
  474.     mkeyw    'Finish',finflg
  475.     mkeyw    'Get',getsflg
  476.     mkeyw    'Host',hostflg
  477.     mkeyw    'Kermit',kerflg
  478.     mkeyw    'Login',pasflg
  479.     mkeyw    'Print',prtflg
  480.     mkeyw    'Send',sndflg
  481.     mkeyw    'Space',spcflg
  482.     mkeyw    'Type',typflg
  483.  
  484. trnstab    db    2            ; Set Translation table
  485.     mkeyw    'Input',1
  486.     mkeyw    'Keyboard',2
  487.  
  488. tcptable db    12            ; TCP/IP command
  489.     mkeyw    'address',1        ; local Internet address
  490.     mkeyw    'domain',2        ; local domain string
  491.     mkeyw    'broadcast',8        ; broadcast of all 0's or all 1's
  492.     mkeyw    'gateway',4        ; gateway address
  493.     mkeyw    'primary-nameserver',5    ; address
  494.     mkeyw    'secondary-nameserver',6
  495.     mkeyw    'subnetmask',3        ; our subnet mask
  496.     mkeyw    'host',7        ; host's IP name or IP number
  497.     mkeyw    'Packet-Driver-interrupt',9
  498.     mkeyw    'Telnet-term-type',10    ; Options term type
  499.     mkeyw    'NewLine-Mode',11     ; CR-NUL vs CRLF
  500.     mkeyw    'debug-Options',12
  501.  
  502. hosthlp    db    cr,lf,'Internet name or number (ddd.ddd.ddd.ddd) of '
  503.     db    'the remote machine$'
  504. domainhlp db    cr,lf,'Name of your domain$'
  505. subnethlp db    cr,lf,'Subnetmask, decimal ddd.ddd.ddd.ddd$'
  506. addrhelp db    cr,lf,'Internet address, decimal ddd.ddd.ddd.ddd, of this'
  507.     db    ' machine or BOOTP or RARP$'
  508. iphelp    db    cr,lf,'Internet address, decimal ddd.ddd.ddd.ddd$'
  509. domainbad db    cr,lf,'?Bad domain name, use is such as my.domain.name$'
  510. addressbad db    cr,lf,'?string is too long$'
  511. hostbad    db    cr,lf,'?Bad host, use IP name or IP number$'
  512. tcppdinthlp db    cr,lf,'Interrupt on PC for Packet Driver, \x60 to \x7f'
  513.     db    ' or use 0 for automatic search,'
  514.     db    cr,lf,' or ODI to use Novell''s ODI interface$'
  515. tcpttyhlp db    cr,lf,' Telnet Options terminal identification override '
  516.     db    'string.'
  517.     db    cr,lf,' This does NOT modify the real terminal type.'
  518.     db    ' Press ENTER to remove this',cr,lf 
  519.     db    ' override and report the real terminal type.$'
  520. tcpnlhlp db    cr,lf,' ON sends CR LF for each CR, OFF sends CR NUL$'
  521.  
  522. tcpaddress db    'unknown',(16-($-tcpaddress)) dup (0),0
  523. tcpsubnet  db    '255.255.255.0',(16-($-tcpsubnet)) dup (0),0
  524. tcpdomain  db    'unknown',(32-($-tcpdomain)) dup (0),0
  525. tcpgateway db    'unknown',(16-($-tcpgateway)) dup (0),0
  526. tcpprimens db    'unknown',(16-($-tcpprimens)) dup (0),0
  527. tcpsecondns db    'unknown',(16-($-tcpsecondns)) dup (0),0
  528. tcphost    db    (60 -($-tcphost)) dup (0),0
  529. tcpbcast db    '255.255.255.255',(16-($-tcpbcast)) dup (0),0
  530. tcpbtpserver db    17 dup (0)        ; bootp server (response)
  531. tcpport    dw    23            ; TCP port
  532. tcppdint dw    0            ; Packet Driver interrupt
  533. tcpttbuf db    32 dup (0),0        ; term-type-override buffer
  534. tcpnewline db    1            ; NewLine-Mode (default is on)
  535. tcpdebug db    0            ; Options debugging (0 is off)
  536.  
  537. tcpdata    dw    offset tcpaddress    ; externally visible far pointers
  538.     dw    offset tcpsubnet    ; keep in this order
  539.     dw    offset tcpdomain
  540.     dw    offset tcpgateway
  541.     dw    offset tcpprimens
  542.     dw    offset tcpsecondns
  543.     dw    offset tcphost
  544.     dw    offset tcpbcast
  545.     dw    offset tcpport
  546.     dw    offset tcppdint
  547.     dw    offset tcpttbuf
  548.     dw    offset tcpbtpserver
  549.     dw    offset tcpnewline
  550.     dw    offset tcpdebug
  551.  
  552. ; MACRO DATA STRUCTURES mcctab
  553. mcclen    equ    macmax*10        ; length of mcctab
  554. mcctab    db    0            ; macro name table entries
  555.     db    mcclen dup (0)        ; room for macro structures
  556. ; END OF MACRO DATA STRUCTURES
  557.  
  558. ibmmac    db    'IBM '            ; startup IBM macro definition + space
  559.     db    'set timer on,set parity mark,set local-echo on,'
  560.     db    'set handshake xon,set flow none,',0    ; asciiz
  561.  
  562.     even
  563. prmptr    dw    kerm            ; pointer to prompt
  564. tempptr    dw    0            ; pointer into work buffer
  565. domacptr dw    0            ; pointer to DO MAC string
  566. min    dw    0 
  567. max    dw    0 
  568. numerr    dw    0
  569. numhlp    dw    0
  570. temp    dw    0
  571. temp1    dw    0            ; Temporary storage
  572. temp2    dw    0            ; Temporary storage
  573. askecho db    0            ; ask's echo control flag
  574. temptc    db    3,0,0,'T',0,0        ; temp, for takclos, word cnt,<null>T#
  575. deftemp    dw    0
  576. stkadr    dw    0    ; non-zero if replacement keyboard xlator present
  577. mccptr    dw    mcctab             ; ptr to first free byte in mcctab
  578. macptr    dw    0            ; temp to hold segment of string
  579. npages    dw    10             ; # of pages of scrolling on each side
  580. rollwidth dw    0            ; columns to roll back 80..207
  581. portirq    db    4 dup (0)        ; user specified IRQ's for COM1..4
  582. data    ends
  583.  
  584. code1    segment
  585.     extrn    makebuf:far
  586. code1    ends
  587.  
  588. code    segment
  589.     extrn comnd:near, baudst:near, prompt:near, coms:near, cwdir:near
  590.     extrn isfile:near, strlen:near, strcpy:near, cnvlin:near
  591.     extrn katoi:near, decout:near, vts:near, setalrm:near, serrst:near
  592.     extrn prnopen:near, pntflsh:near, takrd:near, prtasz:near
  593.     extrn setnbios:near    ; in MSXIBM, needs stub for other machines
  594.  
  595.     assume    cs:code, ds:data, es:nothing
  596.  
  597. ; DO defined macro command
  598. ; DO macname variable variable   also defines variables \%1, \%2, ...\%9
  599. DOCOM    PROC    NEAR
  600.     mov    dx,offset mcctab    ; table of macro defs
  601.     xor    bx,bx            ; help is table
  602.     mov    ah,cmkey        ; get key word (macro name)
  603.     call    comnd            ; get pointer to keyword structure
  604.     jnc    docom1            ; nc = success, bx = 16 bit data
  605.     ret                ; failure
  606. docom1:    mov    domacptr,bx        ; segment of definition string
  607.     mov    comand.cmquiet,0    ; permit command echoing
  608.     mov    bx,offset decbuf    ; point to borrowed work buffer
  609.     mov    word ptr[bx],0        ; clear buffer
  610.     mov    dx,offset dohlp        ; help
  611.     mov    comand.cmblen,length rdbuf ; length of analysis buffer
  612.     mov    ah,cmline        ; get line of text, if any
  613.     call    comnd
  614.     jnc    docom2            ; nc = success
  615.     ret                ; failure
  616. docom2:    mov    deftemp,ax        ; save byte count of command args
  617.     call    hidemac            ; hide previous \%0..\%9 macros
  618.     call    getname            ; get name of this macro
  619.     mov    cx,word ptr rdbuf    ; length of "\%0 plus found name"
  620.     call    dodecom            ; add keyword+def using DEF MAC below
  621.     jnc    docom2a            ; nc = success
  622.     ret
  623. docom2a:call    docnv            ; convert macro string
  624.     jnc    docom2b            ; nc = success
  625.     ret
  626. docom2b:mov    max,1            ; temp for counting 1 + number args
  627.     mov    word ptr rdbuf+4,' 1'    ; number of first variable
  628. docom3:    mov    word ptr rdbuf,0    ; clear length field, install \%x name
  629.     mov    word ptr rdbuf+2,'%\'    ; start with '\%1 '
  630.     mov    word ptr rdbuf+6,0    ; clear text field
  631.     mov    tempptr,offset rdbuf+6    ; pointer to location of found word
  632.     xor    ch,ch            ; make cx = 1 - 9
  633.     mov    cl,rdbuf+4        ; cx = word # of interest, for getwrd
  634.     sub    cl,'0'            ; remove ascii bias
  635.     mov    si,offset decbuf    ; source = work buffer (borrowed)
  636.     call    getwrd            ; get CX-th word from  work buf (1-9)
  637.     cmp    deftemp,0        ; length of word, was it found?
  638.     je    docom4            ; e = no, end variable definition part
  639.     add    deftemp,4        ; count '\%n ' in command line length
  640.     inc    max            ; one more argument
  641.     mov    cx,deftemp        ; command length for dodecom
  642.     call    dodecom            ; add keyword+def using DEF MAC below
  643.     jnc    docom3a
  644.     ret                ; failure
  645. docom3a:inc    rdbuf+4            ; inc number of variable in '\%n '
  646.     cmp    rdbuf+4,'9'
  647.     jbe    docom3            ; do '1' through '9', if available
  648.  
  649.                     ; DO the macro itself
  650. docom4:    cmp    taklev,maxtak        ; room in take level?
  651.     jl    docom5            ; l = yes, continue
  652.     mov    dx,offset ermes4    ; else complain
  653.     jmp    reterr
  654. docom5:    inc    taklev            ; increment take level
  655.     add    takadr,size takinfo    ; create a Take macro
  656.     mov    bx,takadr        ; point to current structure
  657.     push    es
  658.     mov    es,domacptr        ; segment of macro definition string
  659.     mov    [bx].takbuf,es        ; remember in Take structure
  660.     mov    cx,es:word ptr [0]    ; length of definition string
  661.     pop    es
  662.     mov    [bx].takcnt,cx        ; # of chars in buffer
  663.     mov    [bx].taktyp,0ffh    ; flag as a macro
  664.     mov    [bx].takptr,2        ; point to beginning of def text
  665.     mov    cx,max            ; 1 + number of arguments
  666.     mov    [bx].takargc,cx
  667.     clc                ; success
  668.     ret
  669. DOCOM    ENDP
  670.  
  671. ; Create a new macro, named <0>T<taklev digit>, with the command line of the
  672. ; original macro modified to replace bare commas with Carriage Returns.
  673. ; Enter with domacptr pointing at the segment of the macro's definition.
  674. ; Return with domacptr pointing at the new buffer created by dodecom.
  675. docnv    proc    near
  676.     cmp    taklev,maxtak        ; room in take level?
  677.     jb    docnv1            ; b = yes
  678.     mov    dx,offset ermes4    ; say too many Take files
  679.     mov    ah,prstr        ; display error message
  680.     int    dos
  681.     stc                ; set carry for failure
  682.     ret
  683.  
  684. docnv1:    push    es
  685.     mov    word ptr rdbuf,3    ; length of name, 3 bytes <null>Tn
  686.     mov    rdbuf+2,0
  687.     mov    rdbuf+3,'T'        ; name of <null>Tn
  688.     mov    al,taklev        ; Take level digit
  689.     inc    al            ; for what will be next Take level
  690.     add    al,'0'            ; add ascii bias
  691.     mov    rdbuf+4,al        ; last of the name
  692.     mov    rdbuf+5,' '        ; separate dummy definition
  693.     mov    ax,domacptr
  694.     mov    es,ax            ; seg of definition
  695.     xor    si,si            ; offset of definition
  696.     mov    di,offset rdbuf+6    ; destination
  697.     mov    cx,es:[si]        ; read count of string
  698.     add    si,2            ; point at string itself
  699.     xor    bx,bx            ; brace count
  700.     mov    dl,braceop        ; opening brace (we count them up)
  701.     mov    dh,bracecl        ; closing brace (we count them down)
  702.     xor    bp,bp            ; offset of last closing brace+1
  703.     cmp    es:[si],dl        ; starts with opening brace?
  704.     jne    docnv2            ; ne = no
  705.     inc    si            ; skip this new leading space
  706.     dec    cx            ; and don't count it either
  707.     inc    bh            ; say opening brace was found
  708. docnv2:    mov    al,es:[si]        ; read a char
  709.     inc    si
  710.     cmp    al,dl            ; opening brace?
  711.     jne    docnv3            ; ne = no
  712.     inc    bl            ; count brace level
  713.     jmp    short docnv5
  714. docnv3:    cmp    al,dh            ; closing brace?
  715.     jne    docnv4            ; ne = no
  716.     dec    bl
  717.     or    bl,bl            ; below 0?
  718.     jg    docnv4            ; g = no, still in braces
  719.     jz    docnv5            ; matching interior braces
  720.     or    bh,bh            ; was there an opening brace?
  721.     jz    docnv5            ; z = no, record this one
  722.     xor    bx,bx            ; found opening match, reset to zero
  723.     jmp    short docnv6        ; omit the brace
  724. docnv4:    or    bl,bl            ; in braced clause?
  725.     jnz    docnv5            ; nz = yes, treat comma as literal
  726.     cmp    al,','            ; unbraced comma?
  727.     jne    docnv5            ; ne = no
  728.     mov    al,CR            ; replace bare comma with CR
  729. docnv5:    mov    [di],al
  730.     inc    di
  731. docnv6:    loop    docnv2
  732.     pop    es
  733.     cmp    byte ptr [di-1],cr    ; ends on a Carriage Return?
  734.     je    docnv7            ; e = yes
  735.     mov    byte ptr [di],cr    ; insert one to do sync execution
  736.     inc    di
  737. docnv7:    mov    byte ptr [di],0        ; null terminator, for safety
  738.     sub    di,offset rdbuf+2    ; start of string (skips count)
  739.     mov    cx,di            ; length of string
  740.     call    dodecom            ; define macro from rdbuf+2
  741.     mov    domacptr,ax        ; seg of new string
  742.     ret
  743. docnv    endp
  744.  
  745. ; Extract CX-th word (cx = 1-9) from buffer (DI). Enter with si = source
  746. ; string and tempptr pointing at destination. Returns deftemp (count) of
  747. ; transferred characters. Allow string in curly braces to exist as a word.
  748. ; Adjacent curly braced strings are separate "words":
  749. ;    {this is word-one}{this is word-two}word-three.
  750. ; First level curly braces are removed.
  751. ; All registers preserved.
  752. getwrd    proc    near
  753.     push    si
  754.     push    di
  755.     push    es
  756.     push    ds
  757.     pop    es            ; set es to data segment
  758. getwr1:    push    cx            ; save word counter (1-9)
  759.     mov    deftemp,0        ; no bytes transferred yet
  760.     mov    di,tempptr        ; where to store word/string
  761.     mov    byte ptr [di],0        ; clear destination
  762.     mov    dx,si            ; start looking here in work buf
  763.     call    strlen            ; cx = remaining length of work buf
  764.     jcxz    getwr6            ; z = nothing there, quit
  765. getwr2:    lodsb
  766.     cmp    al,' '            ; skip leading whitespace
  767.     loope    getwr2
  768.     dec    si            ; return to break char
  769.                     ; Parse curly brace delimited string
  770.                     ; end with si after closing brace
  771.     xor    dl,dl            ; assume "opening brace" is a null
  772.     mov    dh,' '            ; assume "closing brace" is a space
  773.     mov    cx,1            ; we are at brace level 1
  774.     cmp    byte ptr [si],braceop    ; starting with a real opening brace?
  775.     jne    getwr3            ; ne = no
  776.     inc    si            ; skip opening brace
  777.     mov    dl,braceop        ; opening brace (we count them up)
  778.     mov    dh,bracecl        ; closing brace (we count them down)
  779. getwr3:    cld                ; search forward
  780.     lodsb                ; read a char
  781.     stosb                ; store in output buffer
  782.     or    al,al            ; at end of text?
  783.     jnz    getwr3a            ; nz = no
  784.     dec    si            ; stay at null terminator
  785.     dec    di
  786.     jmp    short getwr6        ; we are done with this "word"
  787. getwr3a:inc    deftemp            ; count copied char
  788.     cmp    al,dl            ; an opening brace?
  789.     jne    getwr4            ; ne = no
  790.     inc    cx            ; yes, increment brace level
  791.     jmp    short getwr3        ;  and continue scanning
  792.  
  793. getwr4:    cmp    al,dh            ; closing brace?
  794.     jne    getwr3            ; ne = no, continue scanning
  795.     dec    cx            ; yes, decrement brace level
  796.     cmp    byte ptr [si],0        ; have we just read the last char?
  797.     jne    getwr5            ; no, continue scanning
  798.     xor    cx,cx            ; yes, this is the closing brace
  799. getwr5:    or    cx,cx            ; at level 0?
  800.     jg    getwr3            ; g = no, #opening <> #closing braces
  801.     dec    di            ; don't write closing brace
  802.     dec    deftemp            ; do not count closing brace
  803. getwr6:    pop    cx            ; recover word counter
  804.     mov    byte ptr [di],0
  805.     jcxz    getwrx            ; just in case
  806.     loop    getwr1            ; do until desired word is copied
  807. getwrx:    pop    es
  808.     pop    di
  809.     pop    si
  810.     ret
  811. getwrd    endp
  812.  
  813. ; Get macro name, given the action pointer in domacptr.
  814. ; Return rdbuf as word:length that follows, then "\%0 macro-name"
  815. getname proc    near
  816.     push    bx
  817.     push    cx
  818.     push    dx
  819.     push    si
  820.     push    di
  821.     mov    dx,domacptr        ; action word to be matched
  822.     mov    bx,offset mcctab+1    ; table of macro names, skip count
  823.     mov    word ptr rdbuf,4    ; name length and space
  824.     mov    word ptr rdbuf+2,'%\'    ; define '\%0 '
  825.     mov    word ptr rdbuf+4,' 0'
  826.     mov    cl,mcctab        ; number of entries
  827.     xor    ch,ch
  828.     jcxz    getnam3            ; z = empty table
  829. getnam1:push    cx
  830.     mov    cx,[bx]            ; length of name
  831.     mov    si,bx            ; point at structure member
  832.     add    si,2            ; plus count
  833.     add    si,cx            ; plus length of name
  834.     mov    ax,[si]            ; get action word
  835.     cmp    ax,dx            ; correct action word?
  836.     jne    getnam2            ; ne = no
  837.     push    es
  838.     push    ds
  839.     pop    es
  840.     add    word ptr rdbuf,cx    ; length of macro \%0 + name
  841.     mov    di,offset rdbuf+6    ; where to store text
  842.     mov    si,bx
  843.     add    si,2            ; source of text
  844.     cld
  845.     rep    movsb            ; copy name to rdbuf+6
  846.     mov    byte ptr [di],0        ; null terminator
  847.     pop    es
  848.     pop    cx
  849.     jmp    short getnam3        ; exit
  850. getnam2:mov    ax,[bx]            ; get length of name
  851.     add    ax,4            ; plus count and word pointer
  852.     add    bx,ax            ; point to next entry
  853.     pop    cx
  854.     loop    getnam1            ; look at next entry
  855. getnam3:pop    di
  856.     pop    si
  857.     pop    dx
  858.     pop    cx
  859.     pop    bx
  860.     ret
  861. getname    endp
  862.  
  863. ; Renames macros \%0..\%9 by changing the first two characters of the name
  864. ; to be <null><taklev>. Used to preserve old \%n macros and not show them.
  865. hidemac proc    near
  866.     push    bx
  867.     push    cx
  868.     mov    bx,offset mcctab+1    ; table of macro names, skip count
  869.     mov    cl,mcctab        ; number of entries
  870.     xor    ch,ch
  871.     jcxz    hidema3            ; z = empty table
  872. hidema1:cmp    word ptr [bx],3        ; name length, do three byte names
  873.     jne    hidema2            ; ne = not three chars
  874.     cmp    word ptr [bx+2],'%\'    ; starts with correct prefix?
  875.     jne    hidema2            ; ne = no
  876.     mov    al,byte ptr [bx+4]    ; third char of name
  877.     cmp    al,'0'            ; in digits?
  878.     jb    hidema2            ; b = no
  879.     cmp    al,'9'
  880.     ja    hidema2
  881.     xor    al,al            ; prepare new prefix
  882.     mov    ah,taklev        ; of <null><taklev>
  883.     mov    [bx+2],ax        ; change the macro name
  884. hidema2:mov    ax,[bx]            ; get length of name
  885.     add    ax,4            ; plus count and word pointer
  886.     add    bx,ax            ; point to next entry
  887.     loop    hidema1            ; look at next entry
  888. hidema3:pop    cx
  889.     pop    bx
  890.     ret
  891. hidemac    endp
  892.  
  893. ; Removes all current \%0..\%9 macros and renames <null><taklev> macros by
  894. ; changing the first two characters of the names \%n from <null><taklev> to
  895. ; be "\%". Used to recover old \%n macros from hidemac.
  896. unhidemac proc    near
  897.     push    cx
  898.     push    dx
  899.     push    di
  900.     mov    di,offset temptc    ; temp macro name
  901.     mov    word ptr [di+2],'%\'    ; prefix for "\%n"
  902.     mov    cl,'0'            ; trailer for name
  903.     xor    ch,ch            ; null terminator
  904. unhide1:mov    [di+4],cx        ; compose number
  905.     call    remtab            ; remove "\%n" macro
  906.     inc    cl
  907.     cmp    cl,'9'            ; done?
  908.     jna    unhide1            ; na = no, look at next entry
  909.                            ; now do rename of <null><taklev>n
  910. unhide2:mov    di,offset mcctab+1    ; table of macro names, skip count
  911.     mov    cl,mcctab        ; number of entries
  912.     xor    ch,ch
  913.     jcxz    unhide5            ; z = empty table
  914.     xor    dl,dl            ; macro prefix to examine
  915.     mov    dh,taklev
  916. unhide3:cmp    word ptr [di],3        ; do only "<null><taklev>n" names
  917.     jne    unhide4            ; ne = not three chars
  918.     mov    al,[di+4]        ; get char of name
  919.     cmp    al,'0'            ; is it a char in range for \%0..\%9?
  920.     jb    unhide4            ; b = no
  921.     cmp    al,'9'            ; still in range?
  922.     ja    unhide4            ; a = no
  923.     cmp    word ptr [di+2],dx    ; starts with <null><taklev> prefix?
  924.     jne    unhide4            ; ne = no
  925.     mov    [di+2],'%\'        ; change the macro name back to "\%n"
  926. unhide4:mov    ax,[di]            ; get length of name
  927.     add    ax,4            ; plus count and word pointer
  928.     add    di,ax            ; point to next entry
  929.     loop    unhide3            ; look at next entry
  930. unhide5:pop    di
  931.     pop    dx
  932.     pop    cx
  933.     ret
  934. unhidemac endp
  935.  
  936. ; DEFINE and ASSIGN macro commands
  937. ; Data structures comments. Macro name is stored in table mcctab as if we
  938. ; had used macro mkeyw, such as       mkeyw 'mymac',offset my_definition.
  939. ; In detail:    dw    length of name
  940. ;        db    'name'
  941. ;        dw    segment:0 of definition string
  942. ; Mcctab begins with a byte holding the number of macros in the table; one,
  943. ;  IBM, is established at assembly time. Mcctab is 10*macmax bytes long.
  944. ; Pointer mccptr holds the offset of the next free byte in mcctab.
  945. ; Definition strings are stored in individually allocated memory as
  946. ;        dw    length of definition string below
  947. ;        db    'definition string'
  948. ; A new definition is read into buffer rdbuf+2, where word rdbuf is reserved
  949. ;  to hold the length of the macro's name during intermediate processing.
  950. ; If the definition is absent then the macro is removed from the tables.
  951. ;
  952. ; ASSIGN is equivalent to DEFINE, except in the definition string substitution
  953. ; variable names are expanded to their definitions.
  954. ; DEFINE does not expand substitution variables.
  955. ; Both commands will remove a first level curly brace pair if, and only if,
  956. ; the definition begins and ends with them (trailing whitespace is allowed).
  957. ASSIGN    PROC    NEAR
  958.     mov    defkind,0        ; flag command as ASSIGN, vs DEFINE
  959.     jmp    short dodefcom        ; common code
  960. ASSIGN    ENDP
  961.  
  962. DODEF    PROC    NEAR
  963.     mov    defkind,1        ; flag command as DEFINE, vs ASSIGN
  964. DODEFCOM:
  965.     mov    comand.cmper,1        ; do not react to '\%' in macro name
  966.     mov    ah,cmword
  967.     mov    dx,offset rdbuf+2    ; buffer for macro name
  968.     mov    word ptr rdbuf,0
  969.     mov    comand.cmblen,length rdbuf ; length of analysis buffer
  970.     mov    bx,offset macmsg
  971.     call    comnd            ; get macro name
  972.     jnc    dodef1            ; nc = success
  973.     ret                ; failure
  974. dodef1:    or    ax,ax            ; null entry?
  975.     jnz    dodef2            ; nz = no
  976.     mov    dx,offset ermes6    ; more parameters needed
  977.     jmp    reterr
  978.  
  979. dodef2:    mov    bx,offset rdbuf+2    ; start of string
  980.     cmp    word ptr [bx],'%\'    ; \%<char> substitution variable?
  981.     jne    dodef2b            ; ne = no
  982.     cmp    ax,2            ; count, but missing <char>?
  983.     ja    dodef2a            ; a = no
  984.     mov    byte ptr [bx+2],'_'    ; slip in an underscore
  985. dodef2a:mov    ax,3            ; limit to \%<char>, one char name
  986.  
  987. dodef2b:add    bx,ax            ; point to string terminator
  988.     mov    byte ptr [bx],' '    ; replace null with space separator
  989.     mov    word ptr [bx+1],0    ; terminator, in case no command
  990.     inc    bx            ; where definition will start
  991.     mov    ax,cmdblen        ; length of rdbuf
  992.     sub    ax,bx            ; - (current offset - offset rdbuf)
  993.     add    ax,offset rdbuf        ; ax = amount of buffer used
  994.     mov    comand.cmblen,ax    ; our new buffer length
  995.     mov    al,defkind        ; get ASSIGN/DEFINE flag
  996.     mov    comand.cmper,al        ; react (DEF) to '\%' in definition
  997.     mov    ah,cmline        ; get a line of text
  998.     mov    dx,offset macmsg    ; help, bx is buffer offset
  999.     push    bx            ; save starting offset
  1000.     call    comnd            ; get macro definition text
  1001.     pop    bx
  1002.     jnc    dodef3            ; nc = success
  1003.     ret                ; failure
  1004. dodef3:    add    bx,ax            ; end of command line
  1005.     mov    cx,bx
  1006.     sub    cx,offset rdbuf+2    ; length of command line
  1007. ;;    jmp    dodecom
  1008. DODEF    ENDP
  1009.  
  1010. ; Make a macro table entry and allocate buffer space.
  1011. ; Enter with rdbuf+2 et seq = <macro name><spaces><arg><spaces><arg> ...
  1012. ; and CX = byte count of line, starting at rdbuf+2.
  1013. ; Word rdbuf+0 computed here as length of keyword.
  1014. ; Allocates memory based on analyzed size of command line, returns memory
  1015. ; segment in macptr and in AX. Returns carry set if failure.
  1016. DODECOM    PROC    NEAR
  1017.     push    si            ; macro name in rdbuf+1 et seq
  1018.     push    di            ; cmd line length in deftemp
  1019.     push    es
  1020.     push    ds            ; address data segment
  1021.     pop    es
  1022.     mov    deftemp,cx        ; cmd line len, cx = running counter
  1023.     mov    rdbuf,0            ; number of chars in keyword so far
  1024.                     ; uppercase the keyword, look for end
  1025.     mov    si,offset rdbuf+2    ; point at macro name itself
  1026.     xor    dx,dx            ; a counter
  1027.     cld                ; strings go forward
  1028. dode2:    lodsb                ; get a byte
  1029.     cmp    al,'a'            ; map lower case to upper
  1030.     jb    dode3
  1031.     cmp    al,'z'
  1032.     ja    dode3
  1033.     sub    al,'a'-'A'
  1034.     mov    [si-1],al        ; uppercase if necessary
  1035. dode3:    inc    dx            ; increment char count of keyword
  1036.     cmp    al,' '            ; is this the break character?
  1037.     loopne    dode2            ; no, loop thru rest of word
  1038.     jne    dode4            ; ne = did not end with break char
  1039.     dec    dx            ; yes, don't count in length
  1040. dode4:    mov    di,offset rdbuf        ; point at mac name length
  1041.     mov    [di],dx            ; insert length in rdbuf
  1042.     push    dx            ; save length around call
  1043.     call    remtab            ; remove any duplicate keyword
  1044.                     ; check for free space for keyword
  1045.     pop    ax            ; keyword text length
  1046.     add    ax,4            ; plus count and word pointer
  1047.     add    ax,mccptr        ; add to free space pointer
  1048.     cmp    ax,offset mcctab+mcclen ; enough room for name?
  1049.     jb    dode5            ; b = yes
  1050.     mov    dx,offset ermes1    ; too many macro names
  1051.     pop    es
  1052.     pop    di
  1053.     pop    si
  1054.     jmp    reterr
  1055.  
  1056. dode5:    mov    dx,si            ; trim off leading/trailing spaces
  1057.     call    strlen
  1058.     mov    di,si            ; si = definition source address
  1059.     jcxz    dode5a            ; z = empty string
  1060.     add    di,cx            ; start + length
  1061.     dec    di            ; last char of string
  1062.     std
  1063.     mov    al,' '            ; scan off trailing spaces
  1064.     repe    scasb
  1065.     cld
  1066.     mov    byte ptr [di+2],0    ; plant new terminator
  1067. dode5a:    mov    dx,si
  1068.     call    strlen            ; get new length into cx
  1069.     cld
  1070.     mov    di,si            ; scan after keyword name
  1071.     mov    al,' '            ; remove leading spaces in string
  1072.     repe    scasb
  1073.     jne    dode6            ; ne = have some text
  1074.     pop    es            ; all spaces
  1075.     pop    di
  1076.     pop    si
  1077.     clc                ; success
  1078.     ret
  1079. dode6:    dec    di            ; offset auto increment of rep
  1080.     mov    si,di            ; new start of string
  1081.     mov    dx,si            ; source of definition text
  1082.     call    strlen            ; get length of string into cx
  1083.     mov    deftemp,cx        ; remember it here
  1084.                     ; install new keyword
  1085.     jcxz    dode10            ; z = no def, exit now
  1086.     mov    bx,cx            ; string length, in bytes
  1087.     add    bx,2+1+15        ; count + null term + round up
  1088.     mov    cl,4
  1089.     shr    bx,cl            ; convert to paragraphs (divide by 16)
  1090.     mov    cx,bx            ; remember desired paragraphs
  1091.     mov    ah,alloc        ; allocate a memory block
  1092.     int    dos
  1093.     jc    dode12            ; c = error, not enough memory
  1094.      cmp    bx,cx            ; obtained vs wanted
  1095.     jae    dode7            ; ae = enough
  1096.     mov    es,ax            ; allocated segment
  1097.     mov    ah,freemem        ; free it again
  1098.     int    dos
  1099.     jmp    short dode12        ; quit here
  1100.  
  1101. dode7:    mov    macptr,ax        ; store new segment
  1102.     mov    es,ax            ; segment of string
  1103.     xor    di,di            ; offset of count word
  1104.     mov    cx,deftemp        ; length of definition string
  1105.     mov    ax,cx
  1106.     cld
  1107.     stosw                ; store length of string
  1108.     rep    movsb            ; copy string
  1109.     mov    bx,offset mcctab    
  1110.     mov    dx,offset rdbuf        ; count word + name string
  1111.     call    addtab
  1112. dode10:    mov    ax,macptr        ; return buffer segment to caller
  1113.     pop    es
  1114.     pop    di
  1115.     pop    si
  1116.     clc                ; success
  1117.     ret
  1118. dode12:    pop    es            ; no memory, clean stack
  1119.     pop    di
  1120.     pop    si
  1121.     mov    dx,offset ermes2    ; no room for definition
  1122.     mov    ah,prstr
  1123.     int    dos
  1124.     stc
  1125.     ret
  1126. DODECOM    ENDP
  1127.  
  1128. ; ASK <variable or macro name> <prompt string>
  1129. ; Defines indicated variable/macro with text from user at keyboard or pipe
  1130. ; (but not from a Take/macro). Prompt string is required.
  1131. ; ASKQ does the same, but does not echo user's response.
  1132. ASKQ    PROC    NEAR
  1133.     mov    askecho,1        ; temp to flag as Quiet version
  1134.     jmp    short ask0        ; do common code
  1135. ASKQ    ENDP
  1136.  
  1137. ASK    PROC    NEAR
  1138.     mov    askecho,0        ; temp to flag as echoing version
  1139. ask0:                    ; common code for ASK and ASKQ
  1140.     mov    dx,offset rdbuf+2    ; point to work buffer
  1141.     mov    word ptr rdbuf,0
  1142.     mov    bx,offset askhlp1    ; help
  1143.     mov    comand.cmper,1        ; do not expand variable name
  1144.     mov    ah,cmword        ; get variable name
  1145.     call    comnd
  1146.     jnc    ask1            ; nc = success
  1147.     ret                ; failure
  1148. ask1:    or    ax,ax            ; anything given?
  1149.     jnz    ask2            ; nz = yes
  1150.     mov    dx,offset ermes6    ; more parameters needed
  1151.     jmp    reterr
  1152.  
  1153. ask2:    cmp    word ptr rdbuf+2,'%\'    ; \%<char> substitution variable?
  1154.     jne    ask2b            ; ne = no
  1155.     cmp    ax,2            ; but missing <char>
  1156.     ja    ask2a            ; a = no
  1157.     mov    rdbuf+4,'_'        ; slip in an underscore
  1158. ask2a:    mov    ax,3            ; limit to a single char
  1159. ask2b:    mov    bx,offset rdbuf+2    ; start of name
  1160.     add    bx,ax            ; plus length of variable name
  1161.     mov    byte ptr [bx],' '    ; put space separator after name
  1162.     inc    ax            ; count space
  1163.     mov    numhlp,ax        ; remember length here
  1164.                     ; get ASK command prompt string
  1165.     mov    bx,offset decbuf    ; borrowed buffer for prompt
  1166.     mov    byte ptr [bx],0        ; safety terminator
  1167.     mov    dx,offset askhlp2
  1168.     mov    comand.cmblen,127    ; our buffer length
  1169.     sub    comand.cmblen,ax    ;  minus part used above
  1170.     mov    ah,cmline        ; get prompt string
  1171.     call    comnd
  1172.     jnc    ask3            ; nc = success
  1173.     ret                ; failure
  1174. ask3:    or    ax,ax            ; anything given?
  1175.     jnz    ask4            ; nz = yes
  1176.     mov    dx,offset ermes6    ; more parameters needed
  1177.     jmp    reterr
  1178.  
  1179. ask4:    mov    ax,takadr        ; we could be in a macro or Take file
  1180.     mov    temp2,ax        ; save Take address
  1181.     mov    al,taklev
  1182.     xor    ah,ah
  1183.     mov    temp1,ax        ; and Take level
  1184.     mov    dx,size takinfo        ; bytes for each current Take
  1185.     mul    dx            ; times number of active Take/macros
  1186.     sub    takadr,ax        ; clear Take address as if no
  1187.     mov    taklev,0        ;  Take/macro were active so that
  1188.                     ;  user input is from kbd or pipe
  1189.     mov    word ptr [bx],0020h    ; printing terminator for prompt
  1190.     mov    si,offset decbuf
  1191.     mov    di,si            ; convert in-place
  1192.     call    cnvlin            ; convert backslash items
  1193.     mov    dx,si            ; converted prompt string, asciiz
  1194.      call    prompt            ; use our prompt
  1195.     mov    bx,offset rdbuf+129    ; use this buffer for raw user input
  1196.     mov    word ptr [bx],0        ; insert terminator
  1197.     mov    dl,askecho        ; get echo/quiet flag
  1198.     mov    comand.cmquiet,dl    ; 0 if echoing
  1199.     mov    dx,offset askhlp3    ; help for user input
  1200.     mov    ah,cmline        ; read user's input string
  1201.     call    comnd
  1202.     mov    comand.cmquiet,0    ; permit echoing again
  1203.     mov    cx,temp2
  1204.     mov    takadr,cx        ; restore Take address
  1205.     mov    cx,temp1
  1206.     mov    taklev,cl        ; restore Take level
  1207.     jnc    ask5            ; nc = success
  1208.     ret                ; Control-C, quit now
  1209. ask5:    mov    cx,ax            ; length of entry
  1210.     mov    si,offset rdbuf+129    ; source string
  1211.     mov    di,offset rdbuf+2    ; start of variable name
  1212.     add    di,numhlp        ; di points to final user string
  1213.     push    es            ; save es
  1214.     push    ds
  1215.     pop    es            ; set es to data segment
  1216.     cld
  1217.     jcxz    ask8            ; z = empty
  1218.     rep    movsb            ; copy string
  1219. ask8:    xor    al,al            ; get null terminator
  1220.     stosb                ; plant it
  1221.     pop    es
  1222.      mov    dx,offset rdbuf+2    ; command buffer beginning
  1223.     call    strlen            ; CX=len of <variable>< ><user string>
  1224.     jmp    DODECOM            ; define the macro/variable and exit
  1225. ASK    ENDP
  1226.  
  1227. ; GETOK <prompt>   displays prompt or default prompt, asks for affirmative
  1228. ; user reply, returns success/fail status.
  1229. getok    proc    near
  1230.     mov    bx,offset rdbuf        ; point to work buffer
  1231.     mov    word ptr [bx],0        ; safety terminator
  1232.     mov    dx,offset getokhlp
  1233.     mov    comand.cmblen,127    ; our buffer length
  1234.     mov    comand.cmcr,1        ; bare cr is ok
  1235.     mov    ah,cmline        ; get prompt string
  1236.     mov    comand.cmcr,0
  1237.     call    comnd
  1238.     jnc    getok1            ; nc = success
  1239.     ret                ; failure
  1240. getok1:    or    ax,ax            ; anything given?
  1241.     jnz    getok2            ; nz = yes
  1242.     mov    si,offset getdef    ; default prompt
  1243.     mov    di,offset rdbuf
  1244.     call    strcpy            ; paste in default prompt
  1245.  
  1246. getok2:    mov    ax,takadr        ; we could be in a macro or Take file
  1247.     mov    temp2,ax        ; save Take address
  1248.     mov    al,taklev
  1249.     xor    ah,ah
  1250.     mov    temp1,ax        ; and Take level
  1251.     mov    dx,size takinfo        ; bytes for each current Take
  1252.     mul    dx            ; times number of active Take/macros
  1253.     sub    takadr,ax        ; clear Take address as if no
  1254.     mov    taklev,0        ;  Take/macro were active so that
  1255.                     ;  user input is from kbd or pipe
  1256.     mov    si,offset rdbuf
  1257.     mov    di,si            ; convert in-place
  1258.     call    cnvlin            ; convert backslash items
  1259.     mov    dx,si
  1260.     call    strlen            ; get length to cx
  1261.     mov    bx,cx
  1262.     mov    word ptr [si+bx],0020h    ; printing terminator for prompt
  1263. getok3:    mov    dx,offset rdbuf        ; converted prompt string, asciiz
  1264.      call    prompt            ; use our prompt
  1265.     mov    flags.cxzflg,0        ; clear Control-C indicator
  1266.     mov    dx,offset gettab    ; use this table
  1267.     xor    bx,bx            ; table is help
  1268.     mov    comand.cmcr,1        ; null response permitted
  1269.     mov    ah,cmkey        ; read user's input word
  1270.     call    comnd
  1271.     mov    comand.cmcr,0
  1272.     jnc    getok4            ; nc = success
  1273.     cmp    flags.cxzflg,'C'    ; did user type Control-C to quit?
  1274.     jne    short getok3        ; ne = no, syntax failure, reprompt
  1275.     stc                ; set carry flag again
  1276.     jmp    short getok5        ; exit failure
  1277. getok4:    push    bx
  1278.     mov    ah,cmeol        ; get c/r confirmation
  1279.     call    comnd
  1280.     pop    bx            ; recover keyword 16 bit value
  1281. getok5:    mov    cx,temp2
  1282.     mov    takadr,cx        ; restore Take address
  1283.     mov    cx,temp1
  1284.     mov    taklev,cl        ; restore Take level
  1285.     jnc    getok6            ; nc = success
  1286.     mov    kstatus,ksgen        ; failure
  1287.     ret                ; Control-C, quit now
  1288. getok6:    mov    kstatus,bx        ; return status
  1289.     ret
  1290. getok    endp
  1291.  
  1292. ; Initialize macro IBM at Kermit startup time
  1293. initibm    proc    near
  1294.     mov    si,offset ibmmac    ; text of IBM macro
  1295.     mov    di,offset rdbuf+2    ; where command lines go
  1296.     call    strcpy            ; copy it there
  1297.     mov    dx,di            ; get length of command line
  1298.     call    strlen            ; set cx to length, for dodecom
  1299.     jmp    dodecom            ; now define the macro
  1300. initibm    endp
  1301.  
  1302. ; Open a disk based Take file buffer. Define macro named "<null>T<'taklev'>",
  1303. ; in mcctab and allocate 128 byte uninitiated buffer for disk i/o. Leading null
  1304. ; is to prevent user from employing the same name accidentally. Return seg
  1305. ; of buffer in [takadr].takbuf and set [takadr].takptr to offset of first
  1306. ; byte after leading count byte. Uses dodecom to make this macro.
  1307. ; Return carry clear for success, carry set for failure.
  1308.  
  1309. TAKOPEN    PROC    NEAR
  1310.     push    ax
  1311.     push    bx
  1312.     push    cx
  1313.     push    dx
  1314.     cmp    taklev,maxtak        ; room in take level?
  1315.     jb    takope1            ; b = yes
  1316.     mov    dx,offset ermes4    ; say too many Take files
  1317.     mov    ah,prstr        ; display error message
  1318.     int    dos
  1319.     stc                ; set carry for failure
  1320.     jmp    short takope2
  1321.  
  1322. takope1:mov    word ptr rdbuf,3    ; length of name, 3 bytes <null>Tn
  1323.     mov    rdbuf+2,0
  1324.     mov    rdbuf+3,'T'        ; name of <null>Tn
  1325.     mov    al,taklev        ; Take level digit
  1326.     inc    al            ; for what will be next Take level
  1327.     add    al,'0'            ; add ascii bias
  1328.     mov    rdbuf+4,al        ; last of the name
  1329.     mov    rdbuf+5,' '        ; separate dummy definition
  1330.     mov    cx,tbufsiz        ; fill with dummy non-blank data
  1331.     push    cx            ; length of buffer, for dodecom
  1332.     push    di
  1333.     push    es            ; save es
  1334.     push    ds            ; set es to data segment
  1335.     pop    es
  1336.     cld
  1337.     mov    al,'.'            ; dummy fill pattern
  1338.     mov    di,offset rdbuf+6    ; definition text starts here
  1339.     rep    stosb            ; store the pattern
  1340.     pop    es
  1341.     pop    di
  1342.     pop    cx            ; get command length again
  1343.     call    dodecom            ; define our Take macro
  1344.     jc    takope2            ; c = failure
  1345.     xor    ax,ax
  1346.     xor    cx,cx
  1347.     cmp    taklev,0        ; at top level now?
  1348.     je    takope3            ; e = yes
  1349.     mov    bx,takadr
  1350.     mov    ax,[bx].takargc        ; get argument count
  1351.     mov    cx,[bx].takctr        ; get COUNT
  1352. takope3:add    takadr,size takinfo    ; pointer to new Take structure
  1353.     inc    taklev
  1354.     mov    bx,takadr        ; pointer to new Take structure
  1355.     mov    [bx].takargc,ax        ; copy in old argc
  1356.     mov    [bx].takctr,cx        ; copy in old count
  1357.     mov    ax,macptr        ; segment of buffer
  1358.     mov    [bx].takbuf,ax        ; segment of Take buffer
  1359.     mov    [bx].takcnt,tbufsiz-2    ; number of unread bytes
  1360.     mov    [bx].takptr,2        ; init pointer to definition itself
  1361.     clc                ; carry clear for success
  1362. takope2:pop    dx
  1363.     pop    cx
  1364.     pop    bx
  1365.     pop    ax
  1366.     ret
  1367. TAKOPEN    ENDP
  1368.  
  1369. ; Close Take file. Enter at Take level to be closed. Removes pseudo macro
  1370. ; name <null>Tn and its buffer, closes disk file, pops Take level.
  1371.  
  1372. TAKCLOS    PROC    NEAR
  1373.     cmp    taklev,0        ; anything to close?
  1374.     jle    takclo3            ; le = no
  1375.     push    ax
  1376.     push    bx
  1377.     push    cx
  1378.     mov    al,taklev        ; Take level digit
  1379.     add    al,'0'            ; add ascii bias
  1380.     mov    temptc+2,0
  1381.     mov    temptc+3,'T'
  1382.     mov    temptc+4,al        ; last of the name
  1383.     push    di
  1384.     mov    di,offset temptc    ; pointer for remtab
  1385.     call    remtab            ; remove possible old macro and buffer
  1386.     pop    di
  1387.     mov    bx,takadr        ; point to Take structure
  1388.     mov    al,[bx].taktyp
  1389.     cmp    [bx].taktyp,0feh    ; disk file?
  1390.     jne    takclo1            ; ne = no, no buffer to deallocate
  1391.     mov    bx,[bx].takhnd        ; get file handle
  1392.     mov    ah,close2        ; close file
  1393.     int    dos
  1394.     dec    taklev            ; pop disk file Take level
  1395.     sub    takadr,size takinfo    ; get previous Take's address
  1396.     jmp    short takclo2
  1397.  
  1398. takclo1:dec    taklev            ; pop macro Take level
  1399.     sub    takadr,size takinfo    ; get previous Take's address
  1400.     cmp    al,0ffh            ; regular macro?
  1401.     jne    takclo2            ; ne = no, no unhiding necessary
  1402.     call    unhidemac        ; rename previous \%n macros
  1403. takclo2:pop    cx
  1404.     pop    bx
  1405.     pop    ax            ; close prev Take/Macro if at EOF too
  1406.      cmp    taklev,0        ; Take/macro still open?
  1407.     je    takclo3            ; e = no
  1408.     push    bx
  1409.     mov    bx,takadr        ; get it's address
  1410.     cmp    [bx].takcnt,0        ; is it at EOF?
  1411.     pop    bx
  1412.     ja    takclo3            ; a = no
  1413.     call    takrd            ; empty Take, try filling buf again
  1414.     push    bx
  1415.     mov    bx,takadr        ; get it's address
  1416.     cmp    [bx].takcnt,0        ; is it at EOF?
  1417.     pop    bx
  1418.     ja    takclo3            ; a = not an empty Take file
  1419.     jmp    takclos            ; yes, close it too
  1420. takclo3:ret
  1421. TAKCLOS    ENDP
  1422.  
  1423. ; POP/END command. Defend against command parser closing the Take/Macro at
  1424. ; the end of file. Return optional trailing number in ERRORLEVEL (errlev).
  1425. POPCMD    proc    near
  1426.     mov    ah,cmline        ; get optional error value and msg
  1427.     mov    bx,offset rdbuf+1
  1428.     mov    rdbuf,'\'        ; in case the user did not specify
  1429.     mov    dx,offset pophlp    ; help on numerical argument
  1430.     mov    comand.cmcr,1        ; bare c/r's allowed
  1431.     call    comnd
  1432.     mov    comand.cmcr,0        ; restore normal state
  1433.     jc    popcmd3            ; c = failure
  1434.     mov    ah,cmeol        ; confirm
  1435.     call    comnd
  1436.     jc    popcmd3
  1437.     mov    si,offset rdbuf
  1438.     cmp    byte ptr [si+1],'\'    ; user specified?
  1439.     jne    popcmd1            ; ne = no, use ours
  1440.     inc    si            ; yes, use theirs
  1441. popcmd1:call    katoi            ; convert to number in ax
  1442.     jc    popcmd2            ; c = not a number
  1443.     mov    errlev,al        ; return value in ERRORLEVEL
  1444.     mov    kstatus,ax        ; and in STATUS
  1445.     mov    di,si            ; msg pointer, convert in-place
  1446.     call    cnvlin            ; convert braces and numbers
  1447. popcmd4:lodsb                ; read a msg char
  1448.     or    al,al            ; null terminator?
  1449.     jz    popcmd2            ; z = empty string
  1450.     cmp    al,' '            ; leading white space?
  1451.     je    popcmd4            ; be = leading white space
  1452.     dec    si            ; backup to non-white char
  1453.     mov    di,si            ; msg pointer, convert in-place
  1454.     call    cnvlin            ; convert braces and numbers
  1455.     mov    dx,offset crlf
  1456.     mov    ah,prstr
  1457.     int    dos
  1458.     mov    dx,si            ; message
  1459.     call    prtasz
  1460. popcmd2:mov    al,oldtak        ; Take level previous to this cmd
  1461.     sub    al,taklev        ; minus Take level now
  1462.     ja    popcmd3            ; a = have exited macro already
  1463.     jmp    takclos            ; close current Macro/Take
  1464. popcmd3:ret
  1465. POPCMD    endp
  1466.  
  1467. ; add an entry to a keyword table
  1468. ; enter with bx = table address, dx = ptr to new entry, macptr = string seg
  1469. ; mccptr = offset of free bytes in table mcctab.
  1470. ; no check is made to see if the entry fits in the table.
  1471. addtab    proc    near
  1472.     push    cx
  1473.     push    si
  1474.     push    es
  1475.     push    bp
  1476.     cld
  1477.     mov    ax,ds
  1478.     mov    es,ax        ; address data segment
  1479.     mov    bp,bx        ; remember where macro name table starts
  1480.     mov    cl,[bx]        ; pick up length of table
  1481.     xor    ch,ch
  1482.     inc    bx        ; point to actual table
  1483.     jcxz    addta4        ; cx = 0 if table is presently empty
  1484.  
  1485. addta1:    push    cx        ; preserve count
  1486.     mov    si,dx        ; point to entry
  1487.     lodsw            ; get length of new entry
  1488.     mov    cx,[bx]        ; and length of table entry
  1489.     cmp    ax,cx        ; are they the same?
  1490.     lahf            ; remember result of comparison
  1491.     jae    addta2        ; is new smaller? ae = no, use table length
  1492.     mov    cx,ax        ; else use length of new entry
  1493. addta2:    lea    di,[bx+2]    ; point to actual keyword
  1494.     repe    cmpsb        ; compare strings
  1495.     pop    cx        ; restore count
  1496.     jb    addta4        ; below, insert before this one
  1497.     jne    addta3        ; not below or same, keep going
  1498.     sahf            ; same. get back result of length comparison
  1499.     jb    addta4        ; if new len is smaller, insert here
  1500.     jne    addta3        ; if not same size, keep going
  1501.     mov    si,bx        ; else this is where entry goes
  1502.     jmp    short addta6    ; no insertion required
  1503. addta3:    mov    ax,[bx]        ; length of keyword
  1504.     add    bx,ax        ; skip this entry
  1505.     add    bx,4        ; length word and 16 bit value
  1506.     loop    addta1        ; and keep looking
  1507. addta4:    mov    si,bx        ; this is first location to move
  1508.     mov    di,bx
  1509.     inc    ds:byte ptr [bp] ; remember we're adding one
  1510.     jcxz    addta6        ; z = no more entries, forget this stuff
  1511. addta5:    mov    bx,[di]        ; get length
  1512.     lea    di,[bx+di+4]    ; end is origin + length + 4 for len, value
  1513.     loop    addta5        ; loop thru remaining keywords
  1514.     mov    cx,di
  1515.     sub    cx,si        ; compute # of bytes to move
  1516.     push    si        ; preserve loc for new entry
  1517.     mov    si,di        ; first to move is last
  1518.     dec    si        ; minus one
  1519.     mov    di,dx        ; new entry
  1520.     mov    bx,[di]        ; get length
  1521.     lea    di,[bx+si+4]    ; dest is source + length of new + 4
  1522.     std            ; move backward
  1523.     rep    movsb        ; move the table down (compress it)
  1524.     cld            ; put flag back
  1525.     pop    si
  1526. addta6:    mov    di,si        ; this is where new entry goes
  1527.     mov    si,dx        ; this is where it comes from
  1528.     mov    cx,[si]        ; length of name
  1529.     add    cx,2        ; include count byte
  1530.     add    mccptr,cx    ; update free space pointer: cnt+name
  1531.     rep    movsb        ; insert new entry
  1532.     mov    ax,macptr    ; and string address
  1533.     stosw
  1534.     add    mccptr,2    ; plus string address
  1535.     pop    bp
  1536.     pop    es
  1537.     pop    si
  1538.     pop    cx
  1539.     ret
  1540. addtab    endp
  1541.  
  1542. ; If new keyword matches an existing one then remove existing keyword,
  1543. ; its string definition, compress tables mcctab and macbuf, readjust string
  1544. ; pointers for each macro name, reduce number of macro table entries by one.
  1545. ; Enter with DI pointing at length word of mac name (followed by mac name).
  1546. ; Otherwise, exit with no changes.  13 June 1987 [jrd]
  1547. remtab    proc    near
  1548.     push    ax
  1549.     push    bx
  1550.     push    cx
  1551.     push    si
  1552.     push    di
  1553.     mov    bx,temp            ; preserve
  1554.     push    bx
  1555.     mov    bx,offset mcctab+1    ; table of macro keywords
  1556.     mov    temp,0            ; temp = current keyword
  1557.     cmp    byte ptr mcctab,0    ; any macros defined?
  1558.     jne    remta1            ; ne = yes
  1559.     jmp    remtax            ; else exit now
  1560. remta1:                    ; match table keyword and text word
  1561.     mov    si,di            ; pointer to user's cnt+name
  1562.     mov    cx,[si]            ; length of user's macro name
  1563.     add    si,2            ; point to new macro name
  1564.     cmp    cx,[bx]            ; compare length vs table keyword
  1565.     jne    remta4            ; ne = not equal lengths, try another
  1566.     push    si            ; lengths match, how about spelling?
  1567.     push    bx
  1568.     add    bx,2            ; point at start of keyword
  1569. remta2:    mov    ah,[bx]            ; keyword char
  1570.     mov    al,[si]            ; new text char
  1571.     cmp    al,ah            ; test characters
  1572.     jne    remta3            ; ne = no match
  1573.     inc     si            ; move to next char
  1574.     inc    bx
  1575.     loop    remta2            ; loop through entire length
  1576. remta3:    pop    bx
  1577.     pop    si
  1578.     jcxz    remta6            ; z: cx = 0, exit with match;
  1579.                     ;  else select next keyword
  1580. remta4:    inc    temp            ; number of keyword to test next
  1581.     mov    cx,temp
  1582.     cmp    cl,mcctab        ; all done? Recall, temp starts at 0
  1583.     jb    remta5            ; b = not yet
  1584.     jmp    remtax            ; exhausted search, unsuccessfully
  1585. remta5:    mov    ax,[bx]            ; cnt (keyword length from macro)
  1586.     add    ax,4            ; skip count and word pointer
  1587.     add    bx,ax            ; bx = start of next keyword slot
  1588.     jmp    short remta1        ; do another comparison
  1589.                     ; new name already present as a macro
  1590. remta6:    cld                ; clear macro string and macro name
  1591.     push    ds
  1592.     pop    es            ; set es to data segment
  1593.     mov    temp,bx            ; save ptr to found keyword
  1594.     mov    ax,[bx]            ; cnt (keyword length of macro)
  1595.     add    ax,2            ; skip cnt
  1596.     add    bx,ax            ; point to string segment field
  1597.     add    ax,2            ; count segment field bytes
  1598.     sub    mccptr,ax        ; readjust free space ptr for names
  1599.     push    bx
  1600.     push    es
  1601.     mov    es,[bx]            ; segment of string
  1602.     mov    ax,ds            ; check for being in our data segment
  1603.     cmp    ax,[bx]            ; same as our data seg?
  1604.     je    remta7            ; e = yes, don't free that
  1605.     mov    ah,freemem        ; free that memory block
  1606.     int    dos
  1607. remta7:    pop    es
  1608.     pop    bx
  1609.                     ; clear keyword table mcctab
  1610.     add    bx,2            ; compute source = next keyword
  1611.     mov    si,bx            ; address of next keyword
  1612.     mov    di,temp            ; address of found keyword
  1613.     mov    cx,offset mcctab+mcclen ; address of buffer end
  1614.     sub    cx,si            ; amount to move
  1615.     jcxz    remtax            ; cx = 0 means none
  1616.     rep    movsb            ; move down keywords (deletes current)
  1617.     dec    mcctab            ; one less keyword
  1618. remtax:    pop    temp            ; recover temp variable
  1619.     pop    di
  1620.     pop    si
  1621.     pop    cx
  1622.     pop    bx
  1623.     pop    ax
  1624.     ret
  1625. remtab    endp
  1626.  
  1627. ; Common Get keyword + Get Confirm sequence. Call with dx = keyword table,
  1628. ; bx = help message offset. Returns result in BX. Modifies AX, BX.
  1629. ; Returns carry clear if sucessful else carry set. Used in many places below.
  1630. keyend    proc    near
  1631.     mov    ah,cmkey
  1632.     call    comnd
  1633.     jnc    keyend1            ; nc = success
  1634.     ret                ; failure
  1635. keyend1:push    bx            ; save returned results around call
  1636.     mov    ah,cmeol        ; get c/r confirmation
  1637.     call    comnd
  1638.     pop    bx            ; recover keyword 16 bit value
  1639.     ret                ; return with carry from comnd
  1640. keyend    endp
  1641.  
  1642. srvdsa    proc    near            ; DISABLE Server commands
  1643.     mov    dx,offset srvdetab
  1644.     mov    bx,offset sdshlp
  1645.     call    keyend
  1646.     jc    srvdsa1            ; c = failure
  1647.     cmp    apctrap,0        ; disable from APC
  1648.     jne    srvdsa1            ; ne = yes
  1649.     or    denyflg,bx        ; turn on bit (deny) for that item
  1650. srvdsa1:ret
  1651. srvdsa    endp
  1652.  
  1653. srvena    proc    near            ; ENABLE Server commands
  1654.     mov    dx,offset srvdetab    ; keyword table
  1655.     mov    bx,offset sdshlp    ; help on keywords
  1656.     call    keyend
  1657.     jc    srvena1            ; c = failure
  1658.     cmp    apctrap,0        ; disable from APC
  1659.     jne    srvena1            ; ne = yes
  1660.     not    bx            ; invert bits
  1661.     and    denyflg,bx        ; turn off (enable) selected item
  1662. srvena1:ret
  1663. srvena    endp
  1664.  
  1665.  
  1666. ; This is the SET command
  1667. ; Called analyzers return carry clear for success, else carry set.
  1668. SETCOM    PROC    NEAR            ; Dispatch all SET commands from here
  1669.     mov    kstatus,kssuc        ; global status, success
  1670.     mov    dx,offset settab    ; Parse a keyword from the set table
  1671.     mov    bx,offset sethlp
  1672.     mov    ah,cmkey
  1673.     call    comnd
  1674.     jc    setcom1            ; c = failure
  1675.     jmp    bx            ; execute analyzer routine
  1676. setcom1:ret
  1677. SETCOM    endp
  1678.  
  1679. SETATT    PROC    NEAR            ; Set attributes on | off
  1680.     mov    dx,offset atttab
  1681.     xor    bx,bx
  1682.     mov    ah,cmkey
  1683.     call    comnd
  1684.     jc    setatt3            ; c = failure
  1685.     mov    dx,bx            ; hold results in dx
  1686.     cmp    dl,0ffh            ; ON/OFF (all of them)?
  1687.     je    setatt1            ; e = yes
  1688.     push    dx
  1689.     mov    dx,offset ontab        ; get on/off state
  1690.     xor    bx,bx
  1691.     mov    ah,cmkey
  1692.     call    comnd
  1693.     pop    dx
  1694.     jc    setatt3            ; c = failure
  1695.     mov    dh,bl            ; store on/off state in dh
  1696. setatt1:push    dx
  1697.     mov    ah,cmeol
  1698.     call    comnd
  1699.     pop    dx
  1700.     jc    setatt3
  1701.     mov    al,flags.attflg        ; current flags
  1702.     not    dl            ; all but those affected
  1703.     and    al,dl            ; turn off affected flags
  1704.     or    dh,dh            ; off (dh = 0)?
  1705.     jz    setatt2            ; z = yes
  1706.     not    dl            ; affected flags back again as ones
  1707.     or    al,dl            ; turn on affected flags
  1708. setatt2:mov    flags.attflg,al
  1709. setatt3:ret
  1710. SETATT    ENDP
  1711.  
  1712. ; SET BAUD or SET SPEED
  1713. ; See system dependent routine BAUDST in file MSXxxx.ASM
  1714.  
  1715. ; SET BELL on or off
  1716.  
  1717. BELLST    PROC    NEAR
  1718.     mov    dx,offset ontab        ; on/off table
  1719.     xor    bx,bx            ; help
  1720.     call    keyend
  1721.     jc    bellst1            ; c = failure
  1722.     mov    flags.belflg,bl
  1723. bellst1:ret
  1724. BELLST    ENDP
  1725.  
  1726. ; SET BLOCK-CHECK
  1727.  
  1728. BLKSET    PROC    NEAR
  1729.     mov    dx,offset blktab    ; table
  1730.     xor    bx,bx            ; help, use table
  1731.     call    keyend
  1732.     jc    blkset1            ; c = failure
  1733.     mov    dtrans.chklen,bl    ; use this char as initial checksum
  1734. blkset1:ret
  1735. BLKSET    ENDP
  1736.  
  1737.  
  1738. ; Set port addresses for COM1 .. COM4 at Kermit initialization time via
  1739. ; Environment. Called by command parser while doing Environment reading in
  1740. ; mssker.asm and via SET COM1 .. SET COM4.
  1741. COM1PORT proc    near
  1742.     mov    bx,0            ; offset of com1 port address
  1743.     jmp    short comport
  1744. COM1PORT endp
  1745. COM2PORT proc    near
  1746.     mov    bx,2            ; offset of com2 port address
  1747.     jmp    short comport
  1748. COM2PORT endp
  1749. COM3PORT proc    near
  1750.     mov    bx,4            ; offset of com3 port address
  1751.     jmp    short comport
  1752. COM3PORT endp
  1753.  
  1754. COM4PORT proc    near
  1755.     mov    bx,6            ; offset of com4 port address
  1756. ;;    jmp    comport
  1757. COM4PORT endp
  1758.  
  1759. COMPORT    proc    near            ; worker for above
  1760.     push    bx            ; save offset
  1761.     mov    dx,offset rdbuf+1
  1762.     mov    word ptr rdbuf,0
  1763.     mov    bx,offset comhlp
  1764.     mov    ah,cmword        ; get port address number
  1765.     call    comnd
  1766.     jnc    compor3
  1767.     pop    bx            ; fail
  1768.     ret
  1769. compor3:mov    numerr,0        ; no error message
  1770.     mov    min,100h        ; smallest number
  1771.     mov    max,0fff0h        ; largest magnitude
  1772.     mov    numhlp,0        ; help
  1773.     call    numwd            ; parse this word
  1774.     jnc    compor4            ; nc = success, value in ax
  1775.     pop    bx
  1776.     ret
  1777. compor4:mov    temp1,ax        ; save port address
  1778.     mov    dx,offset rdbuf+1
  1779.     mov    word ptr rdbuf,0
  1780.     mov    bx,offset irqhlp
  1781.     mov    temp2,0
  1782.     mov    ah,cmword        ; read IRQ
  1783.     call    comnd
  1784.     jnc    compor5
  1785.     pop    bx
  1786.     ret
  1787. compor5:push    ax
  1788.     mov    ah,cmeol        ; get command confirmation
  1789.     call    comnd
  1790.     pop    ax
  1791.     jnc    compor5a        ; nc = success
  1792.     ret
  1793. compor5a:or    ax,ax            ; anything given?
  1794.     jz    compor7            ; z = no
  1795.     mov    numhlp,0        ; help
  1796.     mov    numerr,0        ; no error message
  1797.     mov    min,2            ; smallest number
  1798.     mov    max,15            ; largest magnitude
  1799.     call    numwd            ; parse this word
  1800.     jnc    compor6            ; nc = success
  1801.     pop    bx
  1802.     ret
  1803. compor6:mov    temp2,ax        ; save IRQ
  1804. compor7:pop    bx            ; recover offset
  1805.     cmp    word ptr machnam,'BI'    ; check for "IBM-PC"
  1806.     jne    compor1            ; ne = not this name, fail
  1807.     cmp    word ptr machnam+2,'-M'
  1808.     jne    compor1
  1809.     cmp    word ptr machnam+4,'CP'
  1810.     jne    compor1
  1811.     push    es
  1812.     mov    al,flags.comflg        ; current comms port
  1813.     dec    al            ; count from 0, as per Bios
  1814.     shl    al,1            ; double to use word index of Bios
  1815.     cmp    al,bl            ; using this port now?
  1816.     jne    compor2            ; ne = no
  1817.     call    serrst            ; reset the port
  1818. compor2:mov    cx,40h            ; segment 40h
  1819.     mov    es,cx
  1820.     mov    ax,temp1        ; port address
  1821.     mov    es:[bx],ax        ; set port address
  1822.     pop    es
  1823.     shr    bl,1            ; coms port offset 0,2,4,6 to 0,1,2,3
  1824.     mov    ax,temp2        ; IRQ
  1825.     mov    portirq[bx],al
  1826.     clc
  1827. compor1:ret
  1828. COMPORT    endp
  1829.  
  1830. ; Set CONTROL PREFIXED <code>, CONTROL UNPREFIXED <code>, code can be ALL
  1831. cntlset    proc    near
  1832.     push    es
  1833.     mov    di,seg decbuf        ; copy protlist to work buffer decbuf
  1834.     mov    es,di
  1835.     mov    si,offset protlist
  1836.     mov    di,offset decbuf
  1837.     mov    cx,32
  1838.     cld
  1839.     rep    movsb
  1840.     pop    es
  1841.  
  1842.     mov    dx,offset cntltab    ; table
  1843.     mov    bx,offset cntlhlp    ; help
  1844.     mov    ah,cmkey
  1845.     call    comnd
  1846.     jc    cntlsetx        ; c = failure
  1847.     mov    rdbuf,bl        ; save operation value
  1848. cntlse1:mov    ah,cmword        ; get optional error value and msg
  1849.     mov    dx,offset rdbuf+2
  1850.     mov    rdbuf+1,'\'        ; in case the user did not specify
  1851.     mov    bx,offset ctlhlp    ; help on numerical argument
  1852.     call    comnd
  1853.     jc    cntlsetx        ; c = failure
  1854.     mov    si,offset rdbuf+2
  1855.     or    ax,ax            ; anything given?
  1856.     jnz    cntlse2            ; nz = yes
  1857.     mov    ah,cmeol        ; confirm
  1858.     call    comnd
  1859.     jc    cntlsetx        ; c = failure
  1860.     push    es            ; copy work buffer decbuf to protlist
  1861.     mov    di,seg protlist
  1862.     mov    es,di
  1863.     mov    di,offset protlist
  1864.     mov    si,offset decbuf
  1865.     mov    cx,32
  1866.     cld
  1867.     rep    movsb
  1868.     pop    es
  1869.     clc
  1870.     ret
  1871.  
  1872. cntlse2:mov    al,[si]            ; look for ALL
  1873.     or    al,al            ; end of string?
  1874.     jz    cntlse1            ; z = yes, get more user input
  1875.     cmp    al,','            ; comma separator?
  1876.     jne    cntlse2a        ; ne = no
  1877.     inc    si            ; skip it
  1878.     jmp    short cntlse2
  1879. cntlse2a:or    al,20h            ; to lower
  1880.     cmp    al,'a'            ; a in ALL?
  1881.     je    cntlse8            ; e = got ALL
  1882.     cmp    byte ptr [si],'\'    ; user specified?
  1883.     je    cntlse3            ; e = yes
  1884.     dec    si
  1885.     mov    byte ptr [si],'\'    ; insert prefix
  1886. cntlse3:call    katoi            ; convert to number in ax
  1887.     jc    cntlsety        ; c = failure
  1888.     cmp    al,159            ; out of range?
  1889.     ja    cntlsety        ; a = yes
  1890.     cmp    al,128            ; in 8-bit range?
  1891.     jae    cntlse4            ; ae = yes
  1892.     cmp    al,31            ; out of range?
  1893.     ja    cntlsety        ; a = yes
  1894. cntlse4:mov    ah,rdbuf        ; protected/unprotected pointer 0/1
  1895.     mov    bl,al            ; char
  1896.     and    bl,not 80h        ; strip high bit from index
  1897.     xor    bh,bh
  1898.     or    ah,ah            ; protecting?
  1899.     jz    cntlse6            ; z = yes
  1900.     mov    ah,1            ; assume unprotecting 7-bit char
  1901.     and    al,80h            ; get high bit
  1902.     jz    cntlse5            ; z = no high bit
  1903.     mov    ah,80h            ; set high bit flag
  1904. cntlse5:or    decbuf[bx],ah        ; set unprotection bit
  1905.     jmp    cntlse2            ; get more input
  1906.  
  1907. cntlse6:mov    ah,1            ; assume protecting 7-bit char
  1908.     and    al,80h            ; get high bit
  1909.     jz    cntlse7            ; z = no high bit
  1910.     mov    ah,80h            ; set high bit flag
  1911. cntlse7:not    ah            ; invert bits
  1912.     and    decbuf[bx],ah        ; clear the unprotection bit
  1913.     jmp    cntlse2            ; get more input
  1914.  
  1915. cntlsetx:ret                ; success or failure
  1916.                     ; process ALL
  1917. cntlse8:mov    cx,32
  1918.     xor    bx,bx
  1919.     mov    al,rdbuf        ; get kind of operation
  1920.     or    al,al            ; prefix (0)?
  1921.     je    cntlse9            ; e = yes
  1922.     mov    al,81h            ; unprefix all (7 and 8 bit)
  1923. cntlse9:mov    decbuf[bx],al        ; set the state
  1924.     inc    bx
  1925.     loop    cntlse9            ; do all
  1926.     jmp    cntlse1            ; get more user input
  1927.  
  1928. cntlsety:mov    ah,prstr
  1929.     mov    dx,offset badcntlmsg    ; say out of range
  1930.     int    dos
  1931.     jmp    cntlse1            ; get more input
  1932. cntlset    endp
  1933.  
  1934. ; SET COUNTER number    for script IF COUNTER number <command>
  1935. TAKECTR    PROC    NEAR
  1936.     mov    min,0            ; get decimal char code
  1937.     mov    max,65535        ; range is 0 to 65535 decimal
  1938.     mov    numhlp,offset takchlp    ; help message
  1939.     mov    numerr,0        ; error message
  1940.     call    num0            ; convert number, return it in ax
  1941.     jc    takect2            ; c = error
  1942.     push    ax            ; save numerical code
  1943.     mov    ah,cmeol
  1944.     call    comnd            ; get a confirm
  1945.     pop    ax            ; recover ax
  1946.     jc    takect2            ; c = failure
  1947.     cmp    taklev,0        ; in a Take file?
  1948.     je    takect4            ; e = no
  1949.     push    bx
  1950.     mov    bx,takadr
  1951.     mov    [bx].takctr,ax        ; set COUNT value
  1952.     pop    bx
  1953.     clc                ; success
  1954. takect2:ret
  1955. takect4:mov    dx,offset takcerr    ; say must be in Take file
  1956.     jmp    reterr            ; display msg and return carry clear
  1957. TAKECTR    ENDP
  1958.  
  1959. ; SET DEBUG {OFF | ON | SESSSION | PACKETS}
  1960.  
  1961. DEBST    PROC       NEAR
  1962.     mov    dx,offset debtab
  1963.     mov    bx,offset debhlp
  1964.     call    keyend
  1965.     jnc    debst1            ; nc = success
  1966.     ret                ; failure
  1967. debst1:    or    flags.debug,bl        ; set the mode, except for Off
  1968.     or    bx,bx            ; OFF?
  1969.     jnz    debst2            ; nz = no
  1970.     mov    flags.debug,bl        ; set the DEBUG flags off
  1971. debst2:    clc                ; success
  1972.     ret
  1973. DEBST    ENDP
  1974.  
  1975. ; SET DESTINATION   of incoming files
  1976.  
  1977. DESSET    PROC    NEAR
  1978.     mov    dx,offset destab
  1979.     xor    bx,bx
  1980.     call    keyend
  1981.     jc    desset1            ; c = failure
  1982.     mov    flags.destflg,bl    ; set the destination flag
  1983. desset1:ret
  1984. DESSET    ENDP
  1985.  
  1986. ; SET DEFAULT-DISK    for sending/receiving, etc
  1987. ; See cwdir in file mssker
  1988.  
  1989. ; SET DELAY seconds   Used only for SEND command in local mode
  1990. SETDELY    PROC    NEAR
  1991.     mov    min,0            ; smallest acceptable value
  1992.     mov    max,63            ; largest acceptable value
  1993.     mov    numhlp,offset delyhlp    ; help message
  1994.     mov    numerr,0        ; complaint message
  1995.     call    num0            ; parse numerical input
  1996.     jc    setdly1            ; c = error
  1997.     mov    trans.sdelay,al
  1998. setdly1:ret                ; success or failure
  1999. SETDELY    ENDP
  2000.  
  2001. ; SET DISPLAY Quiet/Regular/Serial/7-Bit/8-Bit (inverse of Set Remote on/off)
  2002. ; Accepts two keywords in one command
  2003. disply    proc    near
  2004.     mov    ah,cmkey
  2005.     mov    dx,offset distab
  2006.     mov    bx,offset dishlp
  2007.     call    comnd
  2008.     jnc    displ0            ; nc = success
  2009.     ret                ; return failure
  2010. displ0:    mov    temp1,bx        ; save parsed value
  2011.     mov    temp2,0ffffh        ; assume no second keyword
  2012.     mov    comand.cmcr,1        ; bare CR's are allowed
  2013.     mov    ah,cmkey        ; parse for second keyword
  2014.     mov    dx,offset distab
  2015.     mov    bx,offset dishlp
  2016.     call    comnd
  2017.     jc    displ1            ; no keyword
  2018.     mov    temp2,bx        ; get key value
  2019. displ1:    mov    comand.cmcr,0        ; bare CR's are not allowed
  2020.     mov    ah,cmeol
  2021.     call    comnd            ; confirm
  2022.     jnc    displ2            ; nc = success
  2023.     ret                ; failure
  2024. displ2:    mov    ax,temp1        ; examine first key value
  2025.     call    dispcom            ; do common code
  2026.     mov    ax,temp2        ; examine second key value
  2027. ;    jmp    dispcom            ; finish in common code
  2028.  
  2029. dispcom:or    ax,ax            ; check range
  2030.     jle    dispc3            ; le = not legal, ignore
  2031.     cmp    al,7            ; 7-8 bit value?
  2032.     jge    dispc2            ; ge = yes
  2033.     and    flags.remflg,not(dquiet+dregular+dserial)
  2034.     or    flags.remflg,al        ; set display mode
  2035.     clc                ; success
  2036.     ret                ; check next key value
  2037. dispc2:    cmp    al,8            ; set 8-bit wide display?
  2038.     ja    dispc3            ; a = bad value
  2039.     and    flags.remflg,not d8bit    ; assume want 7 bit mode
  2040.     cmp    al,7            ; really want 7 bit mode?
  2041.     je    dispc3            ; e = yes
  2042.     or    flags.remflg,d8bit    ; set 8 bit flag
  2043. dispc3:    clc                ; success
  2044.     ret                ; end of display common code
  2045. disply    endp
  2046.  
  2047.  
  2048. ; Set Dump filename  for saving screen images on disk.
  2049. ; Puts filename in global string dmpname
  2050. setdmp    proc    near
  2051.     mov    dx,offset rdbuf        ; work area
  2052.     mov    rdbuf,0            ; clear it
  2053.     mov     bx,offset dmphlp    ; help message
  2054.     mov    ah,cmword        ; allow paths
  2055.     call    comnd
  2056.     jc    setdmp2            ; c = failure
  2057.     mov    ah,cmeol
  2058.     call    comnd
  2059.     jc    setdmp2            ; c = failure
  2060.     mov    dx,offset rdbuf        ; assume we will use this text
  2061.     call    strlen            ; filename given?
  2062.     mov    si,dx            ; for strcpy
  2063.     or    cx,cx            ; length of user's filename
  2064.     jg    setdmp1            ; g = filename is given
  2065.     mov    si,offset dmpdefnam    ; no name, use default instead
  2066. setdmp1:mov    di,offset dmpname    ; copy to globally available loc
  2067.     call    strcpy
  2068.     clc
  2069. setdmp2:ret
  2070. setdmp    endp
  2071.  
  2072. ; Set DUPLEX {FULL, HALF}
  2073. setdup    proc    near
  2074.     xor    bx,bx
  2075.     mov    dx,offset duptab
  2076.     call    keyend
  2077.     jc    setdup1            ; c = failure
  2078.     mov    si,portval
  2079.     mov    [si].duplex,bl        ; set value
  2080.     mov    [si].ecoflg,0        ; turn off local echoing
  2081.     or    bl,bl            ; full duplex?
  2082.     jz    setdup1            ; z = yes
  2083.     mov    [si].floflg,0        ; no flow control for half duplex
  2084.     mov    [si].ecoflg,1        ; turn on local echoing
  2085.     call    serrst            ; reset port so opening uses above
  2086. setdup1:ret
  2087. setdup    endp
  2088.  
  2089. ; SET EOF
  2090.  
  2091. SETEOF    PROC    NEAR
  2092.     xor    bx,bx
  2093.     mov    dx,offset seoftab
  2094.     call    keyend
  2095.     jc    seteof1            ; c = failure
  2096.     mov    flags.eofcz,bl        ; set value
  2097. seteof1:ret
  2098. SETEOF    ENDP
  2099.  
  2100. ; SET End-of-Packet char (for Sent packets)
  2101. ; Archic, here for downward compatibility
  2102. EOLSET    PROC    NEAR
  2103.     mov    stflg,'S'        ; set send/receive flag to Send
  2104.     jmp    sreol            ; use Set Send/Rec routine do the work
  2105. EOLSET    ENDP
  2106.  
  2107. ; SET ERRORLEVEL number
  2108. SETERL    PROC    NEAR
  2109.     mov    numhlp,offset erlhlp    ; help
  2110.     mov    numerr,0        ; error message
  2111.     mov    min,0            ; smallest number
  2112.     mov    max,255            ; largest magnitude
  2113.     call    num0            ; parse numerical input
  2114.     jc    seterl1            ; c = error
  2115.     mov    errlev,al        ; store result
  2116.     clc
  2117. seterl1:ret
  2118. SETERL    ENDP
  2119.  
  2120. ; SET ESCAPE character.
  2121. ; Accept literal control codes and \### numbers. [jrd] 18 Oct 1987
  2122. ESCSET    PROC    NEAR
  2123.     mov    ah,cmword
  2124.     mov    dx,offset rdbuf        ; work space
  2125.     mov    word ptr rdbuf,0    ; clear it
  2126.     mov    bx,offset eschlp    ; help
  2127.     call    comnd
  2128.     jc    escse2            ; c = failure
  2129.     or    ax,ax            ; anything given?
  2130.     jnz    escse1            ; nz = yes
  2131.     mov    dx,offset ermes6    ; more parameters needed
  2132.     jmp    reterr
  2133. escse1:    mov    ah,cmeol        ; get a confirm
  2134.     call    comnd
  2135.     jc    escse2            ; c = failure
  2136.     mov    si,offset rdbuf        ; source of chars
  2137.     call    katoi            ; convert escaped numbers to binary
  2138.     cmp    ax,spc            ; is it a control code?
  2139.     jae    escse3            ; ae = no, complain
  2140.     or    ax,ax            ; non-zero too?
  2141.     jz    escse3            ; z = zero
  2142.     mov    trans.escchr,al        ; save new escape char code
  2143.     clc
  2144. escse2:    ret
  2145. escse3:    mov    dx,offset escerr
  2146.     jmp    reterr
  2147. ESCSET    ENDP
  2148.  
  2149. ; SET FILE {DISPLAY, WARNING, TYPE, CHARACTER-SET}
  2150. SETFILE    proc    near
  2151.     mov    dx,offset setfitab    ; SET FILE table
  2152.     xor    bx,bx
  2153.     mov    ah,cmkey
  2154.     call    comnd
  2155.     jc    setfiy            ; c = failure
  2156.     or    bl,bl            ; Warning?
  2157.     jnz    setfi1            ; nz = no
  2158.                     ; entry point for old SET WARNING
  2159. FILWAR:    mov    dx,offset warntab    ; warning table, on, off, no-super
  2160.     xor    bx,bx
  2161.     call    keyend
  2162.     jc    setfiy            ; c = failure
  2163.     mov    flags.flwflg,bl        ; set the filewarning flag
  2164. setfiy:    ret
  2165.  
  2166. setfi1:    cmp    bl,1            ; SET FILE CHARACTER-SET?
  2167.     jne    setfi2            ; ne = no
  2168.     mov    dx,offset setchtab    ; table of char sets
  2169.     xor    bx,bx
  2170.     call    keyend            ; get the set id
  2171.     jc    setfiy            ; c = error
  2172.     mov    flags.chrset,bx        ; save the id
  2173.     cmp    bx,866            ; setting CP866?
  2174.     jne    setfi1a            ; ne = no
  2175.     cmp    dtrans.xchset,xfr_cyrillic ; using TRANSFER of Cryillic?
  2176.     je    setfi1a            ; e = yes
  2177.     mov    dtrans.xchset,xfr_cyrillic ; force TRANSFER of Cyrillic
  2178.     mov    trans.xchset,xfr_cyrillic
  2179.     mov    ah,prstr
  2180.     mov    dx,offset setchmsg    ; show warning
  2181.     int    dos
  2182.     clc
  2183.     ret
  2184. setfi1a:cmp    bx,932            ; setting Shift-JIS?
  2185.     jne    setfi1b            ; ne = no
  2186.     mov    dtrans.xchset,xfr_japanese ; force TRANSFER of Japanese-EUC
  2187.     mov    trans.xchset,xfr_japanese
  2188.     mov    ah,prstr
  2189.     mov    dx,offset setchmsg2    ; show warning
  2190.     int    dos
  2191.     clc
  2192.     ret
  2193. setfi1b:cmp    bx,862            ; setting CP862?
  2194.     jne    setfi1c            ; ne = no
  2195.     mov    dtrans.xchset,xfr_hebiso ; force TRANSFER of Latin-Hebrew
  2196.     mov    trans.xchset,xfr_hebiso
  2197.     mov    ah,prstr
  2198.     mov    dx,offset setchmsg3    ; show warning
  2199.     int    dos
  2200. setfi1c:clc
  2201.     ret
  2202.  
  2203. setfi2:    cmp    bl,2            ; SET FILE TYPE?
  2204.     jne    setfi3            ; ne = 3
  2205.     mov    dx,offset xftyptab    ; table of types
  2206.     xor    bx,bx
  2207.     call    keyend
  2208.     jc    setfix            ; c = error
  2209.     mov    dtrans.xtype,bl        ; store transfer type
  2210.     mov    trans.xtype,bl        ; store transfer type
  2211.     ret
  2212. setfi3:    cmp    bl,3            ; SET FILE DISPLAY?
  2213.     jne    setfix            ; ne = no
  2214.     mov    dx,offset distab2    ; table
  2215.     xor    bx,bx
  2216.     call    keyend
  2217.     jc    setfix            ; c = failure
  2218.     and    flags.remflg,not(dquiet+dregular+dserial)
  2219.     or    flags.remflg,bl        ; set display mode
  2220.     clc
  2221. setfix:    ret
  2222. SETFILE    endp
  2223.  
  2224. ; SET FLOW-CONTROL {NONE, XONXOFF, RTS/CTS}
  2225.  
  2226. FLOSET    PROC    NEAR
  2227.     mov    dx,offset flotab
  2228.       xor    bx,bx
  2229.     call    keyend
  2230.     jc    floset3            ; c = failure
  2231.     mov    si,portval
  2232.     mov    ax,floxon        ; xon/xoff pair
  2233.     or    bx,bx            ; any flow control?
  2234.     jz    floset1            ; z = none
  2235.     test    bx,1+2            ; using xon/xoff?
  2236.     jnz    floset2            ; nz = xon/xoff
  2237.     cmp    flags.comflg,4        ; UART? (RTS/CTS case)
  2238.     ja    floset4            ; a = no, error
  2239. floset1:xor    ax,ax            ; clear chars for RTS/CTS and none
  2240. floset2:mov    [si].flowc,ax        ; flow control values
  2241.     mov    [si].floflg,bl        ; flow control kind
  2242.     call    serrst            ; reset port so opening uses above
  2243.     clc
  2244. floset3:ret
  2245. floset4:mov    dx,offset ermes7    ; error message
  2246.     jmp    reterr
  2247. FLOSET    ENDP
  2248.  
  2249. ; SET HANDSHAKE
  2250. ; Add ability to accept general decimal code.
  2251. HNDSET    PROC    NEAR
  2252.     mov    dx,offset hndtab    ; table to scan
  2253.     mov    bx,offset hnd1hlp    ; help message
  2254.     mov    ah,cmkey
  2255.     call    comnd
  2256.     jc    hnd2            ; c = failure
  2257.     cmp    bl,0ffh            ; want a general char code?
  2258.     jne    hnd1            ; ne = no
  2259.     mov    min,0            ; get decimal char code
  2260.     mov    max,255            ; range is 0 to 255 decimal
  2261.     mov    numhlp,offset erlhlp    ; help msg
  2262.     mov    numerr,0        ; error message
  2263.     call    num0            ; convert number, return it in ax
  2264.     jc    hnd2            ; c = error
  2265.     mov    bx,ax            ; recover numerical code
  2266. hnd1:    push    bx            ; handshake type
  2267.     mov    ah,cmeol
  2268.     call    comnd            ; get a confirm
  2269.     pop    bx            ; recover bx
  2270.     jc    hnd2            ; c = failure
  2271.     mov    si,portval
  2272.     or    bl,bl            ; setting handshake off?
  2273.     jz    hnd0            ; z = yes
  2274.     mov    [si].hndflg,1        ; turn on handshaking
  2275.     mov    [si].hands,bl        ; use this char as the handshake
  2276.     clc                ; success
  2277.     ret
  2278. hnd0:    mov    [si].hndflg,bl        ; no handshaking
  2279.     clc                ; success
  2280. hnd2:    ret
  2281. HNDSET    ENDP
  2282.  
  2283. ;   SET INCOMPLETE file disposition
  2284.  
  2285. ABFSET    PROC    NEAR
  2286.     mov    dx,offset abftab
  2287.     xor    bx,bx
  2288.     call    keyend
  2289.     jc    abfset1            ; c = failure
  2290.     mov    flags.abfflg,bl        ; Set the aborted file flag
  2291. abfset1:ret
  2292. ABFSET    ENDP
  2293. ;
  2294. ; Set Input commands (default-timeout, timeout-action, case, echo)
  2295. ; By Jim Strudevant [jrs]
  2296. INPSET    PROC    NEAR
  2297.     mov    ah,cmkey        ; key word
  2298.     mov    dx,offset inptab    ; from inputtable
  2299.     xor    bx,bx            ; no hints
  2300.     call    comnd            ; get the word
  2301.     jc    inpset1            ; c = failure
  2302.     jmp    bx            ; do the sub command
  2303. inpset1:ret
  2304. ;
  2305. ; Set Input Default-timeout in seconds
  2306. ;
  2307. inptmo:    mov    numhlp,offset intoms    ; help
  2308.     mov    numerr,0        ; error message
  2309.     mov    min,0            ; smallest number
  2310.     mov    max,-1            ; largest magnitude
  2311.     call    num0            ; parse numerical input
  2312.     jc    inptmo1            ; c = error
  2313.     mov    script.indfto,ax    ; store result
  2314. inptmo1:ret
  2315. ;
  2316. ; Set Input Timeout action (proceed or quit)
  2317. ;
  2318. inpact:    mov    dx,offset inactb    ; from this list
  2319.     xor    bx,bx            ; no hints
  2320.     call    keyend            ; get it
  2321.     jc    inpact1            ; c = failure
  2322.     mov    script.inactv,bl    ; save the action
  2323. inpact1:ret
  2324. ;
  2325. ; Set Input Echo on or off
  2326. ;
  2327. inpeco:    mov    dx,offset ontab        ; from this list
  2328.     xor    bx,bx            ; no hints
  2329.     call    keyend            ; get it
  2330.     jc    inpeco1            ; c = failure
  2331.     mov    script.inecho,bl    ; save the action
  2332. inpeco1:ret
  2333. ;
  2334. ; Set Input Case observe or ignore
  2335. ;
  2336. inpcas:    mov    dx,offset incstb    ; from this list
  2337.     xor    bx,bx            ; no hints
  2338.     call    keyend            ; get it
  2339.     jc    inpcas1            ; c = failure
  2340.     mov    script.incasv,bl    ; save the action
  2341. inpcas1:ret
  2342. INPSET    ENDP
  2343.  
  2344. ; Set length of script buffer for INPUT/REINPUT at Kermit initialization
  2345. ; time via Environment. Called by command parser while doing Environment
  2346. ; reading in mssker.asm. Do not call after Kermit has initialized.
  2347. SETINPBUF proc    near
  2348.     mov    scpbuflen,128        ; store default buffer length
  2349.     mov    numhlp,0        ; no help
  2350.     mov    numerr,0        ; no error message
  2351.     mov    min,2            ; smallest number (must be non-zero)
  2352.     mov    max,65535        ; largest magnitude (16 bits worth)
  2353.     call    num0            ; parse numerical input
  2354.     jc    setinpbx        ; c = error
  2355.     mov    scpbuflen,ax        ; store result
  2356.     clc
  2357. setinpbx:ret
  2358. SETINPBUF endp
  2359.  
  2360. ; SET KEY
  2361. ; Jumps to new Set Key routine
  2362. setkey    proc    near        
  2363.     cmp    stkadr,0    ; keyboard translator present?
  2364.     je    setk4        ; e = no, use this routine
  2365.     mov    bx,stkadr    ; yes, get offset of procedure
  2366.     jmp    bx        ; jump to keyboard translator
  2367. setk4:    mov    dx,offset ermes5
  2368.     jmp    reterr        ; else print error message
  2369. setkey    endp
  2370.  
  2371. ; SET LOCAL-ECHO {ON | OFF}
  2372.  
  2373. LCAL    PROC    NEAR
  2374.     mov    dx,offset ontab
  2375.     xor    bx,bx
  2376.     call    keyend
  2377.     jc    lcal1            ; c = failure
  2378.     mov    si,portval
  2379.     mov    [si].ecoflg,bl        ; Set the local echo flag
  2380. lcal1:    ret
  2381. LCAL    ENDP
  2382.  
  2383. ; LOG  {PACKETS | SESSION | TRANSACTION} filename
  2384.  
  2385. setcpt    proc    near
  2386.     mov    dx,offset logtab    ; kinds of logging
  2387.     mov    bx,offset loghlp    ; help on kind of logging
  2388.     mov    ah,cmkey        ; parse keyword
  2389.     call    comnd
  2390.     jnc    setcp20            ; nc = success
  2391.     ret                ; failure
  2392. setcp20:mov    numhlp,bx        ; save the parsed value
  2393.     mov    dx,offset rdbuf        ; holds the complete filename
  2394.     mov    rdbuf,0            ; clear buffer
  2395.     mov     bx,offset filhlp    ; ask for filename
  2396.     mov    ah,cmword        ; allow paths
  2397.     call    comnd
  2398.     jnc    setcp21            ; nc = success
  2399.     ret                ; failure
  2400. setcp21:mov    ah,cmeol
  2401.     call    comnd            ; get a confirm
  2402.     jnc    setcp22            ; nc = success
  2403.     ret                ; failure
  2404. setcp22:mov    bx,numhlp        ; recover kind of logging
  2405.     mov    dx,offset rdbuf        ; length of filename to cx
  2406.     call    strlen            ; length of given filename
  2407.     test    bl,logpkt        ; packet logging?
  2408.     jz    setcp2            ; z = no, try others
  2409.     mov    dx,offset lpktnam    ; filename
  2410.     jcxz    setcp1            ; z = no filename given
  2411.     mov    si,offset rdbuf        ; get new name
  2412.     mov    di,dx            ; destination
  2413.     call    strcpy            ; replace old name
  2414. setcp1:    cmp    ploghnd,-1        ; packet log file already open?
  2415.     je    setcp6            ; e = no, open it
  2416.     jmp    setcp16            ; say file is open already
  2417.  
  2418. setcp2:    test    bl,logses        ; session logging?
  2419.     jz    setcp4            ; z = no, try others
  2420.     mov    dx,offset lsesnam    ; use default name
  2421.     jcxz    setcp3            ; z = no filename given
  2422.     mov    si,offset rdbuf        ; get new name
  2423.     mov    di,dx            ; destination
  2424.     call    strcpy            ; replace old name
  2425. setcp3:    cmp    sloghnd,-1        ; transaction file already open?
  2426.     je    setcp6            ; e = no, open it
  2427.     jmp    setcp16            ; say file is open already
  2428.  
  2429. setcp4:    test    bl,logtrn        ; transaction logging?
  2430.     jz    setcp14            ; z = no, error
  2431.     mov    dx,offset ltranam    ; use default name
  2432.     jcxz    setcp5            ; z = no filename given
  2433.     mov    si,offset rdbuf        ; get new name
  2434.     mov    di,dx            ; destination
  2435.     call    strcpy            ; replace old name
  2436. setcp5:    cmp    tloghnd,-1        ; transaction file already open?
  2437.     je    setcp6            ; e = no, open it
  2438.     jmp    setcp16            ; say file is open already
  2439.  
  2440. setcp6:    mov    ax,dx            ; place for filename for isfile
  2441.     call    isfile            ; does file exist already?
  2442.     jc    setcp7            ; c = does not exist so use create
  2443.     test    byte ptr filtst.dta+21,1fh ; file attributes, ok to write?
  2444.     jnz    setcp14            ; nz = no, use error exit    
  2445.     mov    ah,open2        ; open existing file
  2446.     mov    al,1+1            ;  for writing and reading
  2447.     int    dos
  2448.     jc    setcp14            ; if carry then error
  2449.     mov    bx,ax            ; file handle for seeking
  2450.     xor    cx,cx            ; high order displacement
  2451.     xor    dx,dx            ; low order part of displacement
  2452.     mov    ah,lseek        ; seek to EOF (to do appending)
  2453.     mov    al,2            ; says to EOF
  2454.     int    dos
  2455.     jmp    short setcp8
  2456.  
  2457. setcp7:    test    filtst.fstat,80h    ; access problem?
  2458.     jnz    setcp14            ; nz = yes, stop here
  2459.     mov    ah,creat2        ; function is create
  2460.     mov    cx,20H            ; turn on archive bit
  2461.     int    dos            ; create the file, DOS 2.0
  2462.     jc    setcp14            ; if carry bit set then error
  2463.     mov    bx,ax            ; file handle
  2464.  
  2465. setcp8:    cmp    numhlp,logpkt        ; packet logging?
  2466.     jne    setcp9            ; ne = no
  2467.     mov    ploghnd,bx        ; save transaction log handle here
  2468.     jmp    short setcp12
  2469. setcp9:    cmp    numhlp,logses        ; session logging?
  2470.     jne    setcp10            ; ne = no
  2471.     mov    sloghnd,bx        ; save session log handle here
  2472.     jmp    short setcp12
  2473. setcp10:mov    tloghnd,bx        ; save transaction log handle here
  2474.  
  2475. setcp12:mov    ax,numhlp        ; kind of Logging
  2476.     or    flags.capflg,al        ; accumulate kinds of logging
  2477.     clc                ; success
  2478.     ret
  2479.  
  2480. setcp14:mov    dx,offset errcap    ; give error message
  2481.     jmp    reterr            ; and display it
  2482.  
  2483. setcp16:mov    ah,prstr        ; file already open
  2484.     mov    dx,offset erropn
  2485.     int    dos
  2486.     clc                ; return success
  2487.     ret
  2488. setcpt    endp
  2489.  
  2490. ; SET MODE LINE
  2491.  
  2492. MODL    PROC    NEAR
  2493.     mov    dx,offset ontab        ; parse an on or off
  2494.     xor    bx,bx            ; no special help
  2495.     call    keyend
  2496.     jc    modl1            ; c = failure
  2497.     mov    flags.modflg,bl        ; set flag appropriately
  2498. modl1:    ret
  2499. MODL    ENDP
  2500.  
  2501. ; SET OUTPUT commands
  2502. setoutput proc    near
  2503.     mov    dx,offset outputtab    ; OUTPUT command table
  2504.     xor    bx,bx            ; no special help
  2505.     mov    ah,cmkey
  2506.     call    comnd
  2507.     jc    setout1            ; c = failure
  2508.     jmp    short setopace
  2509. setout1:ret    
  2510. setoutput endp
  2511.  
  2512. ; Set OUTPUT Pacing <number millisec between chars>
  2513. setopace proc    near
  2514.     mov    numhlp,offset opacehlp    ; help
  2515.     mov    numerr,0        ; no error message
  2516.     mov    min,0            ; smallest number
  2517.     mov    max,65535        ; largest magnitude (16 bits worth)
  2518.     call    num0            ; parse numerical input
  2519.     jc    setopac1        ; c = error
  2520.     mov    outpace,ax        ; store result
  2521.     clc
  2522. setopac1:ret
  2523. setopace endp
  2524.  
  2525. ; SET PARITY
  2526.  
  2527. SETPAR    PROC    NEAR
  2528.     mov    dx,offset partab    ; parity table
  2529.     xor    bx,bx
  2530.     call    keyend
  2531.     jnc    setp1            ; nc = success
  2532.     ret
  2533. setp1:    mov    si,portval
  2534.     mov    [si].parflg,bl        ; store the parity flag
  2535.     call    serrst            ; reset port so opening uses above
  2536.     clc
  2537.     ret
  2538. SETPAR    ENDP
  2539.  
  2540. ; Set Print filename  for writing material to printers.
  2541. ; Puts filename in global string prnname
  2542. setprn    proc    near
  2543.     mov    dx,offset rdbuf        ; work area
  2544.     mov    rdbuf,0            ; clear it
  2545.     mov     bx,offset prnhlp    ; help message
  2546.     mov    ah,cmword        ; allow paths
  2547.     call    comnd
  2548.     jc    setprn3            ; c = failure
  2549.     mov    ah,cmeol
  2550.     call    comnd
  2551.     jc    setprn3            ; c = failure
  2552.     mov    dx,offset rdbuf        ; assume we will use this text
  2553.     call    strlen            ; filename given?
  2554.     mov    si,dx            ; for strcpy
  2555.     or    cx,cx            ; length of user's filename
  2556.     jg    setprn1            ; g = filename is given
  2557.     mov    si,offset prndefnam    ; no name, use default instead
  2558. setprn1:mov    di,offset prnname    ; copy to globally available loc
  2559.     call    strcpy
  2560.     cmp    prnhand,0        ; handle already in use?
  2561.     jle    setprn2            ; le = no
  2562.     call    pntflsh            ; flush current buffer
  2563.     mov    bx,prnhand        ; close the file now
  2564.     cmp    bx,4            ; don't close DOS PRN
  2565.     je    setprn2            ; e = already available
  2566.     mov    ah,close2
  2567.     int    dos
  2568. setprn2:call    prnopen            ; open printer now, may set carry
  2569.     jnc    setprn3            ; nc = success
  2570.     mov    ah,prstr
  2571.     mov    dx,offset prnerr    ; say can't open the file
  2572.     int    dos
  2573.     mov    si,offset prndefnam    ; use default name as fallback
  2574.     mov    di,offset prnname    ; copy to globally available loc
  2575.     call    strcpy
  2576.     mov    prnhand,4        ; declare handle to be DOS PRN
  2577. setprn3:ret
  2578. setprn    endp
  2579.  
  2580. ; SET PROMPT  Allow user to change the "Kermit-MS>" prompt
  2581. ; {string} and \number notation permitted to represent special chars.
  2582. ; String will be made asciiz
  2583.  
  2584. PROMSET    PROC    NEAR
  2585.     mov    ah,cmline
  2586.     mov    bx,offset rdbuf        ; Read in the prompt
  2587.     mov    word ptr [bx],0        ; clear buffer
  2588.     mov    dx,offset prmmsg
  2589.     mov    comand.cmblen,60    ; 60 byte limit
  2590.     call    comnd
  2591.     jc    prom2            ; c = failure
  2592.     or    ax,ax            ; prompt string?
  2593.     jnz    prom0            ; nz = yes
  2594.     mov    ax,offset kerm        ; no, restore default prompt
  2595.     jmp    short prom1
  2596. prom0:    push    si            ; parse \### constants into
  2597.     push    di            ;  1 byte binary numbers inline
  2598.     mov    si,offset rdbuf        ; source = new prompt string
  2599.     mov    byte ptr [si-1+length rdbuf],0 ; plant null terminator
  2600.     mov    di,offset prm        ; destination
  2601.     call    cnvlin            ; convert \### in string to binary
  2602.     pop    di
  2603.     pop    si
  2604.     mov    bx,cx            ; get byte count
  2605.     mov    prm[bx],0        ; insert null terminator
  2606.     mov    ax,offset prm
  2607. prom1:    mov    prmptr,ax        ; remember it
  2608.     clc                ; success
  2609. prom2:    ret
  2610. PROMSET    ENDP
  2611.  
  2612. ; SET SERVER {LOGIN username password | TIMEOUT}
  2613.  
  2614. SETSRV    PROC    NEAR
  2615.     mov    dx,offset srvtab    ; set server table
  2616.     xor    bx,bx            ; use table for help
  2617.     mov    ah,cmkey        ; get keyword
  2618.     call    comnd
  2619.     jnc    setsrv1            ; c = success
  2620.     ret
  2621. setsrv1:cmp    apctrap,0        ; disable from APC?
  2622.     jne    setsrvx            ; ne = yes
  2623.     cmp    bl,1            ; Login?
  2624.     jne    setsrv2            ; ne = no
  2625.     test    flags.remflg,dserver    ; acting as a server now?
  2626.     jz    setsrv3            ; z = no
  2627.     stc                ; fail
  2628.     ret
  2629. setsrv3:mov    dx,offset rdbuf        ; where to store local username
  2630.     mov    bx,offset luserh    ; help
  2631.     mov    comand.cmblen,16    ; buffer length
  2632.     mov    ah,cmword        ; get username
  2633.     call    comnd
  2634.     jc    setsrvx
  2635.     mov    bx,offset rdbuf+30    ; where to store local password
  2636.     mov    dx,offset lpassh    ; help
  2637.     mov    comand.cmblen,16    ; buffer length
  2638.     mov    ah,cmline        ; get password, allow spaces
  2639.     call    comnd
  2640.     jc    setsrvx
  2641.     mov    si,offset rdbuf        ; only now do we transfer to the
  2642.     mov    di,offset luser        ; active buffers
  2643.     call    strcpy
  2644.     mov    si,offset rdbuf+30
  2645.     mov    di,offset lpass
  2646.     call    strcpy
  2647.     clc
  2648.     ret
  2649.  
  2650. setsrv2:mov    min,0            ; Timeout, smallest acceptable value
  2651.     mov    max,255            ; largest acceptable value, one byte
  2652.     mov    numhlp,offset srvthlp    ; help message
  2653.     mov    numerr,0        ; complaint message
  2654.     call    num0            ; parse numerical input
  2655.     jc    setsrvx            ; c = error
  2656.     mov    srvtmo,al        ; store timeout value
  2657.     clc                ; success
  2658. setsrvx:ret
  2659.     
  2660. SETSRV    ENDP
  2661.  
  2662. ; SET RETRY value. Changes the packet retry limit.
  2663.  
  2664. RETRYSET PROC    NEAR
  2665.     mov    min,1            ; smallest acceptable value
  2666.     mov    max,63            ; largest acceptable value
  2667.     mov    numhlp,offset retryhlp    ; help message
  2668.     mov    numerr,0        ; complaint message
  2669.     call    num0            ; parse numerical input
  2670.     jc    retrys1            ; c = error
  2671.     mov    maxtry,al
  2672. retrys1:ret
  2673. RETRYSET ENDP
  2674.  
  2675. ; Set number of screens in terminal emulator rollback buffer at Kermit
  2676. ; initialization time via Environment. Called by command parser while doing
  2677. ; Environment reading in mssker.asm. Do not call after Kermit has initialized.
  2678. SETROLLB proc    near
  2679.     mov    numhlp,offset rollhlp    ; help
  2680.     mov    numerr,0        ; no error message
  2681.     mov    min,0            ; smallest number
  2682.     mov    max,8000        ; largest magnitude
  2683.     call    num0            ; parse numerical input
  2684.     jc    setrol1            ; c = error
  2685.     mov    npages,ax        ; store result
  2686.     clc
  2687. setrol1:ret
  2688. SETROLLB endp
  2689.  
  2690. ; Set width of rollback screens in terminal emulator rollback buffer at Kermit
  2691. ; initialization time via Environment. Called by command parser while doing
  2692. ; Environment reading in mssker.asm. Do not call after Kermit has initialized.
  2693. SETWIDTH proc    near
  2694.     mov    rollwidth,80        ; default width of rolled screen
  2695.     mov    numhlp,0        ; no help
  2696.     mov    numerr,0        ; no error message
  2697.     mov    min,80            ; smallest number
  2698.     mov    max,207            ; largest magnitude (16 bits worth)
  2699.     call    num0            ; parse numerical input
  2700.     jc    setwid1            ; c = error
  2701.     mov    rollwidth,ax        ; store result
  2702.     clc
  2703. setwid1:ret
  2704. SETWIDTH endp
  2705.  
  2706. ; SET TAKE-ECHO     on or off
  2707.  
  2708. TAKSET    PROC    NEAR
  2709.     mov    dx,offset ontab
  2710.     xor    bx,bx
  2711.     call    keyend
  2712.     jc    takset1            ; c = failure
  2713.     mov    flags.takflg,bl
  2714. takset1:ret
  2715. TAKSET    ENDP
  2716.  
  2717. ; SET TIMER     on or off during file transfer
  2718.  
  2719. TIMSET    PROC    NEAR
  2720.     mov    dx,offset ontab
  2721.     xor    bx,bx
  2722.     call    keyend
  2723.     jc    timset1            ; c = failure
  2724.     mov    flags.timflg,bl
  2725. timset1:ret
  2726. TIMSET    ENDP
  2727.  
  2728. ; SET WINDOW number of windows
  2729. WINSET    PROC    NEAR
  2730.     mov    min,1            ; smallest acceptable value
  2731.     mov    max,maxwind        ; largest acceptable value
  2732.     mov    numhlp,offset winhelp    ; help message
  2733.     mov    numerr,0        ; complaint message
  2734.     call    num0            ; parse numerical input
  2735.     jc    winse5            ; c = error
  2736.     mov    dtrans.windo,al        ; store default window size
  2737.     mov    trans.windo,al        ; and in active variable for makebuf
  2738.     clc                ; success
  2739. winse5:    ret
  2740. WINSET    ENDP
  2741.  
  2742. ; SET SEND parameters
  2743.  
  2744. SENDSET    PROC    NEAR
  2745.     mov    stflg,'S'        ; Setting SEND parameter 
  2746.     mov    dx,offset stsrtb    ; Parse a keyword
  2747.     xor    bx,bx            ; no specific help
  2748.     mov    ah,cmkey
  2749.     call    comnd
  2750.     jc    sendset1        ; c = failure
  2751.     jmp    bx            ; do the action routine
  2752. sendset1:ret
  2753. SENDSET    ENDP
  2754.  
  2755. ; SET RECEIVE parameters
  2756.  
  2757. recset:    mov    stflg,'R'        ; Setting RECEIVE paramter
  2758.     mov    dx,offset stsrtb    ; Parse a keyword
  2759.     xor    bx,bx            ; no specific help
  2760.     mov    ah,cmkey
  2761.     call    comnd
  2762.     jc    recset1            ; c = failure
  2763.     jmp    bx            ; do the action routine
  2764. recset1:ret
  2765.  
  2766. remset    proc    near            ; Set REMOTE ON/OFF
  2767.     mov    dx,offset ontab
  2768.     mov    bx,offset remhlp
  2769.     call    keyend
  2770.     jc    remset2            ; c = failure
  2771.     and    flags.remflg,not (dquiet+dserial+dregular) ; no display bits
  2772.     or    bl,bl            ; want off state? (same as regular)
  2773.     jz    remset1            ; z = yes
  2774.     or    flags.remflg,dquiet    ; else on = quiet display
  2775.     clc
  2776.     ret
  2777. remset1:or    flags.remflg,dregular    ; off = regular display
  2778.     clc
  2779. remset2:ret
  2780. remset    endp
  2781.  
  2782.  
  2783. ; SET Send and Receive End-of-Packet char
  2784.  
  2785. sreol    PROC    NEAR
  2786.     mov    min,0            ; lowest acceptable value
  2787.     mov    max,1FH            ; largest acceptable value
  2788.     mov    numhlp,offset eophlp    ; help message
  2789.     mov    numerr,0        ; error message address
  2790.     call    num0            ; get numerical input
  2791.     jc    sreol3            ; c = error
  2792.     cmp    stflg,'S'        ; setting SEND paramter?
  2793.     je    sreol1
  2794.     mov    trans.reol,al
  2795.     jmp    short sreol2
  2796. sreol1:    mov    dtrans.seol,al
  2797. sreol2:    mov    ah,dtrans.seol
  2798.     mov    trans.seol,ah
  2799.     clc
  2800. sreol3:    ret
  2801. sreol    ENDP
  2802.  
  2803.  
  2804. ; SET SEND and RECEIVE start-of-header
  2805.  
  2806. srsoh:    mov    min,0
  2807.     mov    max,7eh            ; allow printables (control=normal)
  2808.     mov    numhlp,offset sohhlp    ; reuse help message
  2809.     mov    numerr,0        ; error message
  2810.     call    num0        ; Common routine for parsing numerical input
  2811.     jc    srsoh2            ; c = error
  2812.     cmp    stflg,'S'        ; setting SEND paramter?
  2813.     je    srsoh1
  2814.     mov    trans.rsoh,al        ; set Receive soh
  2815.     clc                ; success
  2816.     ret
  2817. srsoh1:    mov    trans.ssoh,al        ; set Send soh
  2818.     clc                ; success
  2819.     ret
  2820. srsoh2:    ret
  2821.  
  2822. ; SET Send Double-char
  2823.  
  2824. srdbl    PROC    NEAR
  2825.     mov    min,0            ; lowest acceptable value
  2826.     mov    max,0ffh        ; largest acceptable value
  2827.     mov    numhlp,offset dblhlp    ; help
  2828.     mov    numerr,0        ; error message address
  2829.     call    num0            ; get numerical input
  2830.     jc    sreol3            ; c = error
  2831.     cmp    stflg,'R'        ; setting Receive paramter?
  2832.     je    srdbl1            ; e = yes, no action
  2833.     mov    trans.sdbl,al        ; store character to be doubled
  2834.     mov    dtrans.sdbl,al
  2835.     clc
  2836. srdbl1:    ret
  2837. srdbl    ENDP
  2838.  
  2839. ; SET Receive Ignore-char
  2840.  
  2841. srign    PROC    NEAR
  2842.     mov    min,0            ; lowest acceptable value
  2843.     mov    max,0ffh        ; largest acceptable value
  2844.     mov    numhlp,offset dblhlp    ; reuse help
  2845.     mov    numerr,0        ; error message address
  2846.     call    num0            ; get numerical input
  2847.     jc    srign1            ; c = error
  2848.     cmp    stflg,'S'        ; setting SEND paramter?
  2849.     je    srign1            ; e = yes, no action
  2850.     mov    trans.rign,al        ; store character to be ignored
  2851.     mov    dtrans.rign,al
  2852.     clc
  2853. srign1:    ret
  2854. srign    ENDP
  2855.  
  2856. ; SET SEND and    RECEIVE TIMEOUT
  2857.  
  2858. srtim:    mov    min,0
  2859.     mov    max,94
  2860.     mov    numhlp,offset timhlp    ; Reuse help message
  2861.     mov    numerr,0        ; error message
  2862.     call    num0        ; Common routine for parsing numerical input
  2863.     jc    srtim3            ; c = error
  2864.     cmp    stflg,'S'        ; Setting SEND paramter?
  2865.     je    srtim1
  2866.     mov    trans.rtime,al
  2867.     jmp    short srtim2
  2868. srtim1:    mov    dtrans.stime,al
  2869. srtim2:    mov    ah,dtrans.stime
  2870.     mov    trans.stime,ah
  2871.     clc
  2872. srtim3:    ret
  2873.  
  2874. ; SET SEND and RECEIVE PACKET LENGTH
  2875. ; dtrans items are real, trans items are just for SHOW information
  2876.  
  2877. srpack:    mov    min,20
  2878.     mov    max,9024
  2879.     mov    numhlp,offset pakhlp    ; help
  2880.     mov    numerr,offset pakerr    ; error message
  2881.     call    num0
  2882.     jnc    srpaks0            ; nc = success
  2883.     ret                ; failure
  2884. srpaks0:cmp    stflg,'S'        ; setting send value?
  2885.     jne    srpakr            ; ne = receive
  2886.     mov    dtrans.slong,ax        ; set send max value
  2887.     mov    trans.slong,ax        ; store current active length
  2888.     mov    dtrans.spsiz,dspsiz    ; set regular 94 byte default
  2889.     mov    trans.spsiz,dspsiz    ; ditto
  2890.     cmp    ax,dspsiz        ; longer than regular packet?
  2891.     jae    srpaks1            ; ae = yes
  2892.     mov    dtrans.spsiz,al        ; shrink regular packet size too
  2893.     mov    trans.spsiz,al        ; shrink regular packet size too
  2894. srpaks1:clc                ; success
  2895.     ret
  2896.  
  2897. srpakr:    mov    dtrans.rlong,ax        ; set receive max value
  2898.     mov    trans.rlong,ax        ; store active length
  2899.     mov    dtrans.rpsiz,drpsiz    ; set regular to default 94 bytes
  2900.     mov    trans.rpsiz,drpsiz
  2901.     mov    trans.rpsiz,drpsiz
  2902.     cmp    ax,drpsiz        ; longer than a regular packet?
  2903.     jae    srpakr1            ; ae = yes
  2904.     mov    dtrans.rpsiz,al        ; shrink regular packet size too
  2905.     mov    trans.rpsiz,al
  2906. srpakr1:clc                ; success
  2907.     ret
  2908.  
  2909.  
  2910. ; SET SEND and RECEIVE number of padding characters
  2911.  
  2912. srnpd:    mov    min,0
  2913.     mov    max,94
  2914.     mov    numhlp,offset timhlp    ; reuse help message
  2915.     mov    numerr,0        ; error message
  2916.     call    num0            ; Parse numerical input
  2917.     jc    srnpd3            ; c = error
  2918.     cmp    stflg,'S'        ; Setting SEND paramter?
  2919.     je    srnpd1            ; e = yes
  2920.     mov    trans.rpad,al        ; set Receive padding
  2921.     jmp    short srnpd2
  2922. srnpd1:    mov    dtrans.spad,al        ; set default Send padding
  2923. srnpd2:    mov    al,dtrans.spad
  2924.     mov    trans.spad,al        ; update active array for I and S pkts
  2925.     clc
  2926. srnpd3:    ret
  2927.  
  2928. ; SET SEND and RECEIVE padding character
  2929.  
  2930. srpad:    mov    min,0
  2931.     mov    max,127
  2932.     mov    numhlp,offset padhlp
  2933.     mov    numerr,offset padhlp
  2934.     call    num0            ; parse numerical input
  2935.     jc    srpad4            ; c = error
  2936.     cmp    ah,127            ; this is allowed
  2937.     je    srpad1
  2938.     cmp    ah,32
  2939.     jb    srpad1            ; between 0 and 31 is OK too
  2940.     mov    ah,prstr
  2941.     mov    dx,offset padhlp
  2942.     int    dos
  2943. srpad1:    cmp    stflg,'S'        ; Send?
  2944.     je    srpad2            ; e = yes, else Receive
  2945.     mov    trans.rpadch,al        ; store receive pad char
  2946.     jmp    short srpad3
  2947. srpad2:    mov    dtrans.spadch,al    ; store Send pad char
  2948. srpad3:    mov    ah,dtrans.spadch
  2949.     mov    trans.spadch,ah      ; update active array for I and S pkts
  2950.     clc                ; success
  2951. srpad4:    ret
  2952.  
  2953. ; SET SEND and    RECEIVE control character prefix
  2954.  
  2955. srquo:    mov    min,33
  2956.     mov    max,126
  2957.     mov    numhlp,offset quohlp    ; help message
  2958.     mov    numerr,0        ; error message
  2959.     call    num0            ; Parse numerical input
  2960.     jc    srquo3            ; c = error
  2961.     cmp    stflg,'S'        ; Setting outgoing quote char?
  2962.     je    srquo1            ; e = yes
  2963.     mov    trans.rquote,al        ; set Receive quote char
  2964.     jmp    short srquo2
  2965. srquo1:    mov    dtrans.squote,al    ; set Send quote char
  2966. srquo2:    clc
  2967. srquo3:    ret
  2968.  
  2969. ; SET SEND Pause number    of milliseconds
  2970.  
  2971. srpaus:    mov    min,0
  2972.     mov    max,65383
  2973.     mov    numhlp,offset pauhlp    ; help
  2974.     mov    numerr,0
  2975.     call    num0            ; Parse numerical input
  2976.     pushf                ; save carry for error state
  2977.     cmp    stflg,'S'        ; Setting SEND paramter?
  2978.     je    srpau0
  2979.     popf
  2980.     mov    dx,offset ermes5    ; "Not implemented" msg
  2981.     jmp    reterr            ; print error message
  2982. srpau0:    popf
  2983.     jc    srpau1            ; c = error
  2984.     mov    spause,ax        ; store value
  2985. srpau1:    ret
  2986.  
  2987. ; SET TCP/IP address nnn.nnn.nnn.nnn
  2988. ; SET TCP/IP subnetmask nnn.nnn.nnn.nnn
  2989. ; SET TCP/IP gateway nnn.nnn.nnn.nnn
  2990. ; SET TCP/IP primary-nameserver nnn.nnn.nnn.nnn
  2991. ; SET TCP/IP secondary-nameserver nnn.nnn.nnn.nnn
  2992. ; SET TCP/IP domain string
  2993.  
  2994. tcpipset proc    near
  2995.     mov    ah,cmkey        ; get keyword
  2996.     mov    dx,offset tcptable    ; table
  2997.     xor    bx,bx            ; help
  2998.     call    comnd
  2999.     jnc    tcpse1
  3000.     ret
  3001. tcpse1:    mov    word ptr rdbuf,bx    ; keyword index
  3002.     mov    comand.cmblen,17    ; length of user's buffer
  3003.     cmp    bx,1            ; local address?
  3004.     jne    tcpse1a            ; ne = no
  3005.     mov    bx,offset addrhelp    ; address help
  3006.     jmp    short tcpse4
  3007. tcpse1a:cmp    bx,2            ; domain name?
  3008.     jne    tcpse2            ; ne = no
  3009.     mov    bx,offset domainhlp    ; domain help
  3010.     mov    comand.cmblen,32    ; length of user's buffer
  3011.     jmp    short tcpse4
  3012. tcpse2:    cmp    bx,6            ; subnet mask?
  3013.     jne    tcpse3            ; ne = no
  3014.     mov    bx,offset subnethlp
  3015.     jmp    short tcpse4
  3016. tcpse3:    cmp    bx,7            ; Host?
  3017.     jne    tcpse3a            ; ne = no
  3018.     mov    bx,offset hosthlp
  3019.     mov    comand.cmblen,60    ; length of user's buffer
  3020.     jmp    short tcpse4
  3021. tcpse3a:cmp    bx,9            ; PD interrupt?
  3022.     jne    tcpse3b            ; ne = no
  3023.     mov    bx,offset tcppdinthlp
  3024.     jmp    short tcpse4
  3025. tcpse3b:cmp    bx,10            ; term type?
  3026.     jne    tcpse3c            ; ne = no
  3027.     mov    bx,offset tcpttyhlp
  3028.     mov    comand.cmblen,32    ; length of user's buffer
  3029.     jmp    short tcpse4
  3030. tcpse3c:cmp    bx,11            ; newline mode?
  3031.     jne    tcpse3d            ; ne = no
  3032.     jmp    tcpse13
  3033. tcpse3d:cmp    bx,12            ; debug mode?
  3034.     jne    tcpse3e            ; ne = no
  3035.     jmp    tcpse14
  3036.  
  3037. tcpse3e:mov    bx,offset iphelp    ; Internet number help
  3038. tcpse4:    mov    ah,cmword        ; get a string
  3039.     mov    dx,offset rdbuf+2    ; work buffer
  3040.     call    comnd
  3041.     jnc    tcpse5
  3042.     ret
  3043. tcpse5:    push    ax            ; save string length in ax
  3044.     mov    ah,cmeol
  3045.     call    comnd
  3046.     pop    ax
  3047.     jnc    tcpse6
  3048.     ret
  3049. tcpse6:    mov    si,offset rdbuf+2    ; user's string
  3050.     mov    bx,word ptr rdbuf    ; comand kind
  3051.     cmp    bx,2            ; domain?
  3052.     jne    tcpse8            ; ne = no
  3053.     mov    di,offset tcpdomain
  3054.     cmp    ax,32            ; exceeded 32 chars?
  3055.     jbe    tcpse7            ; be = no
  3056.     mov    ah,prstr
  3057.     mov    dx,offset domainbad    ; compain
  3058.     int    dos
  3059.     stc
  3060.     ret
  3061. tcpse7:    cmp    ax,32            ; address oversized?
  3062.     jbe    tcpse9            ; be = no
  3063.     mov    ah,prstr
  3064.     mov    dx,offset addressbad    ; say bad address
  3065.     int    dos
  3066.     stc
  3067.     ret
  3068. tcpse8:    mov    di,offset tcpaddress
  3069.     cmp    bx,1            ; local address?
  3070.     je    tcpse9            ; e = yes
  3071.     mov    di,offset tcpsubnet
  3072.     cmp    bx,3            ; subnet?
  3073.     je    tcpse9            ; e = yes
  3074.     mov    di,offset tcpgateway
  3075.     cmp    bx,4            ; gateway?
  3076.     je    tcpse9
  3077.     mov    di,offset tcpprimens
  3078.     cmp    bx,5            ; primary-nameserver?
  3079.     je    tcpse9
  3080.     mov    di,offset tcpsecondns    ; secondary-nameserer
  3081.     cmp    bx,6
  3082.     je    tcpse9
  3083.     mov    di,offset tcphost    ; host name or number
  3084.     cmp    bx,7
  3085.     je    tcpse9
  3086.     mov    di,offset tcpbcast    ; broadcast
  3087. tcpse9:    cmp    bx,9            ; port or other?
  3088.     jae    tcpse10            ; ae = yes
  3089.     call    strcpy
  3090.     clc
  3091.     ret
  3092. tcpse10:cmp    bx,9            ; PD interrupt?
  3093.     jne    tcpse12            ; ne = no
  3094.     mov    si,offset rdbuf+2
  3095.     cmp    byte ptr [si],'\'    ; backslash present?
  3096.     je    tcpse11            ; e = yes
  3097.     dec    si
  3098.     mov    byte ptr [si],'\'
  3099. tcpse11:mov    ax,word ptr [si+1]
  3100.     and    ax,not 2020h        ; to upper case
  3101.     cmp    ax,'DO'            ; ODI?
  3102.     je    tcpse11a        ; e = yes, use "DO"
  3103.     push    bx
  3104.     call    katoi            ; number to ax
  3105.     pop    bx
  3106. tcpse11a:mov    tcppdint,ax
  3107.     clc
  3108.     ret
  3109. tcpse12:cmp    bx,10            ; term-type string?
  3110.     jne    tcpse13            ; ne = no
  3111.     mov    si,offset rdbuf+2
  3112.     mov    di,offset tcpttbuf    ; copy string to holding place
  3113.     call    strcpy
  3114.     clc
  3115.     ret
  3116. tcpse13:cmp    bx,11            ; newline mode?
  3117.     jne    tcpse14            ; ne = no
  3118.     mov    dx,offset ontab        ; on/off table
  3119.     mov    bx,offset tcpnlhlp    ; help
  3120.     call    keyend
  3121.     jc    tcpse14            ; fail
  3122.     mov    tcpnewline,bl        ; set mode
  3123.     clc
  3124.     ret
  3125. tcpse14:cmp    bx,12            ; debug mode?
  3126.     jne    tcpse15            ; ne = no
  3127.     mov    dx,offset ontab        ; on/off table
  3128.     xor    bx,bx            ; help
  3129.     call    keyend
  3130.     jc    tcpse15            ; fail
  3131.     mov    tcpdebug,bl        ; set mode
  3132.     clc
  3133.     ret
  3134. tcpse15:stc                ; fail
  3135.     ret
  3136. tcpipset endp
  3137.  
  3138. ; SET TRANSFER  CHARACTER-SET {Latin1, Shift-JIS, Transparent}
  3139. ; SET TRANSFER  TRANSLATION {Readable, Invertible}
  3140. sxfer    proc    near
  3141.     mov    dx,offset xfertab    ; table of TRANSFER keywords
  3142.     xor    bx,bx
  3143.     mov    ah,cmkey        ; get next keyword
  3144.     call    comnd
  3145.     jc    sxfer1            ; c = error
  3146.     or    bl,bl            ; Character-set?
  3147.     jnz    sxfer2            ; nz = no
  3148.     mov    dx,offset xfchtab    ; Character-set table
  3149.     mov    bx,offset xfchhlp    ; help text
  3150.     call    keyend
  3151.     jc    sxfer1            ; c = error
  3152.     mov    dtrans.xchset,bl    ; store transfer char set ident
  3153.     mov    trans.xchset,bl        ; store transfer char set ident
  3154.     cmp    bl,xfr_cyrillic        ; Cyrillic?
  3155.     jne    sxfer9            ; ne = no
  3156.     mov    ax,flags.chrset        ; get current file character set
  3157.     mov    flags.chrset,866    ; force CP866
  3158.     cmp    ax,866            ; was CP866/LATIN5 File Character set?
  3159.     je    sxfer8            ; e = yes
  3160.     mov    dx,offset xfchbad    ; show warning message
  3161.     mov    ah,prstr
  3162.     int    dos
  3163. sxfer8:    clc
  3164. sxfer1:    ret
  3165. sxfer9:    cmp    bl,xfr_japanese        ; Japanese-EUC?
  3166.     jne    sxfer10            ; ne = no
  3167.     mov    ax,flags.chrset        ; get current file character set
  3168.     mov    flags.chrset,932    ; force Shift-JIS
  3169.     cmp    ax,932            ; was Shift-JIS File Character set?
  3170.     je    sxfer8            ; e = yes
  3171.     mov    dx,offset xfchbad2    ; show warning message
  3172.     mov    ah,prstr
  3173.     int    dos
  3174.     clc
  3175.     ret
  3176. sxfer10:cmp    bl,xfr_hebiso        ; Hebrew-ISO?
  3177.     jne    sxfer8            ; ne = no
  3178.     mov    ax,flags.chrset        ; get current file character set
  3179.     mov    flags.chrset,862    ; force CP 862
  3180.     cmp    ax,862            ; was CP862 the File Character set?
  3181.     je    sxfer8            ; e = yes
  3182.     mov    dx,offset xfchbad3    ; show warning message
  3183.     mov    ah,prstr
  3184.     int    dos
  3185.     clc
  3186.     ret
  3187.  
  3188. sxfer2:    cmp    bx,1            ; LOCKING-SHIFT?
  3189.     jne    sxfer3            ; ne = no
  3190.     mov    dx,offset xfertab1    ; off, on, forced table
  3191.     mov    bx,offset xferhlp1
  3192.     call    keyend
  3193.     jc    sxfer1
  3194.     mov    dtrans.lshift,bl    ; save state
  3195.     mov    trans.lshift,bl
  3196.     clc
  3197.     ret
  3198. sxfer3:    mov    dx,offset xfertab2    ; TRANSLATION table
  3199.     mov    bx,offset xfchhlp2    ; help text
  3200.     call    keyend
  3201.     jc    sxfer1            ; c = error
  3202.     mov    dtrans.xchri,bl        ; store readable/invertible flag
  3203.     mov    trans.xchri,bl
  3204.     clc
  3205.     ret
  3206. sxfer    endp
  3207.  
  3208. ; SET TRANSLATION           Connect mode translate characters
  3209. ; SET TRANSLATION INPUT {Original-byte New-byte | ON | OFF}
  3210. ; SET TRANSLATION KEYBOARD {ON | OFF}, default is ON
  3211.  
  3212. SETRX    PROC    NEAR            ; translate incoming serial port char
  3213.     mov    ah,cmkey
  3214.     mov    dx,offset trnstab    ; direction table (just one entry)
  3215.     xor    bx,bx            ; no help
  3216.     call    comnd
  3217.     jnc    setrx0            ; nc = success
  3218.     ret                ; failure
  3219. setrx0:    cmp    bx,2            ; Keyboard?
  3220.     jne    setrx0b            ; ne = no
  3221.     jmp    setr11            ; do keyboard
  3222. setrx0b:mov    dx,offset rdbuf        ; our work space
  3223.     mov    word ptr rdbuf,0    ; insert terminator
  3224.     mov    bx,offset srxhlp1    ; first help message
  3225.     mov    ah,cmword        ; parse a word
  3226.     call    comnd            ; get incoming byte pattern
  3227.     jnc    setrx0a            ; nc = success
  3228.     ret
  3229. setrx0a:or    ax,ax            ; any text given?
  3230.     jz    setr6            ; nz = no
  3231.     mov    temp,ax            ; save byte count here
  3232.     mov    ax,word ptr rdbuf    ; get first two characters
  3233.     or    ax,2020h        ; convert upper to lower case
  3234.     cmp    ax,'fo'            ; first part of word OFF?
  3235.     je    setr6            ; e = yes, go analyze
  3236.     cmp    ax,'no'            ; word ON?
  3237.     je    setr6            ; e = yes, go do it
  3238.     mov    si,offset rdbuf        ; convert text to number
  3239.     call    katoi            ; number converter procedure, to ax
  3240.     jnc    setr1            ; nc = success    
  3241.     cmp    temp,1            ; just one character given?
  3242.     jne    setr6            ; ne = no, so bad code
  3243. setr1:    mov    min,ax            ; save byte code here
  3244.     mov    dx,offset rdbuf        ; our work space
  3245.     mov    word ptr rdbuf,0    ; insert terminator
  3246.     mov    bx,offset srxhlp1    ; first help message
  3247.     mov    ah,cmword        ; parse a word
  3248.     call    comnd            ; get incoming byte pattern
  3249.     jnc    setr2            ; nc = success
  3250.     ret                ; failure
  3251. setr2:    or    ax,ax            ; any text given?
  3252.     jz    setr6            ; z = no
  3253.     mov    temp,ax            ; save byte count here
  3254.     mov    si,offset rdbuf        ; convert text to number
  3255.     call    katoi            ; number converter procedure
  3256.     jnc    setr3            ; nc = success
  3257.     cmp    temp,1            ; just one character given?
  3258.     jne    setr6            ; ne = no, so bad code or ON/OFF
  3259. setr3:    mov    max,ax            ; save byte code here
  3260.     mov    ah,cmeol        ; get a confirm
  3261.     call    comnd
  3262.     jnc    setr3a            ; nc = success
  3263.     ret                ; failure
  3264. setr3a:    mov    bx,min            ; bl = incoming byte code
  3265.     xor    bh,bh
  3266.     mov    ax,max            ; al = local (translated) byte code
  3267.     mov    rxtable [bx],al        ; store in rx translate table
  3268.     clc                ; success
  3269.     ret
  3270.  
  3271. setr6:    mov    ah,cmeol        ; get a confirm
  3272.     call    comnd
  3273.     jnc    setr6a            ; nc = success
  3274.     ret                ; failure
  3275. setr6a:    mov    dx,offset badrx        ; assume bad construction
  3276.     or    word ptr rdbuf,2020h    ; convert to lower case
  3277.     or    rdbuf+2,20h        ; first three chars
  3278.     cmp    word ptr rdbuf,'fo'    ; key word OFF?
  3279.     jne    setr8            ; ne = no
  3280.     cmp    rdbuf+2,'f'        ; last letter of OFF?
  3281.     jne    setr8            ; ne = no
  3282.     mov    rxtable+256,0        ; OFF is status byte = zero
  3283.     mov    dx,offset rxoffmsg    ; say translation is turned off
  3284.     jmp    short setr9
  3285. setr8:    cmp    word ptr rdbuf,'no'    ; keyword ON?
  3286.     jne    setr9a            ; ne = no, error
  3287.     mov    rxtable+256,1        ; ON is status byte non-zero
  3288.     mov    dx,offset rxonmsg    ; say translation is turned on
  3289. setr9:    cmp    taklev,0        ; executing from a Take file?
  3290.     je    setr9a            ; e = no
  3291.     cmp    flags.takflg,0        ; echo contents of Take file?
  3292.     je    setr10            ; e = no
  3293. setr9a:    mov    ah,prstr        ; bad number message
  3294.     int    dos
  3295. setr10:    clc
  3296.     ret
  3297. setr11:    mov    ah,cmkey        ; SET TRANSLATION KEYBOARD
  3298.     mov    dx,offset ontab        ; on/off
  3299.     xor    bx,bx
  3300.     call    comnd
  3301.     jnc    setr12            ; nc = success
  3302.     ret
  3303. setr12:    mov    ah,cmeol        ; get a confirm
  3304.     call    comnd
  3305.     jnc    setr13            ; nc = success
  3306.     ret                ; failure
  3307. setr13:    mov    flags.xltkbd,bl        ; set keyboard translation on/off
  3308.     clc
  3309.     ret
  3310. SETRX    ENDP
  3311.  
  3312. ; SET TRANSMIT {FILL, LF, Prompt} {ON, OFF, or value}
  3313. SETXMIT    proc    near
  3314.     mov    dx,offset xmitab    ; TRANSMIT keyword table
  3315.     xor    bx,bx
  3316.     mov    ah,cmkey        ; get keyword
  3317.     call    comnd
  3318.     jnc    setxmi1            ; nc = success
  3319.     ret
  3320. setxmi1:cmp    bl,2            ; SET TRANSMIT PROMPT?
  3321.     jne    setxmi2            ; ne = no
  3322.     mov    ah,cmword
  3323.     mov    dx,offset rdbuf+1    ; put answer here
  3324.     mov    bx,offset xpmthlp
  3325.     call    comnd
  3326.     jc    setxmi1d        ; c = error
  3327.     push    ax            ; save length
  3328.     mov    ah,cmeol        ; get a confirm
  3329.     call    comnd
  3330.     pop    cx            ; recover length to cx
  3331.     jc    setxmi1d        ; c = failure
  3332.     mov    al,rdbuf+1
  3333.     cmp    cx,1            ; a single char?
  3334.     je    setxmi1c        ; e = yes, use it as the prompt char
  3335.     mov    si,offset rdbuf+1
  3336.     cmp    byte ptr [si],'\'    ; already quoted?
  3337.     je    setxmi1b        ; e = yes
  3338.     mov    rdbuf,'\'        ; add a numerical quote
  3339.     dec    si            ; point to our escape char
  3340. setxmi1b:call    katoi            ; convert number in rdbuf
  3341.     jc    setxmi1d        ; c = no number, error
  3342. setxmi1c:mov    script.xmitpmt,al    ; store new prompt value
  3343. setxmi1d:ret
  3344.  
  3345. setxmi2:cmp    bl,1            ; LF?
  3346.     jne    setxmi3            ; ne = no
  3347.     mov    dx,offset ontab        ; on or off table
  3348.     xor    bx,bx
  3349.     call    keyend
  3350.     jc    setxmi2a        ; c = failure
  3351.     mov    script.xmitlf,bl    ; set the xmitlf flag
  3352. setxmi2a:ret
  3353.  
  3354. setxmi3:cmp    bl,0            ; FILL?
  3355.     jne    setxmi8            ; ne = no
  3356.     mov    ah,cmword        ; FILL, get a word sized token
  3357.     mov    dx,offset rdbuf+1    ; put it here
  3358.     mov    bx,offset xfilhlp    ; help
  3359.     call    comnd
  3360.     jc    setxmix            ; c = failure
  3361.     push    ax            ; save length in ah
  3362.     mov    ah,cmeol        ; get a confirm
  3363.     call    comnd
  3364.     pop    ax
  3365.     jc    setxmix            ; c = failure
  3366.     cmp    ax,1            ; just one character?
  3367.     ja    setxmi4            ; a = no, there's more
  3368.     mov    al,rdbuf+1        ; get the char
  3369.     mov    script.xmitfill,al    ; store Fill char
  3370.     ret
  3371. setxmi4:mov    ax,word ptr rdbuf+1
  3372.     or    ax,2020h        ; to lower
  3373.     cmp    ax,'on'            ; "none"?
  3374.     jne    setxmi5            ; ne = no
  3375.     mov    script.xmitfill,0    ; no Filling
  3376.     ret
  3377. setxmi5:cmp    ax,'ps'            ; "space"?
  3378.     jne    setxmi6            ; ne = no
  3379.     mov    script.xmitfill,' '    ; use space as filler
  3380.     ret
  3381. setxmi6:mov    si,offset rdbuf+1
  3382.     cmp    byte ptr [si],'\'    ; already quoted?
  3383.     je    setxmi7            ; e = yes
  3384.     mov    rdbuf,'\'        ; add a numerical quote
  3385.     dec    si            ; point to our escape char
  3386. setxmi7:call    katoi            ; convert number in rdbuf
  3387.     jc    setxmix            ; c = no number, error
  3388.     mov    script.xmitfill,al    ; set the xmitfill flag
  3389.     ret
  3390. setxmi8:mov    ah,cmword        ; PAUSE milliseconds
  3391.     mov    dx,offset rdbuf+1    ; put answer here
  3392.     mov    bx,offset xpauhlp
  3393.     call    comnd
  3394.     jc    setxmix            ; c = error
  3395.     push    ax            ; save length
  3396.     mov    ah,cmeol        ; get a confirm
  3397.     call    comnd
  3398.     pop    cx            ; recover length to cx
  3399.     jc    setxmix            ; c = failure
  3400.     mov    si,offset rdbuf+1
  3401.     cmp    byte ptr [si],'\'    ; already quoted?
  3402.     je    setxmi9            ; e = yes
  3403.     mov    rdbuf,'\'        ; add a numerical quote
  3404.     dec    si            ; point to our escape char
  3405. setxmi9:call    katoi            ; convert number in rdbuf
  3406.     jc    setxmix            ; c = no number, error
  3407.     mov    script.xmitpause,ax    ; set the xmitpause flag
  3408. setxmix:ret
  3409. SETXMIT    endp
  3410.  
  3411. ; SET UNKNOWN-CHARACTER-SET {DISCARD, KEEP}, default is KEEP
  3412. unkchset proc    near
  3413.     mov    dx,offset unkctab    ; keep/reject keyword table
  3414.     mov    bx,offset unkchhlp
  3415.     call    keyend
  3416.     jc    unkchx            ; c = failure
  3417.     mov    flags.unkchs,bl        ; 0 = keep, else reject
  3418. unkchx:    ret
  3419. unkchset endp
  3420.  
  3421. ; Common routine for parsing numerical input
  3422. ; Enter with numhlp = offset of help message, numerr = offset of optional
  3423. ;  error message, min, max = allowable range of values.
  3424. ; Returns value in ax, or does parse error return.
  3425. ; Changes ax,bx,dx,si.            [jrd] 18 Oct 1987
  3426. num0:    mov    dx,offset rdbuf+1    ; were to put text
  3427.     mov    word ptr rdbuf,0    ; clear the buffer
  3428.     mov    bx,numhlp        ; help text
  3429.     mov    ah,cmword        ; get a word
  3430.     call    comnd
  3431.     jc    num0x            ; c = failure
  3432.     mov    ah,cmeol
  3433.     call    comnd            ; Get a confirm
  3434.     jc    num0x            ; c = failure
  3435.                     ; second entry point
  3436. numwd:    mov    si,offset rdbuf+1
  3437.     cmp    rdbuf+1,'\'        ; already quoted?
  3438.     je    num0a            ; e = yes
  3439.     mov    rdbuf,'\'        ; add a numerical quote
  3440.     dec    si            ; point to our escape char
  3441. num0a:    call    katoi            ; convert number in rdbuf
  3442.     jc    num0er            ; c = no number, error
  3443.     cmp    ax,max            ; largest permitted value
  3444.     ja    num0er            ; a = error
  3445.     cmp    ax,min            ; smallest permitted value
  3446.     jb    num0er            ; b = error
  3447.     clc
  3448. num0x:    ret                ; return value in ax
  3449.  
  3450. num0er:    mov    ah,prstr
  3451.     mov    dx,numerr        ; comand-specific error message, if any
  3452.     or    dx,dx            ; was any given?
  3453.     jz    num0e1            ; z = no, use generic msg
  3454.     int    dos            ; show given error message
  3455.     jmp    short num0e2
  3456. num0e1:    mov    dx,offset nummsg1    ; get address of numeric error message
  3457.     int    dos
  3458.     mov    ax,min            ; smallest permitted number
  3459.     call    decout            ; display decimal number in ax
  3460.     mov    ah,prstr
  3461.     mov    dx,offset nummsg2    ; "and"
  3462.     int    dos
  3463.     mov    ax,max            ; largest permitted number
  3464.     call    decout
  3465.     mov    ah,prstr
  3466.     mov    dx,offset crlf
  3467.     int    dos
  3468. num0e2:    stc
  3469.     ret
  3470.  
  3471. ; routine to print an error message, then exit without error status
  3472. ; expects message in dx
  3473. reterr    proc    near
  3474.     mov    ah,prstr
  3475.     int    dos
  3476.     clc
  3477.     ret
  3478. reterr    endp
  3479.  
  3480. code    ends
  3481.     end
  3482.