home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / networking / tcpip / amitcp-support / ncftp-1.5.6 / src / amiga / wait.c < prev   
Encoding:
C/C++ Source or Header  |  1994-06-29  |  1.4 KB  |  80 lines

  1. /*
  2.  * need to crosscheck with ATimerLib Version FIXME
  3.  */
  4.  
  5. /* wait specified amount of time */
  6.  
  7. #include <exec/types.h>
  8. #include <exec/memory.h>
  9. #include <devices/timer.h>
  10.  
  11. #ifdef __GNUC
  12. #include "quiet-gcc.h"
  13. #endif
  14.  
  15. #include <clib/exec_protos.h>
  16. #include <clib/alib_protos.h>
  17. #include <pragmas/exec_pragmas.h>
  18.  
  19. #if 0
  20. #include "ATimer.h"
  21. #endif
  22.  
  23. #ifdef ATIMER_USEASSERT
  24. #include <AAssert.h>
  25. #endif
  26.  
  27. extern ULONG SysBase;
  28.  
  29. void
  30. WaitmSecs (unsigned long millisecs)
  31. {
  32.     struct MsgPort *port;
  33.     struct timerequest *req;
  34.     long error;
  35.     
  36.     if(! SysBase)
  37.     SysBase =  *((ULONG *) 4); /* FIXME !!! */
  38.  
  39.  
  40.     if ((port = CreatePort (0L, 0L)) == NULL)
  41.     {
  42.     return;
  43.     }
  44.     if ((req = (struct timerequest *) 
  45.      CreateExtIO (port,
  46.               sizeof (struct timerequest))) == NULL)
  47.     {
  48.     DeletePort (port);
  49.     return;
  50.     }
  51.     if ((error = OpenDevice ((UBYTE *) TIMERNAME, 
  52.                  UNIT_VBLANK, 
  53.                  &(req->tr_node), 
  54.                  0L)) != 0L)
  55.     {
  56.     DeleteExtIO ((struct IORequest *) req);
  57.     DeletePort (port);
  58.     return;
  59.     }
  60.     millisecs *= 1000;
  61.  
  62.     req->tr_node.io_Command = TR_ADDREQUEST;
  63.     req->tr_time.tv_secs = millisecs / 1000000;
  64.     req->tr_time.tv_micro = millisecs % 1000000;
  65.  
  66.     DoIO ((struct IORequest *) req);
  67.  
  68.     CloseDevice ((struct IORequest *) req);
  69.     DeleteExtIO ((struct IORequest *) req);
  70.     DeletePort (port);
  71. }
  72.  
  73. void sleep(unsigned int sleep)
  74. {
  75.     WaitmSecs(sleep * 1000);
  76. }
  77.  
  78.  
  79.  
  80.