home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / dev / asm / tbsource / munix / mu.bak < prev    next >
Text File  |  1993-12-21  |  16KB  |  926 lines

  1. *************************************************
  2. *                        *
  3. *         (C)opyright 1992        *
  4. *                        *
  5. *        by  Tomi Blinnikka        *
  6. *                        *
  7. *    Don´t try to understand the code    *
  8. *                        *
  9. * Version 0.01    09/06/1992            *
  10. *     -0.99ö                    *
  11. *                        *
  12. *************************************************
  13.  
  14.     INCLUDE    "JMPLibs.i"
  15.     INCLUDE    "exec/types.i"
  16.     INCLUDE    "exec/nodes.i"
  17.     INCLUDE    "exec/lists.i"
  18.     INCLUDE    "exec/ports.i"
  19.     INCLUDE    "exec/memory.i"
  20.     INCLUDE    "exec/devices.i"
  21.     INCLUDE    "exec/io.i"
  22.     INCLUDE    "exec/tasks.i"
  23.     INCLUDE    "libraries/dosextens.i"
  24.     INCLUDE    "libraries/dos.i"
  25.     INCLUDE    "devices/serial.i"
  26.     INCLUDE    "dos/dostags.i"
  27.  
  28.     INCLUDE    "XREF:2.0.xref"
  29.     INCLUDE    "XREF:exec.xref"
  30.     INCLUDE    "XREF:dos.xref"
  31. ;    INCLUDE    "XREF:intuition.xref"
  32.  
  33.     XREF    _CreatePort
  34.     XREF    _DeletePort
  35.     XREF    _CreateExtIO
  36.     XREF    _DeleteExtIO
  37.  
  38.     XDEF    _DOSBase
  39.     XDEF    _SysBase
  40.  
  41.     XREF    _LVOCurrentTime
  42.     XREF    _LVOSystemTagList
  43.  
  44. TRUE:        EQU    1
  45.  
  46.         section    MU,CODE
  47.  
  48.         push    d2-d7/a2-a6
  49.         push    d0/a0
  50.  
  51.         sub.l    a1,a1            ;Find our task
  52.         lib    Exec,FindTask
  53.         move.l    d0,OurTask
  54.  
  55.         openlib    Dos,NoDos        ;Keep at beginning
  56.  
  57. CLIStart:    lib    Dos,Output
  58.         move.l    d0,_stdout
  59.         pull    d0/a0
  60.         clr.b    -1(a0,d0.l)
  61.         cmp.b    #'?',(a0)
  62.         beq    Usage
  63.         cmp.w    #'-?',(a0)
  64.         beq    Usage
  65.         cmp.w    #'-h',(a0)
  66.         beq    Usage
  67.  
  68. Cont0.2:    bsr    ConvASCII
  69.         tst.w    d0
  70.         beq    Cont1
  71.         move.w    d0,SerUnit
  72. Cont1:        cmp.b    #' ',(a0)
  73.         bne    Cont1.1
  74.         add.l    #1,a0
  75. Cont1.1:    tst.b    (a0)
  76.         beq    Cont1.2
  77.         move.l    a0,SerName
  78. Cont1.2:
  79.  
  80. MainStart:    move.l    _DosBase,_DOSBase
  81.         move.l    $4,_SysBase
  82.         openlib    Intuition,NoInt
  83.  
  84. ;Create read reply port for serial.device (or modem0.device etc.)
  85.  
  86.         move.l    #0,-(sp)
  87.         pea    SRRPortName        ;S(erial)R(ead)R(eply)PortName
  88.         jsr    _CreatePort
  89.         add.l    #8,sp
  90.         move.l    d0,SRRPort
  91.         beq    ShutDown
  92.  
  93. ;Create read IOReq for serial.device (or for other device, but size is EXTSER)
  94.  
  95.         move.l    #IOEXTSER_SIZE,-(sp)
  96.         move.l    d0,-(sp)
  97.         jsr    _CreateExtIO
  98.          add.l    #8,sp
  99.         move.l    d0,IORRequest
  100.         beq    NoIOReq
  101.  
  102. ;Create write reply port for serial.device (or modem0.device etc.)
  103.  
  104.         move.l    #0,-(sp)
  105.         pea    SWRPortName        ;S(erial)W(rite)R(eply)PortName
  106.         jsr    _CreatePort
  107.         add.l    #8,sp
  108.         move.l    d0,SWRPort
  109.         beq    ShutDown
  110.  
  111. ;Create write IOReq for serial.device (or for other device, but size is EXTSER)
  112.  
  113.         move.l    #IOEXTSER_SIZE,-(sp)
  114.         move.l    d0,-(sp)
  115.         jsr    _CreateExtIO
  116.          add.l    #8,sp
  117.         move.l    d0,IOWRequest
  118.         beq    NoIOReq
  119.  
  120. ;open serial.device
  121.  
  122.         move.l    SerName,a0
  123.         move.l    SerUnit,d0
  124.         move.l    IORRequest,a1
  125.         move.b    #SERF_SHARED,IO_SERFLAGS(a1)
  126.         clr.l    d1                ;no flags
  127.         lib    Exec,OpenDevice
  128.         tst.l    d0
  129.         bne    NoSerial
  130.         move.w    #$1,SerOpen        ;just to tell if open
  131.  
  132. ;Copy info from one req to the other
  133.  
  134.         move.l    IORRequest,a0
  135.         move.l    IOWRequest,a1
  136.         move.l    IO_DEVICE(a0),IO_DEVICE(a1)
  137.         move.l    IO_UNIT(a0),IO_UNIT(a1)
  138.  
  139. ;
  140. ;Main loop here
  141. ;
  142. ;1.  Reset modem
  143. ;2.  Setup read
  144. ;3.  Wait for RING
  145. ;4.  Answer with ATA
  146. ;5.  Wait for CONNECT
  147. ;6.  Delay of 1 SEC
  148. ;7.  Display welcome.txt
  149. ;8.  Ask login
  150. ;9.  Ask for password
  151. ;10. Test password with login
  152. ;11. Loop if incorrect or null
  153. ;12. Parser
  154.  
  155. StartLoop:    bsr    Reset
  156.         bsr    Reader
  157.  
  158. StartLoop2:    clr.w    BufCount
  159.         bsr    WaitForRing
  160.         tst.l    d0
  161.         beq    ShutDown
  162.  
  163.         bsr    Answer
  164.         clr.w    BufCount
  165.         bsr    WaitForConnect
  166.         tst.l    d0
  167.         beq    ShutDown
  168.         cmp.l    #1111111,d0
  169.         beq    StartLoop2
  170.  
  171. ;Login part starts here
  172.  
  173. Logging:    lea.l    LoginSeconds,a0
  174.         lea.l    MicrosTemp,a1
  175.         lib    Intuition,CurrentTime
  176.  
  177.         clr.w    LogFailCount
  178.         bsr    Delay1SEC
  179.  
  180.         bsr    Welcome
  181. Logging1:    bsr    AskLogin
  182.         tst.l    d0
  183.         beq    ShutDown
  184.         tst.b    Buffer3
  185.         beq    Logging1
  186.         bsr    AskPassword
  187.         tst.l    d0
  188.         beq    ShutDown
  189.  
  190.         lea.l    RootName,a0
  191.         lea.l    TempBuf1,a1
  192.         bsr    CmpStrings
  193.         tst.l    d0
  194.         bne    Logging2
  195.         add.w    #1,LogFailCount
  196.         bsr    IncorrectLogin
  197.         cmp.w    #5,LogFailCount
  198.         beq    LoginFailure
  199.         bra    Logging1
  200.  
  201. Logging2:    lea.l    RootPass,a0
  202.         lea.l    Buffer3,a1
  203.         bsr    CmpStrings
  204.         tst.l    d0
  205.         bne    LoggedOn
  206.         add.w    #1,LogFailCount
  207.         bsr    IncorrectLogin
  208.         cmp.w    #5,LogFailCount
  209.         beq    LoginFailure
  210.         bra    Logging1
  211.  
  212. LoggedOn:    bsr    Welcome2
  213.         lea.l    LoginSeconds,a0
  214.         lea.l    MicrosTemp,a1
  215.         lib    Intuition,CurrentTime
  216.  
  217. ;From here on should be command line parser
  218.  
  219. Parser:        bsr    Prompt
  220.  
  221.         clr.w    BufCount
  222.         move.l    #1,d0
  223.         bsr    WaitUntilLF
  224.         tst.l    d0
  225.         beq    ShutDown
  226.  
  227.         lea.l    CMD_LogOut,a0
  228.         bsr    TestCmd
  229.         tst.l    d0
  230.         bne    LogOut
  231.  
  232.         tst.b    Buffer3
  233.         beq    Parser
  234.  
  235.         bsr    DoCommand
  236.         tst.l    d0
  237.         beq    ShutDown
  238.  
  239.         bra    Parser
  240.  
  241. TestCmd:    lea.l    Buffer3,a1
  242.         bsr    CmpStrings
  243.         rts
  244.  
  245. LogOut:        bsr    OnTime
  246.  
  247.         bsr    HangUp
  248.         bra    StartLoop
  249.  
  250. OnTime:        lea.l    LogoutSeconds,a0
  251.         lea.l    MicrosTemp,a1
  252.         lib    Intuition,CurrentTime
  253.  
  254.         move.l    LoginSeconds,d0
  255.         move.l    LogoutSeconds,d1
  256.         sub.l    d0,d1
  257.         divu.w    #60,d1            ;Minutes
  258.         clr.l    d0
  259.         move.w    d1,d0
  260.         move.w    d0,OnTimeMins
  261.  
  262.         lea.l    fstrl,a0        ;HEX->ASCII
  263.         lea.l    OnTimeMins,a1        ;Number2Print
  264.         lea.l    PutChProc,a2
  265.         lea.l    OnTimeText2,a3        ;Destination
  266.         lib    Exec,RawDoFmt
  267.  
  268.         lea.l    OnTimeText1,a0
  269.         bsr    GetLength
  270.         bsr    Writer
  271.         rts
  272.  
  273. ;Waits for login
  274. ;
  275. ;INPUT
  276. ;
  277. ;OUTPUT
  278. ;
  279.  
  280. ;Waits for RING
  281. ;
  282. ;INPUT
  283. ;
  284. ;OUTPUT
  285. ;
  286. ;D0 = -1 if OK
  287. ;D0 =  0 if Break
  288. ;
  289. ;ACTION
  290. ;
  291. ;1. Wait for input, serial or CTRL_C
  292. ;2. If CTRL_C then break
  293. ;3. If serial test for ring
  294. ;4. If D0 = -1 then RING -> OUT
  295. ;5. If not then loop
  296.  
  297. WaitForRing:    bsr    CheckEvent
  298.         tst.l    d0
  299.         beq    WaitForRing_OUT
  300.  
  301.         bsr    TestRing
  302.         tst.l    d0
  303.         beq    WaitForRing        ;No RING so get more chars
  304. WaitForRing_OUT: rts
  305.  
  306. TestRing:    tst.w    BufCount
  307.         bne    TestRing2
  308.         cmp.b    #'R',Buffer1
  309.         bne    TestRing4
  310. TestRing2:    lea.l    Buffer2,a0
  311.         add.w    BufCount,a0
  312.         move.b    Buffer1,(a0)
  313.         add.w    #1,BufCount
  314.         cmp.w    #4,BufCount
  315.         bne    TestRing4
  316.         clr.w    BufCount
  317.         cmp.l    #'RING',Buffer2
  318.         bne    TestRing4
  319. TestRing3:    bsr    ClearSer
  320.         bsr    Reader
  321.         move.l    #-1,d0            ;indicate ring
  322.         rts
  323. TestRing4:    bsr    ClearSer        ;Abort possible prev. read
  324.         bsr    Reader            ;Set up new read
  325.         clr.l    d0
  326.         rts
  327.  
  328. ;Waits for CONNECT
  329. ;
  330. ;INPUT
  331. ;
  332. ;OUTPUT
  333. ;
  334. ;D0 = -1 if OK
  335. ;D0 =  0 if Break
  336. ;
  337. ;ACTION
  338. ;
  339. ;1. Wait for input, serial or CTRL_C
  340. ;2. If CTRL_C then break
  341. ;3. If serial test for connect
  342. ;4. If D0 = -1 then CONNECT -> OUT
  343. ;5. If not then loop
  344.  
  345. WaitForConnect:    bsr    CheckEvent
  346.         tst.l    d0
  347.         beq    WaitForConnect_OUT
  348.  
  349.         bsr    TestConnect
  350.         tst.l    d0
  351.         beq    WaitForConnect        ;No CONNECT so get more chars
  352. WaitForConnect_OUT: rts
  353.  
  354. TestConnect:    tst.w    BufCount
  355.         bne    TestConnect2
  356.         cmp.b    #'C',Buffer1
  357.         bne    TestConnect4
  358. TestConnect2:    lea.l    Buffer2,a0
  359.         add.w    BufCount,a0
  360.         move.b    Buffer1,(a0)
  361.         add.w    #1,BufCount
  362.         cmp.w    #7,BufCount
  363.         bne    TestConnect4
  364.         clr.w    BufCount
  365.         cmp.l    #'CONN',Buffer2
  366.         bne    TestConnect5
  367.         cmp.w    #'EC',Buffer2+4
  368.         bne    TestConnect5
  369.         cmp.b    #'T',Buffer2+6
  370.         bne    TestConnect5
  371. TestConnect3:    bsr    ClearSer
  372.         bsr    Reader
  373.         move.l    #-1,d0            ;indicate CONNECT
  374.         rts
  375. TestConnect4:    bsr    ClearSer        ;Abort possible prev. read
  376.         bsr    Reader            ;Set up new read
  377.         clr.l    d0
  378.         rts
  379. TestConnect5:    bsr    ClearSer        ;Abort possible prev. read
  380.         bsr    Reader            ;Set up new read
  381.         move.l    #1111111,d0
  382.         rts
  383.  
  384. Reset:        lea.l    ResetString,a0
  385.         bsr    GetLength
  386.         bsr    Writer
  387.         rts
  388.  
  389. Answer:        lea.l    AnswerString,a0
  390.         bsr    GetLength
  391.         bsr    Writer
  392.         rts
  393.  
  394. Welcome:    lea.l    WelcomeText1,a0
  395.         bsr    GetLength
  396.         bsr    Writer
  397.         rts
  398.  
  399. ;Add date redirected to some file and reloaded to display login last used
  400.  
  401. Welcome2:    lea.l    WelcomeText2,a0
  402.         bsr    GetLength
  403.         bsr    Writer
  404.         rts
  405.  
  406. AskLogin:    lea.l    LoginText1,a0
  407.         bsr    GetLength
  408.         bsr    Writer
  409.  
  410.         clr.w    BufCount
  411.         move.l    #1,d0
  412.         bsr    WaitUntilLF
  413.         tst.l    d0
  414.         beq    AskLogin_OUT
  415.  
  416.         lea.l    Buffer3,a0
  417.         lea.l    TempBuf1,a1
  418.         move.l    #32,d0
  419.         lib    Exec,CopyMem
  420.         move.l    #-1,d0
  421.         rts
  422. AskLogin_OUT:    clr.l    d0
  423.         rts
  424.  
  425. AskPassword:    lea.l    PasswordText1,a0
  426.         bsr    GetLength
  427.         bsr    Writer
  428.         clr.w    BufCount
  429.         clr.l    d0
  430.         bsr    WaitUntilLF
  431.         rts
  432.  
  433. IncorrectLogin:    lea.l    IncorrectText1,a0
  434.         bsr    GetLength
  435.         bsr    Writer
  436.         rts
  437.  
  438. LoginFailure:    bsr    IncorrectLogin
  439.         lea.l    LogFailureText1,a0
  440.         bsr    GetLength
  441.         bsr    Writer
  442.         bra    LogOut
  443.  
  444. Prompt:        lea.l    PromptText1,a0
  445.         bsr    GetLength
  446.         bsr    Writer
  447.         rts
  448.  
  449. UnknownCMD:    lea.l    CRLFText1,a0
  450.         bsr    GetLength
  451.         bsr    Writer
  452.  
  453.         lea.l    Buffer3,a0
  454.         bsr    GetLength
  455.         bsr    Writer
  456.  
  457.         lea.l    UnknownCMDText1,a0
  458.         bsr    GetLength
  459.         bsr    Writer
  460.         rts
  461.  
  462. Echo:        lea.l    Buffer1,a0
  463.         move.l    #1,d0
  464.         bsr    Writer
  465.         rts
  466.  
  467. HangUp:        lea.l    HangUpString1,a0
  468.         bsr    GetLength
  469.         bsr    Writer
  470.         bsr    Delay1SEC
  471.         lea.l    HangUpString2,a0
  472.         bsr    GetLength
  473.         bsr    Writer
  474.         rts
  475.  
  476. Delay1SEC:    move.l    #50,d1
  477.         lib    Dos,Delay
  478.         rts
  479.  
  480. Break:        lea.l    BreakText1,a0
  481.         bsr    Printer
  482.         clr.l    d0
  483.         rts
  484.  
  485. ClearSer:    move.l    IORRequest,a1
  486.         lib    Exec,CheckIO
  487.         tst.l    d0
  488.         beq    ClearSer1
  489.         move.l    IORRequest,a1
  490.         lib    Exec,WaitIO
  491.  
  492. ClearSer1:    move.l    IORRequest,a1
  493.         ABORTIO
  494.         move.l    IORRequest,a1
  495.         lib    Exec,WaitIO
  496.         rts
  497.  
  498. Reader:        move.l    IORRequest,a1
  499.         move.w    #CMD_READ,IO_COMMAND(a1)
  500.         move.l    #1,IO_LENGTH(a1)
  501.         lea.l    Buffer1,a0
  502.         move.l    a0,IO_DATA(a1)
  503.         lib    Exec,SendIO
  504.         rts
  505.  
  506. ;Writes string to serial port
  507. ;
  508. ;D0 = Length
  509. ;A0 = String
  510.  
  511. Writer:        move.l    IOWRequest,a1
  512.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  513.         move.l    d0,IO_LENGTH(a1)
  514.         move.l    a0,IO_DATA(a1)
  515.         lib    Exec,DoIO        ;May freeze, too bad
  516.         rts
  517.  
  518. PutChProc:    tst.b    d0
  519.         beq    PutChProc_OUT
  520.         move.b    d0,(a3)+
  521. PutChProc_OUT:    rts
  522.  
  523. ;Open AUX device (should ask for the name of the device...)
  524.  
  525. DoCommand:    lea.l    CRLFText1,a0
  526.         bsr    GetLength
  527.         bsr    Writer
  528.  
  529.         lea.l    AUXName,a0
  530.         move.l    a0,d1
  531.         move.l    #MODE_NEWFILE,d2
  532.         lib    Dos,Open
  533.         move.l    d0,AUXFile
  534.         bne    DoCommand2
  535.  
  536.         bsr    NoAUX
  537.         clr.l    d0
  538.         rts
  539.  
  540. DoCommand2:    move.l    d0,CMDAUXFile1
  541.  
  542.         lea.l    CMDTags,a0
  543.         move.l    a0,d2
  544.         lea.l    Buffer3,a0
  545.         move.l    a0,d1
  546.         lib    Dos,SystemTagList
  547.         cmp.l    #-1,d0
  548.         bne    DoCommand3
  549.  
  550.         bsr    UnknownCMD
  551.  
  552. DoCommand3:    move.l    AUXFile,d1
  553.         lib    Dos,Close
  554.         clr.l    AUXFile
  555.  
  556.         move.l    #-1,d0
  557.         rts
  558.  
  559. ShutDown:    tst.w    SerOpen
  560.         beq    ShutDown9000
  561.         bsr    ClearSer
  562.         move.l    IORRequest,a1
  563.         lib    Exec,CloseDevice
  564.  
  565. ShutDown9000:    move.l    IORRequest,d0
  566.         tst.l    d0
  567.         beq    ShutDown8000
  568.         move.l    #IOEXTSER_SIZE,-(sp)
  569.         move.l    d0,-(sp)
  570.         jsr    _DeleteExtIO
  571.         add.l    #8,sp
  572.  
  573. ShutDown8000:    move.l    SRRPort,d0
  574.         tst.l    d0
  575.         beq    ShutDown7000
  576.         move.l    d0,-(sp)
  577.         jsr    _DeletePort
  578.         add.l    #4,sp
  579.  
  580. ShutDown7000:    move.l    IOWRequest,d0
  581.         tst.l    d0
  582.         beq    ShutDown6000
  583.         move.l    #IOEXTSER_SIZE,-(sp)
  584.         move.l    d0,-(sp)
  585.         jsr    _DeleteExtIO
  586.         add.l    #8,sp
  587.  
  588. ShutDown6000:    move.l    SWRPort,d0
  589.         tst.l    d0
  590.         beq    ShutDown5000
  591.         move.l    d0,-(sp)
  592.         jsr    _DeletePort
  593.         add.l    #4,sp
  594.  
  595. ShutDown5000:    tst.l    AUXFile
  596.         beq    ShutDown4000
  597.         move.l    AUXFile,d1
  598.         lib    Dos,Close
  599.  
  600. ShutDown4000:
  601. ShutDown1000:    closlib    Intuition
  602.         closlib    Dos
  603.         pull    d2-d7/a2-a6
  604.         clr.l    d0
  605.         rts
  606.  
  607. ;CheckEvent gets messages from serial.device and keyboard (CTRL_C)
  608. ;
  609. ;Input
  610. ;
  611. ;Output
  612. ;
  613. ;D0 = -1 if serial returned
  614. ;D0 = 0  if CTRL_C given
  615.  
  616. CheckEvent:    clr.l    d0
  617.         clr.l    d1
  618.         move.l    SRRPort,a1        ;serial.device
  619.         move.b    MP_SIGBIT(a1),d1
  620.         bset.l    d1,d0
  621.         bset.l    #SIGBREAKB_CTRL_C,d0    ;and CTRL_C
  622.         lib    Exec,Wait
  623.  
  624.         cmp.l    #SIGBREAKF_CTRL_C,d0    ;If CTRL_C
  625.         beq    Break            ;go break
  626.  
  627.         move.l    #-1,d0            ;Serial returned
  628.         rts
  629.  
  630. ;Wait until LF,CR received or buffer full from serial. Buffer all
  631. ;input with DEL removal
  632. ;
  633. ;INPUT
  634. ;
  635. ;D0 = 1 if echoing is desired
  636. ;
  637. ;OUTPUT
  638. ;
  639. ;Buffer 3 = Data received.
  640.  
  641. WaitUntilLF:    move.l    d0,d5
  642.  
  643. WaitUntilLF1:    bsr    CheckEvent
  644.         tst.l    d0
  645.         beq    WaitUntilLF_OUT
  646.  
  647.         bsr    BufferInput
  648.         tst.l    d0
  649.         beq    WaitUntilLF1        ;No LF so get more chars
  650. WaitUntilLF_OUT: rts
  651.  
  652. BufferInput:    cmp.b    #4,Buffer1        ;Test for CTRL_D
  653.         beq    CTRL_D
  654.         cmp.b    #8,Buffer1        ;Test for BS
  655.         bne    BufferInput2
  656.         bsr    DoBS
  657.         bsr    ClearSer
  658.         bsr    Reader
  659.         clr.l    d0
  660.         rts
  661. BufferInput2:    lea.l    Buffer3,a2
  662.         add.w    BufCount,a2
  663.         move.b    Buffer1,(a2)
  664.         tst.l    d5
  665.         beq    BufferInput2.1
  666.         bsr    Echo
  667.  
  668. BufferInput2.1:    add.w    #1,BufCount
  669.         cmp.w    #32,BufCount        ;Test for full buffer
  670.         beq    BufferInput3        ;Buffer is full
  671.  
  672.         cmp.b    #10,Buffer1
  673.         beq    BufferInput3
  674.         cmp.b    #13,Buffer1
  675.         beq    BufferInput3
  676.         bsr    ClearSer
  677.         bsr    Reader
  678.         clr.l    d0
  679.         rts
  680. BufferInput3:    lea.l    Buffer3,a2
  681.         add.w    BufCount,a2
  682.         clr.b    -1(a2)
  683.         bsr    ClearSer
  684.         bsr    Reader
  685.         move.l    #-1,d0
  686.         rts
  687.  
  688. CTRL_D:        lea.l    ExitText1,a0
  689.         bsr    GetLength
  690.         bsr    Writer
  691.         move.l    #'logo',Buffer3
  692.         move.w    #'ut',Buffer3+4
  693.         move.b    #0,Buffer3+6
  694.         bsr    ClearSer
  695.         bsr    Reader
  696.         move.l    #-1,d0
  697.         rts
  698.  
  699. DoBS:        tst.w    BufCount
  700.         beq    DoBS_OUT
  701.         tst.l    d5
  702.         beq    DoBS1
  703.         bsr    Echo
  704. DoBS1:        sub.w    #1,BufCount
  705. DoBS_OUT:    rts
  706.  
  707. ;Get length of text in given address
  708. ;
  709. ;Input a0 = Address of null terminated text string
  710. ;
  711. ;Result d0 = Length
  712.  
  713. GetLength:    push    a0
  714.         clr.l    d0
  715.         cmp.l    #$00,a0        ;fixes enforcer hit
  716.         beq    GetLength_OUT
  717. GetLength2:    add.l    #1,d0
  718.         tst.b    (a0)+
  719.         bne    GetLength2
  720.         sub.l    #1,d0        ;don't include NULL
  721. GetLength_OUT:    pull    a0
  722.         rts
  723.  
  724. ConvASCII:    clr.l    d0
  725.         clr.l    d1
  726.         cmp.b    #' ',(a0)
  727.         bne    ConvASCII2
  728.         add.l    #1,a0
  729. ConvASCII2:    move.b    (a0),d1
  730.         cmp.b    #'0',d1
  731.         bcs    ConvASCII_OUT
  732.         cmp.b    #'9',d1
  733.         bhi    ConvASCII_OUT
  734.         sub.b    #'0',d1
  735.         mulu.w    #10,d0
  736.         add.l    d1,d0
  737.         add.l    #1,a0
  738.         bra    ConvASCII2
  739. ConvASCII_OUT:    rts
  740.  
  741.  
  742. ;Compares two strings.
  743. ;
  744. ;INPUT
  745. ;
  746. ;A0 String 1
  747. ;A1 String 2
  748. ;
  749. ;OUTPUT
  750. ;
  751. ;D0 = 0 if not same
  752. ;
  753. ;BUGS
  754. ;
  755. ;If String 2 is longer but correct upto length of
  756. ;String 1, routine will say String 1 = String 2
  757. ;String 1 has to have NULL at end!
  758. ;
  759.  
  760. CmpStrings:    tst.b    (a0)
  761.         beq    CmpStrings2
  762.         cmp.b    (a0)+,(a1)+
  763.         beq    CmpStrings
  764.         clr.l    d0
  765.         rts
  766. CmpStrings2:    move.l    #-1,d0
  767.         rts
  768.  
  769. ;Error etc. messages
  770.  
  771. Usage:        lea.l    UsageText1,a0
  772.         bsr    Printer
  773.         bra    ShutDown
  774.  
  775. NoDos:        add.l    #8,sp
  776.         pull    d2-d7/a2-a6
  777.         move.l    #RETURN_FAIL,d0
  778.         rts
  779.  
  780. NoInt:        lea.l    NoIntText1,a0
  781.         bsr    Printer
  782.         bra    ShutDown
  783.  
  784. NoIOReq:    lea.l    NoIOReqText1,a0
  785.         bsr    Printer
  786.         bra    ShutDown
  787.  
  788. NoSerial:    lea.l    NoSerialText1,a0
  789.         bsr    Printer
  790.         move.l    SerName,a0
  791.         bsr    Printer
  792.         lea.l    NoSerialText2,a0
  793.         bsr    Printer
  794.         bra    ShutDown
  795.  
  796. NoAUX:        lea.l    NoAUXText1,a0
  797.         bsr    Printer
  798.         rts
  799.  
  800. Printer:    printa    a0,_stdout
  801.         rts
  802.  
  803. ;Structures
  804.  
  805. ;lib stuff
  806.  
  807. _SysBase:    dc.l    0
  808. _DOSBase:    dc.l    0
  809.  
  810.         libnames
  811.  
  812. ;Other stuff, part I
  813.  
  814. OurTask:    dc.l    0
  815. SRRPort:    dc.l    0
  816. IORRequest:    dc.l    0
  817. SWRPort:    dc.l    0
  818. IOWRequest:    dc.l    0
  819. _stdout:    dc.l    0
  820. ;_stdin:    dc.l    0
  821. AUXFile:    dc.l    0
  822. BufCount:    dc.w    0
  823. LogFailCount:    dc.w    0
  824. LoginSeconds:    dc.l    0
  825. LogoutSeconds:    dc.l    0
  826. OnTimeMins:    dc.l    0
  827. MicrosTemp:    dc.l    0
  828.  
  829. ;Serial device stuff
  830.  
  831. SerName:    dc.l    SerName2        ;A pointer!
  832. SerUnit:    dc.l    0
  833. SerOpen:    dc.w    0
  834.  
  835. ;Strings, error
  836.  
  837. BreakText1:    dc.b    "***Break",10,0
  838. NoIntText1:    dc.b    "ERROR: Couldn't open intuition.library!",10,0
  839. NoIOReqText1:    dc.b    "ERROR: Couldn't get SerialIOReq!",10,0
  840. NoSerialText1:    dc.b    "ERROR: Couldn't open ",0
  841. SerName2:    dc.b    "modem0.device",0
  842. NoSerialText2:    dc.b    10,0
  843. NoAUXText1:    dc.b    "ERROR: Couldn't open AUX:!",10,0
  844.  
  845. ;Strings, names
  846.  
  847. STVersion:    dc.b    "$VER: "
  848. UsageText1:    dc.b    "MUnix v0.01. (C)opyright Tomi Blinnikka 1992",10,10
  849.         dc.b    10,"           !!! BETA TESTER VERSION !!!",10,10,10
  850.         dc.b    "USAGE: MUnix [Unit] [Device]",10,10
  851.         dc.b    "       Where: [Unit] is the unit number",10
  852.         dc.b    "              [Device] is the device name",10,10
  853.         dc.b    "       Default [Device] is serial.device",10,10
  854.         dc.b    "A PhoneLineWatcher clone.",10
  855.         dc.b    "See docs for more information.",10,0
  856. SRRPortName:    dc.b    "MUnix read port",0
  857. SWRPortName:    dc.b    "MUnix write port",0
  858. DEVICEText1:    dc.b    "DEVICE",0
  859. UNITText1:    dc.b    "UNIT",0
  860. YESText1:    dc.b    "YES",0
  861. AUXName:    dc.b    "MDM:",0
  862.  
  863. ;Modem control strings
  864.  
  865. ResetString:    dc.b    "ATZ",13,10,0
  866. AnswerString:    dc.b    "ATA",13,10,0
  867. HangUpString1:    dc.b    "+++",0
  868. HangUpString2:    dc.b    "ATH",13,10,0
  869.  
  870. ;Texts to output
  871.  
  872. WelcomeText1:    dc.b    "Welcome to the INTERACTIVE Systems Corporation",13,10
  873.         dc.b    "       INTERACTIVE UNIX Operating System",13,10,13,10
  874.         dc.b    "System name: tits",13,10,0
  875. WelcomeText2:    dc.b    13,10,"UNIX System V/Amiga UNIX Release 3.2",13,10
  876.         dc.b    "tits",13,10
  877.         dc.b    "Copyright (C) 1984, 1986, 1987, 1988 AT&T",13,10
  878.         dc.b    "Copyright (C) 1988, 1989, 1990, 1991 Commodore-Amiga, Inc.",13,10
  879.         dc.b    "All Rights Reserved",13,10
  880.         dc.b    "Login last used: ",13,10,0
  881. LoginText1:    dc.b    13,10,"login: ",0
  882. PasswordText1:    dc.b    13,10,"Password: ",0
  883. IncorrectText1:    dc.b    13,10,"Login incorrect",13,10,0
  884. LogFailureText1: dc.b    13,10,"Login failure",13,10,0
  885. UnknownCMDText1: dc.b    ": Command not found.",13,10,0
  886. PromptText1:    dc.b    13,10,"/usr/users/docbliny % ",0
  887. ExitText1:    dc.b    "^D",8,8,"exit",13,10,0
  888. CRLFText1:    dc.b    13,10,0
  889. OnTimeText1:    dc.b    "Minutes used: "
  890. OnTimeText2:    dc.b    "    0"
  891. OnTimeText3:    dc.b    13,10,0
  892. fstrl:        dc.b    "%5.d",0
  893.  
  894. ;Users (?!?)
  895.  
  896. ;RootName:    dc.b    "jlaine",0
  897. ;RootPass:    dc.b    "cocacola",0
  898. ;RootName:    dc.b    "tsarvela",0
  899. ;RootPass:    dc.b    "kukka",0
  900. ;RootName:    dc.b    "root",0
  901. ;RootPass:    dc.b    "enigma111",0
  902.  
  903.  
  904. ;Commands
  905.  
  906. CMD_LogOut:    dc.b    "logout",0
  907.  
  908.         ds.l    0
  909.  
  910. CMDTags:    dc.l    SYS_Output
  911. CMDAUXFile1:    dc.l    0
  912.         dc.l    TAG_DONE
  913.  
  914. ;Buffers
  915. ;
  916. ;Buffers 1 - 2 used by WaitForRing, WaitForConnect WaitUntilLF
  917. ;Buffer 3 used by WaitUntilLF
  918.  
  919. Buffer1:    dcb.b    2,0
  920. Buffer2:    dcb.b    16,0
  921. Buffer3:    dcb.b    34,0
  922.  
  923. TempBuf1:    dcb.b    34,0
  924.         end
  925.  
  926.