home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
tbsource.lha
/
TBSource
/
Logger
/
Lv1.05.S
< prev
next >
Wrap
Text File
|
1993-12-21
|
26KB
|
1,458 lines
*************************************************
* *
* (C)opyright 1992 *
* *
* by Tomi Blinnikka *
* *
* Don´t try to understand the code *
* *
* Version 0.01 ??/??/1992 *
* -0.99ö *
* *
* BUGS: *
* *
* Version 1.00 01/08/1992 *
* *
* BUGS: Logging problems, grr... *
* *
* Version 1.01 08/08/1992 *
* *
* BUGS: *
* *
* Version 1.02 09/08/1992 *
* *
* Added speeds. *
* *
* Version 1.03 14/08/1992 *
* *
* Added log! *
* *
* BUGS: Didn't give correct device in arguments *
* *
* Version 1.04 15/08/1992 *
* *
* Version 1.05 22/08/1992 *
* *
* Changed log to be opened/closed before/after *
* writes. *
* *
*************************************************
INCLUDE "JMPLibs.i"
INCLUDE "exec/types.i"
INCLUDE "exec/nodes.i"
INCLUDE "exec/lists.i"
INCLUDE "exec/ports.i"
INCLUDE "exec/memory.i"
INCLUDE "exec/devices.i"
INCLUDE "exec/io.i"
INCLUDE "exec/tasks.i"
INCLUDE "libraries/dosextens.i"
INCLUDE "libraries/dos.i"
INCLUDE "devices/serial.i"
INCLUDE "dos/dostags.i"
INCLUDE "dos/datetime.i"
INCLUDE "XREF:2.0.xref"
INCLUDE "XREF:exec.xref"
INCLUDE "XREF:dos.xref"
XREF _LVOCurrentTime
XREF _LVOSystemTagList
TRUE: EQU 1
section Logger,CODE
push d2-d7/a2-a6
push d0/a0
sub.l a1,a1 ;Find our task
lib Exec,FindTask
move.l d0,OurTask
openlib Dos,NoDos ;Keep at beginning
CLIStart: lib Dos,Output
move.l d0,_stdout
openlib Utility,NoUtility
pull d0/a0
clr.b -1(a0,d0.l)
cmp.b #'?',(a0)
beq Usage
cmp.w #'-?',(a0)
beq Usage
cmp.w #'-h',(a0)
beq Usage
cmp.b #'h',(a0)
beq Usage
cmp.w #'-1',(a0)
bne CLIStart1
move.w #1,LogLevel
add.l #3,a0
CLIStart1: cmp.w #'-2',(a0)
bne CLIStart2
move.w #2,LogLevel
add.l #3,a0
CLIStart2: cmp.w #'-3',(a0)
bne CLIStart3
move.w #3,LogLevel
add.l #3,a0
CLIStart3: cmp.w #'-d',(a0)
bne CLIStart9
move.w #1,Dumb
add.l #3,a0
CLIStart9: cmp.w #'-s',(a0)
bne CLIStart10
add.l #2,a0
bsr ConvASCII
tst.l d0
beq CLIStart2
move.l d0,Speed
CLIStart10: cmp.b #' ',(a0)
bne CLIStart11
add.l #1,a0
bra CLIStart10
CLIStart11:
Cont0.2: bsr ConvASCII
tst.l d0
beq Cont1
move.l d0,SerUnit
Cont1: cmp.b #' ',(a0)
bne Cont1.1
add.l #1,a0
Cont1.1: tst.b (a0)
beq Cont1.2
move.l a0,SerName
Cont1.2:
MainStart: openlib Intuition,NoInt
;Create read reply port for serial.device (or modem0.device etc.)
lib Exec,CreateMsgPort
move.l d0,SRRPort
beq NoMsgPort
;Create read IOReq for serial.device (or for other device, but size is EXTSER)
move.l #IOEXTSER_SIZE,d0
move.l SRRPort,a0
lib Exec,CreateIORequest
move.l d0,IORRequest
beq NoIOReq
;Create write reply port for serial.device (or modem0.device etc.)
lib Exec,CreateMsgPort
move.l d0,SWRPort
beq NoMsgPort
;Create write IOReq for serial.device (or for other device, but size is EXTSER)
move.l #IOEXTSER_SIZE,d0
move.l SWRPort,a0
lib Exec,CreateIORequest
move.l d0,IOWRequest
beq NoIOReq
;open serial.device
move.l SerName,a0
move.l SerUnit,d0
move.l IORRequest,a1
move.l Speed,IO_BAUD(a1)
move.b #SERF_SHARED,IO_SERFLAGS(a1)
clr.l d1 ;no flags
lib Exec,OpenDevice
tst.l d0
bne NoSerial
move.w #$1,SerOpen ;just to tell if open
;Copy info from one req to the other
move.l IORRequest,a0
move.l IOWRequest,a1
move.l IO_DEVICE(a0),IO_DEVICE(a1)
move.l IO_UNIT(a0),IO_UNIT(a1)
add.l #48,a0 ;get start of ioser
add.l #48,a1
move.l #34,d0
lib Exec,CopyMem
;set preferences with IOWReq
tst.l Speed
beq SkipSpeed
move.l IOWRequest,a1
clr.l IO_LENGTH(a1)
clr.l IO_DATA(a1)
move.w #SDCMD_SETPARAMS,IO_COMMAND(a1)
move.l Speed,IO_BAUD(a1)
lib Exec,DoIO
tst.l d0
bne NoSetSer
SkipSpeed:
;
;Main loop here
;
;1. Reset modem
;2. Setup read
;3. Wait for RING (*)
;4. Answer with ATA (*)
;5. Wait for CONNECT (*)
;6. Delay of 1 SEC
;7. Display Getty-Header
;8. Ask login
;9. Ask for password
;10. Test password with login
;11. Loop if incorrect or null
;12. Execute Login-Start of $username
;(*) only if -d(umb) option is not set
bsr Reader
StartLoop: clr.l d1
bset.l #SIGBREAKB_CTRL_C,d1 ;check for CTRL_C
lib Dos,CheckSignal
btst.l #SIGBREAKB_CTRL_C,d0
bne ShutDown
tst.w Dumb
bne StartLoop1
bsr Reset
StartLoop1: tst.w Dumb
bne Logging
StartLoop2: clr.w BufCount
bsr WaitForRing
tst.l d0
beq ShutDown
bsr Answer
clr.w BufCount
bsr WaitForConnect
tst.l d0
beq ShutDown
cmp.l #1111111,d0
beq StartLoop2
clr.l d0
bsr WaitUntilLF ;clears connect speed + CR
clr.l d0
bsr WaitUntilLF ;should clear LF
;Login part starts here
Logging: lea.l LoginSeconds,a0
lea.l MicrosTemp,a1
lib Intuition,CurrentTime
clr.w LogFailCount
tst.w Dumb
bne Logging0.11111
bsr Delay11SECS
Logging0.11111: bsr Welcome
Logging1: bsr AskLogin
tst.l d0
beq ShutDown
tst.b Buffer3
beq Logging1
bsr AskPassword
tst.l d0
beq ShutDown
lea.l PassWdFileN,a0
move.l a0,d1
move.l #MODE_OLDFILE,d2
lib Dos,Open
move.l d0,PassWdFile
bne Logging1.1
lea.l PassWdFileN,a3
bsr FileError1
bra Logging2.9
Logging1.1: bsr ReadUser
tst.l d0
bne Logging2.9
lea.l TempBuf1,a0
lea.l UserName,a1
bsr CmpStrings
tst.l d0
beq Logging1.1
Logging2: lea.l PassWord,a0
lea.l Buffer4,a1
bsr Decrypt
lea.l Buffer4,a0
lea.l Buffer3,a1
bsr CmpStrings
tst.l d0
bne LoggedOn
Logging2.9: add.w #1,LogFailCount
bsr IncorrectLogin
cmp.w #5,LogFailCount
beq LoginFailure
bra Logging1
LoggedOn: move.l PassWdFile,d1
beq LoggedOn1
lib Dos,Close
clr.l PassWdFile
LoggedOn1: lea.l LoginSeconds,a0
lea.l MicrosTemp,a1
lib Intuition,CurrentTime
lea.l CRLFText1,a0
bsr GetLength
bsr Writer
;Do log stuff
cmp.w #2,LogLevel
beq LoggedOn2
cmp.w #3,LogLevel
bne LoggedOn3
LoggedOn2: lea.l CorrectText1,a0
bsr GetLength
bsr Writer2
lea.l TempBuf1,a0
bsr GetLength
bsr Writer2
lea.l LogFailIncText1,a0
bsr GetLength
bsr Writer2
bsr PutDate
lea.l CRLFText1,a0
bsr GetLength
bsr Writer2
LoggedOn3: bsr OpenNIL
tst.l NILFile
beq ShutDown
bsr ClearSer
bsr MakeCmdString
lea.l CmdString1,a0
move.l a0,d1
clr.l d2
move.l NILFile,d3
lib Dos,Execute
bsr CloseNIL
LogOut: lea.l CRLFText1,a0
bsr GetLength
bsr Writer
bsr OnTime
tst.w Dumb
bne LogOut1
bsr HangUp
LogOut1: cmp.w #5,LogFailCount ;don't wait for character
beq LogOut2
bsr CheckEvent
tst.l d0
beq ShutDown
bsr Reader
LogOut2: bra StartLoop
OnTime: lea.l LogoutSeconds,a0
lea.l MicrosTemp,a1
lib Intuition,CurrentTime
move.l LoginSeconds,d0
move.l LogoutSeconds,d1
sub.l d0,d1
divu.w #60,d1 ;Minutes
clr.l d0
move.w d1,d0 ;test moving it straight to mins...
move.w d0,OnTimeMins
lea.l fstrl,a0 ;HEX->ASCII
lea.l OnTimeMins,a1 ;Number2Print
lea.l PutChProc,a2
lea.l OnTimeText2,a3 ;Destination
lib Exec,RawDoFmt
lea.l OnTimeText1,a0
bsr GetLength
bsr Writer
cmp.w #2,LogLevel
beq OnTime2
cmp.w #3,LogLevel
bne OnTime3
OnTime2: lea.l LogOutText1,a0
bsr GetLength
bsr Writer2
bsr PutDate
lea.l CRLFText2,a0
bsr GetLength
bsr Writer2
lea.l OnTimeText1,a0
bsr GetLength
bsr Writer2
OnTime3: lea.l ConnectionText1,a0
bsr GetLength
bsr Writer
rts
;Waits for RING
;
;INPUT
;
;OUTPUT
;
;D0 = -1 if OK
;D0 = 0 if Break
;
;ACTION
;
;1. Wait for input, serial or CTRL_C
;2. If CTRL_C then break
;3. If serial test for ring
;4. If D0 = -1 then RING -> OUT
;5. If not then loop
WaitForRing: bsr CheckEvent
tst.l d0
beq WaitForRing_OUT
bsr TestRing
tst.l d0
beq WaitForRing ;No RING so get more chars
WaitForRing_OUT: rts
TestRing: tst.w BufCount
bne TestRing2
cmp.b #'R',Buffer1
bne TestRing4
TestRing2: lea.l Buffer2,a0
add.w BufCount,a0
move.b Buffer1,(a0)
add.w #1,BufCount
cmp.w #4,BufCount
bne TestRing4
clr.w BufCount
cmp.l #'RING',Buffer2
bne TestRing4
TestRing3: bsr ClearSer
bsr Reader
move.l #-1,d0 ;indicate ring
rts
TestRing4: bsr ClearSer ;Abort possible prev. read
bsr Reader ;Set up new read
clr.l d0
rt