1: /*
   2: #	GETENV(3.icon)
   3: #
   4: #	Get contents of environment variables
   5: #
   6: #	Stephen B. Wampler
   7: #
   8: #	Last modified 8/19/84
   9: #
  10: */
  11: 
  12: #include "../h/rt.h"
  13: 
  14: /*
  15:  * getenv(s) - return contents of environment variable s
  16:  */
  17: 
  18: Xgetenv(nargs, arg1, arg0)
  19: int nargs;
  20: struct descrip arg1, arg0;
  21:    {
  22:    register char *p;
  23:    register int len;
  24:    char sbuf[MAXSTRING];
  25:    extern char *getenv();
  26:    extern char *alcstr();
  27: 
  28:    DeRef(arg1)
  29: 
  30:    if (!QUAL(arg1))         /* check legality of argument */
  31:       runerr(103, &arg1);
  32:    if (STRLEN(arg1) <= 0 || STRLEN(arg1) >= MAXSTRING)
  33:       runerr(401, &arg1);
  34:    qtos(&arg1, sbuf);           /* convert argument to C-style string */
  35: 
  36:    if ((p = getenv(sbuf)) != NULL) {    /* get environment variable */
  37:       len = strlen(p);
  38:       sneed(len);
  39:       STRLEN(arg0) = len;
  40:       STRLOC(arg0) = alcstr(p, len);
  41:       }
  42:    else                 /* fail if variable not in environment */
  43:       fail();
  44:    }
  45: 
  46: Procblock(getenv,-1)

Defined functions

Xgetenv defined in line 18; never used
Last modified: 1984-08-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 823
Valid CSS Valid XHTML 1.0 Strict