; Slayer - a desktop anti-virus for RISC OS
; Copyright (C) 1996 - 2000 Kiwi Software (UK)
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
;
; info@kiwisoft.co.uk
; -------------------------------------------------------------------------


;
			funcName "link_removal"

.kill_link		;grab details about the file
 			mov	r0,#5
			swi	XOS_File
			bvs	exit_from_error
			;r4 is now the file-length
			mov	r7,r4 ;file length
			mov	r0,#&C0
			swi	XOS_Find
			bvs	exit_from_error

			mov	r10,r0  ;filehandle is now in r10
			mov	r0,#3
			mov	r1,r10
			adr	r2,scrap_block
			mov	r3,#4
			mov	r4,#8
			swi	XOS_GBPB
			bvs	exit_from_error
			;now grab eor value from (header+8)+44
			adr	r2,scrap_block
			ldr	r4,[r2]
			mov	r0,#&7FD4
			sub	r4,r4,r0   ;add 44 and sub &8000

			mov	r0,#3
			mov	r1,r10
			mov	r3,#4
			swi	XOS_GBPB
			bvs	exit_from_error
			adr	r2,scrap_block
			ldr	r11,[r2]   ;eor word

			;eor header words
			mov	r3,#12
			add	r4,r4,#&30
			swi	XOS_GBPB
			bvs	exit_from_error

			adr	r2,scrap_block
			ldr	r0,[r2,#0]
			eor	r0,r0,r11
			str	r0,[r2,#0]
			ldr	r0,[r2,#4]
			eor	r0,r0,r11
			str	r0,[r2,#4]
			ldr	r0,[r2,#8]
			eor	r0,r0,r11
			str	r0,[r2,#8]


			mov	r0,#1
			mov	r3,#12
			mov	r4,#0

			swi	XOS_GBPB ;write the new header back out
			bvs	exit_from_error

 			;and now truncate the file

			mov	r0,#3
			mov	r1,r10
			sub	r2,r7,#&4C0
			swi	XOS_Args
			bvs	exit_from_error

			mov	r0,#0
			swi	XOS_Find
			bvs	exit_from_error

			mov	r0,#0
			ldmfd	r13!,{pc}	;unstack and return to caller

