1998-02-01 02:37:08 +01:00
|
|
|
#include "f2c.h"
|
1999-04-12 22:42:45 +02:00
|
|
|
#undef abs
|
|
|
|
#include <stdlib.h>
|
1999-05-03 10:35:22 +02:00
|
|
|
#include <string.h>
|
2002-06-01 14:38:32 +02:00
|
|
|
extern char *F77_aloc (ftnlen, char *);
|
1999-04-12 22:42:45 +02:00
|
|
|
|
1998-02-01 02:37:08 +01:00
|
|
|
/*
|
|
|
|
* getenv - f77 subroutine to return environment variables
|
|
|
|
*
|
|
|
|
* called by:
|
|
|
|
* call getenv (ENV_NAME, char_var)
|
|
|
|
* where:
|
|
|
|
* ENV_NAME is the name of an environment variable
|
|
|
|
* char_var is a character variable which will receive
|
|
|
|
* the current value of ENV_NAME, or all blanks
|
|
|
|
* if ENV_NAME is not defined
|
|
|
|
*/
|
|
|
|
|
2002-06-01 14:38:32 +02:00
|
|
|
void
|
1999-05-03 10:35:22 +02:00
|
|
|
G77_getenv_0 (char *fname, char *value, ftnlen flen, ftnlen vlen)
|
1998-02-01 02:37:08 +01:00
|
|
|
{
|
2002-06-01 14:38:32 +02:00
|
|
|
char buf[256], *ep, *fp;
|
|
|
|
integer i;
|
1999-05-03 10:35:22 +02:00
|
|
|
|
2002-06-01 14:38:32 +02:00
|
|
|
if (flen <= 0)
|
|
|
|
goto add_blanks;
|
2002-06-02 14:54:28 +02:00
|
|
|
for (i = 0; i < (integer) sizeof (buf); i++)
|
2002-06-01 14:38:32 +02:00
|
|
|
{
|
|
|
|
if (i == flen || (buf[i] = fname[i]) == ' ')
|
|
|
|
{
|
|
|
|
buf[i] = 0;
|
|
|
|
ep = getenv (buf);
|
|
|
|
goto have_ep;
|
1999-05-03 10:35:22 +02:00
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
}
|
|
|
|
while (i < flen && fname[i] != ' ')
|
|
|
|
i++;
|
|
|
|
strncpy (fp = F77_aloc (i + 1, "getenv_"), fname, (int) i);
|
|
|
|
fp[i] = 0;
|
|
|
|
ep = getenv (fp);
|
|
|
|
free (fp);
|
|
|
|
have_ep:
|
|
|
|
if (ep)
|
|
|
|
while (*ep && vlen-- > 0)
|
|
|
|
*value++ = *ep++;
|
|
|
|
add_blanks:
|
|
|
|
while (vlen-- > 0)
|
|
|
|
*value++ = ' ';
|
|
|
|
}
|