1#include <stdio.h>
2#include <stdlib.h>
3
4extern char** environ;
5
6int printenv_main (int argc, char **argv)
7{
8    char** e;
9    char* v;
10    int i;
11
12    if (argc == 1) {
13        e = environ;
14        while (*e) {
15            printf("%s\n", *e);
16            e++;
17        }
18    } else {
19        for (i=1; i<argc; i++) {
20            v = getenv(argv[i]);
21            if (v) {
22                printf("%s\n", v);
23            }
24        }
25    }
26
27    return 0;
28}
29
30