home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / MM1 / SOUNDUTILS / cuckoo.lzh / SRC / cuckoo.c
C/C++ Source or Header  |  1994-01-18  |  1KB  |  53 lines

  1. /* released to PD by Andrzej Kotanski, Jan. 18, 1994 */
  2.  
  3. #include <stdio.h>
  4. #include <time.h>
  5. extern errno;
  6.  
  7. main()
  8. {
  9.    int hour, min, pipe, i, nil, win;
  10.    struct sgtbuf timebuf;
  11.  
  12.    getime(&timebuf);
  13.  
  14.    hour = timebuf.t_hour;
  15.    min = timebuf.t_minute;
  16.  
  17.    if ( min > 55 ) {
  18.       hour++;
  19.       min = 0;
  20.    }
  21.    pipe = creat("/pipe/cuckoo", 3);
  22.    if ( pipe == -1 )
  23.       exit(_errmsg(errno, "cannot create pipe\n"));
  24.  
  25.    hour = ((hour % 12) + 11) % 12 + 1;
  26.  
  27.    if ( min > 28 && min < 32 )
  28.       hour = 1;
  29.  
  30.    for ( i = 0; i < hour; i++ )
  31.       writeln(pipe, "play\n", 5);
  32.    writeln(pipe, "quit\n");
  33.  
  34.    nil = open("/nil", 3);
  35.    if ( nil == -1 )
  36.       exit(_errmsg(errno, "cannot open '/nil'\n"));
  37.  
  38.    win = open("/w", 0);
  39.    if ( win == -1 )
  40.       exit(_errmsg(errno, "cannot open '/term'\n"));
  41.  
  42.    close(0);
  43.    dup(pipe);
  44.    close(1);
  45.    dup(win);
  46.    close(2);
  47.    dup(nil);
  48.  
  49.    i = system("playm /h0/demo/snds/cuckoo.iff");
  50.    if ( i )
  51.       exit(_errmsg(errno, "error in forking 'playm'\n"));
  52. }
  53.