home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / comm / tcp / amipop / source / pop_timer.c < prev    next >
C/C++ Source or Header  |  1994-12-05  |  913b  |  55 lines

  1.  
  2. #include "pop.h"
  3.  
  4. int setuptime( void )
  5. {
  6.     timer_mp = CreateMsgPort();
  7.  
  8.     if (timer_mp == NULL )
  9.     {
  10.         doreq("CreateMsgPort() failed\n",bum);
  11.         return(0);
  12.     }
  13.  
  14.     timerio=(struct timerequest *)CreateExtIO(timer_mp,sizeof(struct timerequest));
  15.  
  16.     if ( OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)timerio,0) )
  17.     {
  18.         doreq("OpenDevice() failed\n",bum);
  19.         return(0);
  20.     }
  21.         return(1);
  22. }
  23.  
  24. int closetime( void )
  25. {
  26.     if (timer_mp)
  27.     {
  28.         if (timerio)
  29.         {
  30.             AbortIO( (struct IORequest *)timerio);
  31.             WaitIO( (struct IORequest *)timerio);
  32.             CloseDevice( (struct IORequest *)timerio );
  33.             DeleteExtIO( (struct IORequest *)timerio);
  34.         }
  35.  
  36.                 DeleteMsgPort(timer_mp);
  37.     }
  38.  
  39.     timer_mp=NULL;
  40.     timerio=NULL;
  41.  
  42.     return(0);
  43. }
  44.  
  45. void timereq(void)
  46. {
  47.     timerio->tr_node.io_Command    = TR_ADDREQUEST;
  48.     timerio->tr_time.tv_secs    = (60*timecheck);
  49.     timerio->tr_time.tv_micro    = 0;
  50.     SendIO( (struct IORequest *)timerio );
  51. }
  52.  
  53.  
  54.  
  55.