BSD 3 development
[unix-history] / usr / src / lib / libNS / ftell.c
CommitLineData
1bd0b214
BJ
1/* Copyright (c) 1979 Regents of the University of California */
2#include <stdio.h>
3
4/*
5 * Return file offset.
6 * Coordinates with buffering.
7 */
8
9long tell();
10
11long ftell(iop)
12register FILE *iop;
13{
14 long tres;
15 register adjust;
16
17 if (iop->_cnt < 0)
18 iop->_cnt = 0;
19 if (!(iop->_flag & (_IOREAD|_IOWRT)))
20 _error("ftell\n");
21 tres = tell(fileno(iop));
22 if (tres<0)
23 return(tres);
24 return(tres - iop->_delta + iop->_ptr - iop->_base);
25}