File:  [MW Coherent from dump] / coherent / b / lib / libc / stdio / ftell.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * libc/stdio/ftell.c
 * ANSI-compliant C standard i/o library.
 * ftell()
 * ANSI 4.9.9.4.
 * Find logical file position on stream.
 */

#include <stdio.h>
#include <errno.h>

#define	EFGETPOS	EINVAL

long
ftell(stream) register FILE *stream;
{
	register long offset;
	register _FILE2 *f2p;

	f2p = stream->_f2p;

	if ((offset=lseek(fileno(stream), 0L, SEEK_CUR)) == -1L) {
		errno = EFGETPOS;
		return offset;
	}
	if (f2p->_bp!=NULL)
		offset += stream->_cp - f2p->_dp;
	if (stream->_ff2&_FUNGOT)
		--offset;
	return offset;
}

/* end of libc/stdio/ftell.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.