File:  [Research Unix] / researchv10dc / cmd / icon / pi / pil / getenv.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 3 months ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Dan Cross

/*
 *	GETENV
 *
 *	Get values of environment variables.
 *
 *	Stephen B. Wampler
 *
 *	Last modified 5/2/86 by Ralph E. Griswold
 *
 */

#include "../h/rt.h"

/*
 * getenv(s) - return contents of environment variable s
 */

FncDcl(getenv,1)
   {
   register char *p;
   register int len;
   char sbuf[256];
   extern char *getenv();
   extern char *alcstr();


   if (!Qual(Arg1))			/* check legality of argument */
      runerr(103, &Arg1);
   if (StrLen(Arg1) <= 0 || StrLen(Arg1) >= MaxCvtLen)
      runerr(401, &Arg1);
   qtos(&Arg1, sbuf);			/* convert argument to C-style string */

   if ((p = getenv(sbuf)) != NULL) {	/* get environment variable */
      len = strlen(p);
      strreq(len);
      StrLen(Arg0) = len;
      StrLoc(Arg0) = alcstr(p, len);
      Return;
      }
   else					/* fail if variable not in environment */
      Fail;
   }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.