File:  [OS/2 SDKs] / os2sdk / demos / apps / wakeup / wakeup.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:06 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1988, HEAD
Microsoft OS/2 SDK 03-01-1988

/* WAKEUP.C -- Popup Alarm


WAKEUP
------

        This program takes a time parameter.  It goes into a 
DosSleep and uses VioPopUp to wakeup you up.  It will interrupt
any protected mode or real mode screen group.  The VioPopUp call
always causes an automatic save of the existing screen and turns
over the screen to the program doing VioPopUp.	After a VioEndPopUp,
the original screen is restored.

	Even after it's in the DosSleep, you can abort the program
with a Ctrl-Break.

	You can devote a whole screen group to WAKEUP by executing
just:

		WAKEUP time

or you can run it in the background of a screen group using DETACH:

		DETACH WAKEUP time

 Created by Microsoft Corp. 1986

*/
#define INCL_DOSDATETIME
#define INCL_DOSPROCESS
#define INCL_SUB

#include <os2def.h>
#include <bse.h>	   /* Part of MS OS/2 Development Kit */
#include <stdio.h>

main (argc, argv)
	int	argc ;
	char	*argv [] ;
	{
	DATETIME datetime ;
	static	char	delim [] = ":" ;
	int	hour, min;
	USHORT	col, len, i ;
	ULONG	wakeup, current ;
	USHORT	waitflags ;
	static	char	msg [] = "\xBA WAKE UP! WAKE UP! WAKE UP! \xBA" ;

	if (argc < 2 || 23 < (hour = atoi (strtok (argv [1], delim))) ||
			59 < (min  = atoi (strtok (NULL, delim))))
		{
		puts ("\nSyntax: WAKEUP hour:minute   (24-hour format)") ;
		exit (0) ;
		}
	
	DosGetDateTime (&datetime) ;

	wakeup  = (hour * 60 + min) * 60000L ;
	current = ((datetime.hours * 60 +
			datetime.minutes) * 60L +
			datetime.seconds) * 1000L ;

	if (wakeup < current)
		wakeup += 24 * 3600000L ;
		
	wakeup -= current ;

	puts ("\n\n\n\n\n\t\tWAKEUP scheduled ... \n\n\n\n") ;

	DosSleep (wakeup) ;

	waitflags = 1 ;

	VioPopUp (&waitflags, 0) ;

	col = (80 - sizeof (msg)) / 2 ;
	len = sizeof (msg) - 3 ;

	VioSetCurPos (10, col, 0) ;
	border (len, 201, 187) ;

	VioSetCurPos (11, col, 0) ;
	VioWrtTTy (msg, sizeof (msg), 0) ;

	VioSetCurPos (12, col, 0) ;
	border (len, 200, 188) ;

	while (kbhit ())
		getch () ;

	while (!kbhit ())
		{
		for (i = 1 ; i < 10 ; i++)
			{
			DosBeep (500, 50) ;
			DosBeep (1000, 50) ;
			}
		for (i = 1 ; i < 10 ; i++)
			{
			DosBeep (1000, 50) ;
			DosBeep (2000, 50) ;
			}
		}
	}

border (len, left, right)
	int	len ;
	char	left, right ;
	{
	char	line = 205 ;
	int	i ;

	VioWrtTTy (&left, 1, 0) ;

	for (i = 0 ; i < len ; i++)
		VioWrtTTy (&line, 1, 0) ;

	VioWrtTTy (&right, 1, 0) ;
	}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.