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