xref: /original-bsd/usr.bin/f77/libU77/fseek_.c (revision 14b684c9)
1 /*
2 char id_fseek[] = "@(#)fseek_.c	1.1";
3  *
4  * position a file associated with a fortran logical unit
5  *
6  * calling sequence:
7  *	ierror = fseek(lunit, ioff, ifrom)
8  * where:
9  *	lunit is an open logical unit
10  *	ioff is an offset in bytes relative to the position specified by ifrom
11  *	ifrom	- 0 means 'beginning of the file'
12  *		- 1 means 'the current position'
13  *		- 2 means 'the end of the file'
14  *	ierror will be 0 if successful, a system error code otherwise.
15  */
16 
17 #include	<stdio.h>
18 #include	"../libI77/f_errno.h"
19 #include	"../libI77/fiodefs.h"
20 
21 extern unit units[];
22 
23 long fseek_(lu, off, from)
24 long *lu, *off, *from;
25 {
26 	if (*lu < 0 || *lu >= MXUNIT || *from < 0 || *from > 2)
27 		return((long)(errno=F_ERARG));
28 	if (!units[*lu].ufd)
29 		return((long)(errno=F_ERNOPEN));
30 	if (fseek(units[*lu].ufd, *off, (int)*from) < 0)
31 		return((long)errno);
32 	return(0L);
33 }
34