2000-05-28 13:40:48 +00:00
|
|
|
/*
|
2002-11-24 19:17:16 +00:00
|
|
|
* fdopen.c
|
2000-05-28 13:40:48 +00:00
|
|
|
*
|
|
|
|
* Ullrich von Bassewitz, 17.06.1998
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include "_file.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-11-06 18:04:07 +00:00
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Code */
|
2003-11-06 18:04:07 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FILE* __fastcall__ fdopen (int handle, const char* /*mode*/)
|
2000-05-28 13:40:48 +00:00
|
|
|
{
|
2012-06-10 18:25:22 +00:00
|
|
|
register FILE* f;
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
/* Find a free file slot */
|
2012-06-10 18:25:22 +00:00
|
|
|
if ((f = _fdesc ())) {
|
|
|
|
/* Insert the handle, and return the descriptor */
|
|
|
|
f->f_fd = handle;
|
|
|
|
f->f_flags = _FOPEN;
|
|
|
|
} else {
|
2013-05-09 11:56:54 +00:00
|
|
|
/* No slots */
|
|
|
|
_seterrno (EMFILE); /* Too many files */
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the file descriptor */
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|