home *** CD-ROM | disk | FTP | other *** search
-
- ;
- ;
- ; LibraryKiller V1.0
- ;
- ;
- ;
- ; Author : Roger Fischlin
- ; Steigerwaldweg 6
- ; 6450 Hanau 7
- ; West Germany
- ;
- ;
- ;
- ; This program may be freely distributed .
- ;
- ;
- ;
- ; Assembler : DevPac V2
- ;
- ;
-
-
- incdir "ram:include/"
-
- include exec/memory.i
- include exec/exec_lib.i
- include exec/execbase.i
- include exec/libraries.i
- include exec/lists.i
- include exec/nodes.i
- include libraries/dos_lib.i
- include libraries/dos.i
-
-
-
- CALL_DOS macro
- move.l -SP_DosBase(a5),a6
- jsr _LVO\1(a6)
- endm
- CALL_INT macro
- move.l -SP_IntBase(a5),a6
- jsr _LVO\1(a6)
- endm
- CALL_GFX macro
- move.l -SP_GfxBase(a5),a6
- jsr _LVO\1(a6)
- endm
-
- rsreset
- SP_A0 rs.l 1
- SP_D0 rs.l 1
- SP_DosBase rs.l 1
- SP_Text rs.b 82
-
- SP_SIZEOF rs.w 0
-
-
-
-
- OpenThem link a5,#-SP_SIZEOF
-
- clr.b -1(a0,d0) ; terminate string with 0
-
- move.l a0,-SP_A0(a5) ; save d0/a0
- move.l d0,-SP_D0(a5)
-
- lea dosname(pc),a1 ; open library
- CALLEXEC OldOpenLibrary
- move.l d0,-SP_DosBase(a5)
-
- move.l -SP_A0(a5),a0 ; no command line
- tst.b (a0)
- beq LIST
- cmp.b #"?",(a0) ; command line "?"
- beq Info
-
- jsr REMOVE
-
- CloseLib move.l -SP_DosBase(a5),a1 ; close library
- CALLEXEC CloseLibrary
-
- moveq.l #0,d0
- unlk a5
- rts
-
-
- Info CALL_DOS Output ; write info text
- move.l d0,d1
- lea.l .Text(pc),a0
- move.l a0,d2
- move.l #.TextEnd-.Text,d3
- CALL_DOS Write
- bra CloseLib
-
- .Text dc.b $a,$9b,"1;33;40m"
- dc.b " LibraryKiller V1.0 (5-April-1990)"
- dc.b $9b,"0;32;40m",$a
- dc.b "Author : Roger Fischlin, Steigerwaldweg 6, 6450 Hanau 7, West Germany",$a
- dc.b $9b,"0;31;40m",$a
- dc.b "LibraryKiller removes libraries which are not used any more. This",$a
- dc.b "program may freely distributed.",$a,$a
- dc.b "Usage: LibraryKiller » list all libraries",$a
- dc.b " LibraryKiller <library name> » remove library ( '*' allowed )",$a
- dc.b " LibraryKiller * » remove all libraries",$a,$a
- .TextEnd
- even
-
- dosname DOSNAME
-
-
-
- ******************************************************************
- * search libraries and remove them *
- ******************************************************************
-
-
- REMOVE move.l 4.w,a2 ; exec structure
- lea.l LibList(a2),a2 ; 1st library node
- CALLEXEC Forbid ; another task could add a new library or remove one ....
-
- .Label2 move.l (a2),d0 ; first node
- beq .NotFound ; empty list ?
- .Label4 move.l d0,a2
- move.l (a2),d0 ; pointer to 0
- beq .NotFound
-
- move.l LN_NAME(a2),a1 ; compare names
- move.l -SP_A0(a5),a0
- .Label1 cmp.b #"*",(a0) ; "*" ?
- beq .Found
- cmpm.b (a0)+,(a1)+
- bne.s .Label2
- tst.b -1(a1) ; end of string (0) ?
- bne .Label1
-
-
-
- .Found CALL_DOS Output
- move.l d0,d1
- move.l LN_NAME(a2),a0 ; write libary name
- move.l a0,d2
- moveq.l #-1,d3
- .Label3 addq.l #1,d3
- tst.b (a0)+
- bne.s .Label3
- CALL_DOS Write
-
- cmp.l d0,d3 ; error ?
- bne .NotFound
-
- move.l (a2),d5 ; save pointer
-
- lea.l .InUseText(pc),a0
- move.l a0,d2
- tst.w LIB_OPENCNT(a2) ; nobody uses this library
- bne .NoError ; library still in use ...
-
- move.l a2,a1
- CALLEXEC RemLibrary ; remove library (that's all !!!)
-
- lea.l .RemoveText(pc),a0
- move.l a0,d2
- tst.l d0
- bne.s .NoError
- lea.l .RemoveError(pc),a0
- move.l a0,d2
-
- .NoError CALL_DOS Output ; write result
- move.l d0,d1
- move.l #20,d3
- CALL_DOS Write
- cmp.l d0,d3 ; error ?
- bne.s .NotFound
-
- move.l d5,d0 ; next node
- beq.s .NotFound ; last ?
- bra .Label4
-
- .NotFound CALLEXEC Permit
- rts
-
-
- .RemoveText dc.b " : removed. ",$a
- .InUseText dc.b " : still in use ! ",$a
- .RemoveError dc.b " : remove failed !",$a
-
-
-
- ******************************************************************
- * list all libraries *
- ******************************************************************
-
- LIST CALL_DOS Output ; write first line
- move.l d0,d1
- lea .Header(pc),a0
- move.l a0,d2
- move.l #.HeaderEnd-.Header,d3
- CALL_DOS Write
-
-
-
- move.l 4.w,a2 ; exec structure
- lea.l LibList(a2),a2 ; 1st library node
-
- .Label2 move.l (a2),d0 ; first node
- beq .NoMore ; empty list ?
- move.l d0,a2
- move.l (a2),d0 ; pointer to 0
- beq .NoMore
-
-
- lea -SP_Text-80(a5),a1 ; clear
- move.w #77,d0
- .Label1 move.b #" ",(a1)+
- dbra d0,.Label1
- move.b #$a,(a1)+
-
- move.l LN_NAME(a2),a1 ; copy name
- lea -SP_Text-80(a5),a0
- move.w #19,d0
- .Label3 move.b (a1)+,(a0)+
- dbeq d0,.Label3
-
- moveq.l #0,d0
- move.b LN_TYPE(a2),d0 ; write Type
- lea -SP_Text-80+62-32+1(a5),a0
- bsr .Write4
-
- lea -SP_Text-80+70-32+1(a5),a0
- moveq.l #0,d0
- move.b LN_PRI(a2),d0 ; write Pri
- bpl.s .Positive ; positive ?
- neg.b d0
- move.b #"-",(a0) ; write "-"
- .Positive bsr .Write4
-
- move.w LIB_OPENCNT(a2),d0 ; write OpenCount
- lea -SP_Text-80+78-32+1(a5),a0
- bsr .Write4
-
- move.w LIB_VERSION(a2),d0 ; write version
- lea -SP_Text-80+86-32+1(a5),a0
- bsr .Write4
-
- move.w LIB_REVISION(a2),d0 ; write revision
- lea -SP_Text-80+93-32+1(a5),a0
- bsr .Write4
-
- move.w LIB_NEGSIZE(a2),d0 ; write size
- lea -SP_Text-80+99-32+1(a5),a0
- bsr .Write4
- move.w LIB_POSSIZE(a2),d0
- lea -SP_Text-80+105-32+1(a5),a0
- bsr .Write4
-
- move.l a2,d0 ; write library base
- lea -SP_Text-80+52-32+1(a5),a0
- move.b #"$",(a0)+
- moveq.l #7,d2 ; 8 nibble
- moveq.l #0,d1
- .Label6 rol.l #4,d0 ; get next nibble and
- move.b d0,d1 ; move to lowest nibble
- and.b #$f,d1
- cmp.b #10,d1
- blt.s .Label7
- add.b #"A"-"0"-10,d1 ; offset for letters
- .Label7 add.b #"0",d1 ; convert to ASCII
- move.b d1,(a0)+
- dbra d2,.Label6
-
- CALL_DOS Output ; write line
- move.l d0,d1
- lea -SP_Text-80(a5),a0
- move.l a0,d2
- move.l #78,d3
- CALL_DOS Write
- cmp.l d3,d0 ; error ?
- bne.s .Error
-
- bra .Label2 ; next entry
-
-
-
-
- .NoMore CALL_DOS Output ; write LF
- move.l d0,d1
- lea .Return(pc),a0
- move.l a0,d2
- moveq.l #2,d3
- CALL_DOS Write
-
- .Error bra CloseLib
-
-
-
-
- .Write4 and.l #$ffff,d0
- move.w #"0",d1 ; Word -> ASCII
- cmp.w #999,d0
- bls.s .Label_W1
- divu #1000,d0
- add.b d1,d0
- move.b d0,(a0)
- clr.w d0
- swap d0
- .Label_W1 cmp.w #99,d0
- bls.s .Label_W2
- divu #100,d0
- add.b d1,d0
- move.b d0,1(a0)
- clr.w d0
- swap d0
- .Label_W2 cmp.w #9,d0
- bls.s .Label_W3
- divu #10,d0
- add.b d1,d0
- move.b d0,2(a0)
- clr.w d0
- swap d0
- .Label_W3 add.b d1,d0
- move.b d0,3(a0)
- rts
-
-
-
- .Header dc.b $a,$9b,"0;33;40m"
- dc.b " Libraries",$a,$a
- dc.b $9b,"4;32;40m"
- dc.b "Name Address Type Pri. OpenCnt Vers. Rev. Neg. Pos."
- dc.b $9b,"0;31;40m",$a
- .HeaderEnd
- even
- .Return dc.b $a,$a
-
-
-