xref: /csrg-svn/usr.bin/f77/libU77/ftell_.c (revision 23017)
12531Sdlw /*
2*23017Skre  * Copyright (c) 1980 Regents of the University of California.
3*23017Skre  * All rights reserved.  The Berkeley software License Agreement
4*23017Skre  * specifies the terms and conditions for redistribution.
52531Sdlw  *
6*23017Skre  *	@(#)ftell_.c	5.1	06/07/85
7*23017Skre  */
8*23017Skre 
9*23017Skre /*
102531Sdlw  * return current file position
112531Sdlw  *
122531Sdlw  * calling sequence:
132531Sdlw  *	integer curpos, ftell
142531Sdlw  *	curpos = ftell(lunit)
152531Sdlw  * where:
162531Sdlw  *	lunit is an open logical unit
172531Sdlw  *	curpos will be the current offset in bytes from the start of the
182531Sdlw  *		file associated with that logical unit
192531Sdlw  *		or a (negative) system error code.
202531Sdlw  */
212531Sdlw 
222531Sdlw #include	"../libI77/fiodefs.h"
232531Sdlw #include	"../libI77/f_errno.h"
242531Sdlw 
252531Sdlw extern unit units[];
262531Sdlw 
272531Sdlw long ftell_(lu)
282531Sdlw long *lu;
292531Sdlw {
302531Sdlw 	if (*lu < 0 || *lu >= MXUNIT)
312580Sdlw 		return(-(long)(errno=F_ERUNIT));
322531Sdlw 	if (!units[*lu].ufd)
332531Sdlw 		return(-(long)(errno=F_ERNOPEN));
342531Sdlw 	return(ftell(units[*lu].ufd));
352531Sdlw }
36