source: parpcx/trunk/src/pcx/F2C/getenv_.c @ 2701

Revision 2701, 1.2 KB checked in by lafisk, 8 years ago (diff)

adding #include <acro_config.h>
parpcx isn't building yet because we haven't written a Makefile for it

( Links to Acro-related mail archives at  http://software.sandia.gov/Acro/ )

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#include <acro_config.h>
2#include "f2c.h"
3#undef abs
4#ifdef KR_headers
5extern char *F77_aloc(), *getenv();
6#else
7#include <stdlib.h>
8#include <string.h>
9#ifdef __cplusplus
10extern "C" {
11#endif
12extern char *F77_aloc(ftnlen, char*);
13#endif
14
15/*
16 * getenv - f77 subroutine to return environment variables
17 *
18 * called by:
19 *      call getenv (ENV_NAME, char_var)
20 * where:
21 *      ENV_NAME is the name of an environment variable
22 *      char_var is a character variable which will receive
23 *              the current value of ENV_NAME, or all blanks
24 *              if ENV_NAME is not defined
25 */
26
27#ifdef KR_headers
28 VOID
29getenv_(fname, value, flen, vlen) char *value, *fname; ftnlen vlen, flen;
30#else
31 void
32getenv_(char *fname, char *value, ftnlen flen, ftnlen vlen)
33#endif
34{
35        char buf[256], *ep, *fp;
36        integer i;
37
38        if (flen <= 0)
39                goto add_blanks;
40        for(i = 0; i < sizeof(buf); i++) {
41                if (i == flen || (buf[i] = fname[i]) == ' ') {
42                        buf[i] = 0;
43                        ep = getenv(buf);
44                        goto have_ep;
45                        }
46                }
47        while(i < flen && fname[i] != ' ')
48                i++;
49        strncpy(fp = F77_aloc(i+1, "getenv_"), fname, (int)i);
50        fp[i] = 0;
51        ep = getenv(fp);
52        free(fp);
53 have_ep:
54        if (ep)
55                while(*ep && vlen-- > 0)
56                        *value++ = *ep++;
57 add_blanks:
58        while(vlen-- > 0)
59                *value++ = ' ';
60        }
61#ifdef __cplusplus
62}
63#endif
Note: See TracBrowser for help on using the repository browser.