113685Ssam #ifndef lint 2*34173Srick static char sccsid[] = "@(#)uulog.c 5.6 (Berkeley) 05/04/88"; 313685Ssam #endif 413685Ssam 513685Ssam #include "uucp.h" 613685Ssam 7*34173Srick struct timeb Now; 8*34173Srick 913685Ssam main(argc, argv) 1013685Ssam char *argv[]; 1113685Ssam { 1233961Srick #ifndef LOGBYSITE 1313685Ssam FILE *plogf; 1433961Srick char u[64], s[64]; 1533961Srick #endif /* !LOGBYSITE */ 1618625Sralph char *sys, *user; 1733961Srick int c; 1833961Srick extern char *optarg; 1933961Srick extern int optind; 2013685Ssam 2133961Srick char buf[BUFSIZ]; 2213685Ssam 2313685Ssam strcpy(Progname, "uulog"); 2418625Sralph sys = user = NULL; 2513685Ssam 2633961Srick while ((c = getopt(argc, argv, "s:u:")) != EOF) 2733961Srick switch (c) { 2813685Ssam case 's': 2933961Srick sys = optarg; 3023687Sbloom if (strlen(sys) > MAXBASENAME) 3123687Sbloom sys[MAXBASENAME] = '\0'; 3218625Sralph if (versys(&sys) != SUCCESS){ 3318625Sralph fprintf(stderr,"uulog: unknown system %s\n", sys); 3418625Sralph sys = NULL; 3518625Sralph } 3613685Ssam break; 3713685Ssam case 'u': 3833961Srick user = optarg; 3913685Ssam break; 4033961Srick case '?': 4113685Ssam default: 4233961Srick fprintf(stderr, "unknown flag %s\n", argv[optind-1]); 4333961Srick break; 4413685Ssam } 4513685Ssam 4618625Sralph if (user == NULL && sys == NULL) { 4718625Sralph fprintf(stderr, "usage: uulog [-u user] [-s sys]\n"); 4813685Ssam exit(1); 4913685Ssam } 5013685Ssam 5118625Sralph #ifdef LOGBYSITE 5218625Sralph if (chdir(SPOOL) < 0) { 5318625Sralph perror(SPOOL); 5418625Sralph exit(1); 5518625Sralph } 5618625Sralph /* this program is really obsolete, this is a rude backward compat */ 5718625Sralph if (user) { 5818625Sralph sprintf(buf, "exec cat LOG/uu*/* | egrep '^%s '", user); 5918625Sralph system(buf); 6018625Sralph } 6118625Sralph if (sys) { 6218625Sralph sprintf(buf,"exec cat LOG/uu*/%s", sys); 6318625Sralph system(buf); 6418625Sralph } 6518625Sralph #else !LOGBYSITE 6613685Ssam plogf = fopen(LOGFILE, "r"); 6733961Srick if (plogf == NULL) { 6833961Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", LOGFILE); 6933961Srick cleanup(1); 7033961Srick } 7113685Ssam while (fgets(buf, BUFSIZ, plogf) != NULL) { 7213685Ssam sscanf(buf, "%s%s", u, s); 7333961Srick if (user != NULL && !(prefix(user, u) || prefix(u, user))) 7413685Ssam continue; 7533961Srick if (sys != NULL && !(prefix(sys, s) || prefix(s, sys))) 7613685Ssam continue; 7713685Ssam fputs(buf, stdout); 7813685Ssam fflush(stdout); 7913685Ssam } 8018625Sralph #endif !LOGBYSITE 8113685Ssam exit(0); 8213685Ssam } 8313685Ssam 8413685Ssam cleanup(code) 8513685Ssam int code; 8613685Ssam { 8713685Ssam exit(code); 8813685Ssam } 89