Annotation of 43BSDReno/usr.bin/uucp/uulog.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)uulog.c    5.6     (Berkeley) 5/4/88";
                      3: #endif
                      4: 
                      5: #include "uucp.h"
                      6: 
                      7: struct timeb Now;
                      8: 
                      9: main(argc, argv)
                     10: char *argv[];
                     11: {
                     12: #ifndef LOGBYSITE
                     13:        FILE *plogf;
                     14:        char u[64], s[64];
                     15: #endif /* !LOGBYSITE */
                     16:        char *sys, *user;
                     17:        int c;
                     18:        extern char *optarg;
                     19:        extern int optind;
                     20: 
                     21:        char buf[BUFSIZ];
                     22: 
                     23:        strcpy(Progname, "uulog");
                     24:        sys = user = NULL;
                     25: 
                     26:        while ((c = getopt(argc, argv, "s:u:")) != EOF)
                     27:                switch (c) {
                     28:                case 's':
                     29:                        sys = optarg;
                     30:                        if (strlen(sys) > MAXBASENAME)
                     31:                                sys[MAXBASENAME] = '\0';
                     32:                        if (versys(&sys) != SUCCESS){
                     33:                                fprintf(stderr,"uulog: unknown system %s\n", sys);
                     34:                                sys = NULL;
                     35:                        }
                     36:                        break;
                     37:                case 'u':
                     38:                        user = optarg;
                     39:                        break;
                     40:                case '?':
                     41:                default:
                     42:                        fprintf(stderr, "unknown flag %s\n", argv[optind-1]);
                     43:                        break;
                     44:                }
                     45: 
                     46:        if (user == NULL && sys == NULL) {
                     47:                fprintf(stderr, "usage: uulog [-u user] [-s sys]\n");
                     48:                exit(1);
                     49:        }
                     50: 
                     51: #ifdef LOGBYSITE
                     52:        if (chdir(SPOOL) < 0) {
                     53:                perror(SPOOL);
                     54:                exit(1);
                     55:        }
                     56:        /* this program is really obsolete, this is a rude backward compat */
                     57:        if (user) {
                     58:                sprintf(buf, "exec cat LOG/uu*/* | egrep '^%s '", user);
                     59:                system(buf);
                     60:        }
                     61:        if (sys) {
                     62:                sprintf(buf,"exec cat LOG/uu*/%s", sys);
                     63:                system(buf);
                     64:        }
                     65: #else !LOGBYSITE
                     66:        plogf = fopen(LOGFILE, "r");
                     67:        if (plogf == NULL) {
                     68:                syslog(LOG_WARNING, "fopen(%s) failed: %m", LOGFILE);
                     69:                cleanup(1);
                     70:        }
                     71:        while (fgets(buf, BUFSIZ, plogf) != NULL) {
                     72:                sscanf(buf, "%s%s", u, s);
                     73:                if (user != NULL && !(prefix(user, u) || prefix(u, user)))
                     74:                        continue;
                     75:                if (sys != NULL && !(prefix(sys, s) || prefix(s, sys)))
                     76:                        continue;
                     77:                fputs(buf, stdout);
                     78:                fflush(stdout);
                     79:        }
                     80: #endif !LOGBYSITE
                     81:        exit(0);
                     82: }
                     83: 
                     84: cleanup(code)
                     85: int code;
                     86: {
                     87:        exit(code);
                     88: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.