home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
tbsource.lha
/
TBSource
/
Logger
/
L.S
< prev
next >
Wrap
Text File
|
1993-12-21
|
30KB
|
1,658 lines
*************************************************
* *
* (C)opyright 1992-93 *
* *
* 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. *
* *
* Version 1.06 03/10/1992 *
* *
* Added local option. *
* *
* BUGS: Had a bug in the parser, unaligned *
* reads AGAIN. *
* *
* Version 1.07 05/12/1992 *
* *
* Fixed bug with options given to program to *
* execute. Serial unit was incorrect. *
* *
* BUGS: Parser? *
* *
* Version 1.08 24/12/1992 *
* *
* Parser not intuitive but should work. *
* Device is now closed before the command is *
* run. Modified for A2232 Mount and AUXs. *
* *
* BUGS: Had a 'bra' instead of a 'bsr' in the *
* error output routines. *
* *
* Unalignment bug in MakeCmdString. *
* *
* A bug in OpenSer caused a 'beq' out *
* of the whole subroutine. *
* *
* Parser won't accept any device starting *
* with a letter of one of the commands. *
* *
* Version 1.09 28/12/1992 *
* *
* Changed directory names to Logger-standard. *
* *
* BUGS: Try 'Logger' and press CTRL-C... *
* *
* Version 1.10 29/12/1992 *
* *
* Changed parser to Commodore standard. *
* *
* Removed utility.library stuff. *
* *
* BUGS: *
* *
* Version 1.11 1/1/1993 *
* *
* Fixed bug in CmpStrings *
* *
*************************************************
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
FALSE: EQU 0
LF: EQU 10
CR: EQU 13
section Logger,CODE
push d2-d7/a2-a6
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
flib Dos,Input
move.l d0,_stdin
lea.l CLTemplate1,a0
move.l a0,d1
lea.l CLArray1,a0
move.l a0,d2
clr.l d3
lib Dos,ReadArgs
move.l d0,RDArgs1
beq NoRDArgs
tst.l LLPointer
beq DoParsing1
move.l LLPointer,a0
move.l (a0),LogLevel
DoParsing1: tst.l UnitPointer
beq DoParsing2
move.l UnitPointer,a0
move.l (a0),SerUnit
DoParsing2: tst.l SpeedPointer
beq DoParsing3
move.l SpeedPointer,a0
move.l (a0),Speed
DoParsing3: tst.l Local
beq DoParsing4
move.l #1,Dumb
lea.l SerName3,a0
move.l a0,SerName
move.b #'c',ASCIIUnit
clr.b ASCIIUnit+1
DoParsing4:
MainStart: openlib Intuition,NoInt
;Skip opening device stuff if local mode requested
tst.l Local
bne Logging
bsr OpenSer
tst.l d0
beq ShutDown
bsr Reader
;
;Main loop here
;
;0. Setup device stuff (*2)
;1. Reset modem (*) (*2)
;2. Setup read (*) (*2)
;3. Wait for RING (*) (*2)
;4. Answer with ATA (*) (*2)
;5. Wait for CONNECT (*) (*2)
;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
;(*2) only if -l(ocal) option is not set
StartLoop: tst.l Local
bne Logging
clr.l d1
bset.l #SIGBREAKB_CTRL_C,d1 ;check for CTRL_C
lib Dos,CheckSignal
btst.l #SIGBREAKB_CTRL_C,d0
beq StartLoop0.1 ;DEBUG
bsr Break
bra ShutDown
StartLoop0.1: tst.l Dumb
bne Logging
StartLoop1: bsr Reset
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.l 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.l #2,LogLevel
beq LoggedOn2
cmp.l #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
bsr CloseSer
lea.l CmdString1,a0
move.l a0,d1
tst.l Local
beq LoggedOn4
move.l _stdin,d2
move.l _stdout,d3
bra LoggedOn5
LoggedOn4: clr.l d2
move.l NILFile,d3
LoggedOn5: lib Dos,Execute
tst.l Local
bne LoggedOn6
; move.l #4*50,d1 ;DEBUG
; lib Dos,Delay ;DEBUG
bsr OpenSer
tst.l d0
beq ShutDown
bsr Reader
LoggedOn6: bsr CloseNIL
LogOut: lea.l CRLFText1,a0
bsr GetLength
bsr Writer
bsr OnTime
tst.l Dumb
bne LogOut1
bsr HangUp
LogOut1: cmp.w #5,LogFailCount ;don't wait for character
beq LogOut2
bsr CheckEvent
tst.l d0
bne LogOut1.1
bsr EndCLI
bra ShutDown
LogOut1.1: bsr Reader
LogOut2: bra StartLoop
EndCLI: tst.l Local
beq EndCLI2
lea.l CmdString2,a0
move.l a0,d1
clr.l d2
clr.l d3
lib Dos,Execute
EndCLI2: rts
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.l #2,LogLevel
beq OnTime2
cmp.l #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