Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

getenv_.c

Go to the documentation of this file.
00001 #include "f2c.h"
00002 
00003 /*
00004  * getenv - f77 subroutine to return environment variables
00005  *
00006  * called by:
00007  *      call getenv (ENV_NAME, char_var)
00008  * where:
00009  *      ENV_NAME is the name of an environment variable
00010  *      char_var is a character variable which will receive
00011  *              the current value of ENV_NAME, or all blanks
00012  *              if ENV_NAME is not defined
00013  */
00014 
00015 #ifdef KR_headers
00016 VOID getenv_(fname, value, flen, vlen) char *value, *fname; ftnlen vlen, flen;
00017 #else
00018 void getenv_(char *fname, char *value, ftnlen flen, ftnlen vlen)
00019 #endif
00020 {
00021 extern char **environ;
00022 register char *ep, *fp, *flast;
00023 register char **env = environ;
00024 
00025 flast = fname + flen;
00026 for(fp = fname ; fp < flast ; ++fp)
00027         if(*fp == ' ')
00028                 {
00029                 flast = fp;
00030                 break;
00031                 }
00032 
00033 while (ep = *env++)
00034         {
00035         for(fp = fname; fp<flast ; )
00036                 if(*fp++ != *ep++)
00037                         goto endloop;
00038 
00039         if(*ep++ == '=') {      /* copy right hand side */
00040                 while( *ep && --vlen>=0 )
00041                         *value++ = *ep++;
00042 
00043                 goto blank;
00044                 }
00045 endloop: ;
00046         }
00047 
00048 blank:
00049         while( --vlen >= 0 )
00050                 *value++ = ' ';
00051 }
 

Powered by Plone

This site conforms to the following standards: