home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / msvp98b1.lzh / MSSSET.ASM < prev    next >
Assembly Source File  |  1993-05-14  |  100KB  |  3,225 lines

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