summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorGravatar John Kohl <jtkohl@mit.edu>1989-10-30 04:47:10 +0000
committerGravatar John Kohl <jtkohl@mit.edu>1989-10-30 04:47:10 +0000
commit5264caa5b84b684462dc95dca998f27e4ab74c69 (patch)
tree0469df22d1b43d8dba6f8f1be3791965f8cdef51 /clients
parent7847819337c18f8dfa6b574edcc931b96361562b (diff)
add support for -f - (read stdin)
(code from Marc Horowitz)
Diffstat (limited to 'clients')
-rw-r--r--clients/znol/znol.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/clients/znol/znol.c b/clients/znol/znol.c
index 826add2..4af99b6 100644
--- a/clients/znol/znol.c
+++ b/clients/znol/znol.c
@@ -47,19 +47,6 @@ main(argc,argv)
exit (1);
}
- envptr = getenv("HOME");
- if (envptr)
- (void) strcpy(anyonename,envptr);
- else {
- if (!(pwd = getpwuid((int) getuid()))) {
- fprintf(stderr,"Who are you?\n");
- exit (1);
- }
-
- (void) strcpy(anyonename,pwd->pw_dir);
- }
- (void) strcat(anyonename,"/.anyone");
-
for (arg=1;arg<argc;arg++) {
if (!strcmp(argv[arg],"on")) {
onoff = ON;
@@ -114,10 +101,29 @@ main(argc,argv)
exit(1);
}
+ if (!useronly) {
+ /* If no filename specified, get the default */
+ if (!filenamed) {
+ envptr = getenv("HOME");
+ if (envptr)
+ (void) strcpy(anyonename,envptr);
+ else {
+ if (!(pwd = getpwuid((int) getuid()))) {
+ fprintf(stderr,"You are not listed in the password file.\n");
+ exit (1);
+ }
+ (void) strcpy(anyonename,pwd->pw_dir);
+ }
+ (void) strcat(anyonename,"/.anyone");
+ }
- if (!useronly && !(fp = fopen(anyonename,"r"))) {
- fprintf(stderr,"Can't open %s for input\n",anyonename);
- exit (1);
+ /* if the filename is "-", read stdin */
+ if (strcmp(anyonename,"-") == 0) {
+ fp = stdin;
+ } else if (!(fp = fopen(anyonename,"r"))) {
+ fprintf(stderr,"Can't open %s for input\n",anyonename);
+ exit (1);
+ }
}
ind = 0;