home *** CD-ROM | disk | FTP | other *** search
- *****************************************
- * MountENV *
- * Mount tool for HappyENV-Handler *
- * 0.8 31.8.96 *
- *****************************************
-
- ; MountENV is Public Domain
-
- ;Can be started from WB and CLI
- ;Tabsize=8
-
- INCDIR source:include/
- INCLUDE exec/exec_lib.i
- INCLUDE dos/dos_lib.i
- INCLUDE libraries/expansion_lib.i
-
- pr_CLI = 172
- pr_MsgPort = 92
- pr_CurrentDir = 152
- sm_NumArgs = 28
- sm_ArgList = 36
-
- dn_Next = 0
- dn_Type = 4
- dn_Task = 8
- dn_Lock = 12
- dn_Handler = 16
- dn_StackSize = 20
- dn_Priority = 24
- dn_Startup = 28
- dn_SegList = 32
- dn_GlobalVec = 36
- dn_Name = 40
- dn_SIZEOF = 44
-
- ACCESS_READ = -2
-
- ;init place for needed structures on stack
- start moveq #20,d5 ;set return-code to FAIL
- move.l 4.w,a6 ;exec-base to a6
- sub.l a1,a1
- jsr _LVOFindTask(a6) ;find this task
- move.l d0,a4 ;a4=this task
-
- ;check for WB or CLI start
- moveq #0,d6 ;reset WB-msg
- tst.l pr_CLI(a4) ;a4=this task
- bne.s .CLI
- lea pr_MsgPort(a4),a0 ;it was WB-start
- jsr _LVOWaitPort(a6)
- lea pr_MsgPort(a4),a0
- jsr _LVOGetMsg(a6)
- move.l d0,d6 ;d6=message from WB
-
- .CLI lea dosname(pc),a1 ;open dos.library
- moveq #30,d0
- jsr _LVOOpenLibrary(a6)
- tst.l d0
- beq Ende2
- move.l d0,a6
- lea envarc(pc),a0
- move.l a0,d1
- moveq #ACCESS_READ,d2
- jsr _LVOLock(a6) ;make real assign out of
- move.l d0,d1 ;defer assign to ENVARC:
- beq.s .A
- jsr _LVOUnLock(a6)
- .A move.l a6,a1
- move.l 4.w,a6
- jsr _LVOCloseLibrary(a6)
-
- moveq #dn_SIZEOF,d0 ;get mem for device node
- move.l #1<<16!1,d1
- jsr _LVOAllocMem(a6)
- tst.l d0
- beq.s Ende2
- move.l d0,a2
-
- moveq #handend-handler,d0 ;init device node
- lea handler(pc),a1
- bsr CopyBSTR
- beq.s Ende2
- move.l d0,dn_Handler(a2)
- move.l #2000,dn_StackSize(a2)
- moveq #5,d0
- move.l d0,dn_Priority(a2)
- moveq #-1,d0
- move.l d0,dn_GlobalVec(a2)
- moveq #envend-envname,d0
- lea envname(pc),a1
- bsr CopyBSTR
- beq.s Ende2
- move.l d0,dn_Name(a2)
-
- lea expname(pc),a1 ;open expansion.library
- moveq #30,d0
- move.l 4.w,a6
- jsr _LVOOpenLibrary(a6)
- tst.l d0
- beq.s Ende2
- move.l d0,a6
- move.l a2,a0 ;add new device node
- moveq #0,d0
- moveq #0,d1
- jsr _LVOAddDosNode(a6)
- tst.l d0
- beq.s Ende3
- moveq #0,d5 ;set return code to OK
-
- ;clean up all things used
- Ende3 move.l a6,a1
- move.l 4.w,a6
- jsr _LVOCloseLibrary(a6)
-
- ;end program
- Ende2 move.l d5,d0 ;set return-code
- tst.l d6 ;wb-msg ? -> started from WB
- bne.s .Jump
- rts ;THE END ! from CLI
- .Jump jsr _LVOForbid(a6) ;must be in forbid-state
- move.l d6,a1
- jmp _LVOReplyMsg(a6) ;THE END ! from WB
-
-
- CopyBSTR ;entry: d0=size, a1=string
- ;exit: d0=BSTR
- movem.l a0-a2/a6,-(sp)
- move.l a1,a2
- moveq #1,d1
- move.l 4.w,a6
- jsr _LVOAllocMem(a6)
- move.l d0,a1
- lsr.l #2,d0
- beq.s .end
- .loop move.b (a2)+,(a1)+
- bne.s .loop
- tst.l d0
- .end movem.l (sp)+,a0-a2/a6
- rts
-
- version dc.b "$VER: MountENV 0.8 (31.8.96)",10,0
- dosname dc.b "dos.library",0
- expname dc.b "expansion.library",0
- envarc dc.b "ENVARC:",0
- handler dc.b 18,"L:HappyENV-Handler",0
- handend
- envname dc.b 3,"ENV",0
- envend
- end
-
-