arch/m68k-amiga: Define the gcc symbol 'start' instead of using .bss
[AROS.git] / compiler / clib / ftell.c
blobe0493259bd474de528a6357719b272bbb6418eea
1 /*
2 Copyright © 1995-2003, 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 "__errno.h"
12 #include "__stdio.h"
13 #include "__fdesc.h"
15 /*****************************************************************************
17 NAME */
18 #include <stdio.h>
20 long ftell (
22 /* SYNOPSIS */
23 FILE * stream)
25 /* FUNCTION
26 Tell the current position in a stream.
28 INPUTS
29 stream - Obtain position of this stream
31 RESULT
32 The position on success and -1 on error.
33 If an error occurred, the global variable errno is set.
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 fopen(), fseek(), fwrite()
44 INTERNALS
46 ******************************************************************************/
48 long cnt;
49 BPTR fh;
50 fdesc *fdesc = __getfdesc(stream->fd);
52 if (!fdesc)
54 errno = EBADF;
55 return 0;
58 fh = (BPTR)(fdesc->fcb->fh);
60 Flush (fh);
61 cnt = Seek (fh, 0, OFFSET_CURRENT);
63 if (cnt == -1)
64 errno = IoErr2errno (IoErr ());
66 return cnt;
67 } /* ftell */