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

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 
1.1.1.2 ! root        8: DosSleep and uses VioPopUp to wakeup you up.  It will interrupt
        !             9: any protected mode or real mode screen group.  The VioPopUp call
1.1       root       10: always causes an automatic save of the existing screen and turns
1.1.1.2 ! root       11: over the screen to the program doing VioPopUp. After a VioEndPopUp,
1.1       root       12: the original screen is restored.
                     13: 
1.1.1.2 ! root       14:        Even after it's in the DosSleep, you can abort the program
1.1       root       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: 
1.1.1.2 ! root       26:  Created by Microsoft Corp. 1986
        !            27: 
1.1       root       28: */
1.1.1.2 ! root       29: #define INCL_DOSDATETIME
        !            30: #define INCL_DOSPROCESS
        !            31: #define INCL_SUB
1.1       root       32: 
1.1.1.2 ! root       33: #include <os2def.h>
        !            34: #include <bse.h>          /* Part of MS OS/2 Development Kit */
1.1       root       35: #include <stdio.h>
                     36: 
                     37: main (argc, argv)
                     38:        int     argc ;
                     39:        char    *argv [] ;
                     40:        {
1.1.1.2 ! root       41:        DATETIME datetime ;
1.1       root       42:        static  char    delim [] = ":" ;
1.1.1.2 ! root       43:        int     hour, min;
        !            44:        USHORT  col, len, i ;
        !            45:        ULONG   wakeup, current ;
        !            46:        USHORT  waitflags ;
1.1       root       47:        static  char    msg [] = "\xBA WAKE UP! WAKE UP! WAKE UP! \xBA" ;
                     48: 
                     49:        if (argc < 2 || 23 < (hour = atoi (strtok (argv [1], delim))) ||
                     50:                        59 < (min  = atoi (strtok (NULL, delim))))
                     51:                {
                     52:                puts ("\nSyntax: WAKEUP hour:minute   (24-hour format)") ;
                     53:                exit (0) ;
                     54:                }
                     55:        
1.1.1.2 ! root       56:        DosGetDateTime (&datetime) ;
1.1       root       57: 
                     58:        wakeup  = (hour * 60 + min) * 60000L ;
1.1.1.2 ! root       59:        current = ((datetime.hours * 60 +
1.1       root       60:                        datetime.minutes) * 60L +
                     61:                        datetime.seconds) * 1000L ;
                     62: 
                     63:        if (wakeup < current)
                     64:                wakeup += 24 * 3600000L ;
                     65:                
                     66:        wakeup -= current ;
                     67: 
                     68:        puts ("\n\n\n\n\n\t\tWAKEUP scheduled ... \n\n\n\n") ;
                     69: 
1.1.1.2 ! root       70:        DosSleep (wakeup) ;
1.1       root       71: 
                     72:        waitflags = 1 ;
                     73: 
1.1.1.2 ! root       74:        VioPopUp (&waitflags, 0) ;
1.1       root       75: 
                     76:        col = (80 - sizeof (msg)) / 2 ;
                     77:        len = sizeof (msg) - 3 ;
                     78: 
1.1.1.2 ! root       79:        VioSetCurPos (10, col, 0) ;
1.1       root       80:        border (len, 201, 187) ;
                     81: 
1.1.1.2 ! root       82:        VioSetCurPos (11, col, 0) ;
        !            83:        VioWrtTTy (msg, sizeof (msg), 0) ;
1.1       root       84: 
1.1.1.2 ! root       85:        VioSetCurPos (12, col, 0) ;
1.1       root       86:        border (len, 200, 188) ;
                     87: 
                     88:        while (kbhit ())
                     89:                getch () ;
                     90: 
                     91:        while (!kbhit ())
                     92:                {
                     93:                for (i = 1 ; i < 10 ; i++)
                     94:                        {
1.1.1.2 ! root       95:                        DosBeep (500, 50) ;
        !            96:                        DosBeep (1000, 50) ;
1.1       root       97:                        }
                     98:                for (i = 1 ; i < 10 ; i++)
                     99:                        {
1.1.1.2 ! root      100:                        DosBeep (1000, 50) ;
        !           101:                        DosBeep (2000, 50) ;
1.1       root      102:                        }
                    103:                }
                    104:        }
                    105: 
                    106: border (len, left, right)
                    107:        int     len ;
                    108:        char    left, right ;
                    109:        {
                    110:        char    line = 205 ;
                    111:        int     i ;
                    112: 
1.1.1.2 ! root      113:        VioWrtTTy (&left, 1, 0) ;
1.1       root      114: 
                    115:        for (i = 0 ; i < len ; i++)
1.1.1.2 ! root      116:                VioWrtTTy (&line, 1, 0) ;
1.1       root      117: 
1.1.1.2 ! root      118:        VioWrtTTy (&right, 1, 0) ;
1.1       root      119:        }

unix.superglobalmegacorp.com

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