aboutsummaryrefslogtreecommitdiff
path: root/sys/mtio/mtskip.x
blob: f51948a4c7a11734218c01c85c7d448d49f1b485 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<fset.h>

# MT_SKIP_RECORD -- Skip records on an opened file.  Return the actual number
# of records skipped; stop if EOF is reached.

int procedure mt_skip_record (fd, nrecords)

int	fd				#I magtape device
int	nrecords			#I number of records to skip

pointer	sp, buf
int	n, bufsize
errchk	aread, await
int	await(), fstati()

begin
	call smark (sp)
	bufsize = fstati (fd, F_BUFSIZE)
	call salloc (buf, bufsize, TY_CHAR)

	for (n=1;  n <= nrecords;  n=n+1) {
	    call aread (fd, Memc[buf], bufsize, 0)
	    if (await (fd) == EOF)
		break
	}

	call sfree (sp)
	return (n-1)
end