home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
sysutl
/
printenv.arc
/
PRINTENV.C
next >
Wrap
Text File
|
1989-05-07
|
1KB
|
43 lines
/*
* 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);
}