/* This file is part of the Project Athena Zephyr Notification System. * It contains code for the "znol" command. * * Created by: Robert French * * $Id$ * * Copyright (c) 1987 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file * "mit-copyright.h". */ #include #include #include #ifndef lint static const char rcsid_znol_c[] = "$Id$"; #endif #define SUBSATONCE 7 #define ON 1 #define OFF 0 int main(int argc, char *argv[]) { register char *cp; char *realm; ZSubscription_t subs[SUBSATONCE]; ZLocations_t locations; FILE *fp = NULL; struct passwd *pwd; char anyonename[BUFSIZ],name[BUFSIZ],cleanname[BUFSIZ],*envptr; char *comment_ptr; int onoff = ON,quiet = 0,justlist = 0,useronly = 0, filenamed = 0; int retval,arg,ind,one,numlocs,i; int wgport = 0; if ((retval = ZInitialize()) != ZERR_NONE) { com_err(argv[0],retval,"initializing"); exit (1); } for (arg=1;argpw_dir); } (void) strcat(anyonename,"/.anyone"); } /* 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; for (;;) { if (!useronly) { if (!fgets(cleanname,sizeof cleanname,fp)) break; if (cleanname[0] == '#' || cleanname[0] == '\0' || cleanname[0] == '\n') continue; /* ignore comment and empty lines */ comment_ptr = strchr(cleanname, '#'); if (comment_ptr) *comment_ptr = '\0'; /* Ignore from # onwards */ /* Get rid of old-style nol entries, just in case */ cp = cleanname + strlen(cleanname) - 1; *cp = '\0'; while(*--cp == ' ') *cp = '\0'; if (*cleanname == '@' || !*cleanname) continue; } else if (ind) break; /* only do the one name */ subs[ind].zsub_class = LOGIN_CLASS; (void) strcpy(name,cleanname); if (!strchr(name,'@')) { cp = name + strlen(name); *cp++ = '@'; (void) strcpy(cp,ZGetRealm()); } cp = strchr(name,'@'); if (cp[0] && strcmp(cp+1,ZGetRealm())) { realm = cp + 1; *cp = '\0'; if ((subs[ind].zsub_classinst = malloc((unsigned)(strlen(name) + strlen(realm) + 2))) == NULL) { fprintf (stderr, "znol: out of memory"); exit (1); } (void) sprintf(subs[ind].zsub_classinst, "%s@%s", name, realm); (void) strcpy(name, subs[ind].zsub_classinst); if ((subs[ind].zsub_recipient = malloc((unsigned)(strlen(realm)+2))) == NULL) { fprintf (stderr, "znol: out of memory"); exit (1); } (void) sprintf(subs[ind++].zsub_recipient, "@%s", realm); } else { if ((subs[ind].zsub_classinst = malloc((unsigned)(strlen(name)+1))) == NULL) { fprintf (stderr, "znol: out of memory"); exit (1); } (void) strcpy(subs[ind].zsub_classinst, name); subs[ind++].zsub_recipient = ""; } if (!quiet && onoff == ON) { if ((retval = ZLocateUser(name,&numlocs,ZAUTH)) != ZERR_NONE) { com_err(argv[0],retval,"locating user"); exit(1); } one = 1; if (numlocs) { for (i=0;i