Annotation of researchv10dc/cmd/icon/pi/pil/getenv.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *     GETENV
                      3:  *
                      4:  *     Get values of environment variables.
                      5:  *
                      6:  *     Stephen B. Wampler
                      7:  *
                      8:  *     Last modified 5/2/86 by Ralph E. Griswold
                      9:  *
                     10:  */
                     11: 
                     12: #include "../h/rt.h"
                     13: 
                     14: /*
                     15:  * getenv(s) - return contents of environment variable s
                     16:  */
                     17: 
                     18: FncDcl(getenv,1)
                     19:    {
                     20:    register char *p;
                     21:    register int len;
                     22:    char sbuf[256];
                     23:    extern char *getenv();
                     24:    extern char *alcstr();
                     25: 
                     26: 
                     27:    if (!Qual(Arg1))                    /* check legality of argument */
                     28:       runerr(103, &Arg1);
                     29:    if (StrLen(Arg1) <= 0 || StrLen(Arg1) >= MaxCvtLen)
                     30:       runerr(401, &Arg1);
                     31:    qtos(&Arg1, sbuf);                  /* convert argument to C-style string */
                     32: 
                     33:    if ((p = getenv(sbuf)) != NULL) {   /* get environment variable */
                     34:       len = strlen(p);
                     35:       strreq(len);
                     36:       StrLen(Arg0) = len;
                     37:       StrLoc(Arg0) = alcstr(p, len);
                     38:       Return;
                     39:       }
                     40:    else                                        /* fail if variable not in environment */
                     41:       Fail;
                     42:    }

unix.superglobalmegacorp.com

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