.title fgetb Input a binary block .ident /000001/ ; ;+ ; ; Index Input a binary block ; ; Usage ; ; fgetb(buffer, maxbytes, lbn, iop); ; char *buffer; ; int bufsiz; ; unsigned lbn; ; FILE *iop; ; ; Description ; ; Read one or more disk blocks from the indicated file. ; Bufsiz is the buffer size and must be a multiple of ; 512. Lbn is the logical block number to read. ; ; The block is read by a direct QIO IO.RVB call. ; Your program should only use block reads or writes ; unless your very sure of the effect of mixing ; IO types. ; ; If sucessfull, the actual number of bytes read is returned. ; On error, NULL is returned. The actual error can be found ; in $$ferr. ; ; Fgetb() is not present on Unix standard I/O libraries. ; ; Internal ; ; You may get the IO status block used by defining $$iosb as ; extern int $$iosb[2] in your program. This routine uses event ; flag 1. ; ; Bugs ; ; Only works with RSX. Lbn should be a long, but if you ; need to read more than 65K blocks into a file, you know ; how to fix this routine. ; ;- ; ; Edit history ; 000001 16-sep-84 HJJ Initial edit ; 000002 12-jun-85 hjj routine now passes error code back in $$ferr .ident /000002/ .psect c$code fgetb:: jsr r5,csv$ mov #IO.RVB, r0 ; io code mov C$PMTR+6(r5),r4 ;Get IOV pointer clr -(sp) ; push qio params mov C$PMTR+4(r5), -(sp) ;lbn (low part) clr -(sp) ; lbn high part clr -(sp) ; blank mov C$PMTR+2(r5), -(sp) ;Nbytes mov C$PMTR+0(r5), -(sp) ;Buffer call $$qiow ; do it bcs 20$ ; it broke mov r0, $$ferr ; r0 has status of $$qiow mov $$iosb+2, r0 ; get bytes read br 30$ ; bye 20$: mov r0, $$ferr ; r0 has status of $$qiow clr r0 ; return NULL for error 30$: jmp cret$ ;Done .end