; Scanning from filehandle code for VDEngine
; 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
; -------------------------------------------------------------------------



; main entry point
; =>	r1 Pointer to file name
;
; <= 	r0 Result of check
;	/no/ other registers preserved

; free regs are: r9, r10, r11, r12(temp)
; usable regs are: r0-r6
; /must/ preserve r7, r8

; pc on entry already stacked
.scan_from_filehandle

 ; grab file info
 		mov	r0,#2	;read extent
 		;r1 already contains filehandle
 		swi	OS_Args
 		mov	filelength,r2

; read first and last xxx bytes

 		mov	r0,#3			;read bytes
 		;r1 already contains file handle
 		adr	r2,bufferTopOfFile
 		mov	r3,#FILE_TOP_BUFFER_SIZE
 		mov	r4,#0
 		swi	XOS_GBPB
 		ldmvsfd	r13!,{pc}		;error - leave

 		;r1 already contains file handle
 		adr	r2,bufferBottomOfFile
 		mov	r3,#FILE_BOTTOM_BUFFER_SIZE
		sub	r4,filelength,r3

 		;file might not be big enough...
 		cmp	filelength,r3
 		sublt	r3,r3,filelength	;filelength-buffer size
 		addlt	r2,r2,r3	;add that to buffer pointer
		movlt	r4,#0		;read from start
		movlt	r3,filelength	;read /all/ bytes from file

 		mov	r0,#3			;read bytes
 		swi	XOS_GBPB
 		ldmvsfd	r13!,{pc}		;error - leave

; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; We have the memory, now do the actual checks

#include 	"VDEng:main.s.Scan4All"

; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

