113685Ssam #ifndef lint 2*23687Sbloom static char sccsid[] = "@(#)uulog.c 5.4 (Berkeley) 06/23/85"; 313685Ssam #endif 413685Ssam 513685Ssam #include "uucp.h" 613685Ssam 713685Ssam #ifndef SYSBUF 813685Ssam static char SYSBUF[BUFSIZ]; 913685Ssam #endif 1013685Ssam 1113685Ssam main(argc, argv) 1213685Ssam char *argv[]; 1313685Ssam { 1413685Ssam FILE *plogf; 1518625Sralph char *sys, *user; 1613685Ssam 1718625Sralph char buf[BUFSIZ], u[64], s[64]; 1813685Ssam 1913685Ssam setbuf(stdout, SYSBUF); 2013685Ssam strcpy(Progname, "uulog"); 2118625Sralph sys = user = NULL; 2213685Ssam 2313685Ssam 2413685Ssam while (argc>1 && argv[1][0] == '-') { 2513685Ssam switch (argv[1][1]) { 2613685Ssam case 's': 2718625Sralph sys = &argv[1][2]; 2818625Sralph if (*sys == NULL && argc > 2 && argv[2][0] != '-') { 2918625Sralph sys = &argv[2][0]; 3013685Ssam argv++; 3113685Ssam argc--; 3213685Ssam } 33*23687Sbloom if (strlen(sys) > MAXBASENAME) 34*23687Sbloom sys[MAXBASENAME] = '\0'; 3518625Sralph if (versys(&sys) != SUCCESS){ 3618625Sralph fprintf(stderr,"uulog: unknown system %s\n", sys); 3718625Sralph sys = NULL; 3818625Sralph } 3913685Ssam break; 4013685Ssam case 'u': 4113685Ssam user = &argv[1][2]; 4213685Ssam if (*user == NULL && argc > 2 && argv[2][0] != '-') { 4313685Ssam user = &argv[2][0]; 4413685Ssam argv++; 4513685Ssam argc--; 4613685Ssam } 4713685Ssam break; 4813685Ssam default: 4913685Ssam printf("unknown flag %s\n", argv[1]); break; 5013685Ssam } 5113685Ssam --argc; argv++; 5213685Ssam } 5313685Ssam 5413685Ssam 5518625Sralph if (user == NULL && sys == NULL) { 5618625Sralph fprintf(stderr, "usage: uulog [-u user] [-s sys]\n"); 5713685Ssam exit(1); 5813685Ssam } 5913685Ssam 6018625Sralph #ifdef LOGBYSITE 6118625Sralph if (chdir(SPOOL) < 0) { 6218625Sralph perror(SPOOL); 6318625Sralph exit(1); 6418625Sralph } 6518625Sralph /* this program is really obsolete, this is a rude backward compat */ 6618625Sralph if (user) { 6718625Sralph sprintf(buf, "exec cat LOG/uu*/* | egrep '^%s '", user); 6818625Sralph system(buf); 6918625Sralph } 7018625Sralph if (sys) { 7118625Sralph sprintf(buf,"exec cat LOG/uu*/%s", sys); 7218625Sralph system(buf); 7318625Sralph } 7418625Sralph #else !LOGBYSITE 7513685Ssam plogf = fopen(LOGFILE, "r"); 7613685Ssam ASSERT(plogf != NULL, "CAN NOT OPEN", LOGFILE, 0); 7713685Ssam while (fgets(buf, BUFSIZ, plogf) != NULL) { 7813685Ssam sscanf(buf, "%s%s", u, s); 7913685Ssam if (user != NULL && !prefix(user, u)) 8013685Ssam continue; 8118625Sralph if (sys != NULL && !prefix(sys, s)) 8213685Ssam continue; 8313685Ssam fputs(buf, stdout); 8413685Ssam fflush(stdout); 8513685Ssam } 8618625Sralph #endif !LOGBYSITE 8713685Ssam exit(0); 8813685Ssam } 8913685Ssam 9013685Ssam cleanup(code) 9113685Ssam int code; 9213685Ssam { 9313685Ssam exit(code); 9413685Ssam } 95