2 * fdopen - convert a (UNIX) file descriptor into a FILE pointer
7 #include "../stdio/loc_incl.h"
21 if (fd
< 0) return (FILE *)NULL
;
22 for (i
= 0; __iotab
[i
] != 0 ; i
++)
28 flags
|= _IOREAD
| _IOREADING
;
33 flags
|= _IOWRITE
| _IOWRITING
;
43 flags
|= _IOREAD
| _IOWRITE
;
45 /* The sequence may be followed by aditional characters */
52 if ( fstat( fd
, &st
) < 0 ) {
56 if ( st
.st_mode
& S_IFIFO
) {
60 if ((stream
= (FILE *) malloc(sizeof(FILE))) == NULL
) {
64 if ((flags
& _IOREAD
) && (flags
& _IOWRITE
))
65 flags
&= ~(_IOREADING
| _IOWRITING
);
69 stream
->_flags
= flags
;