xref: /csrg-svn/usr.bin/f77/libU77/fseek_.c (revision 2578)
12530Sdlw /*
2*2578Sdlw char id_fseek[] = "@(#)fseek_.c	1.2";
32530Sdlw  *
42530Sdlw  * position a file associated with a fortran logical unit
52530Sdlw  *
62530Sdlw  * calling sequence:
72530Sdlw  *	ierror = fseek(lunit, ioff, ifrom)
82530Sdlw  * where:
92530Sdlw  *	lunit is an open logical unit
102530Sdlw  *	ioff is an offset in bytes relative to the position specified by ifrom
112530Sdlw  *	ifrom	- 0 means 'beginning of the file'
122530Sdlw  *		- 1 means 'the current position'
132530Sdlw  *		- 2 means 'the end of the file'
142530Sdlw  *	ierror will be 0 if successful, a system error code otherwise.
152530Sdlw  */
162530Sdlw 
172530Sdlw #include	<stdio.h>
182530Sdlw #include	"../libI77/f_errno.h"
192530Sdlw #include	"../libI77/fiodefs.h"
202530Sdlw 
212530Sdlw extern unit units[];
222530Sdlw 
232530Sdlw long fseek_(lu, off, from)
242530Sdlw long *lu, *off, *from;
252530Sdlw {
26*2578Sdlw 	if (*lu < 0 || *lu >= MXUNIT)
27*2578Sdlw 		return((long)(errno=F_ERUNIT));
28*2578Sdlw 	if (*from < 0 || *from > 2)
292530Sdlw 		return((long)(errno=F_ERARG));
302530Sdlw 	if (!units[*lu].ufd)
312530Sdlw 		return((long)(errno=F_ERNOPEN));
322530Sdlw 	if (fseek(units[*lu].ufd, *off, (int)*from) < 0)
332530Sdlw 		return((long)errno);
342530Sdlw 	return(0L);
352530Sdlw }
36