void exp_unused() {}
#if 0
#include "expect_cf.h"
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYSSELECT_H
# include <sys/select.h>
#endif
#ifdef HAVE_PTYTRAP
# include <sys/ptyio.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef _AIX
#include <sys/select.h>
#endif
#if !defined( FD_SET ) && defined( HAVE_SYS_BSDTYPES_H )
# include <sys/bsdtypes.h>
#endif
#include "tcl.h"
#include "exp_prog.h"
#include "exp_command.h"
#include "exp_event.h"
#ifdef HAVE_SYSCONF_H
#include <sys/sysconfig.h>
#endif
#ifndef FD_SET
#define FD_SET(fd,fdset) (fdset)->fds_bits[0] |= (1<<(fd))
#define FD_CLR(fd,fdset) (fdset)->fds_bits[0] &= ~(1<<(fd))
#define FD_ZERO(fdset) (fdset)->fds_bits[0] = 0
#define FD_ISSET(fd,fdset) (((fdset)->fds_bits[0]) & (1<<(fd)))
#ifndef AUX2
typedef struct fd_set {
long fds_bits[1];
} fd_set;
#endif
#endif
static struct timeval zerotime = {0, 0};
static struct timeval anytime = {0, 0};
int
exp_get_next_event(interp,masters, n,master_out,timeout,key)
Tcl_Interp *interp;
int *masters;
int n;
int *master_out;
int timeout;
int key;
{
static rr = 0;
int i;
struct timeval *t;
fd_set rdrs;
fd_set excep;
#ifdef __Lynx__
#define EXCEP 0
#else
#define EXCEP &excep
#endif
for (i=0;i<n;i++) {
struct exp_f *f;
int m;
rr++;
if (rr >= n) rr = 0;
m = masters[rr];
f = exp_fs + m;
if (f->key != key) {
f->key = key;
f->force_read = FALSE;
*master_out = m;
return(EXP_DATA_OLD);
} else if ((!f->force_read) && (f->size != 0)) {
*master_out = m;
return(EXP_DATA_OLD);
}
}
if (timeout >= 0) {
t = &anytime;
t->tv_sec = timeout;
} else {
t = NULL;
}
restart:
if (Tcl_AsyncReady()) {
int rc = Tcl_AsyncInvoke(interp,TCL_OK);
if (rc != TCL_OK) return(exp_tcl2_returnvalue(rc));
return EXP_RECONFIGURE;
}
FD_ZERO(&rdrs);
FD_ZERO(&excep);
for (i = 0;i < n;i++) {
FD_SET(masters[i],&rdrs);
FD_SET(masters[i],&excep);
}
if (-1 == select(exp_fd_max+1,
(SELECT_MASK_TYPE *)&rdrs,
(SELECT_MASK_TYPE *)0,
(SELECT_MASK_TYPE *)EXCEP,
t)) {
if (errno == EINTR) goto restart;
else if (errno == EBADF) {
for (i=0;i<n;i++) {
fd_set suspect;
FD_ZERO(&suspect);
FD_SET(masters[i],&suspect);
if (-1 == select(exp_fd_max+1,
(SELECT_MASK_TYPE *)&suspect,
(SELECT_MASK_TYPE *)0,
(SELECT_MASK_TYPE *)0,
&zerotime)) {
exp_error(interp,"invalid spawn_id (%d)\r",masters[i]);
return(EXP_TCLERROR);
}
}
} else {
exp_error(interp,"select: %s\r",Tcl_PosixError(interp));
return(EXP_TCLERROR);
}
}
for (i=0;i<n;i++) {
rr++;
if (rr >= n) rr = 0;
if (FD_ISSET(masters[rr],&rdrs)) {
*master_out = masters[rr];
return(EXP_DATA_NEW);
} else if (FD_ISSET(masters[rr], &excep)) {
#ifndef HAVE_PTYTRAP
*master_out = masters[rr];
return(EXP_EOF);
#else
struct request_info ioctl_info;
if (ioctl(masters[rr],TIOCREQCHECK,&ioctl_info) < 0) {
exp_debuglog("ioctl error on TIOCREQCHECK: %s",Tcl_ErrnoMsg(errno));
break;
}
if (ioctl_info.request == TIOCCLOSE) {
*master_out = masters[rr];
return(EXP_EOF);
}
if (ioctl(masters[rr], TIOCREQSET, &ioctl_info) < 0)
exp_debuglog("ioctl error on TIOCREQSET after ioctl or open on slave: %s", Tcl_ErrnoMsg(errno));
goto restart;
#endif
}
}
return(EXP_TIMEOUT);
}
int
exp_get_next_event_info(interp,fd,ready_mask)
Tcl_Interp *interp;
int fd;
int ready_mask;
{
return 0;
}
int
exp_dsleep(interp,sec)
Tcl_Interp *interp;
double sec;
{
struct timeval t;
t.tv_sec = sec;
t.tv_usec = (sec - t.tv_sec) * 1000000L;
restart:
if (Tcl_AsyncReady()) {
int rc = Tcl_AsyncInvoke(interp,TCL_OK);
if (rc != TCL_OK) return rc;
}
if (-1 == select(1,
(SELECT_MASK_TYPE *)0,
(SELECT_MASK_TYPE *)0,
(SELECT_MASK_TYPE *)0,
&t)
&& errno == EINTR)
goto restart;
return TCL_OK;
}
#if 0
int
exp_usleep(interp,usec)
Tcl_Interp *interp;
long usec;
{
struct timeval t;
t.tv_sec = usec/1000000L;
t.tv_usec = usec%1000000L;
restart:
if (Tcl_AsyncReady()) {
int rc = Tcl_AsyncInvoke(interp,TCL_OK);
if (rc != TCL_OK) return(exp_tcl2_returnvalue(rc));
}
if (-1 == select(1,
(SELECT_MASK_TYPE *)0,
(SELECT_MASK_TYPE *)0,
(SELECT_MASK_TYPE *)0,
&t)
&& errno == EINTR)
goto restart;
return TCL_OK;
}
#endif
void
exp_init_event()
{
#if 0
#ifdef _SC_OPEN_MAX
maxfds = sysconf(_SC_OPEN_MAX);
#else
maxfds = getdtablesize();
#endif
#endif
exp_event_exit = 0;
}
#endif