Annotation of coherent/a/usr/bob/uusrc/src/uulog.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *  uulog.c
                      3:  *
                      4:  *  Dump the UUCP uucico or uuxqt log files.
                      5:  */
                      6: 
                      7: #include "dcp.h"
                      8: 
                      9: #define LOGSDIR         ".Log"
                     10: 
                     11: char   logdir[LOGFLEN];
                     12: char   command[BUFSIZ];
                     13: char   *sysname = NULL;
                     14: char   *process = "uucico";
                     15: int    fflag = 0;
                     16: int    tailnum = 0;
                     17: 
                     18: extern int optind;
                     19: extern int optopt;
                     20: extern char *optarg;
                     21: 
                     22: main(argc, argv)
                     23: int argc;
                     24: char *argv[];
                     25: {
                     26:        int ch, exstat=0;
                     27: 
                     28:        while ( (ch=getopt(argc, argv, "f:n:vVx")) != EOF ) {
                     29:                switch (ch) {
                     30:                case 'f':
                     31:                        fflag = 1;
                     32:                        sysname = optarg;
                     33:                        break;
                     34:                case 'n':
                     35:                        tailnum = atoi(optarg);
                     36:                        break;
                     37:                case 'x':
                     38:                        process = "uuxqt";
                     39:                        break;
                     40:                case 'v':
                     41:                case 'V':
                     42:                        fatal("uulog: Version %s", VERSION);
                     43:                case '?':
                     44:                default:
                     45:                        usage("Improper option usage: %c", optopt);
                     46:                }
                     47:        }
                     48:        sprintf(logdir, "%s/%s/%s", SPOOLDIR, LOGSDIR, process);
                     49:        if ( fflag ) {
                     50:                if ( optind < argc )
                     51:                        usage("only one system with -f flag");
                     52:                if ( tailnum > 0 )
                     53:                        sprintf(command, "tail -%df %s/%s", tailnum,
                     54:                                                        logdir, sysname);
                     55:                else
                     56:                        sprintf(command, "tail -f %s/%s", logdir, sysname);
                     57:                exit( system(command) );
                     58:        }
                     59: 
                     60:        if ( optind >= argc ) {
                     61:                if ( tailnum > 0 )
                     62:                        sprintf(command, "for zz in `uuname`; do \
                     63:                                          tail -%d %s/$zz; done",
                     64:                                                        tailnum, logdir);
                     65:                else
                     66:                        sprintf(command, "for zz in `uuname`; do \
                     67:                                          cat %s/$zz; done", logdir);
                     68:                exit( system(command) );
                     69:        }
                     70: 
                     71:        for (;optind<argc; optind++) {
                     72:                if ( tailnum > 0 )
                     73:                        sprintf(command, "tail -%d %s/%s", tailnum,
                     74:                                                logdir, argv[optind]);
                     75:                else
                     76:                        sprintf(command, "cat %s/%s", logdir, argv[optind]);
                     77:                exstat |= system(command);
                     78:        }
                     79:        exit(exstat);
                     80: }
                     81: 
                     82: usage(x)
                     83: {
                     84:        fatal("\n%r\n\
                     85: Usage: uulog [ -n <tail-numlines> ] [ -x ] [ -f <sys> ]\n\
                     86:        uulog [ -n <tail-numlines> ] [ -x ] [ system ... ]\n\
                     87: ", &x);
                     88: }

unix.superglobalmegacorp.com

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