home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / comm / bbs / eazybbs / source / getsystime.c < prev    next >
C/C++ Source or Header  |  1994-09-08  |  2KB  |  82 lines

  1.  
  2. #ifdef __SASC
  3. #include <proto/exec.h>
  4. #endif
  5. #ifdef DICE
  6. #include <clib/exec_protos.h>
  7. #endif
  8.  
  9. #include <proto/exec.h>
  10. #include <exec/types.h>
  11. #include <exec/memory.h>
  12. #include <exec/io.h>
  13. #include <exec/devices.h>
  14. #include <devices/timer.h>
  15. #include <clib/alib_protos.h>
  16.  
  17.  
  18.  
  19. #if 0
  20. Prototype BOOL OpenTimer4MsgId(void);
  21. Prototype void GetTimer4MsgId(struct timeval *);
  22. Prototype void CloseTimer4MsgId(void);
  23. #endif
  24.  
  25.  
  26. static struct MsgPort *msgid_tport = NULL;
  27. static struct timerequest *msgid_tio = NULL;
  28. static BOOL msgid_topen = FALSE;
  29.  
  30.  
  31.  
  32. BOOL OpenTimer4MsgId(void)
  33. {
  34.     if (!msgid_topen) {
  35.         if (msgid_tport = CreatePort(NULL, 0L)) {
  36.             if (msgid_tio = (struct timerequest *) CreateExtIO(msgid_tport, sizeof(struct timerequest))) {
  37.                 if (!OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest *) msgid_tio, 0L)) {
  38.                     msgid_topen = TRUE;
  39.                     return (TRUE);
  40.                 }
  41.                 else {
  42.                     DeleteExtIO((struct IORequest *) msgid_tio);
  43.                     msgid_tio = NULL;
  44.                     DeletePort(msgid_tport);
  45.                     msgid_tport = NULL;
  46.                 }
  47.             }
  48.             else {
  49.                 DeletePort(msgid_tport);
  50.                 msgid_tport = NULL;
  51.             }
  52.         }
  53.     }
  54.     return (FALSE);
  55. }
  56.  
  57.  
  58.  
  59. void GetTimer4MsgId(struct timeval *tv)
  60. {
  61.     /* if (!msgid_topen) return; */
  62.  
  63.     msgid_tio->tr_node.io_Command = TR_GETSYSTIME;
  64.     DoIO((struct IORequest *) msgid_tio);
  65.  
  66.     *tv = msgid_tio->tr_time;
  67. }
  68.  
  69.  
  70.  
  71. void CloseTimer4MsgId(void)
  72. {
  73.     if (msgid_topen) {
  74.         CloseDevice((struct IORequest *) msgid_tio);
  75.         msgid_topen = FALSE;
  76.         DeleteExtIO((struct IORequest *) msgid_tio);
  77.         msgid_tio = NULL;
  78.         DeletePort(msgid_tport);
  79.         msgid_tport = NULL;
  80.     }
  81. }
  82.