home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / Logger / L.S < prev    next >
Text File  |  1993-12-21  |  30KB  |  1,658 lines

  1. *************************************************
  2. *                        *
  3. *           (C)opyright 1992-93        *
  4. *                        *
  5. *        by Tomi Blinnikka        *
  6. *                        *
  7. *    Don´t try to understand the code    *
  8. *                        *
  9. * Version 0.01    ??/??/1992            *
  10. *     -0.99ö                    *
  11. *                        *
  12. * BUGS:                        *
  13. *                        *
  14. * Version 1.00    01/08/1992            *
  15. *                        *
  16. * BUGS:    Logging problems, grr...        *
  17. *                        *
  18. * Version 1.01    08/08/1992            *
  19. *                        *
  20. * BUGS:                        *
  21. *                        *
  22. * Version 1.02    09/08/1992            *
  23. *                        *
  24. * Added speeds.                    *
  25. *                        *
  26. * Version 1.03    14/08/1992            *
  27. *                        *
  28. * Added log!                    *
  29. *                        *
  30. * BUGS:    Didn't give correct device in arguments    *
  31. *                        *
  32. * Version 1.04    15/08/1992            *
  33. *                        *
  34. * Version 1.05    22/08/1992            *
  35. *                        *
  36. * Changed log to be opened/closed before/after    *
  37. * writes.                    *
  38. *                        *
  39. * Version 1.06    03/10/1992            *
  40. *                        *
  41. * Added local option.                *
  42. *                        *
  43. * BUGS: Had a bug in the parser, unaligned    *
  44. * reads AGAIN.                    *
  45. *                        *
  46. * Version 1.07    05/12/1992            *
  47. *                        *
  48. * Fixed bug with options given to program to    *
  49. * execute. Serial unit was incorrect.        *
  50. *                        *
  51. * BUGS: Parser?                    *
  52. *                        *
  53. * Version 1.08    24/12/1992            *
  54. *                        *
  55. * Parser not intuitive but should work.        *
  56. * Device is now closed before the command is    *
  57. * run. Modified for A2232 Mount and AUXs.    *
  58. *                        *
  59. * BUGS: Had a 'bra' instead of a 'bsr' in the    *
  60. *    error output routines.            *
  61. *                        *
  62. *    Unalignment bug in MakeCmdString.    *
  63. *                        *
  64. *    A bug in OpenSer caused a 'beq' out    *
  65. *    of the whole subroutine.        *
  66. *                        *
  67. *    Parser won't accept any device starting    *
  68. *    with a letter of one of the commands.    *
  69. *                        *
  70. * Version 1.09    28/12/1992            *
  71. *                        *
  72. * Changed directory names to Logger-standard.    *
  73. *                        *
  74. * BUGS: Try 'Logger' and press CTRL-C...    *
  75. *                        *
  76. * Version 1.10    29/12/1992            *
  77. *                        *
  78. * Changed parser to Commodore standard.        *
  79. *                        *
  80. * Removed utility.library stuff.        *
  81. *                        *
  82. * BUGS:                        *
  83. *                        *
  84. * Version 1.11    1/1/1993            *
  85. *                        *
  86. * Fixed bug in CmpStrings            *
  87. *                        *
  88. *************************************************
  89.  
  90.     INCLUDE    "JMPLibs.i"
  91.     INCLUDE    "exec/types.i"
  92.     INCLUDE    "exec/nodes.i"
  93.     INCLUDE    "exec/lists.i"
  94.     INCLUDE    "exec/ports.i"
  95.     INCLUDE    "exec/memory.i"
  96.     INCLUDE    "exec/devices.i"
  97.     INCLUDE    "exec/io.i"
  98.     INCLUDE    "exec/tasks.i"
  99.     INCLUDE    "libraries/dosextens.i"
  100.     INCLUDE    "libraries/dos.i"
  101.     INCLUDE    "devices/serial.i"
  102.     INCLUDE    "dos/dostags.i"
  103.     INCLUDE    "dos/datetime.i"
  104.  
  105.     INCLUDE    "XREF:2.0.xref"
  106.     INCLUDE    "XREF:exec.xref"
  107.     INCLUDE    "XREF:dos.xref"
  108.  
  109.     XREF    _LVOCurrentTime
  110.     XREF    _LVOSystemTagList
  111.  
  112. TRUE:        EQU    1
  113. FALSE:        EQU    0
  114.  
  115. LF:        EQU    10
  116. CR:        EQU    13
  117.  
  118.         section    Logger,CODE
  119.  
  120.         push    d2-d7/a2-a6
  121.  
  122.         sub.l    a1,a1            ;Find our task
  123.         lib    Exec,FindTask
  124.         move.l    d0,OurTask
  125.  
  126.         openlib    Dos,NoDos        ;Keep at beginning
  127.  
  128. CLIStart:    lib    Dos,Output
  129.         move.l    d0,_stdout
  130.  
  131.         flib    Dos,Input
  132.         move.l    d0,_stdin
  133.  
  134.         lea.l    CLTemplate1,a0
  135.         move.l    a0,d1
  136.         lea.l    CLArray1,a0
  137.         move.l    a0,d2
  138.         clr.l    d3
  139.         lib    Dos,ReadArgs
  140.         move.l    d0,RDArgs1
  141.         beq    NoRDArgs
  142.  
  143.         tst.l    LLPointer
  144.         beq    DoParsing1
  145.         move.l    LLPointer,a0
  146.         move.l    (a0),LogLevel
  147. DoParsing1:    tst.l    UnitPointer
  148.         beq    DoParsing2
  149.         move.l    UnitPointer,a0
  150.         move.l    (a0),SerUnit
  151. DoParsing2:    tst.l    SpeedPointer
  152.         beq    DoParsing3
  153.         move.l    SpeedPointer,a0
  154.         move.l    (a0),Speed
  155. DoParsing3:    tst.l    Local
  156.         beq    DoParsing4
  157.         move.l    #1,Dumb
  158.         lea.l    SerName3,a0
  159.         move.l    a0,SerName
  160.         move.b    #'c',ASCIIUnit
  161.         clr.b    ASCIIUnit+1
  162. DoParsing4:
  163.  
  164. MainStart:    openlib    Intuition,NoInt
  165.  
  166. ;Skip opening device stuff if local mode requested
  167.  
  168.         tst.l    Local
  169.         bne    Logging
  170.  
  171.         bsr    OpenSer
  172.         tst.l    d0
  173.         beq    ShutDown
  174.  
  175.         bsr    Reader
  176.  
  177. ;
  178. ;Main loop here
  179. ;
  180. ;0.  Setup device stuff (*2)
  181. ;1.  Reset modem (*) (*2)
  182. ;2.  Setup read (*) (*2)
  183. ;3.  Wait for RING (*) (*2)
  184. ;4.  Answer with ATA (*) (*2)
  185. ;5.  Wait for CONNECT (*) (*2)
  186. ;6.  Delay of 1 SEC
  187. ;7.  Display Getty-Header
  188. ;8.  Ask login
  189. ;9.  Ask for password
  190. ;10. Test password with login
  191. ;11. Loop if incorrect or null
  192. ;12. Execute Login-Start of $username
  193.  
  194. ;(*) only if -d(umb) option is not set
  195. ;(*2) only if -l(ocal) option is not set
  196.  
  197. StartLoop:    tst.l    Local
  198.         bne    Logging
  199.  
  200.         clr.l    d1
  201.         bset.l    #SIGBREAKB_CTRL_C,d1    ;check for CTRL_C
  202.         lib    Dos,CheckSignal
  203.         btst.l    #SIGBREAKB_CTRL_C,d0
  204.         beq    StartLoop0.1        ;DEBUG
  205.         bsr    Break
  206.         bra    ShutDown
  207.  
  208. StartLoop0.1:    tst.l    Dumb
  209.         bne    Logging
  210.  
  211. StartLoop1:    bsr    Reset
  212.  
  213. StartLoop2:    clr.w    BufCount
  214.         bsr    WaitForRing
  215.         tst.l    d0
  216.         beq    ShutDown
  217.  
  218.         bsr    Answer
  219.         clr.w    BufCount
  220.         bsr    WaitForConnect
  221.         tst.l    d0
  222.         beq    ShutDown
  223.         cmp.l    #1111111,d0
  224.         beq    StartLoop2
  225.  
  226.         clr.l    d0
  227.         bsr    WaitUntilLF    ;clears connect speed + CR
  228.         clr.l    d0
  229.         bsr    WaitUntilLF    ;should clear LF
  230.  
  231. ;Login part starts here
  232.  
  233. Logging:    lea.l    LoginSeconds,a0
  234.         lea.l    MicrosTemp,a1
  235.         lib    Intuition,CurrentTime
  236.  
  237.         clr.w    LogFailCount
  238.         tst.l    Dumb
  239.         bne    Logging0.11111
  240.         bsr    Delay11SECS
  241.  
  242. Logging0.11111:    bsr    Welcome
  243. Logging1:    bsr    AskLogin
  244.         tst.l    d0
  245.         beq    ShutDown
  246.         tst.b    Buffer3
  247.         beq    Logging1
  248.         bsr    AskPassword
  249.         tst.l    d0
  250.         beq    ShutDown
  251.  
  252.         lea.l    PassWdFileN,a0
  253.         move.l    a0,d1
  254.         move.l    #MODE_OLDFILE,d2
  255.         lib    Dos,Open
  256.         move.l    d0,PassWdFile
  257.         bne    Logging1.1
  258.  
  259.         lea.l    PassWdFileN,a3
  260.         bsr    FileError1
  261.         bra    Logging2.9
  262.  
  263. Logging1.1:    bsr    ReadUser
  264.         tst.l    d0
  265.         bne    Logging2.9
  266.         lea.l    TempBuf1,a0
  267.         lea.l    UserName,a1
  268.         bsr    CmpStrings
  269.         tst.l    d0
  270.         beq    Logging1.1
  271.  
  272. Logging2:    lea.l    PassWord,a0
  273.         lea.l    Buffer4,a1
  274.         bsr    Decrypt
  275.         lea.l    Buffer4,a0
  276.         lea.l    Buffer3,a1
  277.         bsr    CmpStrings
  278.         tst.l    d0
  279.         bne    LoggedOn
  280. Logging2.9:    add.w    #1,LogFailCount
  281.         bsr    IncorrectLogin
  282.         cmp.w    #5,LogFailCount
  283.         beq    LoginFailure
  284.         bra    Logging1
  285.  
  286. LoggedOn:    move.l    PassWdFile,d1
  287.         beq    LoggedOn1
  288.         lib    Dos,Close
  289.         clr.l    PassWdFile
  290.  
  291. LoggedOn1:    lea.l    LoginSeconds,a0
  292.         lea.l    MicrosTemp,a1
  293.         lib    Intuition,CurrentTime
  294.  
  295.         lea.l    CRLFText1,a0
  296.         bsr    GetLength
  297.         bsr    Writer
  298.  
  299. ;Do log stuff
  300.  
  301.         cmp.l    #2,LogLevel
  302.         beq    LoggedOn2
  303.         cmp.l    #3,LogLevel
  304.         bne    LoggedOn3
  305. LoggedOn2:    lea.l    CorrectText1,a0
  306.         bsr    GetLength
  307.         bsr    Writer2
  308.         lea.l    TempBuf1,a0
  309.         bsr    GetLength
  310.         bsr    Writer2
  311.         lea.l    LogFailIncText1,a0
  312.         bsr    GetLength
  313.         bsr    Writer2
  314.         bsr    PutDate
  315.         lea.l    CRLFText1,a0
  316.         bsr    GetLength
  317.         bsr    Writer2
  318.  
  319. LoggedOn3:    bsr    OpenNIL
  320.         tst.l    NILFile
  321.         beq    ShutDown
  322.  
  323.         bsr    ClearSer
  324.  
  325.         bsr    MakeCmdString
  326.  
  327.  
  328.         bsr    CloseSer
  329.  
  330.         lea.l    CmdString1,a0
  331.         move.l    a0,d1
  332.         tst.l    Local
  333.         beq    LoggedOn4
  334.         move.l    _stdin,d2
  335.         move.l    _stdout,d3
  336.         bra    LoggedOn5
  337. LoggedOn4:    clr.l    d2
  338.         move.l    NILFile,d3
  339. LoggedOn5:    lib    Dos,Execute
  340.  
  341.  
  342.         tst.l    Local
  343.         bne    LoggedOn6
  344.  
  345. ;        move.l    #4*50,d1    ;DEBUG
  346. ;        lib    Dos,Delay    ;DEBUG
  347.  
  348.         bsr    OpenSer
  349.         tst.l    d0
  350.         beq    ShutDown
  351.  
  352.         bsr    Reader
  353.  
  354. LoggedOn6:    bsr    CloseNIL
  355.  
  356. LogOut:        lea.l    CRLFText1,a0
  357.         bsr    GetLength
  358.         bsr    Writer
  359.         bsr    OnTime
  360.  
  361.         tst.l    Dumb
  362.         bne    LogOut1
  363.         bsr    HangUp
  364. LogOut1:    cmp.w    #5,LogFailCount        ;don't wait for character
  365.         beq    LogOut2
  366.         bsr    CheckEvent
  367.         tst.l    d0
  368.         bne    LogOut1.1
  369.         bsr    EndCLI
  370.         bra    ShutDown
  371. LogOut1.1:    bsr    Reader
  372. LogOut2:    bra    StartLoop
  373.  
  374. EndCLI:        tst.l    Local
  375.         beq    EndCLI2
  376.         lea.l    CmdString2,a0
  377.         move.l    a0,d1
  378.         clr.l    d2
  379.         clr.l    d3
  380.         lib    Dos,Execute
  381. EndCLI2:    rts
  382.  
  383. OnTime:        lea.l    LogoutSeconds,a0
  384.         lea.l    MicrosTemp,a1
  385.         lib    Intuition,CurrentTime
  386.  
  387.         move.l    LoginSeconds,d0
  388.         move.l    LogoutSeconds,d1
  389.         sub.l    d0,d1
  390.         divu.w    #60,d1            ;Minutes
  391.         clr.l    d0
  392.         move.w    d1,d0            ;test moving it straight to mins...
  393.         move.w    d0,OnTimeMins
  394.  
  395.         lea.l    fstrl,a0        ;HEX->ASCII
  396.         lea.l    OnTimeMins,a1        ;Number2Print
  397.         lea.l    PutChProc,a2
  398.         lea.l    OnTimeText2,a3        ;Destination
  399.         lib    Exec,RawDoFmt
  400.  
  401.         lea.l    OnTimeText1,a0
  402.         bsr    GetLength
  403.         bsr    Writer
  404.  
  405.         cmp.l    #2,LogLevel
  406.         beq    OnTime2
  407.         cmp.l    #3,LogLevel
  408.         bne    OnTime3
  409. OnTime2:    lea.l    LogOutText1,a0
  410.         bsr    GetLength
  411.         bsr    Writer2
  412.         bsr    PutDate
  413.         lea.l    CRLFText2,a0
  414.         bsr    GetLength
  415.         bsr    Writer2
  416.         lea.l    OnTimeText1,a0
  417.         bsr    GetLength
  418.         bsr    Writer2
  419.  
  420. OnTime3:    lea.l    ConnectionText1,a0
  421.         bsr    GetLength
  422.         bsr    Writer
  423.         rts
  424.  
  425. ;Waits for RING
  426. ;
  427. ;INPUT
  428. ;
  429. ;OUTPUT
  430. ;
  431. ;D0 = -1 if OK
  432. ;D0 =  0 if Break
  433. ;
  434. ;ACTION
  435. ;
  436. ;1. Wait for input, serial or CTRL_C
  437. ;2. If CTRL_C then break
  438. ;3. If serial test for ring
  439. ;4. If D0 = -1 then RING -> OUT
  440. ;5. If not then loop
  441.  
  442. WaitForRing:    bsr    CheckEvent
  443.         tst.l    d0
  444.         beq    WaitForRing_OUT
  445.  
  446.         bsr    TestRing
  447.         tst.l    d0
  448.         beq    WaitForRing        ;No RING so get more chars
  449. WaitForRing_OUT: rts
  450.  
  451. TestRing:    tst.w    BufCount
  452.         bne    TestRing2
  453.         cmp.b    #'R',Buffer1
  454.         bne    TestRing4
  455. TestRing2:    lea.l    Buffer2,a0
  456.         add.w    BufCount,a0
  457.         move.b    Buffer1,(a0)
  458.         add.w    #1,BufCount
  459.         cmp.w    #4,BufCount
  460.