/********************************************************************** * Copyright (c) Digital Equipment Corporation 1984, 1985, 1986. * * All Rights Reserved. * * Reference "/usr/src/COPYRIGHT" for applicable restrictions. * **********************************************************************/ static char Sccsid[]="@(#)fdfopen.c 3.0 4/22/86"; /* Interfaces with /lib/libS.a First arg is file descriptor, second is read/write mode (0/1). Returns file pointer on success, NULL on failure (no file structures available). */ # include "stdio.h" # include "sys/types.h" # include "macros.h" FILE * fdfopen(fd, mode) register int fd, mode; { register FILE *iop; if (fstat(fd, &Statbuf) < 0) return(NULL); for (iop = _iob; iop->_flag&(_IOREAD|_IOWRT); iop++) if (iop >= &_iob[_NFILE-1]) return(NULL); iop->_flag &= ~(_IOREAD|_IOWRT); iop->_file = fd; if (mode) iop->_flag |= _IOWRT; else iop->_flag |= _IOREAD; return(iop); }