home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / MM1 / SOUNDUTILS / audioplay.lzh / AUDIOPLAY / SRC / dial.c < prev    next >
C/C++ Source or Header  |  1995-03-26  |  1KB  |  96 lines

  1. /* dial - a simple touchtone dialer */
  2. /* could be used as a speed dialer in an application */
  3. /* Boisy G. Pitre - 3/19/95 */
  4.  
  5. #include <stdio.h>
  6. #include <types.h>
  7. #include <errno.h>
  8.  
  9. #ifndef _TYPES_H
  10. typedef unsigned long u_int32;
  11. typedef long          int32;
  12.  
  13. typedef int32         process_id;
  14. typedef int32         status_code;
  15. typedef int32         error_code;
  16. #endif
  17.  
  18. int os9forkc();
  19.  
  20. extern char **environ;
  21.  
  22. main(argc, argv)
  23. int argc;
  24. char *argv[];
  25. {
  26.     char *p;
  27.     char file[24];
  28.     u_int32 sleepTime;
  29.  
  30.     p = argv[1];
  31.  
  32.     while (*p) {
  33.         switch (*p) {
  34.             case '1':
  35.             case '2':
  36.             case '3':
  37.             case '4':
  38.             case '5':
  39.             case '6':
  40.             case '7':
  41.             case '8':
  42.             case '9':
  43.             case '0':
  44.                 sprintf(file, "tt%c.iff", *p);
  45.                 playsound(file);
  46.                 break;
  47.  
  48.             case '*':
  49.                 strcpy(file, "ttstar.iff");
  50.                 playsound(file);
  51.                 break;
  52.  
  53.             case '#':
  54.                 strcpy(file, "ttpound.iff");
  55.                 playsound(file);
  56.                 break;
  57.  
  58.             case ',':
  59.                 /* sleep for 1 second */
  60.                 sleepTime = 0x80000100;
  61.                 tsleep(sleepTime);
  62.                 break;
  63.         }
  64.         p++;
  65.     }
  66. }
  67.  
  68.  
  69. /*
  70.  * void playsound(char *file)
  71.  *
  72.  * Plays either a .wav or .iff sound file
  73.  */
  74. playsound(file)
  75. char *file;
  76. {
  77.     char tmp[10], tmp2[10];
  78.     char *argv[6];
  79.     process_id pid;
  80.     status_code status;
  81.     error_code err;
  82.  
  83.     argv[0] = "audioplay";
  84.     argv[1] = "-q";
  85.     argv[2] = file;
  86.     argv[3] = NULL;
  87.  
  88.     pid = os9exec(os9forkc, argv[0], argv, environ, 0, 0, 3);
  89.  
  90.     if (pid == -1) {
  91.         Bell(1);
  92.     } else {
  93.         while (pid != wait(&status));
  94.     }
  95. }
  96.