home *** CD-ROM | disk | FTP | other *** search
/ Da Capo / da_capo_vol1.bin / programs / amiga / midi / midi_playground / sourcecode / amigados.c next >
C/C++ Source or Header  |  1993-01-23  |  2KB  |  66 lines

  1. /**************************************************************************
  2. * amigados.c:    Requestor and Environment Variable routines.
  3. *        Part of MP, the MIDI Playground.
  4. *
  5. * Author:    Daniel Barrett
  6. * Version:    See the file "version.h".
  7. * Copyright:    None!  This program is in the Public Domain.
  8. *        Please share it with others.
  9. ***************************************************************************/
  10.  
  11.     
  12. #include <exec/types.h>
  13. #include <stdlib.h>
  14. #include <functions.h>
  15. #include <libraries/dos.h>
  16. #include <libraries/dosextens.h>
  17.  
  18.     
  19. void DisableRequestors(void);
  20. void EnableRequestors(void);
  21.  
  22.     
  23. #define    ENV_NAME_LENGTH        BUFSIZ
  24.  
  25.     
  26. /* Return the value of ENV: environment variable "variableName", if it
  27.  * exists.   We use this instead of the built-in getenv() because we
  28.  * want to turn off requestors during the search for ENV:, in case it
  29.  * is not mounted. */
  30.  
  31. char *GetEnv(char *variableName)
  32. {
  33.     char *result;
  34.  
  35.     DisableRequestors();        /* In case ENV: is non-existent. */
  36.     result = getenv(variableName);
  37.     EnableRequestors();
  38.     return(result);
  39. }
  40.  
  41.  
  42. /***************************************************************************
  43. * Deal with requestors.
  44. ***************************************************************************/
  45.  
  46. static APTR oldWindowPtr;
  47. static struct Process *theProc;
  48.  
  49. /* Turn off system requestors for this process. */
  50.  
  51. void DisableRequestors(void)
  52. {
  53.     theProc = (struct Process *)FindTask(NULL);
  54.     oldWindowPtr = theProc->pr_WindowPtr;
  55.     theProc->pr_WindowPtr = (APTR)(-1L);
  56. }
  57.  
  58.  
  59. /* Turn on system requestors for this process, after they have been
  60.  * turned off by DisableRequestors(), above. */
  61.  
  62. void EnableRequestors(void)
  63. {
  64.     theProc->pr_WindowPtr = oldWindowPtr;
  65. }
  66.