.title gets ; ; function to read a record from a VMS file ; ; call sequence n = gets(rab, buffer, size) ; ; where rab is the integer descriptor from an openf call ; buffer is a character buffer to receive the record ; size is the size of the buffer ; ; returns -3(ERR) if error reading record ; number of bytes read if successful ; err=-3 rab=4 ; offset from ap for rab address buf=8 ; offset from ap for buf address siz=12 ; offset from ap for size of buf .psect st_gets_data rel,con,gbl,noexe,wrt,rd,pic,noshr,usr,novec,long msg: .ascid "Record too large for buffer - truncated" .psect st_pure_code rel,con,lcl,exe,nowrt,rd,pic,shr,usr,novec,long .entry gets ^m movl @rab(ap),r2 ; rab address in r2 movl buf(ap),rab$l_ubf(r2) ; user buffer address in rab movw @siz(ap),rab$w_usz(r2) ; size of buffer in rab $get rab=r2 blbs r0,10$ ; low bit set => success cmpl r0,#rms$_rtb ; record too big? bneq error ; no, real hard error pushal msg ; report error to user calls #1,g^lib$put_output ; ... 10$: movzwl rab$w_rsz(r2),r0 ; number of bytes in record returned movl rab$w_rfa(r2),rab_l_curbl(r2) ; save current RFA movw rab$w_rfa+4(r2),rab_l_curby(r2) ; ret error: movl #err,r0 ret .end