getenv_.c
Go to the documentation of this file.
00001 #include "f2c.h"
00002 #undef abs
00003 #ifdef KR_headers
00004 extern char *F77_aloc(), *getenv();
00005 #else
00006 #include <stdlib.h>
00007 #include <string.h>
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 extern char *F77_aloc(ftnlen, const char*);
00012 #endif
00013 
00014 /*
00015  * getenv - f77 subroutine to return environment variables
00016  *
00017  * called by:
00018  *      call getenv (ENV_NAME, char_var)
00019  * where:
00020  *      ENV_NAME is the name of an environment variable
00021  *      char_var is a character variable which will receive
00022  *              the current value of ENV_NAME, or all blanks
00023  *              if ENV_NAME is not defined
00024  */
00025 
00026 #ifdef KR_headers
00027  VOID
00028 getenv_(fname, value, flen, vlen) char *value, *fname; ftnlen vlen, flen;
00029 #else
00030  void
00031 getenv_(char *fname, char *value, ftnlen flen, ftnlen vlen)
00032 #endif
00033 {
00034         char buf[256], *ep, *fp;
00035         integer i;
00036 
00037         if (flen <= 0)
00038                 goto add_blanks;
00039         for(i = 0; i < sizeof(buf); i++) {
00040                 if (i == flen || (buf[i] = fname[i]) == ' ') {
00041                         buf[i] = 0;
00042                         ep = getenv(buf);
00043                         goto have_ep;
00044                         }
00045                 }
00046         while(i < flen && fname[i] != ' ')
00047                 i++;
00048         strncpy(fp = F77_aloc(i+1, "getenv_"), fname, (int)i);
00049         fp[i] = 0;
00050         ep = getenv(fp);
00051         free(fp);
00052  have_ep:
00053         if (ep)
00054                 while(*ep && vlen-- > 0)
00055                         *value++ = *ep++;
00056  add_blanks:
00057         while(vlen-- > 0)
00058                 *value++ = ' ';
00059         }
00060 #ifdef __cplusplus
00061 }
00062 #endif


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:50