home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / EXTRAS / UUCODE / UUPC / TEST / UPC12ES1.ZIP / LIB / trumpet.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-11  |  4.6 KB  |  150 lines

  1. /*--------------------------------------------------------------------*/
  2. /*       t r u m p e t . c                                            */
  3. /*                                                                    */
  4. /*       Audio support for UUPC/extended                              */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*       Changes Copyright (c) 1989-1993 by Kendra Electronic         */
  9. /*       Wonderworks.                                                 */
  10. /*                                                                    */
  11. /*       All rights reserved except those explicitly granted by       */
  12. /*       the UUPC/extended license agreement.                         */
  13. /*--------------------------------------------------------------------*/
  14.  
  15. /*--------------------------------------------------------------------*/
  16. /*                          RCS Information                           */
  17. /*--------------------------------------------------------------------*/
  18.  
  19. /*
  20.  *    $Id: trumpet.c 1.3 1993/10/12 00:48:44 ahd Exp $
  21.  *
  22.  *    Revision history:
  23.  *    $Log: trumpet.c $
  24.  * Revision 1.3  1993/10/12  00:48:44  ahd
  25.  * Normalize comments
  26.  *
  27.  * Revision 1.2  1993/09/20  04:39:51  ahd
  28.  * OS/2 2.x support
  29.  *
  30.  * Revision 1.1  1993/07/31  16:22:16  ahd
  31.  * Initial revision
  32.  *
  33.  */
  34.  
  35. /*--------------------------------------------------------------------*/
  36. /*    Use a complex beep upon mail delivery if way to control the     */
  37. /*    speaker is available; if using MS C 6.0 under DOS, we can't     */
  38. /*    so don't try                                                    */
  39. /*--------------------------------------------------------------------*/
  40.  
  41. #if defined(__TURBOC__) && !defined(_Windows)
  42. #define SMARTBEEP
  43. #endif
  44.  
  45. #if defined(FAMILYAPI) || defined(WIN32) || defined(__OS2__)
  46. #define SMARTBEEP
  47. #endif
  48.  
  49. /*--------------------------------------------------------------------*/
  50. /*                        System include files                        */
  51. /*--------------------------------------------------------------------*/
  52.  
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #include <io.h>
  56. #include <ctype.h>
  57. #include <sys/types.h>
  58. #include <string.h>
  59. #include <process.h>
  60. #include <limits.h>
  61.  
  62. #ifdef __TURBOC__
  63. #include <dos.h>
  64. #endif
  65.  
  66. #ifdef WIN32
  67. #include <windows.h>
  68. #endif
  69.  
  70. #if defined(FAMILYAPI) || defined(__OS2__)
  71. #include <os2.h>
  72. #endif
  73.  
  74. /*--------------------------------------------------------------------*/
  75. /*                    UUPC/extended include files                     */
  76. /*--------------------------------------------------------------------*/
  77.  
  78. #include "lib.h"
  79.  
  80. #ifdef SMARTBEEP
  81. #include "ssleep.h"
  82. #endif
  83.  
  84. /*--------------------------------------------------------------------*/
  85. /*    t r u m p e t                                                   */
  86. /*                                                                    */
  87. /*    Trumpet the arrival of remote mail to a local user              */
  88. /*--------------------------------------------------------------------*/
  89.  
  90. void trumpet( const char *tune)
  91. {
  92. #ifdef SMARTBEEP
  93.    char buf[BUFSIZ];
  94.    char *token = buf;
  95.    size_t tone, duration;
  96. #endif
  97.  
  98.    if (tune == NULL)          /* Should we announce?  */
  99.       return;                 /* No --> Return quietly (literally)    */
  100.  
  101. /*--------------------------------------------------------------------*/
  102. /*             We are to announce the arrival of the mail             */
  103. /*--------------------------------------------------------------------*/
  104.  
  105. #ifdef SMARTBEEP
  106.    strcpy(buf,tune);          /* Save the data                        */
  107.  
  108.    while( (token = strtok( token, ",")) != NULL)
  109.    {
  110.       tone = (size_t) atoi(token);
  111.       token = strtok( NULL, ",");
  112.       duration = (token == NULL) ? 500 : (size_t) atoi(token);
  113.  
  114. #ifdef WIN32
  115.       Beep( tone, duration );
  116.  
  117.       if (tone == 0)
  118.          ddelay(duration);
  119.  
  120. #elif defined(FAMILYAPI) || defined(__OS2__)
  121.  
  122.       DosBeep( tone, duration );
  123.  
  124.       if (tone == 0)
  125.          ddelay(duration);
  126.  
  127. #else
  128.       if (tone != 0)
  129.          sound( tone );
  130.  
  131.       ddelay(duration);
  132.  
  133.       nosound();
  134.  
  135. #endif /* __TURBOC__ */
  136.  
  137.       token = NULL;           /* Look at next part of string   */
  138.    } /* while */
  139.  
  140. #else /* SMARTBEEP */
  141.  
  142. /*--------------------------------------------------------------------*/
  143. /*      We cannot play the requested tune; just beep at the user      */
  144. /*--------------------------------------------------------------------*/
  145.  
  146.    fputc('\a', stdout);
  147. #endif /* SMARTBEEP */
  148.  
  149. } /* trumpet */
  150.