]> git.sur5r.net Git - cc65/blob - libsrc/common/fdopen.c
Made Olivers devnum patch (r4588) work with the PET-II models. On these
[cc65] / libsrc / common / fdopen.c
1 /*
2  * fdopen.c
3  *
4  * Ullrich von Bassewitz, 17.06.1998
5  */
6
7
8
9 #include <stdio.h>
10 #include <fcntl.h>
11 #include <errno.h>
12 #include "_file.h"
13
14
15
16 /*****************************************************************************/
17 /*                                   Code                                    */
18 /*****************************************************************************/
19
20
21
22 FILE* __fastcall__ fdopen (int handle, const char* /*mode*/)
23 {
24     FILE* f;
25
26     /* Find a free file slot */
27     if (!(f = _fdesc ())) {
28         /* No slots */
29         _errno = EMFILE;                /* Too many files */
30         return 0;
31     }
32
33     /* Insert the handle, and return the descriptor */
34     f->f_fd    = handle;
35     f->f_flags = _FOPEN;
36
37     /* Return the file descriptor */
38     return f;
39 }
40
41
42
43