Annotation of 43BSD/contrib/icon/pifuncs/getenv.c, revision 1.1.1.1

1.1       root        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)

unix.superglobalmegacorp.com

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