* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)findfp.c 5.2 (Berkeley) %G%";
#define active(iop) ((iop)->_flag & (_IOREAD|_IOWRT|_IORW))
#define NSTATIC 3 /* stdin + stdout + stderr */
{ 0, NULL
, NULL
, 0, _IOREAD
, 0 }, /* stdin */
{ 0, NULL
, NULL
, 0, _IOWRT
, 1 }, /* stdout */
{ 0, NULL
, NULL
, 0, _IOWRT
|_IONBF
, 2 }, /* stderr */
static FILE *_lastbuf
= _iob
+ NSTATIC
;
nfiles
= getdtablesize();
iobglue
= (FILE **)calloc(nfiles
, sizeof *iobglue
);
endglue
= iobglue
+ nfiles
;
for (fp
= _iob
; fp
< _lastbuf
; /* void */)
while (*iov
!= NULL
&& active(*iov
))
*iov
= (FILE *)calloc(1, sizeof **iov
);
register int (*function
)();
for (fp
= _iob
; fp
< _lastbuf
; fp
++)
for (iov
= iobglue
; iov
< endglue
; iov
++)
if (*iov
!= NULL
&& active(*iov
))