Metropoli BBS
VIEWER: delay.c MODE: TEXT (ASCII)
/***************************************************************************
 *		  Copyright (C) 1995  Charles P. Peterson                  *
 *	     4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
 *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
 *                                                                         *
 *		  This is free software with NO WARRANTY.                  *
 *	      See gfft.c, or run program itself, for details.              *
 *		      Support is available for a fee.                      *
 ***************************************************************************
 *
 * Program:     gfft--General FFT analysis
 * File:        gopen.c
 * Purpose:     Wait a specified number of seconds
 * Author:      Charles Peterson (CPP)
 * History:     26-Jan-1995 CPP (1.26) Created.
 * Comments:    
 */

#include <stdio.h>  /* FALSE, TRUE */
#include <exec/types.h>
#include <devices/timer.h>
#include <clib/exec_protos.h>
#include <clib/alib_protos.h>

void delay (int seconds)
{
    struct MsgPort *timer_mp;
    struct timerequest *timer_iorp;
    int error = 0;
/*
 * Open timer device
 */

    if (timer_mp = CreatePort (0,0))
    {
	if (timer_iorp = (struct timerequest *)
	      CreateExtIO (timer_mp, sizeof (struct timerequest)))
	{
	    if (!(error=OpenDevice(TIMERNAME, UNIT_MICROHZ, 
				   (struct IORequest *) timer_iorp, 0)))
	    {

/*
 * Submit timer request
 */
		timer_iorp->tr_node.io_Command = TR_ADDREQUEST;
		timer_iorp->tr_time.tv_secs = seconds;
		timer_iorp->tr_time.tv_micro = 0;
		DoIO ((struct IORequest *) timer_iorp);

/*
 * Cleanup
 */
		CloseDevice ((struct IORequest *) timer_iorp);
	    }
	    DeleteExtIO ((struct IORequest *) timer_iorp);
	}
	DeletePort(timer_mp);
    }
}

[ RETURN TO DIRECTORY ]