]> git.sur5r.net Git - cc65/blob - libsrc/common/fdopen.c
Removed (pretty inconsistently used) tab chars from source code base.
[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     register FILE* f;
25
26     /* Find a free file slot */
27     if ((f = _fdesc ())) {
28         /* Insert the handle, and return the descriptor */
29         f->f_fd    = handle;
30         f->f_flags = _FOPEN;
31     } else {
32         /* No slots */
33         _seterrno (EMFILE);      /* Too many files */
34     }
35
36     /* Return the file descriptor */
37     return f;
38 }
39
40
41
42