Re: 4gl - How Can I Read UNIX* Env. Variables ???
Posted in 1994
/* */ /* This function returns an environment variable to a 4gl calling module. */ /* The process_id is returned as if stored in an environment variable PID. */ /* The general function was developed by Don Edwards and Allen Huang */ /* based on two specific functions developed by Gloria Chu. */ /* */ /* Modifed by R. Hoskins to return a NULL terminated string if the */ /* environment variable does not exist. */ /* */ /******************************************************************************/ #include <string.h> #include <stdio.h> get_env_var() { char envvar[16]; char *envval,*getenv(); int i; popquote(envvar,16); for( i=0; i<16 && envvar[i] != ' ' ;i++ ) { } envvar[i]='\\0'; if(strcmp(envvar,"PID") == 0) { i=getpid(); sprintf(envvar,"%d",i); envval=envvar; } else if (!(envval=getenv(envvar))) envval = "\\0"; retquote(envval); return(1); } ciao p ****************************************************************************** Peter Wages VSE Corporation 2760 Eisenhower Ave Alexandria, Virginia pmwages@cais.com Work: (703) 329-2626 Home: (202) 244-3511 ******************************************************************************