Annotation of 43BSD/ucb/printenv.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #ifndef lint
                      8: char copyright[] =
                      9: "@(#) Copyright (c) 1980 Regents of the University of California.\n\
                     10:  All rights reserved.\n";
                     11: #endif not lint
                     12: 
                     13: #ifndef lint
                     14: static char sccsid[] = "@(#)printenv.c 5.1 (Berkeley) 5/31/85";
                     15: #endif not lint
                     16: 
                     17: /*
                     18:  * printenv
                     19:  *
                     20:  * Bill Joy, UCB
                     21:  * February, 1979
                     22:  */
                     23: 
                     24: extern char **environ;
                     25: 
                     26: main(argc, argv)
                     27:        int argc;
                     28:        char *argv[];
                     29: {
                     30:        register char **ep;
                     31:        int found = 0;
                     32: 
                     33:        argc--, argv++;
                     34:        if (environ)
                     35:                for (ep = environ; *ep; ep++)
                     36:                        if (argc == 0 || prefix(argv[0], *ep)) {
                     37:                                register char *cp = *ep;
                     38: 
                     39:                                found++;
                     40:                                if (argc) {
                     41:                                        while (*cp && *cp != '=')
                     42:                                                cp++;
                     43:                                        if (*cp == '=')
                     44:                                                cp++;
                     45:                                }
                     46:                                printf("%s\n", cp);
                     47:                        }
                     48:        exit (!found);
                     49: }
                     50: 
                     51: prefix(cp, dp)
                     52:        char *cp, *dp;
                     53: {
                     54: 
                     55:        while (*cp && *dp && *cp == *dp)
                     56:                cp++, dp++;
                     57:        if (*cp == 0)
                     58:                return (*dp == '=');
                     59:        return (0);
                     60: }

unix.superglobalmegacorp.com

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