]> git.sur5r.net Git - cc65/blob - libsrc/common/fseek.c
New loadable mouse drivers
[cc65] / libsrc / common / fseek.c
1 /*
2  * fseek.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 int __fastcall__ fseek (FILE* f, long offset, int whence)
23 {
24     long res;
25
26     /* Is the file open? */
27     if ((f->f_flags & _FOPEN) == 0) {
28         _errno = EINVAL;                /* File not open */
29         return -1;
30     }
31
32     res = lseek(f->f_fd, offset, whence);
33     if (res == -1L) return -1;
34     return 0;
35 }
36