xref: /csrg-svn/usr.bin/f77/libU77/ftell_.c (revision 47944)
1*47944Sbostic /*-
2*47944Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic  * All rights reserved.
42531Sdlw  *
5*47944Sbostic  * %sccs.include.proprietary.c%
623017Skre  */
723017Skre 
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)ftell_.c	5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic 
1223017Skre /*
132531Sdlw  * return current file position
142531Sdlw  *
152531Sdlw  * calling sequence:
162531Sdlw  *	integer curpos, ftell
172531Sdlw  *	curpos = ftell(lunit)
182531Sdlw  * where:
192531Sdlw  *	lunit is an open logical unit
202531Sdlw  *	curpos will be the current offset in bytes from the start of the
212531Sdlw  *		file associated with that logical unit
222531Sdlw  *		or a (negative) system error code.
232531Sdlw  */
242531Sdlw 
252531Sdlw #include	"../libI77/fiodefs.h"
262531Sdlw #include	"../libI77/f_errno.h"
272531Sdlw 
282531Sdlw extern unit units[];
292531Sdlw 
ftell_(lu)302531Sdlw long ftell_(lu)
312531Sdlw long *lu;
322531Sdlw {
332531Sdlw 	if (*lu < 0 || *lu >= MXUNIT)
342580Sdlw 		return(-(long)(errno=F_ERUNIT));
352531Sdlw 	if (!units[*lu].ufd)
362531Sdlw 		return(-(long)(errno=F_ERNOPEN));
372531Sdlw 	return(ftell(units[*lu].ufd));
382531Sdlw }
39