]> git.sur5r.net Git - cc65/blob - libsrc/common/fopen.c
Reintroduce a patch for a bug that has been lost between version 1.2 and 1.3
[cc65] / libsrc / common / fopen.c
1 /*
2  * fopen.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 FILE* fopen (const char* name, const char* mode)
17 {
18     FILE* f;
19
20     /* Find a free file slot */
21     if (!(f = _fdesc ())) {
22         /* No slots */
23         _errno = EMFILE;                /* Too many files */
24         return 0;
25     }
26
27     /* Open the file and return the descriptor */
28     return _fopen (name, mode, f);
29 }
30
31
32