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: }

Defined functions

Index defined in line 39; used 1 times
  • in line 26
bufcopy defined in line 56; used 2 times
main defined in line 13; never used

Defined variables

buf defined in line 11; used 9 times

Defined macros

NAMEPOS defined in line 10; used 1 times
  • in line 27
Last modified: 1985-10-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1111
Valid CSS Valid XHTML 1.0 Strict