.title fgetr Get a random record from an index file .ident /000007/ ; ;+ ; ; Index Get a random record from an index file ; ; Usage ; ; fgetr(buffer, maxbytes, rec, iop); ; char *buffer; ; int maxbytes; ; int rec; ; FILE *iop; ; ; Description ; ; Read a record from the indicated file. Maxbytes is the ; maximum record size. Rec is the record number. ; ; The record is read by a direct call to the file ; service GET$R routine. Your program must not mix calls ; to fget() with calls to other I/O routines, such as ; fgets(). ; ; The actual number of bytes read is returned. Returns ; null on error. You must check $$ferr for the error code. ; ; Fgetr() is not present on Unix standard I/O libraries. ; ; Internal ; ; Must be used with fopenx "x" option. Users should be ; familiar with FCS macro calls. ; ; Bugs ; ;- ; ; Edit history ; 000001 18-Nov-84 HJJ Created from FGET. ; .mcall get$r .psect c$code fgetr:: jsr r5,csv$ ;02 mov C$PMTR+6(r5),r4 ;Get IOV pointer mov C$PMTR+0(r5),r2 ;Buffer mov C$PMTR+2(r5),r1 ;Nbytes mov C$PMTR+4(r5),r3 ;record number mov r4,r0 ;R0 must point to FDB add #V$FDB,R0 ;Now it does GET$R r0,r2,r1,r3,,geterr ;Get the record mov V$FDB+F.NRBD(R4),R0 ;R0 := actual byte count jmp cret$ ;Done geterr: movb F.ERR+V$FDB(R4),R0 ;Get error code mov r0,$$ferr ;Save in $$ferr for user clr r0 ; report error jmp cret$ ;Done .end