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