/* This file is part of the Project Athena Zephyr Notification System. * It contains code for the "znol" command. * * Created by: Robert French * * $Source$ * $Author$ * * Copyright (c) 1987 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file * "mit-copyright.h". */ #include #include #include #include #ifndef lint static char rcsid_znol_c[] = "$Header$"; #endif lint #define SUBSATONCE 7 #define ON 1 #define OFF 0 extern char *getenv(), *malloc(); extern uid_t getuid(); main(argc,argv) int argc; char *argv[]; { ZSubscription_t subs[SUBSATONCE]; ZLocations_t locations; FILE *fp; struct passwd *pwd; char anyonename[BUFSIZ],name[BUFSIZ],cleanname[BUFSIZ],*envptr; int onoff = ON,quiet = 0,justlist = 0,useronly = 0, filenamed = 0; int retval,arg,ind,one,numlocs,i; short wgport; 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] == '#') /* ignore comment lines */ continue; /* Get rid of old-style nol entries, just in case */ cleanname[strlen(cleanname)-1] = '\0'; while (cleanname[strlen(cleanname)-1] == ' ') cleanname[strlen(cleanname)-1] = '\0'; if (*cleanname == '@' || !*cleanname) continue; } else if (ind) break; /* only do the one name */ subs[ind].class = LOGIN_CLASS; (void) strcpy(name,cleanname); if (!index(name,'@')) { (void) strcat(name,"@"); (void) strcat(name,ZGetRealm()); } subs[ind].classinst = malloc((unsigned)(strlen(name)+1)); (void) strcpy(subs[ind].classinst,name); subs[ind++].recipient = ""; if (!quiet && onoff == ON) { if ((retval = ZLocateUser(name,&numlocs)) != ZERR_NONE) { com_err(argv[0],retval,"locating user"); exit(1); } one = 1; if (numlocs) { for (i=0;i