xref: /csrg-svn/usr.bin/f77/libU77/ftell_.c (revision 2531)
1*2531Sdlw /*
2*2531Sdlw char id_ftell[] = "@(#)ftell_.c	1.1";
3*2531Sdlw  *
4*2531Sdlw  * return current file position
5*2531Sdlw  *
6*2531Sdlw  * calling sequence:
7*2531Sdlw  *	integer curpos, ftell
8*2531Sdlw  *	curpos = ftell(lunit)
9*2531Sdlw  * where:
10*2531Sdlw  *	lunit is an open logical unit
11*2531Sdlw  *	curpos will be the current offset in bytes from the start of the
12*2531Sdlw  *		file associated with that logical unit
13*2531Sdlw  *		or a (negative) system error code.
14*2531Sdlw  */
15*2531Sdlw 
16*2531Sdlw #include	"../libI77/fiodefs.h"
17*2531Sdlw #include	"../libI77/f_errno.h"
18*2531Sdlw 
19*2531Sdlw extern unit units[];
20*2531Sdlw 
21*2531Sdlw long ftell_(lu)
22*2531Sdlw long *lu;
23*2531Sdlw {
24*2531Sdlw 	if (*lu < 0 || *lu >= MXUNIT)
25*2531Sdlw 		return(-(long)(errno=F_ERARG));
26*2531Sdlw 	if (!units[*lu].ufd)
27*2531Sdlw 		return(-(long)(errno=F_ERNOPEN));
28*2531Sdlw 	return(ftell(units[*lu].ufd));
29*2531Sdlw }
30