Annotation of 42BSD/usr.bin/uucp/uulog.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)uulog.c    5.1 (Berkeley) 7/2/83";
                      3: #endif
                      4: 
                      5: #include "uucp.h"
                      6: 
                      7: #ifndef        SYSBUF
                      8: static char SYSBUF[BUFSIZ];
                      9: #endif
                     10: 
                     11: /*******
                     12:  *
                     13:  *     uulog  -  
                     14:  *
                     15:  *     options:
                     16:  *             -s  -  system name for search
                     17:  *             -u  -  user name for search
                     18:  *
                     19:  *     exit codes:
                     20:  *             0  -  normal
                     21:  *
                     22:  */
                     23: 
                     24: main(argc, argv)
                     25: char *argv[];
                     26: {
                     27:        FILE *plogf;
                     28:        char *system, *user;
                     29: 
                     30:        char buf[BUFSIZ], u[20], s[20];
                     31: 
                     32:        setbuf(stdout, SYSBUF);
                     33:        strcpy(Progname, "uulog");
                     34:        system = user = NULL;
                     35: 
                     36: 
                     37:        while (argc>1 && argv[1][0] == '-') {
                     38:                switch (argv[1][1]) {
                     39:                case 's':
                     40:                        system = &argv[1][2];
                     41:                        if (*system == NULL && argc > 2 && argv[2][0] != '-') {
                     42:                                system = &argv[2][0];
                     43:                                argv++;
                     44:                                argc--;
                     45:                        }
                     46:                        if (strlen(system) > 7)
                     47:                                system[7] = 0;
                     48:                        break;
                     49:                case 'u':
                     50:                        user = &argv[1][2];
                     51:                        if (*user == NULL && argc > 2 && argv[2][0] != '-') {
                     52:                                user = &argv[2][0];
                     53:                                argv++;
                     54:                                argc--;
                     55:                        }
                     56:                        break;
                     57:                default:
                     58:                        printf("unknown flag %s\n", argv[1]); break;
                     59:                }
                     60:                --argc;  argv++;
                     61:        }
                     62: 
                     63: 
                     64:        if (user == NULL && system == NULL) {
                     65:                fprintf(stderr, "usage: uulog [-u user] [-s system]\n");
                     66:                exit(1);
                     67:        }
                     68: /*     chmod(LOGFILE, 0666);   rm-ed by rti!trt */
                     69: 
                     70:        plogf = fopen(LOGFILE, "r");
                     71:        ASSERT(plogf != NULL, "CAN NOT OPEN", LOGFILE, 0);
                     72:        while (fgets(buf, BUFSIZ, plogf) != NULL) {
                     73:                sscanf(buf, "%s%s", u, s);
                     74:                if (user != NULL && !prefix(user, u))
                     75:                        continue;
                     76:                if (system != NULL && !prefix(system, s))
                     77:                        continue;
                     78:                fputs(buf, stdout);
                     79:                fflush(stdout);
                     80:        }
                     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.