/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "sfhdr.h"
/* Poll a set of streams to see if any is available for I/O.
** Ready streams are moved to front of array but retain the
** same relative order.
**
** Written by Kiem-Phong Vo.
*/
#if __STD_C
#else
reg int n; /* number of streams in array */
#endif
{
if(n <= 0 || !fa)
return -1;
return -1;
/* a SF_READ stream is ready if there is buffered read data */
/* a SF_WRITE stream is ready if there is no write data */
for(r = c = eintr = 0; r < n; ++r) /* compute streams that must be checked */
{ f = fa[r];
status[r] = 0;
/* terminate poll on interrupt? */
eintr++;
/* check accessibility */
continue;
continue;
/* has discipline, ask its opinion */
continue;
else if(m > 0)
continue;
}
}
check[c++] = r;
else /* seekable streams are always ready */
}
}
/* terminate poll on interrupt only if all streams marked SF_IOINTR */
np = -1;
#if _lib_poll
if(c > 0)
/* construct the poll array */
for(m = 0, r = 0; r < c; ++r, ++m)
if(HASAUXFD(f))
m += 1;
}
return -1;
for(m = 0, r = 0; r < c; ++r, ++m)
{ /* a sfpopen situation with two file descriptors */
{ m += 1;
}
}
}
errno = 0;
else break;
}
if(np > 0) /* poll succeeded */
np = c;
for(m = 0, r = 0; r < np; ++r, ++m)
}
m += 1;
}
}
}
#endif /*_lib_poll*/
#if _lib_select
if(np < 0 && c > 0)
m = 0;
for(r = 0; r < c; ++r)
if(f->file > m)
m = f->file;
}
}
}
if(tm < 0)
else
}
errno = 0;
else break;
}
if(np > 0)
np = c;
for(r = 0; r < np; ++r)
}
}
else
}
}
}
}
#endif /*_lib_select*/
for(r = c = 0; c < n; ++c)
{ if(status[c] == 0)
continue;
f = fa[c];
/* announce status */
if(c > r) /* move to front of list */
fa[r] = f;
}
r += 1;
}
return r ? r : np < 0 ? -1 : 0;
}