home *** CD-ROM | disk | FTP | other *** search
- /*
- * printenv - print the "values" of shell variables, sort of like
- * in Unix. This one accepts multiple arguments, though.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- char copyright[] = "89.05.07 version (C) Copyright 1989 RAMontante";
- /* Permission granted to use or redistribute this program in source
- * or executable form, for noncommercial purposes, as long as this
- * copyright notice remains intact.
- */
-
- int return_val = 0;
-
- void main(int argc, char *argv[], char *env[])
- {
- char **envp, **argp;
- char *val;
- int no_match;
-
- if (argc < 2) {
- for (envp = env; *envp != NULL; ) {
- puts(*(envp++));
- }
- } else for (argp = argv; *(++argp) != NULL; ) {
- argc = strlen(*argp); /** Let's be cheap and reuse `argc' **/
- envp = env;
- while (*envp != NULL) {
- if (0 == (no_match = strnicmp(*envp++, *argp, argc))) {
- for (val = *(--envp) + argc; *(val++) != '='; )
- {}
- puts(val);
- break;
- }
- }
- if (no_match)
- return_val++;
- }
- exit(return_val);
- }