.title fputb Output a binary block .ident /000001/ ; ;+ ; ; Index Output a binary block ; ; Usage ; ; fputb(buffer, maxbytes, lbn, iop); ; char *buffer; ; int bufsiz; ; unsigned lbn; ; FILE *iop; ; ; Description ; ; Write one or more disk blocks to the indicated file. ; Bufsiz is the buffer size and must be a multiple of ; 512. Lbn is the logical block number to write. ; ; The block is written by a direct QIO IO.WVB call. ; Your program should only use block reads or writes ; unless your very sure of the effect of mixing ; io types. ; ; This routine will not extend a file if you specify ; a lbn past the current end of file. Write to an existing ; file or preallocate the correct size. ; ; If sucessfull, the actual number of bytes written is returned. ; On error, the dsw or iosb error code is returned in $$ferr ; and the function returns NULL. ; ; Fputb will move the end of file pointer up if you write ; to a logical block higher than the current value end of ; file block value. ; ; Fputb() is not present on Unix standard I/O libraries. ; ; Internal ; ; ; Bugs ; ; Only works with RSX. Lbn should be a long, but if you ; need to write 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 fputb:: jsr r5,csv$ mov #IO.WVB, 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 C$PMTR+2(r5), r0 ; get bytes to write add #400, r0 ; round up ash #-9., r0 ; convert to blocks add C$PMTR+4(r5), r0 ; add to starting block mov C$PMTR+6(r5),r4 ;Get IOV pointer add #V$FDB, r4 ; point to fdb cmp r0, F.EFBK+2(r4) ; is this block higher blos 15$ mov r0, F.EFBK+2(r4) ; yes, replace end of block # 15$: mov $$iosb+2, r0 ; get bytes written br 30$ 20$: mov r0, $$ferr ; r0 has status of $$qiow clr r0 ; NULL indicates error 30$: jmp cret$ ;Done .end