]> git.sur5r.net Git - cc65/blob - libsrc/common/ftell.c
New loadable mouse drivers
[cc65] / libsrc / common / ftell.c
1 /*
2  * ftell.c
3  *
4  * Christian Groessler, 07-Aug-2000
5  */
6
7
8
9 #include <stdio.h>
10 #include <errno.h>
11 #include <unistd.h>
12 #include "_file.h"
13
14
15
16 /*****************************************************************************/
17 /*                                   Code                                    */
18 /*****************************************************************************/
19
20
21
22 long __fastcall__ ftell (FILE* f)
23 {
24     long pos;
25
26     /* Is the file open? */
27     if ((f->f_flags & _FOPEN) == 0) {
28         _errno = EINVAL;                /* File not open */
29         return -1L;
30     }
31
32     pos = lseek(f->f_fd, 0L, SEEK_CUR);
33     return pos;    /* -1 for error, comes from lseek() */
34 }
35