Annotation of os2sdk/demos/apps/wakeup/wakeup.c, revision 1.1

1.1     ! root        1: /* WAKEUP.C -- Popup Alarm
        !             2: 
        !             3: 
        !             4: WAKEUP
        !             5: ------
        !             6: 
        !             7:         This program takes a time parameter.  It goes into a 
        !             8: DOSSLEEP and uses VIOPOPUP to wakeup you up.  It will interrupt
        !             9: any protected mode or real mode screen group.  The VIOPOPUP call
        !            10: always causes an automatic save of the existing screen and turns
        !            11: over the screen to the program doing VIOPOPUP.  After a VIOENDPOPUP,
        !            12: the original screen is restored.
        !            13: 
        !            14:         Even after it's in the DOSSLEEP, you can abort the program
        !            15: with a Ctrl-Break.
        !            16: 
        !            17:        You can devote a whole screen group to WAKEUP by executing
        !            18: just:
        !            19: 
        !            20:                WAKEUP time
        !            21: 
        !            22: or you can run it in the background of a screen group using DETACH:
        !            23: 
        !            24:                DETACH WAKEUP time
        !            25: 
        !            26: */
        !            27: 
        !            28: #include <doscalls.h>          /* Part of 286DOS Development Kit */
        !            29: #include <subcalls.h>
        !            30: #include <stdio.h>
        !            31: 
        !            32: #define  BYTE unsigned char
        !            33: #define  WORD unsigned  int
        !            34: #define DWORD unsigned long
        !            35: 
        !            36: main (argc, argv)
        !            37:        int     argc ;
        !            38:        char    *argv [] ;
        !            39:        {
        !            40:        struct  DateTime datetime ;
        !            41:        static  char    delim [] = ":" ;
        !            42:        int     hour, min, col, len, i ;
        !            43:        long    wakeup, current ;
        !            44:        WORD    waitflags ;
        !            45:        static  char    msg [] = "\xBA WAKE UP! WAKE UP! WAKE UP! \xBA" ;
        !            46: 
        !            47:        if (argc < 2 || 23 < (hour = atoi (strtok (argv [1], delim))) ||
        !            48:                        59 < (min  = atoi (strtok (NULL, delim))))
        !            49:                {
        !            50:                puts ("\nSyntax: WAKEUP hour:minute   (24-hour format)") ;
        !            51:                exit (0) ;
        !            52:                }
        !            53:        
        !            54:        DOSGETDATETIME (&datetime) ;
        !            55: 
        !            56:        wakeup  = (hour * 60 + min) * 60000L ;
        !            57:        current = ((datetime.hour * 60 +
        !            58:                        datetime.minutes) * 60L +
        !            59:                        datetime.seconds) * 1000L ;
        !            60: 
        !            61:        if (wakeup < current)
        !            62:                wakeup += 24 * 3600000L ;
        !            63:                
        !            64:        wakeup -= current ;
        !            65: 
        !            66:        puts ("\n\n\n\n\n\t\tWAKEUP scheduled ... \n\n\n\n") ;
        !            67: 
        !            68:        DOSSLEEP (wakeup) ;
        !            69: 
        !            70:        waitflags = 1 ;
        !            71: 
        !            72:        VIOPOPUP (&waitflags, 0) ;
        !            73: 
        !            74:        col = (80 - sizeof (msg)) / 2 ;
        !            75:        len = sizeof (msg) - 3 ;
        !            76: 
        !            77:        VIOSETCURPOS (10, col, 0) ;
        !            78:        border (len, 201, 187) ;
        !            79: 
        !            80:        VIOSETCURPOS (11, col, 0) ; 
        !            81:        VIOWRTTTY (msg, sizeof (msg), 0) ;
        !            82: 
        !            83:        VIOSETCURPOS (12, col, 0) ;
        !            84:        border (len, 200, 188) ;
        !            85: 
        !            86:        while (kbhit ())
        !            87:                getch () ;
        !            88: 
        !            89:        while (!kbhit ())
        !            90:                {
        !            91:                for (i = 1 ; i < 10 ; i++)
        !            92:                        {
        !            93:                        DOSBEEP (500, 50) ;
        !            94:                        DOSBEEP (1000, 50) ;
        !            95:                        }
        !            96:                for (i = 1 ; i < 10 ; i++)
        !            97:                        {
        !            98:                        DOSBEEP (1000, 50) ;
        !            99:                        DOSBEEP (2000, 50) ;
        !           100:                        }
        !           101:                }
        !           102:        }
        !           103: 
        !           104: border (len, left, right)
        !           105:        int     len ;
        !           106:        char    left, right ;
        !           107:        {
        !           108:        char    line = 205 ;
        !           109:        int     i ;
        !           110: 
        !           111:        VIOWRTTTY (&left, 1, 0) ;
        !           112: 
        !           113:        for (i = 0 ; i < len ; i++)
        !           114:                VIOWRTTTY (&line, 1, 0) ;
        !           115: 
        !           116:        VIOWRTTTY (&right, 1, 0) ;
        !           117:        }

unix.superglobalmegacorp.com

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