Annotation of 43BSDTahoe/new/notes/utility/nfrank.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <ctype.h>
        !             3: /*     Using data gleaned from nfstats, prints notesfile popularity
        !             4: **     sorted by number of entries. The largest value is to be ignored
        !             5: **     'cause it's really the total for all notesfiles.
        !             6: **     Charley Kline, Tue May 31 09:59:57 CDT 1983
        !             7:  *
        !             8:  * $Header: /mntb/3/srg/notes/work/utility/RCS/nfrank.c,v 1.6 84/03/07 19:05:21 notes Exp $
        !             9: */
        !            10: #define NAMEPOS 13
        !            11: char    buf[80];
        !            12: 
        !            13: main ()
        !            14: {
        !            15:     FILE * popen (), *fdns, *fdtemp;
        !            16:     char   *fgets (), *rindex (), nfname[30], entries[20];
        !            17:     char    hostname[32];
        !            18: 
        !            19:     if ((fdns = popen ("nfstats net.\\*", "r")) == NULL)
        !            20:        perror ("nfstats"),
        !            21:            exit (-1);
        !            22:     fdtemp = fopen ("/tmp/top20junk", "w");
        !            23:     gethostname (hostname, sizeof hostname);
        !            24:     while (fgets (buf, sizeof buf, fdns) != NULL)
        !            25:     {
        !            26:        if (Index (buf, hostname))
        !            27:            bufcopy (buf, NAMEPOS, nfname);
        !            28:        if (!strncmp (buf, "Orphan", 6))
        !            29:            bufcopy (rindex (buf, ':'), 2, entries),
        !            30:                fprintf (fdtemp, "%8d\t%s\n", atoi (entries), nfname);
        !            31:     }
        !            32:     fclose (fdtemp);
        !            33:     pclose (fdns);
        !            34:     system ("sort -r /tmp/top20junk");
        !            35:     unlink ("/tmp/top20junk");
        !            36: }
        !            37: 
        !            38: 
        !            39: Index (a, b) char  *a,
        !            40:                    *b;
        !            41: {
        !            42:     char   *p,
        !            43:            *index ();
        !            44: 
        !            45: next: 
        !            46:     if ((p = index (a, *b++)) == 0)
        !            47:        return (0);
        !            48:     p++;
        !            49:     while (*b)
        !            50:        if (*p++ != *b++)
        !            51:            goto next;
        !            52:     return (1);
        !            53: }
        !            54: 
        !            55: 
        !            56: bufcopy (buf, start, to) char  *buf,
        !            57:                                *to;
        !            58: int     start;
        !            59: {
        !            60:     char   *p = buf + start;
        !            61: 
        !            62:     while (isprint (*p))
        !            63:        *to++ = *p++;
        !            64:     *to = '\0';
        !            65:     return;
        !            66: }
        !            67: 

unix.superglobalmegacorp.com

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