File:  [CSRG BSD Unix] / 43BSD / contrib / icon / pifuncs / getenv.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

/*
#	GETENV(3.icon)
#
#	Get contents of environment variables
#
#	Stephen B. Wampler
#
#	Last modified 8/19/84
#
*/

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

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

Xgetenv(nargs, arg1, arg0)
int nargs;
struct descrip arg1, arg0;
   {
   register char *p;
   register int len;
   char sbuf[MAXSTRING];
   extern char *getenv();
   extern char *alcstr();

   DeRef(arg1)

   if (!QUAL(arg1))			/* check legality of argument */
      runerr(103, &arg1);
   if (STRLEN(arg1) <= 0 || STRLEN(arg1) >= MAXSTRING)
      runerr(401, &arg1);
   qtos(&arg1, sbuf);			/* convert argument to C-style string */

   if ((p = getenv(sbuf)) != NULL) {	/* get environment variable */
      len = strlen(p);
      sneed(len);
      STRLEN(arg0) = len;
      STRLOC(arg0) = alcstr(p, len);
      }
   else					/* fail if variable not in environment */
      fail();
   }

Procblock(getenv,-1)

unix.superglobalmegacorp.com

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