Created
June 23, 2009 19:39
-
-
Save e1senh0rn/134780 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef lint | |
char copyright[] = | |
"@(#) Copyright (c) 1987 Regents of the University of California.\n\ | |
All rights reserved.\n"; | |
#endif /* not lint */ | |
#ifndef lint | |
static char rcsid[] = "$OpenBSD: guesswhat.c,v 1.5 2003/06/10 22:20:49 deraadt Exp $"; | |
#endif /* not lint */ | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int | |
main(int argc, char *argv[]) | |
{ | |
extern char **environ; | |
char *cp, **ep; | |
int len; | |
if (argc < 2) { | |
for (ep = environ; *ep; ep++) | |
puts(*ep); | |
exit(0); | |
} | |
len = strlen(*++argv); | |
for (ep = environ; *ep; ep++) | |
if (!strncmp(*ep, *argv, len)) { | |
cp = *ep + len; | |
if (!*cp || *cp == '=') { | |
puts(*cp ? cp + 1 : cp); | |
exit(0); | |
} | |
} | |
exit(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment