home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / new / dev / asm / tbsource / logger / l.s < prev    next >
Encoding:
Text File  |  1993-12-21  |  28.9 KB  |  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.         bne    TestRing4
  461.         clr.w    BufCount
  462.         cmp.l    #'RING',Buffer2
  463.         bne    TestRing4
  464. TestRing3:    bsr    ClearSer
  465.         bsr    Reader
  466.         move.l    #-1,d0            ;indicate ring
  467.         rts
  468. TestRing4:    bsr    ClearSer        ;Abort possible prev. read
  469.         bsr    Reader            ;Set up new read
  470.         clr.l    d0
  471.         rts
  472.  
  473. ;Waits for CONNECT
  474. ;
  475. ;INPUT
  476. ;
  477. ;OUTPUT
  478. ;
  479. ;D0 = -1 if OK
  480. ;D0 =  0 if Break
  481. ;
  482. ;ACTION
  483. ;
  484. ;1. Wait for input, serial or CTRL_C
  485. ;2. If CTRL_C then break
  486. ;3. If serial test for connect
  487. ;4. If D0 = -1 then CONNECT -> OUT
  488. ;5. If not then loop
  489.  
  490. WaitForConnect:    bsr    CheckEvent
  491.         tst.l    d0
  492.         beq    WaitForConnect_OUT
  493.  
  494.         bsr    TestConnect
  495.         tst.l    d0
  496.         beq    WaitForConnect        ;No CONNECT so get more chars
  497. WaitForConnect_OUT: rts
  498.  
  499. TestConnect:    tst.w    BufCount
  500.         bne    TestConnect2
  501.         cmp.b    #'C',Buffer1
  502.         bne    TestConnect4
  503. TestConnect2:    lea.l    Buffer2,a0
  504.         add.w    BufCount,a0
  505.         move.b    Buffer1,(a0)
  506.         add.w    #1,BufCount
  507.         cmp.w    #7,BufCount
  508.         bne    TestConnect4
  509.         clr.w    BufCount
  510.         cmp.l    #'CONN',Buffer2
  511.         bne    TestConnect5
  512.         cmp.w    #'EC',Buffer2+4
  513.         bne    TestConnect5
  514.         cmp.b    #'T',Buffer2+6
  515.         bne    TestConnect5
  516. TestConnect3:    bsr    ClearSer
  517.         bsr    Reader
  518.         move.l    #-1,d0            ;indicate CONNECT
  519.         rts
  520. TestConnect4:    bsr    ClearSer        ;Abort possible prev. read
  521.         bsr    Reader            ;Set up new read
  522.         clr.l    d0
  523.         rts
  524. TestConnect5:    bsr    ClearSer        ;Abort possible prev. read
  525.         bsr    Reader            ;Set up new read
  526.         move.l    #1111111,d0
  527.         rts
  528.  
  529. Reset:        lea.l    ResetString,a0
  530.         bsr    GetLength
  531.         bsr    Writer
  532.         rts
  533.  
  534. Answer:        lea.l    AnswerString,a0
  535.         bsr    GetLength
  536.         bsr    Writer
  537.         rts
  538.  
  539. Welcome:    lea.l    WelcomeFileN,a0
  540.         move.l    a0,d1
  541.         move.l    #MODE_OLDFILE,d2
  542.         lib    Dos,Open
  543.         move.l    d0,WelcomeFile
  544.         beq    Welcome_ERR1
  545.  
  546.         move.l    d0,d1
  547.         bsr    GetFileLength
  548.         tst.l    d0
  549.         beq    Welcome2
  550.  
  551.         move.l    d0,WelcomeLength
  552.         move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1    ;Type of memory wanted
  553.         lib    Exec,AllocMem
  554.         move.l    d0,WelcomeMem
  555.         beq    Welcome_ERR2
  556.  
  557.         move.l    WelcomeFile,d1
  558.         move.l    WelcomeMem,d2
  559.         move.l    WelcomeLength,d3
  560.         lib    Dos,Read
  561.         cmp.l    WelcomeLength,d0
  562.         bne    Welcome_ERR3
  563.  
  564.         clr.l    d4
  565.         move.l    WelcomeMem,a3
  566. Welcome1:    move.l    a3,a0
  567.         bsr    GetLLength
  568.         add.l    d0,d4
  569.         add.l    d0,a3
  570.         sub.l    #1,d0
  571.         bsr    Writer
  572.         lea.l    CRLFText1,a0
  573.         bsr    GetLength
  574.         bsr    Writer
  575.  
  576.         cmp.l    WelcomeLength,d4
  577.         bcs    Welcome1
  578.  
  579. Welcome2:    move.l    WelcomeFile,d1
  580.         lib    Dos,Close
  581.         clr.l    WelcomeFile
  582.  
  583.         tst.l    WelcomeMem
  584.         beq    Welcome_OUT
  585.         move.l    WelcomeMem,a1
  586.         move.l    WelcomeLength,d0
  587.         lib    Exec,FreeMem
  588.         clr.l    WelcomeMem
  589.         clr.l    WelcomeLength
  590.  
  591. Welcome_OUT:    rts
  592.  
  593. Welcome_ERR1:    lea.l    WelcomeFileN,a3
  594.         bsr    FileError1
  595.         bra    Welcome_OUT
  596.  
  597. Welcome_ERR2:    bsr    WarnLowMem
  598.         bra    Welcome2
  599.  
  600. Welcome_ERR3:    lea.l    WelcomeFileN,a3
  601.         bsr    FileError2
  602.         bra    Welcome_OUT
  603.  
  604. AskLogin:    lea.l    LoginText1,a0
  605.         bsr    GetLength
  606.         bsr    Writer
  607.  
  608.         clr.w    BufCount
  609.         move.l    #1,d0
  610.         bsr    WaitUntilLF
  611.         tst.l    d0
  612.         beq    AskLogin_OUT
  613.  
  614.         lea.l    Buffer3,a0
  615.         lea.l    TempBuf1,a1
  616.         move.l    #32,d0
  617.         lib    Exec,CopyMem
  618.         move.l    #-1,d0
  619.         rts
  620. AskLogin_OUT:    clr.l    d0
  621.         rts
  622.  
  623. AskPassword:    lea.l    PasswordText1,a0
  624.         bsr    GetLength
  625.         bsr    Writer
  626.         clr.w    BufCount
  627.         clr.l    d0
  628.         bsr    WaitUntilLF
  629.         rts
  630.  
  631. IncorrectLogin:    lea.l    IncorrectText1,a0
  632.         bsr    GetLength
  633.         bsr    Writer
  634.         cmp.l    #1,LogLevel
  635.         beq    IncorrectLogin1
  636.         cmp.l    #3,LogLevel
  637.         bne    IncorrectLogin_OUT
  638. IncorrectLogin1: lea.l    IncorrectText2,a0
  639.         bsr    GetLength
  640.         bsr    Writer2
  641.         lea.l    TempBuf1,a0
  642.         bsr    GetLength
  643.         bsr    Writer2
  644.         lea.l    LogFailIncText2,a0
  645.         bsr    GetLength
  646.         bsr    Writer2
  647.         lea.l    Buffer3,a0
  648.         bsr    GetLength
  649.         bsr    Writer2
  650.         lea.l    LogFailIncText1,a0
  651.         bsr    GetLength
  652.         bsr    Writer2
  653.         bsr    PutDate
  654.         lea.l    CRLFText1,a0
  655.         bsr    GetLength
  656.         bsr    Writer2
  657.  
  658. IncorrectLogin_OUT: rts
  659.  
  660. LoginFailure:    lea.l    LogFailureText1,a0
  661.         bsr    GetLength
  662.         bsr    Writer
  663.         cmp.l    #1,LogLevel
  664.         beq    LoginFailure1
  665.         cmp.l    #3,LogLevel
  666.         bne    LoginFailure_OUT
  667. LoginFailure1:    lea.l    LogFailureText2,a0
  668.         bsr    GetLength
  669.         bsr    Writer2
  670.         lea.l    CRLFText1,a0
  671.         bsr    GetLength
  672.         bsr    Writer2
  673. LoginFailure_OUT: bra    LogOut
  674.  
  675. Echo:        lea.l    Buffer1,a0
  676.         move.l    #1,d0
  677.         bsr    Writer
  678.         rts
  679.  
  680. HangUp:        bsr    Delay3SECS
  681.         lea.l    HangUpString1,a0
  682.         bsr    GetLength
  683.         bsr    Writer
  684.         bsr    Delay3SECS
  685.         lea.l    HangUpString2,a0
  686.         bsr    GetLength
  687.         bsr    Writer
  688.         bsr    Delay1SEC
  689.         rts
  690.  
  691. Delay1SEC:    move.l    #51,d1
  692.         lib    Dos,Delay
  693.         rts
  694. Delay3SECS:    move.l    #3*51,d1
  695.         lib    Dos,Delay
  696.         rts
  697. Delay11SECS:    move.l    #11*51,d1
  698.         lib    Dos,Delay
  699.         rts
  700.  
  701. Break:        lea.l    BreakText1,a0
  702.         bsr    Printer
  703.         clr.l    d0
  704.         rts            ;careful!
  705.  
  706. OpenNIL:    tst.l    NILFile
  707.         bne    OpenNIL_OUT
  708.         lea.l    NILName,a0
  709.         move.l    a0,d1
  710.         move.l    #MODE_NEWFILE,d2
  711.         lib    Dos,Open
  712.         move.l    d0,NILFile
  713. OpenNIL_OUT:    rts
  714.  
  715. CloseNIL:    move.l    NILFile,d1
  716.         beq    CloseNIL1
  717.         lib    Dos,Close
  718.         clr.l    NILFile
  719. CloseNIL1:    rts
  720.  
  721. MakeCmdString:    tst.l    Local
  722.         bne    MakeCmdString2
  723.         lea.l    fstrl2,a0        ;HEX->ASCII
  724.         lea.l    SerUnit,a1        ;Number2Print
  725.         lea.l    PutChProc,a2
  726.         lea.l    ASCIIUnit,a3        ;Destination
  727.         lib    Exec,RawDoFmt
  728.  
  729. MakeCmdString2:    lea.l    CmdString1,a0
  730.         lea.l    UserCommand,a4
  731.         move.l    a4,a5
  732.         add.l    #64,a5
  733.         bsr    MCS1
  734.  
  735.         move.b    #' ',(a0)+
  736.  
  737.         lea.l    UserName,a4
  738.         move.l    a4,a5
  739.         add.l    #10,a5
  740.         bsr    MCS1
  741.  
  742.         move.b    #' ',(a0)+
  743.         move.b    #'"',(a0)+
  744.  
  745.         lea.l    RealName,a4
  746.         move.l    a4,a5
  747.         add.l    #64,a5
  748.         bsr    MCS1
  749.  
  750.         move.b    #'"',(a0)+
  751.         move.b    #' ',(a0)+
  752.         move.b    #'"',(a0)+
  753.  
  754.         lea.l    UserHome,a4
  755.         move.l    a4,a5
  756.         add.l    #64,a5
  757.         bsr    MCS1
  758.  
  759.         move.b    #'"',(a0)+
  760.         move.b    #' ',(a0)+
  761.         move.b    #'"',(a0)+
  762.  
  763.         lea.l    Office,a4
  764.         move.l    a4,a5
  765.         add.l    #64,a5
  766.         bsr    MCS1
  767.  
  768.         move.b    #'"',(a0)+
  769.         move.b    #' ',(a0)+
  770.  
  771.         move.l    SerName,a4
  772.         move.l    a4,a5
  773.         add.l    #20,a5
  774.         bsr    MCS1
  775.  
  776.         move.b    #' ',(a0)+
  777.  
  778. ;;;;;        move.l    ASCIIUnit,(a0)+        ;BUGGY, DO NOT USE!!!
  779. ;;;;;        move.w    ASCIIUnit+4,(a0)+    ;See new below.
  780.  
  781.         move.b    ASCIIUnit,(a0)+        ;Keep last!
  782.         move.b    ASCIIUnit+1,(a0)+
  783.         move.b    ASCIIUnit+2,(a0)+
  784.         move.b    ASCIIUnit+3,(a0)+
  785.  
  786.         move.b    ASCIIUnit+4,(a0)+
  787.         move.b    ASCIIUnit+5,(a0)+
  788.  
  789.         clr.b    (a0)+
  790.  
  791. ;        lea.l    CmdString1,a0        ;DEBUG
  792. ;        bsr    Printer            ;DEBUG
  793.  
  794.         rts
  795.  
  796. MCS1:        move.b    (a4)+,(a0)+
  797.         tst.b    (a4)
  798.         beq    MCS2
  799.         cmp.l    a4,a5
  800.         bne    MCS1
  801. MCS2:        rts
  802.  
  803. WarnLowMem:    lea.l    LowMemText1,a0
  804.         bsr    GetLength
  805.         bsr    Writer
  806.         rts
  807.  
  808. ;Outputs error message
  809. ;
  810. ;Inputs a3 = Filename
  811.  
  812. FileError1:    lea.l    FileErrorText1,a0
  813.         bsr    GetLength
  814.         bsr    Writer
  815.         move.l    a3,a0
  816.         bsr    GetLength
  817.         bsr    Writer
  818.         lea.l    CRLFText1,a0
  819.         bsr    GetLength
  820.         bsr    Writer
  821.         lea.l    FileErrorText1,a0
  822.         bsr    GetLength
  823.         bsr    Writer2            ;log them
  824.         move.l    a3,a0
  825.         bsr    GetLength
  826.         bsr    Writer2
  827.         lea.l    CRLFText1,a0
  828.         bsr    GetLength
  829.         bsr    Writer2
  830.         rts
  831.  
  832. FileError2:    lea.l    FileErrorText2,a0
  833.         bsr    GetLength
  834.         bsr    Writer
  835.         move.l    a3,a0
  836.         bsr    GetLength
  837.         bsr    Writer
  838.         lea.l    CRLFText1,a0
  839.         bsr    GetLength
  840.         bsr    Writer
  841.         lea.l    FileErrorText2,a0
  842.         bsr    GetLength
  843.         bsr    Writer2
  844.         move.l    a3,a0
  845.         bsr    GetLength
  846.         bsr    Writer2
  847.         lea.l    CRLFText1,a0
  848.         bsr    GetLength
  849.         bsr    Writer2
  850.         rts
  851.  
  852. ;Outputs error message
  853. ;
  854. ;Inputs a3 = Filename
  855.  
  856. FileError3:    lea.l    FileErrorText1,a0
  857.         bsr    Printer
  858.         move.l    a3,a0
  859.         bsr    Printer
  860.         lea.l    CRLFText1,a0
  861.         bsr    Printer
  862.         rts
  863.  
  864. ClearSer:    tst.l    Local
  865.         bne    ClearSer_OUT
  866.         clr.w    Requested
  867.         move.l    IORRequest,a1
  868.         lib    Exec,CheckIO
  869.         tst.l    d0
  870.         beq    ClearSer1
  871.         move.l    IORRequest,a1
  872.         lib    Exec,WaitIO
  873.         rts
  874. ClearSer1:    move.l    IORRequest,a1
  875.         ABORTIO
  876.         move.l    IORRequest,a1
  877.         lib    Exec,WaitIO
  878. ClearSer_OUT:    rts
  879.  
  880. Reader:        tst.l    Local
  881.         bne    Reader_OUT
  882.         move.w    #1,Requested
  883.         move.l    IORRequest,a1
  884.         move.w    #CMD_READ,IO_COMMAND(a1)
  885.         move.l    #1,IO_LENGTH(a1)
  886.         lea.l    Buffer1,a0
  887.         move.l    a0,IO_DATA(a1)
  888.         lib    Exec,SendIO
  889. Reader_OUT:    rts
  890.  
  891. ;Writes string to serial port
  892. ;
  893. ;D0 = Length
  894. ;A0 = String
  895.  
  896. Writer:        tst.l    Local
  897.         bne    LocalWriter
  898.         move.l    IOWRequest,a1
  899.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  900.         move.l    d0,IO_LENGTH(a1)
  901.         move.l    a0,IO_DATA(a1)
  902.         lib    Exec,DoIO        ;May freeze, too bad
  903.         rts
  904.  
  905. ;Writes string to _stdout
  906. ;
  907. ;D0 = Length
  908. ;A0 = String
  909.  
  910. LocalWriter:    move.l    _stdout,d1
  911.         move.l    a0,d2
  912.         move.l    d0,d3
  913.         lib    Dos,Write
  914.         rts
  915.  
  916. ;Tries to write string to logfile
  917. ;
  918. ;D0 = Length
  919. ;A0 = String
  920.  
  921. Writer2:    push    a0/d0
  922.         bsr    OpenLog
  923.         tst.l    d0
  924.         beq    Writer2_OUT2
  925.         pull    a0/d0
  926.         move.l    LogFile,d1
  927.         beq    Writer2_OUT
  928.         move.l    a0,d2
  929.         move.l    d0,d3
  930.         lib    Dos,Write
  931.         bsr    CloseLog
  932. Writer2_OUT:    rts
  933. Writer2_OUT2:    add.l    #8,sp
  934.         rts
  935.  
  936. ;Try to open logfile
  937.  
  938. OpenLog:    lea.l    LogFileN,a0
  939.         move.l    a0,d1
  940.         move.l    #MODE_READWRITE,d2
  941.         lib    Dos,Open
  942.         move.l    d0,LogFile
  943.         bne    OpenLog1
  944.  
  945.         lea.l    LogFileN,a3
  946.         bsr    FileError3
  947.         bra    OpenLog2
  948.  
  949. OpenLog1:    bsr    SeekEnd
  950.         move.l    #-1,d0
  951.         rts
  952. OpenLog2:    clr.l    d0
  953.         rts
  954.  
  955. CloseLog:    move.l    LogFile,d1
  956.         beq    CloseLog1
  957.         lib    Dos,Close
  958.         clr.l    LogFile
  959. CloseLog1:    rts
  960.  
  961. PutDate:    lea.l    DateTime1,a0
  962.         move.l    a0,d1
  963.         lib    Dos,DateStamp
  964.         lea.l    DateTime1,a0
  965.         move.l    a0,d1
  966.         lib    Dos,DateToStr
  967.         tst.l    d0
  968.         beq    PutDate_OUT
  969.         lea.l    StrTime1,a0
  970.         bsr    GetLength
  971.         bsr    Writer2
  972.         lea.l    SpaceText1,a0
  973.         bsr    GetLength
  974.         bsr    Writer2
  975.         lea.l    StrDay1,a0
  976.         bsr    GetLength
  977.         bsr    Writer2
  978.         lea.l    SpaceText1,a0
  979.         bsr    GetLength
  980.         bsr    Writer2
  981.         lea.l    StrDate1,a0
  982.         bsr    GetLength
  983.         bsr    Writer2
  984. PutDate_OUT:    rts
  985.  
  986. PutChProc:    tst.b    d0
  987.         beq    PutChProc_OUT
  988.         move.b    d0,(a3)+
  989. PutChProc_OUT:    rts
  990.  
  991. ShutDown:    bsr    CloseSer
  992.  
  993. ShutDown9000:    ;print    <"debug serial_closed",13,10>        ;DEBUG
  994. ShutDown5000:    move.l    RDArgs1,d1
  995.         beq    ShutDown4600
  996.         lib    Dos,FreeArgs
  997. ShutDown4600:    move.l    WelcomeFile,d1
  998.         beq    ShutDown4500
  999.         lib    Dos,Close
  1000. ShutDown4500:    ;print    <"debug_welcome_file_closed",13,10>    ;DEBUG
  1001.         move.l    PassWdFile,d1
  1002.         beq    ShutDown4400
  1003.         lib    Dos,Close
  1004. ShutDown4400:    ;print    <"debug_NIL_closing",13,10>        ;DEBUG
  1005.         move.l    NILFile,d1
  1006.         beq    ShutDown4300
  1007.         lib    Dos,Close
  1008. ShutDown4300:    ;print    <"debug_log_closing",13,10>        ;DEBUG
  1009.         move.l    LogFile,d1
  1010.         beq    ShutDown4000
  1011.         lib    Dos,Close
  1012.  
  1013. ShutDown4000:    ;print    <"freeing memory",13,10>        ;DEBUG
  1014.         tst.l    WelcomeMem
  1015.         beq    ShutDown3000
  1016.         move.l    WelcomeMem,a1
  1017.         move.l    WelcomeLength,d0
  1018.         lib    Exec,FreeMem
  1019.  
  1020. ShutDown3000:    ;print    <"closing libraries"13,10>        ;DEBUG
  1021. ShutDown1000:    closlib    Intuition
  1022.         ;print    <"About to close dos.library",13,10>    ;DEBUG
  1023.         closlib    Dos
  1024.         pull    d2-d7/a2-a6
  1025.         clr.l    d0
  1026.         rts
  1027.  
  1028. ;open serial.device
  1029.  
  1030. OpenSer:    tst.w    SerOpen
  1031.         bne    OpenSer_OUT
  1032.  
  1033. ;Create read reply port for serial.device (or modem0.device etc.)
  1034. ;ADD: Add port to public list, and remove the port!
  1035.  
  1036.         lib    Exec,CreateMsgPort
  1037.         move.l    d0,SRRPort
  1038.         beq    NoMsgPort
  1039.  
  1040. ;        move.l    SRRPort,a1
  1041. ;        lea.l    RPortText1,a0
  1042. ;        move.l    a0,LN_NAME(a1)
  1043. ;        lib    Exec,AddPort
  1044.  
  1045. ;Create read IOReq for serial.device (or for other device, but size is EXTSER)
  1046.  
  1047.         move.l    #IOEXTSER_SIZE,d0
  1048.         move.l    SRRPort,a0
  1049.         lib    Exec,CreateIORequest
  1050.         move.l    d0,IORRequest
  1051.         beq    NoIOReq
  1052.  
  1053. ;Create write reply port for serial.device (or modem0.device etc.)
  1054. ;ADD: Add port to public list, and remove the port!
  1055.  
  1056.         lib    Exec,CreateMsgPort
  1057.         move.l    d0,SWRPort
  1058.         beq    NoMsgPort
  1059.  
  1060. ;        move.l    SWRPort,a1
  1061. ;        lea.l    WPortText1,a0
  1062. ;        move.l    a0,LN_NAME(a1)
  1063. ;        lib    Exec,AddPort
  1064.  
  1065. ;Create write IOReq for serial.device (or for other device, but size is EXTSER)
  1066.  
  1067.         move.l    #IOEXTSER_SIZE,d0
  1068.         move.l    SWRPort,a0
  1069.         lib    Exec,CreateIORequest
  1070.         move.l    d0,IOWRequest
  1071.         beq    NoIOReq
  1072.  
  1073. ;open the device
  1074.  
  1075.         move.l    SerName,a0
  1076.         move.l    SerUnit,d0
  1077.         move.l    IORRequest,a1
  1078.         move.l    Speed,IO_BAUD(a1)
  1079.         move.b    #SERF_SHARED,IO_SERFLAGS(a1)
  1080.         clr.l    d1                ;no flags
  1081.         lib    Exec,OpenDevice
  1082.         tst.l    d0
  1083.         bne    NoSerial
  1084.         move.w    #$1,SerOpen        ;just to tell if open
  1085.  
  1086. ;Copy info from one req to the other
  1087.  
  1088.         move.l    IORRequest,a0
  1089.         move.l    IOWRequest,a1
  1090.         move.l    IO_DEVICE(a0),IO_DEVICE(a1)
  1091.         move.l    IO_UNIT(a0),IO_UNIT(a1)
  1092.         add.l    #48,a0            ;get start of ioser
  1093.         add.l    #48,a1
  1094.         move.l    #34,d0
  1095.         lib    Exec,CopyMem
  1096.  
  1097. ;set preferences with IOWReq
  1098.  
  1099.         tst.l    Speed
  1100.         beq    OpenSer_OUT
  1101.         move.l    IOWRequest,a1
  1102.         clr.l    IO_LENGTH(a1)
  1103.         clr.l    IO_DATA(a1)
  1104.         move.w    #SDCMD_SETPARAMS,IO_COMMAND(a1)
  1105.         move.l    Speed,IO_BAUD(a1)
  1106.         lib    Exec,DoIO
  1107.         tst.l    d0
  1108.         bne    NoSetSer
  1109.  
  1110. OpenSer_OUT:    move.l    #$DEAF,d0
  1111.         rts
  1112.  
  1113. CloseSer:    tst.w    SerOpen
  1114.         beq    CloseSer_OUT
  1115.         tst.w    Requested
  1116.         beq    CloseSer2
  1117.         bsr    ClearSer
  1118. CloseSer2:    move.l    IORRequest,a1
  1119.         lib    Exec,CloseDevice
  1120.  
  1121.         move.l    IORRequest,a0
  1122.         lib    Exec,DeleteIORequest
  1123.  
  1124.         move.l    SRRPort,a0
  1125.         lib    Exec,DeleteMsgPort
  1126.  
  1127.         move.l    IOWRequest,a0
  1128.         lib    Exec,DeleteIORequest
  1129.  
  1130.         move.l    SWRPort,a0
  1131.         lib    Exec,DeleteMsgPort
  1132.  
  1133.         clr.w    SerOpen
  1134. CloseSer_OUT:    rts
  1135.  
  1136. ;CheckEvent gets messages from serial.device and keyboard (CTRL_C)
  1137. ;
  1138. ;Inputs
  1139. ;
  1140. ;Result
  1141. ;
  1142. ;D0 = -1 if serial returned
  1143. ;D0 = 0  if CTRL_C given
  1144.  
  1145. CheckEvent:    tst.l    Local
  1146.         bne    CheckEvent1
  1147.         clr.l    d0
  1148.         clr.l    d1
  1149.         move.l    SRRPort,a1        ;serial.device
  1150.         move.b    MP_SIGBIT(a1),d1
  1151.         bset.l    d1,d0
  1152.         bset.l    #SIGBREAKB_CTRL_C,d0    ;and CTRL_C
  1153.         lib    Exec,Wait
  1154.  
  1155.         cmp.l    #SIGBREAKF_CTRL_C,d0    ;If CTRL_C
  1156.         beq    Break            ;go break
  1157.  
  1158.         move.l    #-1,d0            ;Serial returned
  1159.         rts
  1160.  
  1161. CheckEvent1:    clr.l    d1
  1162.         bset.l    #SIGBREAKB_CTRL_C,d1    ;check for CTRL_C
  1163.         lib    Dos,CheckSignal
  1164.         btst.l    #SIGBREAKB_CTRL_C,d0
  1165.         bne    CheckEvent2
  1166.         move.l    #-1,d0
  1167.         rts
  1168. CheckEvent2:    clr.l    d0
  1169.         rts
  1170.  
  1171. ReadUser:    move.l    PassWdFile,d1
  1172.         lea.l    UserName,a0
  1173.         move.l    a0,d2
  1174.         move.l    #DataSize,d3
  1175.         lib    Dos,Read
  1176.         cmp.l    #DataSize,d0
  1177.         beq    ReadUser2
  1178.         lib    Dos,IoErr
  1179.         tst.l    d0
  1180.         beq    ReadUser1
  1181.         lea.l    PassWdFileN,a3
  1182.         bsr    FileError2
  1183. ReadUser1:    move.l    #-1,d0
  1184.         rts
  1185. ReadUser2:    clr.l    d0
  1186.         rts
  1187.  
  1188. ;Compares two strings.
  1189. ;
  1190. ;INPUT
  1191. ;
  1192. ;A0 String 1
  1193. ;A1 String 2
  1194. ;
  1195. ;OUTPUT
  1196. ;
  1197. ;D0 = 0 if not same
  1198. ;
  1199. ;BUGS
  1200. ;
  1201. ;String 1 has to have NULL at end!
  1202. ;
  1203.  
  1204. CmpStrings:    bsr    GetLength
  1205.         move.l    d0,d4        ;length of string1 to d4
  1206.         push    a0
  1207.         move.l    a1,a0
  1208.         bsr    GetLength
  1209.         pull    a0
  1210.         cmp.l    d4,d0        ;length of string2 in d3
  1211.         bne    CmpStrings1.1
  1212. CmpStrings1:    tst.b    (a0)
  1213.         beq    CmpStrings2
  1214.         cmp.b    (a0)+,(a1)+
  1215.         beq    CmpStrings1
  1216. CmpStrings1.1:    clr.l    d0
  1217.         rts
  1218. CmpStrings2:    move.l    #-1,d0
  1219.         rts
  1220.  
  1221. ;Decrypts passwords
  1222. ;
  1223. ;Input a0 = pointer to encrypted password
  1224. ;      a1 = pointer to buffer for decrypted password
  1225. ;
  1226.  
  1227. Decrypt:    clr.l    d1
  1228. Decrypt1:    move.l    (a0)+,d0
  1229.         swap.l    d0
  1230.         rol.l    #7,d0
  1231.         sub.l    #$DEADBEEF,d0
  1232.         ror.l    #2,d0
  1233.         move.l    d0,(a1)+
  1234.         add.l    #1,d1
  1235.         cmp.l    #3,d1
  1236.         bne    Decrypt1
  1237.         rts
  1238.  
  1239. ;Wait until LF, CR received or buffer full from serial. Buffer all
  1240. ;input with DEL removal
  1241. ;
  1242. ;INPUT
  1243. ;
  1244. ;D0 = 1 if echoing is desired
  1245. ;
  1246. ;OUTPUT
  1247. ;
  1248. ;Buffer 3 = Data received.
  1249.  
  1250. WaitUntilLF:    tst.l    Local
  1251.         bne    GetString2
  1252.         move.l    d0,d5
  1253.  
  1254. WaitUntilLF1:    bsr    CheckEvent
  1255.         tst.l    d0
  1256.         beq    WaitUntilLF_OUT
  1257.  
  1258.         bsr    BufferInput
  1259.         tst.l    d0
  1260.         beq    WaitUntilLF1        ;No LF so get more chars
  1261. WaitUntilLF_OUT: rts
  1262.  
  1263. ;Gets a string one letter at a time from the CLI. Handles BS correctly
  1264. ;
  1265. ;Inputs    D0 = 1 if echoing is desired
  1266. ;
  1267.  
  1268. GetString2:    move.l    d0,d5
  1269.         move.l    _stdin,d1
  1270.         move.l    #TRUE,d2
  1271.         lib    Dos,SetMode
  1272. GetString2.01:    lea.l    Buffer3,a2
  1273.         move.l    _stdin,d1
  1274.         lib    Dos,Flush
  1275.         clr.l    d4
  1276. GetString2.1:    move.l    _stdin,d1
  1277.         lib    Dos,FGetC
  1278.         cmp.l    #-1,d0
  1279.         beq    GetString2.4
  1280.         cmp.l    #8,d0            ;BS
  1281.         bne    GetString2.2
  1282.         beq    DoBS2
  1283. GetString2.2:    cmp.l    #CR,d0            ;CR
  1284.         beq    GetString2.4
  1285.         cmp.l    #LF,d0            ;LF
  1286.         beq    GetString2.4
  1287.         add.l    #1,d4
  1288.         move.b    d0,(a2)+
  1289.         tst.l    d5
  1290.         beq    GetString2.3
  1291.         bsr    Printer2
  1292. GetString2.3:    cmp.l    #32,d4
  1293.         bne    GetString2.1
  1294. GetString2.4:    clr.b    (a2)+
  1295.         move.l    _stdin,d1
  1296.         move.l    #FALSE,d2
  1297.         lib    Dos,SetMode
  1298.         rts
  1299.  
  1300. DoBS2:        tst.l    d4
  1301.         beq    DoBS2_OUT
  1302.         sub.l    #1,d4
  1303.         sub.l    #1,a2
  1304.         tst.l    d5
  1305.         beq    DoBS2_OUT
  1306.         push    a0
  1307.         lea.l    EraseText1,a0
  1308.         bsr    Printer
  1309.         pull    a0
  1310. DoBS2_OUT:    bra    GetString2.1
  1311.  
  1312. BufferInput:    cmp.b    #8,Buffer1        ;Test for BS
  1313.         bne    BufferInput2
  1314.         bsr    DoBS
  1315.         bsr    ClearSer
  1316.         bsr    Reader
  1317.         clr.l    d0
  1318.         rts
  1319. BufferInput2:    lea.l    Buffer3,a2
  1320.         add.w    BufCount,a2
  1321.         move.b    Buffer1,(a2)
  1322.         tst.l    d5
  1323.         beq    BufferInput2.1
  1324.         bsr    Echo
  1325.  
  1326. BufferInput2.1:    add.w    #1,BufCount
  1327.         cmp.w    #32,BufCount        ;Test for full buffer
  1328.         beq    BufferInput3        ;Buffer is full
  1329.  
  1330.         cmp.b    #10,Buffer1
  1331.         beq    BufferInput3
  1332.         cmp.b    #13,Buffer1
  1333.         beq    BufferInput3
  1334.         bsr    ClearSer
  1335.         bsr    Reader
  1336.         clr.l    d0
  1337.         rts
  1338. BufferInput3:    lea.l    Buffer3,a2
  1339.         add.w    BufCount,a2
  1340.         clr.b    -1(a2)
  1341.         bsr    ClearSer
  1342.         bsr    Reader
  1343.         move.l    #-1,d0
  1344.         rts
  1345.  
  1346. DoBS:        tst.w    BufCount
  1347.         beq    DoBS_OUT
  1348.         tst.l    d5
  1349.         beq    DoBS1
  1350.         bsr    Echo
  1351.         lea.l    SpaceText1,a0
  1352.         bsr    GetLength
  1353.         bsr    Writer
  1354.         bsr    Echo
  1355. DoBS1:        sub.w    #1,BufCount
  1356. DoBS_OUT:    rts
  1357.  
  1358. ;Get length of text in given address
  1359. ;
  1360. ;Input a0 = Address of null terminated text string
  1361. ;
  1362. ;Result d0 = Length
  1363.  
  1364. GetLength:    push    a0
  1365.         clr.l    d0
  1366.         cmp.l    #$00,a0        ;fixes enforcer hit
  1367.         beq    GetLength_OUT
  1368. GetLength2:    add.l    #1,d0
  1369.         tst.b    (a0)+
  1370.         bne    GetLength2
  1371.         sub.l    #1,d0        ;don't include NULL
  1372. GetLength_OUT:    pull    a0
  1373.         rts
  1374.  
  1375. ;Get line length of text in given address, including LF
  1376. ;
  1377. ;Input a0 = Address of LF terminated text string
  1378. ;
  1379. ;Result d0 = Length
  1380.  
  1381. GetLLength:    push    a0
  1382.         clr.l    d0
  1383.         cmp.l    #$00,a0        ;fixes enforcer hit
  1384.         beq    GetLLength_OUT
  1385. GetLLength2:    add.l    #1,d0
  1386.         cmp.b    #10,(a0)+
  1387.         bne    GetLLength2
  1388. GetLLength_OUT:    pull    a0
  1389.         rts
  1390.  
  1391. ;Gets the length of the file given
  1392. ;
  1393. ;Input d1 = File
  1394. ;
  1395. ;Result d0 = Length of file in bytes
  1396. ;
  1397.  
  1398. GetFileLength:    push    d5-d6
  1399.         move.l    d1,d6
  1400.         move.l    #00,d2
  1401.         move.l    #01,d3
  1402.         lib    Dos,Seek
  1403.         move.l    d6,d1
  1404.         lib    Dos,Seek
  1405.  
  1406.         move.l    d0,d5
  1407.         move.l    d6,d1
  1408.         move.l    #0,d2
  1409.         move.l    #-1,d3
  1410.         lib    Dos,Seek
  1411.  
  1412.         move.l    d5,d0
  1413.         pull    d5-d6
  1414.         rts
  1415.  
  1416. ;Seeks to end of the file given
  1417. ;
  1418. ;Input d1 = File
  1419. ;
  1420. ;Result d0 = Length of file in bytes
  1421. ;
  1422.  
  1423. SeekEnd:    push    d2-d6
  1424.         move.l    d1,d6
  1425.         move.l    #00,d2
  1426.         move.l    #01,d3
  1427.         lib    Dos,Seek
  1428.         move.l    d6,d1
  1429.         lib    Dos,Seek
  1430.         pull    d2-d6
  1431.         rts
  1432.  
  1433. ;Error etc. messages
  1434.  
  1435. NoDos:        pull    d2-d7/a2-a6
  1436.         move.l    #RETURN_FAIL,d0
  1437.         rts
  1438.  
  1439. NoRDArgs:    lea.l    ArgErrorText1,a0
  1440.         bsr    Printer
  1441.         bra    ShutDown
  1442.  
  1443. NoInt:        lea.l    NoIntText1,a0
  1444.         bsr    Printer
  1445.         bra    ShutDown
  1446.  
  1447. NoMsgPort:    lea.l    NoMsgPortText1,a0
  1448.         bsr    Printer
  1449.         clr.l    d0
  1450.         rts
  1451.  
  1452. NoIOReq:    lea.l    NoIOReqText1,a0
  1453.         bsr    Printer
  1454.         clr.l    d0
  1455.         rts
  1456.  
  1457. NoSerial:    lea.l    NoSerialText1,a0
  1458.         bsr    Printer
  1459.         move.l    SerName,a0
  1460.         bsr    Printer
  1461.         lea.l    NoSerialText2,a0
  1462.         bsr    Printer
  1463.         clr.l    d0
  1464.         rts
  1465.  
  1466. NoSetSer:    lea.l    NoSetSerText1,a0
  1467.         bsr    Printer
  1468.         clr.l    d0
  1469.         rts
  1470.  
  1471. Printer:    printa    a0,_stdout
  1472.         rts
  1473.  
  1474. Printer2:    push    d0-d7/a0-a6
  1475.         move.l    _stdout,d1
  1476.         move.l    a0,d2
  1477.         move.l    #1,d3
  1478.         lib    Dos,Write
  1479.         pull    d0-d7/a0-a6
  1480.         rts
  1481.  
  1482. ;Structures
  1483.         ds.l    0
  1484.  
  1485. ;lib stuff
  1486.  
  1487.         libnames
  1488.  
  1489.         ds.l    0
  1490.  
  1491. ;Task stuff
  1492.  
  1493. OurTask:    dc.l    0
  1494.  
  1495. ;Other stuff XIV
  1496.  
  1497. RDArgs1:    dc.l    0
  1498. LoginSeconds:    dc.l    0
  1499. LogoutSeconds:    dc.l    0
  1500. OnTimeMins:    dc.l    0
  1501. MicrosTemp:    dc.l    0
  1502. BufCount:    dc.w    0
  1503. LogFailCount:    dc.w    0
  1504.  
  1505. ;Options, the Command Line Arrays
  1506.  
  1507. CLArray1:
  1508. LLPointer:    dc.l    0
  1509. Local:        dc.l    0            ;0=If through device, 1=if local
  1510. Dumb:        dc.l    0
  1511. SerName:    dc.l    SerName2        ;A pointer!
  1512. UnitPointer:    dc.l    0
  1513. SpeedPointer:    dc.l    0
  1514.  
  1515. LogLevel:    dc.l    0            ;0=none, 1=failures, 2=logins, 3=both
  1516. SerUnit:    dc.l    0
  1517. Speed:        dc.l    0
  1518.  
  1519. ;Ports/reqs/etc.
  1520.  
  1521. SRRPort:    dc.l    0
  1522. IORRequest:    dc.l    0
  1523. SWRPort:    dc.l    0
  1524. IOWRequest:    dc.l    0
  1525.  
  1526. ;Files
  1527.  
  1528. WelcomeFile:    dc.l    0
  1529. WelcomeLength:    dc.l    0
  1530. PassWdFile:    dc.l    0
  1531. LogFile:    dc.l    0
  1532. _stdout:    dc.l    0
  1533. _stdin:        dc.l    0
  1534. NILFile:    dc.l    0
  1535.  
  1536. ;Memory allocations
  1537.  
  1538. WelcomeMem:    dc.l    0
  1539.  
  1540. ;Serial device stuff
  1541.  
  1542. SerOpen:    dc.w    0
  1543. Requested:    dc.w    0
  1544.  
  1545. ;Strings, error
  1546.  
  1547. BreakText1:    dc.b    "***Break: Logger",13,10,0
  1548. NoIntText1:    dc.b    "ERROR: Couldn't open intuition.library!",13,10,0
  1549. ArgErrorText1:    dc.b    "ERROR: Invalid arguments specified.",13,10,0
  1550. NoMsgPortText1:    dc.b    "ERROR: Couldn't get message port!",13,10,0
  1551. NoIOReqText1:    dc.b    "ERROR: Couldn't get SerialIOReq!",13,10,0
  1552. NoSerialText1:    dc.b    "ERROR: Couldn't open ",0
  1553. SerName2:    dc.b    "serial.device",0
  1554. NoSerialText2:    dc.b    13,10,0
  1555. SerName3:    dc.b    "console.device",0
  1556. NoSetSerText1:    dc.b    "ERROR: Couldn't set parameters for device!",13,10,0
  1557. NILName:    dc.b    "NIL:",0
  1558. LowMemText1:    dc.b    13,10,"WARNING: System is low on memory!",13,10,0
  1559. FileErrorText1:    dc.b    13,10,"ERROR: Couldn't open file: ",0
  1560. FileErrorText2:    dc.b    13,10,"ERROR: A read error occured on file: ",0
  1561.  
  1562. ;Strings, names
  1563.  
  1564. CLTemplate1:    dc.b    "LL=LOGLEVEL/N/K,LOCAL/S,DUMB/S,DEV=DEVICE/K,UNIT/N/K,SPEED/N/K",0
  1565. STVersion:    dc.b    "$VER: Logger 1.11 (1.1.93) (C)opyright Tomi Blinnikka 1993",0
  1566. RPortText1:    dc.b    "Logger read port",0
  1567. WPortText1:    dc.b    "Logger write port",0
  1568.  
  1569. ;Filenames etc.
  1570.  
  1571. WelcomeFileN:    dc.b    "LOGGER:Logger-Header",0
  1572. PassWdFileN:    dc.b    "LOGGER:PassWd.LOGGER",0
  1573. LogFileN:    dc.b    "LOGGER:Logger.LOG",0
  1574. ExecuteText1:    dc.b    "C:Execute",0
  1575.         ds.l    0
  1576. ASCIIUnit:    dc.b    "     ",0
  1577.  
  1578. ;Modem control strings
  1579.  
  1580. ResetString:    dc.b    "ATZ",13,10,0
  1581. AnswerString:    dc.b    "ATA",13,10,0
  1582. HangUpString1:    dc.b    "+++",0
  1583. HangUpString2:    dc.b    "ATH0",13,10,0
  1584.  
  1585. ;Texts to output
  1586.  
  1587. LoginText1:    dc.b    13,10,"login: ",0
  1588. PasswordText1:    dc.b    13,10,"Password: ",0
  1589. CorrectText1:    dc.b    "*   Login correct:  ",0
  1590. IncorrectText1:    dc.b    13,10,"Login incorrect",13,10,0
  1591. IncorrectText2:    dc.b    "**  Login incorrect: ",0
  1592. LogFailureText1: dc.b    "Login failure",13,10,0
  1593. LogFailureText2: dc.b    "*** Login failure",0
  1594. LogOutText1:    dc.b    "    Logged out: ",0
  1595. LogFailIncText1: dc.b    " - ",0
  1596. LogFailIncText2: dc.b    ", ",0
  1597. SpaceText1:    dc.b    " ",0
  1598. CRLFText1:    dc.b    13,10,0
  1599. CRLFText2:    dc.b    13,10,"    ",0
  1600. EraseText1:    dc.b    8," ",8,0
  1601. OnTimeText1:    dc.b    "Minutes used: "
  1602. OnTimeText2:    dc.b    "    0"
  1603. OnTimeText3:    dc.b    13,10,0
  1604. ConnectionText1: dc.b    13,10,"Connection closed.",13,10,0
  1605. fstrl:        dc.b    "%5.d",0
  1606. fstrl2:        dc.b    "%-5.ld",0
  1607.  
  1608.         ds.l    0
  1609.  
  1610. ;Buffers
  1611. ;
  1612. ;Buffers 1 - 2 used by WaitForRing, WaitForConnect WaitUntilLF
  1613. ;Buffer 3 used by WaitUntilLF
  1614.  
  1615. Buffer1:    dcb.b    2,0
  1616. Buffer2:    dcb.b    16,0
  1617. Buffer3:    dcb.b    34,0
  1618. Buffer4:    dcb.b    12,0
  1619.  
  1620. TempBuf1:    dcb.b    34,0
  1621.  
  1622. CmdString1:    dcb.b    400,0
  1623. CmdString2:    dc.b    "EndCLI",0
  1624.         ds.l    0
  1625.  
  1626. DATA_START:
  1627. UserName:    dc.b    "root"
  1628.         dcb.b    12-4,0                ;username
  1629. PassWord:    dcb.b    12,0                ;passwd (default is 'root')
  1630. RealName:    dc.b    "System Administraitor"        ;note the 'i' :)
  1631.         dcb.b    64-21,0                ;realname of user
  1632. UserHome:    dc.b    "USERS:root"
  1633.         dcb.b    64-10,0                ;user home directory
  1634. Office:        dc.b    "Admin"
  1635.         dcb.b    64-5,0                ;Office for finger etc.
  1636. UserCommand:    dc.b    "C:Execute Rem:Login-Start"    ;command to start
  1637.         dcb.b    64-25,0
  1638. DATA_END:    dc.l    0,0
  1639.  
  1640. DataSize:    EQU    (DATA_END-DATA_START)
  1641.  
  1642.         ds.l    0
  1643.  
  1644. DateTime1:    dcb.b    12,0        ;DateStamp
  1645.         dc.b    FORMAT_DOS    ;dat_Format
  1646.         dc.b    0        ;dat_Flags
  1647.         dc.l    StrDay1        ;dat_StrDay
  1648.         dc.l    StrDate1    ;dat_StrDate
  1649.         dc.l    StrTime1    ;dat_StrTime
  1650.  
  1651. StrDay1:    dcb.b    LEN_DATSTRING,0
  1652. StrDate1:    dcb.b    LEN_DATSTRING,0
  1653. StrTime1:    dcb.b    LEN_DATSTRING,0
  1654.  
  1655.         end
  1656.  
  1657.  
  1658.