home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1992 Commodore-Amiga, Inc.
- *
- * This example is provided in electronic form by Commodore-Amiga, Inc. for
- * use with the "Amiga ROM Kernel Reference Manual: Devices", 3rd Edition,
- * published by Addison-Wesley (ISBN 0-201-56775-X).
- *
- * The "Amiga ROM Kernel Reference Manual: Devices" contains additional
- * information on the correct usage of the techniques and operating system
- * functions presented in these examples. The source and executable code
- * of these examples may only be distributed in free electronic form, via
- * bulletin board or as part of a fully non-commercial and freely
- * redistributable diskette. Both the source and executable code (including
- * comments) must be included, without modification, in any copy. This
- * example may not be published in printed form or distributed with any
- * commercial product. However, the programming techniques and support
- * routines set forth in these examples may be used in the development
- * of original executable software products for Commodore Amiga computers.
- *
- * All other rights reserved.
- *
- * This example is provided "as-is" and is subject to change; no
- * warranties are made. All use is at your own risk. No liability or
- * responsibility is assumed.
- *
- *****************************************************************************
- *
- * Get_Systime.c
- *
- * Get system time example
- *
- * Compile with SAS C 5.10: LC -b1 -cfistq -v -y -L
- *
- * Run from CLI only
- */
-
- #include <exec/types.h>
- #include <exec/io.h>
- #include <exec/memory.h>
- #include <devices/timer.h>
-
- #include <clib/exec_protos.h>
- #include <clib/alib_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/intuition_protos.h>
-
- #include <stdio.h>
-
-
- BOOL main(VOID);
-
- BOOL main ()
- {
- struct timerequest *TimerIO;
- struct MsgPort *TimerMP;
- struct Message *TimerMSG;
- LONG error;
- LONG hrs,secs,mins;
- char buffer[50];
-
- TimerMP = CreatePort(0,0);
- if(!TimerMP) return(NULL);
- TimerIO = (struct timerequest *)CreateExtIO(TimerMP,sizeof(struct timerequest));
- if (!TimerIO) return(NULL);
- error=OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)TimerIO,0L);
- if (error) return (NULL);
- TimerIO->tr_node.io_Command = TR_GETSYSTIME;
- DoIO((struct IORequest *) TimerIO);
- secs=TimerIO->tr_time.tv_secs;
- mins=secs/60;
- hrs=mins/60;
- secs=secs%60;
- mins=mins%60;
- hrs=hrs%60;
-
- CloseDevice((struct IORequest *) TimerIO);
- DeleteExtIO((struct IORequest *) TimerIO);
- DeletePort(TimerMP);
- sprintf(buffer,"%2d:%2d:%2d\n",hrs,mins,secs);
- printf(buffer);
- }
-