/************************************************************************** * amigados.c: Requestor and Environment Variable routines. * Part of MP, the MIDI Playground. * * Author: Daniel Barrett * Version: See the file "version.h". * Copyright: None! This program is in the Public Domain. * Please share it with others. ***************************************************************************/ #include #include #include #include #include void DisableRequestors(void); void EnableRequestors(void); #define ENV_NAME_LENGTH BUFSIZ /* Return the value of ENV: environment variable "variableName", if it * exists. We use this instead of the built-in getenv() because we * want to turn off requestors during the search for ENV:, in case it * is not mounted. */ char *GetEnv(char *variableName) { char *result; DisableRequestors(); /* In case ENV: is non-existent. */ result = getenv(variableName); EnableRequestors(); return(result); } /*************************************************************************** * Deal with requestors. ***************************************************************************/ static APTR oldWindowPtr; static struct Process *theProc; /* Turn off system requestors for this process. */ void DisableRequestors(void) { theProc = (struct Process *)FindTask(NULL); oldWindowPtr = theProc->pr_WindowPtr; theProc->pr_WindowPtr = (APTR)(-1L); } /* Turn on system requestors for this process, after they have been * turned off by DisableRequestors(), above. */ void EnableRequestors(void) { theProc->pr_WindowPtr = oldWindowPtr; }