home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / lib_examples / a2d.c next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  2.0 KB  |  72 lines

  1. ;/* a2d.c - Execute me to compile me with SAS C 5.10
  2. LC -b1 -cfis -j73 a2d.c
  3. Blink FROM LIB:c.o,a2d.o TO a2d LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6.     #include <exec/types.h>
  7.     #include <exec/memory.h>
  8.     #include <dos/datetime.h>
  9.     #include <devices/timer.h>
  10.  
  11.     #include <clib/exec_protos.h>
  12.     #include <clib/timer_protos.h>
  13.     #include <clib/utility_protos.h>
  14.  
  15.     #include <stdio.h>
  16.  
  17.     LONG main(void);
  18.  
  19.     struct Library *TimerBase;
  20.     struct Library *UtilityBase;
  21.  
  22.     LONG main(void)
  23.     {
  24.       struct ClockData *clockdata;
  25.       struct timerequest *tr;
  26.       struct timeval *tv;
  27.       LONG seconds;
  28.  
  29.       if (UtilityBase = OpenLibrary("utility.library", 37))
  30.       {
  31.         if (tr = AllocMem(sizeof(struct timerequest), MEMF_CLEAR))
  32.         {
  33.           if (tv = AllocMem(sizeof(struct timeval), MEMF_CLEAR))
  34.           {
  35.             if (clockdata = AllocMem(sizeof(struct ClockData), MEMF_CLEAR))
  36.             {
  37.               if (!(OpenDevice("timer.device", UNIT_VBLANK, (struct IORequest *)tr, 0) ))
  38.               {
  39.                 TimerBase = tr->tr_node.io_Device;
  40.  
  41.                 GetSysTime(tv);
  42.  
  43.                 printf("GetSysTime():\t%d %d\n", tv->tv_secs, tv->tv_micro);
  44.  
  45.                 Amiga2Date(tv->tv_secs, clockdata);
  46.  
  47.                 printf("Amiga2Date():  sec %d min %d hour %d\n", clockdata->sec,
  48.                         clockdata->min, clockdata->hour);
  49.  
  50.                 printf("               mday %d month %d year %d wday %d\n", clockdata->mday,
  51.                        clockdata->month, clockdata->year, clockdata->wday);
  52.  
  53.                 seconds = CheckDate(clockdata);
  54.  
  55.                 printf("CheckDate():\t%ld\n", seconds);
  56.  
  57.                 seconds = Date2Amiga(clockdata);
  58.  
  59.                 printf("Date2Amiga():\t%ld\n", seconds);
  60.  
  61.                 CloseDevice((struct IORequest *)tr);
  62.               }
  63.               FreeMem(clockdata, sizeof(struct ClockData));
  64.             }
  65.             FreeMem(tv, sizeof(struct timeval));
  66.           }
  67.           FreeMem(tr, sizeof(struct timerequest));
  68.         }
  69.         CloseLibrary(UtilityBase);
  70.       }
  71.     }
  72.