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
|
|
|
/*****************************************************************************/
|
|
|
|
/* Code */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FILE* __fastcall__ fdopen (int handle, const char* /*mode*/)
|
2000-05-28 13:40:48 +00:00
|
|
|
{
|
|
|
|
FILE* f;
|
|
|
|
|
|
|
|
/* Find a free file slot */
|
|
|
|
if (!(f = _fdesc ())) {
|
|
|
|
/* No slots */
|
2010-06-03 20:18:43 +00:00
|
|
|
return (FILE*) _seterrno (EMFILE); /* Too many files */
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Insert the handle, and return the descriptor */
|
|
|
|
f->f_fd = handle;
|
|
|
|
f->f_flags = _FOPEN;
|
|
|
|
|
|
|
|
/* Return the file descriptor */
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|