xref: /csrg-svn/usr.bin/f77/libU77/ftell_.c (revision 2580)
12531Sdlw /*
2*2580Sdlw char id_ftell[] = "@(#)ftell_.c	1.2";
32531Sdlw  *
42531Sdlw  * return current file position
52531Sdlw  *
62531Sdlw  * calling sequence:
72531Sdlw  *	integer curpos, ftell
82531Sdlw  *	curpos = ftell(lunit)
92531Sdlw  * where:
102531Sdlw  *	lunit is an open logical unit
112531Sdlw  *	curpos will be the current offset in bytes from the start of the
122531Sdlw  *		file associated with that logical unit
132531Sdlw  *		or a (negative) system error code.
142531Sdlw  */
152531Sdlw 
162531Sdlw #include	"../libI77/fiodefs.h"
172531Sdlw #include	"../libI77/f_errno.h"
182531Sdlw 
192531Sdlw extern unit units[];
202531Sdlw 
212531Sdlw long ftell_(lu)
222531Sdlw long *lu;
232531Sdlw {
242531Sdlw 	if (*lu < 0 || *lu >= MXUNIT)
25*2580Sdlw 		return(-(long)(errno=F_ERUNIT));
262531Sdlw 	if (!units[*lu].ufd)
272531Sdlw 		return(-(long)(errno=F_ERNOPEN));
282531Sdlw 	return(ftell(units[*lu].ufd));
292531Sdlw }
30