Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site bnl.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!linus!philabs!sbcs!bnl!slb From: slb@bnl.UUCP (San Barr hanging out @ The Beach) Newsgroups: net.sources Subject: Updated cwho.c for Chat system Message-ID: <879@bnl.UUCP> Date: Thu, 14-Feb-85 18:15:50 EST Article-I.D.: bnl.879 Posted: Thu Feb 14 18:15:50 1985 Date-Received: Mon, 18-Feb-85 05:12:58 EST Distribution: net Lines: 53 I've updated the small cwho utility for the Chat system so it notifies the user "No users logged into Chat" if no-one is logged in insted of sitting there, rather dumb, and not printing any messages. Please send all updates and improvments to slb@bnl.ARPA ----------------CUT HERE---------------- #include #include #include #include "chat.h" struct stat sbuf; struct logs lbuf; main() /* Show who's logged into chat */ { int lfile; if (stat(LOGFILE) == EOF) { puts("No users logged into Chat."); exit(1); } if (sbuf.st_size == 0) { puts("No users logged into Chat."); exit(1); } if ((lfile=open(LOGFILE, 0)) == EOF) exit(1); puts("Users In Chat Tty When"); while (read(lfile, (char *) &lbuf, sizeof(lbuf))==sizeof(lbuf)) { if (lbuf.l_line[0]=='\0' || lbuf.l_name[0]=='\0') continue; /* Skip blankies */ printf("%-20.20s %-5.5s %7.7s\n",lbuf.l_name, lbuf.l_line,lbuf.l_time); } if (close(lfile) == EOF) { perror(LOGFILE); exit(1); } } -- Sanford L. Barr Famous designer of the Write Only Memory. -- -- ..!decvax!philabs!sbcs!bnl!slb