Eric Smith edb200d
COMMENT - Standard C-Kermit initialization file
Eric Smith edb200d
;
Eric Smith edb200d
; For C-Kermit Version: 8.0
Eric Smith edb200d
;
Eric Smith edb200d
; Filename:
Eric Smith edb200d
;   .kermrc     (UNIX, OS-9, Aegis)
Eric Smith edb200d
;   CKERMIT.INI (OS/2, VMS, OpenVMS, AOS/VS, Atari ST, Commodore Amiga)
Eric Smith edb200d
;   ckermit.ini (Stratus VOS)
Eric Smith edb200d
;   K95.INI     (Kermit 95 -- but this big version is not used there)
Eric Smith edb200d
;   K2.INI      (Kermit/2  -- but ditto)
Eric Smith edb200d
;
Eric Smith edb200d
; Authors:
Eric Smith edb200d
;   Frank da Cruz, Christine M. Gianone, Jeffrey Altman
Eric Smith edb200d
;   Columbia University, New York, NY 10025-7799, USA
Eric Smith edb200d
;
Eric Smith edb200d
; This is the standard and recommended C-Kermit 8.0 initialization file.  To
Eric Smith edb200d
; override settings or definitions made in this file, to add new settings or
Eric Smith edb200d
; definitions, or to make any other desired customizations, create a separate,
Eric Smith edb200d
; personal customization file called:
Eric Smith edb200d
;
Eric Smith edb200d
;   .mykermrc     (UNIX, OS-9, Aegis, BeBox, Plan 9)
Eric Smith edb200d
;   CKERMOD.INI   (OS/2, VMS, OpenVMS, AOS/VS, Atari ST, Commodore Amiga)
Eric Smith edb200d
;   ckermod.ini   (VOS)
Eric Smith edb200d
;
Eric Smith edb200d
; You can also define the customization filename in an environment
Eric Smith edb200d
; variable (logical name in VMS), CKERMOD, which takes precedence over
Eric Smith edb200d
; the names shown above.
Eric Smith edb200d
;
Eric Smith edb200d
; WHAT THIS FILE DOES:
Eric Smith edb200d
;
Eric Smith edb200d
; . Defines your default dialing directory name:
Eric Smith edb200d
;     .kdd for UNIX, OS-9 and Aegis; CKERMIT.KDD for other operating systems.
Eric Smith edb200d
;        You can override this with the environment variable K_DIAL_DIRECTORY
Eric Smith edb200d
; . Defines your default network directory name:
Eric Smith edb200d
;     .knd for UNIX, OS-9 and Aegis; CKERMIT.KND for other operating systems.
Eric Smith edb200d
;        You can override this with the environment variable K_NET_DIRECTORY
Eric Smith edb200d
; . Defines your default services directory name:
Eric Smith edb200d
;     .ksd for UNIX, OS-9 and Aegis; CKERMIT.KSD for other operating systems.
Eric Smith edb200d
;        You can override this with environment variable K_SERVICE_DIRECTORY.
Eric Smith edb200d
; . Defines your customization file name (name given above)
Eric Smith edb200d
; . Performs system-dependent setups for UNIX, VMS, OS/2, etc.
Eric Smith edb200d
; . Defines VTPRINT macros for use with K95, MS-DOS Kermit, etc.
Eric Smith edb200d
; . If you have a services directory, all the macros needed to use it are
Eric Smith edb200d
;     defined.  If you don't have a services directory, the macros are not
Eric Smith edb200d
;     defined and Kermit starts faster.
Eric Smith edb200d
; . Executes your personal customization file, if you have one.
Eric Smith edb200d
;   NOTE: Your customization file is NOT executed by Kermit itself; it is
Eric Smith edb200d
;   executed by this file.
Eric Smith edb200d
;
Eric Smith edb200d
; In UNIX, with C-Kermit 7.0 and later, you can store this file with a name
Eric Smith edb200d
; other than .kermrc, and it will not be executed automatically, but, if you
Eric Smith edb200d
; give this file execute permission, you can execute directly because of the
Eric Smith edb200d
; "kerbang line" at the top, whenever you want all of the above actions to
Eric Smith edb200d
; occur.  The kerbang line must reflect the actual full path of the Kermit
Eric Smith edb200d
; 7.0-or-later executable.
Eric Smith edb200d
;
Eric Smith edb200d
; C-Kermit 6.0 is documented in the book "Using C-Kermit", 2nd Edition,
Eric Smith edb200d
; by Frank da Cruz and Christine M. Gianone, 1997, Digital Press /
Eric Smith edb200d
; Butterworth-Heinemann, ISBN 1-55558-164-1.  New features of subsequent
Eric Smith edb200d
; versions are documented at the Kermit website:
Eric Smith edb200d
; http://www.columbia.edu/kermit/
Eric Smith edb200d
;
Eric Smith edb200d
; Everything after this point depends on the script programming language.
Eric Smith edb200d
; The CHECK command terminates this command file immediately if the script
Eric Smith edb200d
; programming language (IF command) is not configured.
Eric Smith edb200d
;
Eric Smith edb200d
set take error on		; This makes CHECK quit if no script language.
Eric Smith edb200d
check if			; Do we have an IF command?  If not, quit now.
Eric Smith edb200d
set take error off		; Back to normal.
Eric Smith edb200d
Eric Smith edb200d
local _sd _servicedir _xp       ; Declare local variables.
Eric Smith edb200d
Eric Smith edb200d
COMMENT - C-Kermit version 6.0 or later required.
Eric Smith edb200d
;
Eric Smith edb200d
Eric Smith edb200d
asg _xp \v(xprogram)
Eric Smith edb200d
if not def _xp asg _xp \v(program)
Eric Smith edb200d
if not equal "\m(_xp)" "C-Kermit" -
Eric Smith edb200d
  stop 1 \v(cmdfile): This initialization file is only for C-Kermit.
Eric Smith edb200d
echo Executing \v(cmdfile) for \v(system)...
Eric Smith edb200d
if < \v(version) 60000 -
Eric Smith edb200d
  stop 1 \v(cmdfile): C-Kermit 6.0 or later required.
Eric Smith edb200d
Eric Smith edb200d
forward \v(system)		; First do system-dependent items...
Eric Smith edb200d
Eric Smith edb200d
:unknown			; Should not happen
Eric Smith edb200d
Stop 1 Error: System type unknown!
Eric Smith edb200d
Eric Smith edb200d
:Aegis				; Apollo Aegis and
Eric Smith edb200d
:UNIX				; UNIX, all versions
Eric Smith edb200d
asg _myinit -
Eric Smith edb200d
  \v(home).mykermrc		; Customization filename
Eric Smith edb200d
if remote forward COMMON        ; Skip local-mode items if "-R"
Eric Smith edb200d
asg _dialdir -
Eric Smith edb200d
  \v(home).kdd			; C-Kermit dialing directory
Eric Smith edb200d
asg _netdir -
Eric Smith edb200d
  \v(home).knd			; C-Kermit network directory
Eric Smith edb200d
asg _servicedir -
Eric Smith edb200d
  \v(home).ksd			; C-Kermit services directory
Eric Smith edb200d
forward COMMON                  ; End of UNIX section
Eric Smith edb200d
Eric Smith edb200d
:OS9/68K			; OS-9
Eric Smith edb200d
asg _myinit -
Eric Smith edb200d
  \v(home).mykermrc		; Customization filename
Eric Smith edb200d
if remote forward COMMON
Eric Smith edb200d
asg _dialdir -
Eric Smith edb200d
  \v(home).kdd			; C-Kermit dialing directory
Eric Smith edb200d
asg _netdir -
Eric Smith edb200d
  \v(home).knd			; C-Kermit network directory
Eric Smith edb200d
asg _servicedir -
Eric Smith edb200d
  \v(home).ksd			; C-Kermit services directory
Eric Smith edb200d
else set file display crt
Eric Smith edb200d
forward COMMON			; End of OS-9 section
Eric Smith edb200d
Eric Smith edb200d
:VMS				; VMS and OpenVMS
Eric Smith edb200d
forward COMMON
Eric Smith edb200d
Eric Smith edb200d
:OS/2				; Kermit 95
Eric Smith edb200d
:WIN32
Eric Smith edb200d
echo This initialization file is not for use with K95.
Eric Smith edb200d
forward COMMON                  ; End of OS/2 section
Eric Smith edb200d
Eric Smith edb200d
:AOS/VS				; Data General AOS/VS
Eric Smith edb200d
set window 1			; Sliding windows don't work
Eric Smith edb200d
set file char dg-international	; File character-set
Eric Smith edb200d
set xfer char latin1		; Transfer character-set
Eric Smith edb200d
set file display crt            ; File transfer fisplay
Eric Smith edb200d
def cli push			; Escape to CLI
Eric Smith edb200d
def reset -			; Macro to reset DG DASHER terminal
Eric Smith edb200d
 run write [!ascii 236 306 301]
Eric Smith edb200d
forward COMMON                  ; End of AOS/VS section
Eric Smith edb200d
Eric Smith edb200d
:Amiga				; Commodore Amiga
Eric Smith edb200d
def cls echo \27[H\27[2J	; CLS command to clear the screen
Eric Smith edb200d
set file char latin1		; Use Latin Alphabet 1 for file transfer
Eric Smith edb200d
set xfer char latin1		; ...
Eric Smith edb200d
forward COMMON                  ; End of Amiga section
Eric Smith edb200d
Eric Smith edb200d
:Atari_ST			; Atari ST
Eric Smith edb200d
def cls echo \27H\27J		; Clear screen a`la VT52
Eric Smith edb200d
set server display on		; Show file xfer display in server mode too
Eric Smith edb200d
set server timeout 15		; Nonzero required for ^C interruption!
Eric Smith edb200d
forward COMMON                  ; End of Atari ST section
Eric Smith edb200d
Eric Smith edb200d
:Macintosh			; Apple Macintosh
Eric Smith edb200d
set server display on		; Show file xfer display in server mode too.
Eric Smith edb200d
forward COMMON
Eric Smith edb200d
Eric Smith edb200d
:Stratus_VOS                    ; Stratus VOS
Eric Smith edb200d
asg _myinit \v(home)ckermod.ini
Eric Smith edb200d
if remote forward COMMON
Eric Smith edb200d
asg _dialdir \v(home)ckermit.kdd
Eric Smith edb200d
asg _netdir \v(home)ckermit.knd
Eric Smith edb200d
asg _servicedir \v(home)ckermit.ksd
Eric Smith edb200d
forward COMMON                  ; End of Stratus VOS section
Eric Smith edb200d
Eric Smith edb200d
:COMMON				; For all systems
Eric Smith edb200d
Eric Smith edb200d
; Define macros that are useful when running C-Kermit in remote mode.
Eric Smith edb200d
; These macros serve no purpose on local-mode-only versions such as
Eric Smith edb200d
; OS/2, Macintosh, Amiga, and Atari ST Kermit, so we skip defining them
Eric Smith edb200d
; for those systems.
Eric Smith edb200d
;
Eric Smith edb200d
if not = 0 \findex(\v(system),WIN32:OS/2:Macintosh:Amiga:Atari_ST) -
Eric Smith edb200d
  forward files
Eric Smith edb200d
Eric Smith edb200d
; VTPRINT macro.  Print a file on your PC's local printer.
Eric Smith edb200d
Eric Smith edb200d
def VTPRINT echo \27[5i, type \%1, echo \27[4i
Eric Smith edb200d
; or if your printer needs a formfeed to force the page out:
Eric Smith edb200d
; def VTPRINT  def echo \27[5i, type \%1, echo \12\27[4i
Eric Smith edb200d
Eric Smith edb200d
; Macros for host-initiated file transfer using APC:
Eric Smith edb200d
;   NOT NEEDED ANY MORE because of autodownload/autoupload.
Eric Smith edb200d
;   Remove the following FORWARD command to reinstate these definitions:
Eric Smith edb200d
Eric Smith edb200d
:FILES
Eric Smith edb200d
Eric Smith edb200d
; Get customization and directory file names.  Environment variables take
Eric Smith edb200d
; precedence, so you do not have to edit this file to change these filenames.
Eric Smith edb200d
;
Eric Smith edb200d
if def \$(CKERMOD) assign _myinit \$(CKERMOD)
Eric Smith edb200d
if not def _myinit assign _myinit \v(home)CKERMOD.INI
Eric Smith edb200d
Eric Smith edb200d
if remote forward CUSTOM ; Skip all this if -R given on command line
Eric Smith edb200d
Eric Smith edb200d
if def \$(K_NET_DIRECTORY) assign _netdir \$(K_NET_DIRECTORY)
Eric Smith edb200d
if not def _netdir assign _netdir \v(home)CKERMIT.KND
Eric Smith edb200d
Eric Smith edb200d
if def \$(K_DIAL_DIRECTORY) assign _dialdir \$(K_DIAL_DIRECTORY)
Eric Smith edb200d
if not def _dialdir assign _dialdir \v(home)CKERMIT.KDD
Eric Smith edb200d
Eric Smith edb200d
CHECK DIAL			; Is there a DIAL command?
Eric Smith edb200d
xif fail { 			; No.
Eric Smith edb200d
    echo DIAL disabled
Eric Smith edb200d
    forward CUSTOM
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
CHECK NETWORK
Eric Smith edb200d
xif success {
Eric Smith edb200d
    xif exist \m(_netdir) {
Eric Smith edb200d
	set net directory \m(_netdir)
Eric Smith edb200d
	echo { Network directory is \m(_netdir) }
Eric Smith edb200d
    }
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
if eq "\v(name)" "telnet" forward CUSTOM
Eric Smith edb200d
Eric Smith edb200d
xif exist \m(_dialdir) {
Eric Smith edb200d
    set dial directory \m(_dialdir)
Eric Smith edb200d
    echo { Dial directory is \m(_dialdir) }
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - Services directory
Eric Smith edb200d
Eric Smith edb200d
if def \$(K_SERVICE_DIRECTORY) assign _servicedir \$(K_SERVICE_DIRECTORY)
Eric Smith edb200d
if not def _servicedir assign _servicedir \v(home)CKERMIT.KSD
Eric Smith edb200d
Eric Smith edb200d
; If no services directory is found skip all the big macro definitions and
Eric Smith edb200d
; go straight to the bottom, where we execute the customization file.
Eric Smith edb200d
Eric Smith edb200d
if not exist \m(_servicedir) forward custom
Eric Smith edb200d
Eric Smith edb200d
echo { Services directory is \m(_servicedir)}
Eric Smith edb200d
Eric Smith edb200d
def MAX_SVCS 200               ; Adjust this if you have more entries
Eric Smith edb200d
define _sd 0                   ; Assume no services directory
Eric Smith edb200d
open read \m(_servicedir)      ; Try to open services directory file
Eric Smith edb200d
xif success {
Eric Smith edb200d
    declare \&d[\m(MAX_SVCS)]  ; It's open, declare directory array
Eric Smith edb200d
    for \%i 1 \m(MAX_SVCS) 1 { ; Read the lines into the array
Eric Smith edb200d
	read \&d[\%i]
Eric Smith edb200d
	if fail break
Eric Smith edb200d
    }
Eric Smith edb200d
    close read
Eric Smith edb200d
    xif > \%i  \m(MAX_SVCS) {
Eric Smith edb200d
	echo Too many entries in services directory
Eric Smith edb200d
	echo { Maximum is \m(MAX_SVCS).}
Eric Smith edb200d
	echo { Change definition of MAX_SVCS in \v(cmdfile) to allow more. }
Eric Smith edb200d
	echo { Services directory disabled.}
Eric Smith edb200d
    } else {
Eric Smith edb200d
        asg \&d[0] \feval(\%i - 1)
Eric Smith edb200d
        define _sd 1
Eric Smith edb200d
    }
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
xif not \m(_sd) {
Eric Smith edb200d
    def access echo { Services directory not available.}
Eric Smith edb200d
    asg list \m(access)
Eric Smith edb200d
} else {
Eric Smith edb200d
    def FIND {
Eric Smith edb200d
	set case off
Eric Smith edb200d
	for \%i 1 \&d[0] 1 {
Eric Smith edb200d
	    if eq {\%1} {\fsubstr(\&d[\%i],1,\flen(\%1))} break
Eric Smith edb200d
	}
Eric Smith edb200d
	if not > \%i \&d[0] return \&d[\%i]
Eric Smith edb200d
    }
Eric Smith edb200d
    def LIST {
Eric Smith edb200d
	xif > \v(argc) 1 {
Eric Smith edb200d
	    find \%1
Eric Smith edb200d
	    if def \v(return) echo \v(return)
Eric Smith edb200d
	    else echo \%1: Not found
Eric Smith edb200d
	} else {
Eric Smith edb200d
	    echo \&d[0] items in services directory:
Eric Smith edb200d
	    for \%i 1 \&d[0] 1 { echo \fcont(\&d[\%i]) }
Eric Smith edb200d
	}
Eric Smith edb200d
    }
Eric Smith edb200d
    def SPLIT { asg _word1 \%1, asg _word2 \%2 }
Eric Smith edb200d
    def DOACCESS {               ; (Used internally by ACCESS macro)
Eric Smith edb200d
	do \%5 \%6 \%7 \%8 \%9   ; Do the connection macro
Eric Smith edb200d
	if fail end 1
Eric Smith edb200d
        split \%3                ; Get words from \%3
Eric Smith edb200d
	asg \%3 \m(_word1)
Eric Smith edb200d
	asg \%2 \m(_word2)
Eric Smith edb200d
	do \%3 \%4 {\%1} \%2     ; Login macro, userid, password, prompt
Eric Smith edb200d
    }
Eric Smith edb200d
    def ACCESS {
Eric Smith edb200d
	if not defined \%1 end 1 access what?        ; Check service
Eric Smith edb200d
	find \%1                                     ; Look it up
Eric Smith edb200d
	if success doaccess {\%2} \v(return)         ; OK, try it
Eric Smith edb200d
	else end 1 "\%1" not in services directory   ; Not found
Eric Smith edb200d
	if fail end 1                                ; DOACCESS failed?
Eric Smith edb200d
	xif eq \v(cmdlevel) 1 {
Eric Smith edb200d
	    echo
Eric Smith edb200d
	    echo ACCESS: Login succeeded - CONNECTing...
Eric Smith edb200d
            show escape
Eric Smith edb200d
            output \13
Eric Smith edb200d
	    connect /quietly
Eric Smith edb200d
        }
Eric Smith edb200d
    }
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
:CONNECTION ; Macros for making connections
Eric Smith edb200d
Eric Smith edb200d
COMMENT - SERIAL macro.  Arguments:
Eric Smith edb200d
; \%1 = device name
Eric Smith edb200d
; \%2 = speed
Eric Smith edb200d
;
Eric Smith edb200d
def SERIAL {
Eric Smith edb200d
    if < \v(argc) 3                         ; All arguments given?
Eric Smith edb200d
      end 1 Usage: SERIAL device speed      ; No.
Eric Smith edb200d
    set line \%1                            ; OK, try to SET LINE.
Eric Smith edb200d
    if failure -                            ; If this failed,
Eric Smith edb200d
      end 1 Can't open device: \%1          ; print message and quit.
Eric Smith edb200d
    set speed \%2                           ; Try to set the speed.
Eric Smith edb200d
    if fail end 1 Unsupported speed: \%2    ; Failed.
Eric Smith edb200d
    echo Connection successful.             ; Succeeded.
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - NET macro.  Arguments:
Eric Smith edb200d
; \%1 = network type
Eric Smith edb200d
; \%2 = host name or address
Eric Smith edb200d
;
Eric Smith edb200d
def NET {
Eric Smith edb200d
    if < \v(argc) 3 end 1 Usage: NET network host
Eric Smith edb200d
    set network type \%1
Eric Smith edb200d
    if fail end 1 unsupported network: \%1
Eric Smith edb200d
    set login user                ; Don't send user ID.
Eric Smith edb200d
    set host \%2
Eric Smith edb200d
    if fail end 1 Can't reach host: \%2
Eric Smith edb200d
    echo Connection successful.
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - CALL macro.  Arguments:
Eric Smith edb200d
;
Eric Smith edb200d
; \%1 = modem type
Eric Smith edb200d
; \%2 = device name
Eric Smith edb200d
; \%3 = speed
Eric Smith edb200d
; \%4 = phone number
Eric Smith edb200d
;
Eric Smith edb200d
def CALL {
Eric Smith edb200d
    if < \v(argc) 5 -         ; All arguments present?
Eric Smith edb200d
      end 1 Usage: CALL modem device speed number
Eric Smith edb200d
    xif not equal {\v(modem)} {\%1} { ; Set modem type
Eric Smith edb200d
        set modem \%1
Eric Smith edb200d
        if fail end 1 unknown modem type: \%1
Eric Smith edb200d
    }
Eric Smith edb200d
    xif not equal {\v(line)} {\%2} { ; Communication device
Eric Smith edb200d
        set line \%2
Eric Smith edb200d
        if fail end 1 can't open device: \%2
Eric Smith edb200d
    }
Eric Smith edb200d
    xif not equal {\v(speed)} {\%3} { ; Communication speed
Eric Smith edb200d
        set speed \%3
Eric Smith edb200d
        if fail end 1 unsupported speed: \%3
Eric Smith edb200d
    }
Eric Smith edb200d
    dial \%4                  ; Dial the number
Eric Smith edb200d
    if fail end 1 Can't place call: \%4
Eric Smith edb200d
    end 0 Connection successful.
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - TCPCALL macro.  Arguments:
Eric Smith edb200d
;
Eric Smith edb200d
; \%1 = server name:port
Eric Smith edb200d
; \%2 = modem type
Eric Smith edb200d
; \%3 = phone number
Eric Smith edb200d
;
Eric Smith edb200d
def TCPCALL {
Eric Smith edb200d
    if < \v(argc) 4 -         ; All arguments present?
Eric Smith edb200d
      end 1 Usage: TCPCALL server[:port] modem number
Eric Smith edb200d
    set net type tcp/ip       ; Which network to use
Eric Smith edb200d
    if fail end 1 unsupported network: tcp/ip
Eric Smith edb200d
    set host \%1              ; Access server and port
Eric Smith edb200d
    if fail end 1 can't access server \%1
Eric Smith edb200d
    set modem \%2             ; Set modem type
Eric Smith edb200d
    if fail end 1 unknown modem type: \%2
Eric Smith edb200d
    dial \%3                  ; Dial the number
Eric Smith edb200d
    if fail end 1 Can't place call: \%3
Eric Smith edb200d
    end 0 Connection successful.
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - SPRINT macro.  Arguments:
Eric Smith edb200d
; \%1 = Service name or address
Eric Smith edb200d
;
Eric Smith edb200d
def SPRINT {
Eric Smith edb200d
    if < \v(argc) 2 end 1 Usage: \%0 service
Eric Smith edb200d
    set input timeout proceed
Eric Smith edb200d
    output @D\13
Eric Smith edb200d
    input 10 TERMINAL=
Eric Smith edb200d
    if fail end 1 No terminal prompt
Eric Smith edb200d
    out D1\13
Eric Smith edb200d
    inp 10 @
Eric Smith edb200d
    if fail end 1 No atsign prompt
Eric Smith edb200d
    output c \%1\13
Eric Smith edb200d
    input 10 CONNECTED
Eric Smith edb200d
    if fail end 1 Can't access \%1 from SprintNet
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - ULOGIN macro.  For logging into systems where user ID is required
Eric Smith edb200d
; but there is no password.  Arguments:
Eric Smith edb200d
; \%1 = UNIX user ID
Eric Smith edb200d
;
Eric Smith edb200d
define ULOGIN {
Eric Smith edb200d
    if < \v(argc) 2 end 1 Usage: \%0 userid
Eric Smith edb200d
    set input timeout proceed     ; Handle timeouts ourselves
Eric Smith edb200d
    set case on                   ; Case is important in UNIX
Eric Smith edb200d
    minput 5 login: Username: {User ID:} {User Name:}
Eric Smith edb200d
    out \%1\13                    ; Send username, carriage return
Eric Smith edb200d
    end 0
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - VMSLOGIN macro.  Arguments:
Eric Smith edb200d
; \%1 = VMS user ID
Eric Smith edb200d
; \%2 = Password.  If password not supplied, it is prompted for.
Eric Smith edb200d
; \%3 = System prompt.  If omitted a default is supplied.
Eric Smith edb200d
;
Eric Smith edb200d
define VMSLOGIN {
Eric Smith edb200d
    if < \v(argc) 2 end 1 Usage: \%0 userid [ password [ prompt ] ]
Eric Smith edb200d
    while not defined \%2 {
Eric Smith edb200d
        askq \%2 { \%1's password: }
Eric Smith edb200d
    }
Eric Smith edb200d
    set parity none               ; Set communication parameters
Eric Smith edb200d
    set duplex full
Eric Smith edb200d
    set handshake none
Eric Smith edb200d
    set input timeout proceed     ; Handle timeouts ourselves
Eric Smith edb200d
    in 5 Username:                ; Is prompt already there?
Eric Smith edb200d
    xif fail {                    ; No.
Eric Smith edb200d
        for \%i 1 3 1 {           ; Try 3 times to get it.
Eric Smith edb200d
            out \13               ; Send carriage return
Eric Smith edb200d
            in 5 Username:        ; Look for prompt
Eric Smith edb200d
            if success break      ; Success, go log in
Eric Smith edb200d
        }
Eric Smith edb200d
        if > \%i 3 end 1 No Username prompt
Eric Smith edb200d
    }
Eric Smith edb200d
    out \%1\13                    ; Send username, carriage return
Eric Smith edb200d
    inp 5 Password:               ; Wait 5 sec for this prompt
Eric Smith edb200d
    if fail end 1 No password prompt
Eric Smith edb200d
    pause                         ; Wait a sec
Eric Smith edb200d
    out \%2\13                    ; Send password
Eric Smith edb200d
    xif not emulation {           ; No emulator built in?
Eric Smith edb200d
        set input echo off        ; Protect terminal from this
Eric Smith edb200d
        minput 10 {\27Z} {\27[c} {\27[0c} ; Get terminal ID query
Eric Smith edb200d
        xif success {                     ; Got one
Eric Smith edb200d
            output \27[\?1c               ; Send VT100 terminal ID
Eric Smith edb200d
            in 2 \27[6n                   ; Screen dimension query?
Eric Smith edb200d
            if succ out \27[\v(rows);\v(cols)R ; Send dimensions
Eric Smith edb200d
        }
Eric Smith edb200d
        set input echo on         ; Echo input again
Eric Smith edb200d
    }
Eric Smith edb200d
    if not def \%3 -              ; If we were not given a prompt
Eric Smith edb200d
      asg \%3 {\v(prompt)}        ; use the SET LOGIN PROMPT value
Eric Smith edb200d
    if not def \%3 -              ; If we still don't have a prompt
Eric Smith edb200d
      asg \%3 {\13$\32}           ; use this one as the default
Eric Smith edb200d
    reinp 0 \%3                   ; Did we INPUT the prompt already?
Eric Smith edb200d
    if fail inp 60 \%3            ; No, look now.
Eric Smith edb200d
    if fail end 1
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - UNIXLOGIN macro.  Arguments:
Eric Smith edb200d
; \%1 = UNIX user ID
Eric Smith edb200d
; \%2 = Password.  If password not supplied, it is prompted for.
Eric Smith edb200d
; \%3 = System prompt.  If omitted a default is supplied.
Eric Smith edb200d
;
Eric Smith edb200d
define UNIXLOGIN {
Eric Smith edb200d
    local \%m \%i
Eric Smith edb200d
    if < \v(argc) 2 -
Eric Smith edb200d
      end 1 Usage: \%0 userid [ password [ prompt ] ]
Eric Smith edb200d
    while not defined \%2 {
Eric Smith edb200d
        askq \%2 { \%1's password: }
Eric Smith edb200d
    }
Eric Smith edb200d
    set input echo on
Eric Smith edb200d
    set parity none               ; Set communication parameters.
Eric Smith edb200d
    set duplex full
Eric Smith edb200d
    set handshake none
Eric Smith edb200d
    set input timeout proceed     ; Handle timeouts ourselves
Eric Smith edb200d
    set case on                   ; Case is important in UNIX
Eric Smith edb200d
    def \%m 10                    ; Waiting time for INPUT
Eric Smith edb200d
    for \%i 1 5 1 {
Eric Smith edb200d
        minput \%m login: {ssword:} {Password for \%1:}
Eric Smith edb200d
	if success break
Eric Smith edb200d
	output \B\13
Eric Smith edb200d
        \%m ::= 6-\%1
Eric Smith edb200d
    }
Eric Smith edb200d
    if > \%i 5 end 1 {No response from host}
Eric Smith edb200d
    xif = \v(minput) 1 {	  ; Have username prompt
Eric Smith edb200d
	output \%1\13		  ; Send username
Eric Smith edb200d
        minput 5 {ssword:} {ssword for \%1:} ; Wait for password prompt
Eric Smith edb200d
	if fail end 1 {No password prompt}
Eric Smith edb200d
    }
Eric Smith edb200d
    pause                         ; Wait a sec
Eric Smith edb200d
    out \%2\13                    ; Send password
Eric Smith edb200d
    if not def \%3 -              ; If we were not given a prompt
Eric Smith edb200d
      asg \%3 {\v(prompt)}        ; use the SET LOGIN PROMPT value
Eric Smith edb200d
    if not def \%3 -              ; If we still don't have a prompt
Eric Smith edb200d
      asg \%3 {\10$ }             ; use this one as the default
Eric Smith edb200d
    reinp 0 \%3                   ; Did we INPUT the prompt already?
Eric Smith edb200d
    if fail inp 60 \%3            ; No, look now.
Eric Smith edb200d
    if fail end 1
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - VMLINELOGIN macro.  Arguments:
Eric Smith edb200d
; \%1 = User ID
Eric Smith edb200d
; \%2 = Password
Eric Smith edb200d
;
Eric Smith edb200d
define VMLINELOGIN {
Eric Smith edb200d
    if < \v(argc) 2 -
Eric Smith edb200d
      end 1 Usage: \%0 userid [ password ]
Eric Smith edb200d
    while not defined \%2 {
Eric Smith edb200d
        askq \%2 { \%1's password: }
Eric Smith edb200d
    }
Eric Smith edb200d
    set parity mark               ; Set communication parameters
Eric Smith edb200d
    set flow none
Eric Smith edb200d
    set handshake xon
Eric Smith edb200d
    set duplex half
Eric Smith edb200d
    set input timeout quit        ; Don't bother with IF FAILURE
Eric Smith edb200d
    input 10 BREAK KEY            ; Look for BREAK KEY prompt
Eric Smith edb200d
    pause 1                       ; Wait a second
Eric Smith edb200d
    output \B                     ; Send BREAK
Eric Smith edb200d
    input 10 .\17, output logon \%1\13    ; Now log in
Eric Smith edb200d
    input 10 .\17, output \%2\13          ; Send password
Eric Smith edb200d
    input 10 .\17, output \13             ; Send carriage return
Eric Smith edb200d
    input 10 .\17, output \13             ; Send another one
Eric Smith edb200d
    end 0
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - VMFULLOGIN macro.  Arguments:
Eric Smith edb200d
; \%1 = User ID
Eric Smith edb200d
; \%2 = Password
Eric Smith edb200d
;
Eric Smith edb200d
define VMFULLOGIN {
Eric Smith edb200d
    if < \v(argc) 2 -
Eric Smith edb200d
      end 1 Usage: \%0 userid [ password ]
Eric Smith edb200d
    while not defined \%2 {
Eric Smith edb200d
        askq \%2 { \%1's password: }
Eric Smith edb200d
    }
Eric Smith edb200d
    set input timeout quit      ; Quit if INPUT fails
Eric Smith edb200d
    set parity even             ; Set communication parameters
Eric Smith edb200d
    set duplex full
Eric Smith edb200d
    set handshake none
Eric Smith edb200d
    set flow xon/xoff
Eric Smith edb200d
    out \13                     ; Send carriage return
Eric Smith edb200d
    inp 5 TERMINAL TYPE:        ; Get terminal-type prompt
Eric Smith edb200d
    out vt-100\13               ; Just send "vt-100"
Eric Smith edb200d
    inp 20 RUNNING              ; Get RUNNING message
Eric Smith edb200d
    pau 1                       ; Wait one second
Eric Smith edb200d
    out \%1\9\%2\13             ; Send user ID, tab, password
Eric Smith edb200d
    out \13\13                  ; Two more carriage returns
Eric Smith edb200d
    end 0
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - CISLOGIN macro.  Arguments:
Eric Smith edb200d
; \%1 = CompuServe User ID
Eric Smith edb200d
; \%2 = Password
Eric Smith edb200d
; \%3 = Prompt
Eric Smith edb200d
;
Eric Smith edb200d
define CISLOGIN {
Eric Smith edb200d
    if < \v(argc) 2 -
Eric Smith edb200d
      end 1 Usage: \%0 userid [ password [ prompt ] ]
Eric Smith edb200d
    while not defined \%2 {
Eric Smith edb200d
        askq \%2 { \%1's password: }
Eric Smith edb200d
    }
Eric Smith edb200d
    set terminal bytesize 7     ; No 8-bit characters
Eric Smith edb200d
    set input timeout quit      ; Skip the IF FAILURE's
Eric Smith edb200d
    output \13                  ; Send initial carriage return
Eric Smith edb200d
    input 5 Host Name:          ; Look for Host Name prompt
Eric Smith edb200d
    output cis\13               ; Send "cis" and carriage return
Eric Smith edb200d
    input 5 User ID:            ; Look for User ID prompt
Eric Smith edb200d
    output \%1\13               ; Send ID and carriage return
Eric Smith edb200d
    input Password:             ; Look for Password prompt
Eric Smith edb200d
    output \%2\13               ; Send password and CR
Eric Smith edb200d
    if not def \%3 asg \%3 \v(prompt)
Eric Smith edb200d
    if not def \%3 asg \%3 {CompuServe Information Service}
Eric Smith edb200d
    input 30 \%3
Eric Smith edb200d
    end 0
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - DOWLOGIN macro.  Arguments:
Eric Smith edb200d
; \%1 = Dow Jones Password
Eric Smith edb200d
;
Eric Smith edb200d
define DOWLOGIN {
Eric Smith edb200d
    while not defined \%1 {              ; Get password
Eric Smith edb200d
        askq \%1 { Dow Jones password: }
Eric Smith edb200d
    }
Eric Smith edb200d
    set input timeout proceed
Eric Smith edb200d
    input 20 SERVICE PLEASE\?\?\?\?      ; Look for Dow prompt
Eric Smith edb200d
    if fail end 1 No service prompt
Eric Smith edb200d
    out djnr\13                          ; Select DJNR
Eric Smith edb200d
    input 10 @@@@@@@@                        ; Get password prompt
Eric Smith edb200d
    if fail end 1 No password prompt
Eric Smith edb200d
    pause 1                              ; Wait a second, then...
Eric Smith edb200d
    output \%1\13                        ; send password and CR
Eric Smith edb200d
    input 30 ENTER QUERY                 ; Get DJNR query prompt
Eric Smith edb200d
    if fail end 1 No main query prompt
Eric Smith edb200d
    pause 1
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
COMMENT - DJNRSPRINT macro: Log in to Dow Jones via SprintNet.
Eric Smith edb200d
;
Eric Smith edb200d
def djnrsprint sprint dow, if success dowlogin
Eric Smith edb200d
Eric Smith edb200d
COMMENT - NOLOGIN macro.  Does nothing.  Use when login not required.
Eric Smith edb200d
;
Eric Smith edb200d
def nologin comment
Eric Smith edb200d
Eric Smith edb200d
:CUSTOM ; Customization file
Eric Smith edb200d
Eric Smith edb200d
; In VMS and OpenVMS, allow for system-wide site customizations
Eric Smith edb200d
Eric Smith edb200d
xif equal "\v(system)" "VMS" {
Eric Smith edb200d
    xif exist CKERMIT_INI:CKERMIT.SYS {
Eric Smith edb200d
	echo Executing CKERMIT_INI:CKERMIT.SYS
Eric Smith edb200d
	take CKERMIT_INI:CKERMIT.SYS
Eric Smith edb200d
    }
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
; Execute user's personal customization file
Eric Smith edb200d
Eric Smith edb200d
xif exist \m(_myinit)  {		; If it exists,
Eric Smith edb200d
    echo Executing \m(_myinit)...	; print message,
Eric Smith edb200d
    take \m(_myinit)			; and TAKE the file.
Eric Smith edb200d
}
Eric Smith edb200d
Eric Smith edb200d
; Finish up with traditional greeting.
Eric Smith edb200d
Eric Smith edb200d
if < \v(ntime) 43200 echo Good Morning!
Eric Smith edb200d
  else if < \v(ntime) 61200 echo Good Afternoon!
Eric Smith edb200d
  else echo Good Evening.
Eric Smith edb200d
Eric Smith edb200d
End ; of C-Kermit 7.0 initialization file.