/* 4m v2.15 (setdelay.c)
 * (C) Copyright 1990 by Carrick Sean Casey
 * (C) Copyright 1993 by Scott Chasin and Michaeljon Miller
 *
 * 3-22-93 See file COPYING for copyright information.
 *
 * Timer and polling
 *
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <signal.h>
#include <errno.h>

#ifdef NEEDS_SELECT
# include "select.h"
#endif

#include "ipcf.h"
#include "externs.h"

/* turn off input polling for a user */

void setpolltimeout(msecs)
     int msecs;
{
    static struct timeval t;

    if (msecs < 0) {
        polltimeout = (struct timeval *) 0;
    } else {
        t.tv_sec = msecs / 1000;
        t.tv_usec = msecs - (t.tv_sec * 1000);
        polltimeout = &t;
    }

    return;
}

void setpolldelay(msecs)
     int msecs;
{
    static struct itimerval it;

    if (msecs == 0)
        polldelay = (struct itimerval *) 0;
    else {
        it.it_interval.tv_sec = it.it_value.tv_sec = (int) (msecs / 1000);
        it.it_interval.tv_usec = it.it_value.tv_usec =
            (msecs * 1000) - (it.it_value.tv_sec * 1000000);
        polldelay = &it;
    }

    return;
}
