Listtree.mcc: use internal inherited class of NListtree
[AROS.git] / compiler / posixc / ftell.c
blob415fcf1c72a6704e5674c636843fe42d8f0e1f42
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Tell the position in a stream.
6 */
8 #include <errno.h>
9 #include <dos/dos.h>
10 #include <proto/dos.h>
11 #include "__stdio.h"
12 #include "__fdesc.h"
14 /*****************************************************************************
16 NAME */
17 #include <stdio.h>
19 long ftell (
21 /* SYNOPSIS */
22 FILE * stream)
24 /* FUNCTION
25 Tell the current position in a stream.
27 INPUTS
28 stream - Obtain position of this stream
30 RESULT
31 The position on success and -1 on error.
32 If an error occurred, the global variable errno is set.
34 NOTES
36 EXAMPLE
38 BUGS
40 SEE ALSO
41 fopen(), fseek(), fwrite()
43 INTERNALS
45 ******************************************************************************/
47 long cnt;
48 BPTR fh;
49 fdesc *fdesc = __getfdesc(stream->fd);
51 if (!fdesc)
53 errno = EBADF;
54 return 0;
57 fh = fdesc->fcb->handle;
59 Flush (fh);
60 cnt = Seek (fh, 0, OFFSET_CURRENT);
62 if (cnt == -1)
63 errno = __stdc_ioerr2errno (IoErr ());
65 return cnt;
66 } /* ftell */