#include #include #define MAXUFDS 500 #define USRLEN 70 /* NOTE: look for literal 70's in format strings if changing USRLEN */ /* TOTBLK is a program to report on a file containing a list of who (or what) owns a certain UFD and the total blocks allocated to that owner. The file is [1,1]DISKUSE.RPT, created by the command file [2,31] DISKUSE.CMD. USAGE: totblk [owner] [-ffilespec] AUTHOR: Allen A. Watson THE RECORD 150 River Street Hackensack, NJ 07601 (201) 646-4111 */ int lsw=0, fsw=0, usw=0, found=0; long count=0, total=0, dif=0, oldcnt=0; int usersw=0; int alllist, userlist; char *user= "**********************************************************************"; char *fufd, ufd[10], oldufd[10]; char *ufdfile = "DISKUSE.RPT;2 "; /* filespec buffer */ char *oldfile = "DISKUSE.RPT;1 "; /* YESTERDAY'S FILE*/ char *s, *c; main (argc, argv) char *argv[]; int argc; { register FILE *in; register FILE *old; register int n; char temp [133]; int index(); tiatt(); /* attach terminal so CNTL/O works */ /* process arguments */ if (argc > 3) error ("totblk usage: tot [user] [-ffilespec]"); while (--argc > 0) { *s = (*++argv)[0]; switch (*s) { case '-': switch (tolower((*argv)[1])) /* a switch is given */ { case 'F': case 'f': cpystr (ufdfile, &((*argv)[2])); fsw = 1; break; case 'U': case 'u': /* prepend unit to filespec */ cpystr(temp, &((*argv)[2])); strcat(temp, ufdfile); cpystr(ufdfile, temp); usw = 1; break; default: error("totblk: illegal switch %c\n", (*argv)[1]); break; } break; default: usersw++; user = *argv; break; } } /* so far, listing is all this program does */ lsw = 1; /* check validity of combinations */ if (usw+fsw > 1) error("totblk: unit can be included in -ffilespec"); /* set type of listing wanted */ alllist = lsw && (!usersw); userlist = lsw && usersw; /* open files needed */ if ((in = fopen(ufdfile, "r")) == NULL) error ("hog: cannot open %s", ufdfile); if ((old = fopen(oldfile, "r")) == NULL) error ("hog: cannot open %s", ufdfile); /* skip first two records of each file */ fgetss(temp, 132, in); fgetss(temp, 132, in); fgetss(temp, 132, old); fgetss(temp, 132, old); /* do listing if desired */ if (lsw) { n = 0; while (fgetss(temp, 132, in) != NULL) { /* above reads data from line */ /* if (userlist && ( (pnt = index(temp, user)) != -1)) ) { */ sscanf (temp, "%ld %*12c %9s", &count, ufd); fgetss(temp, 132, old); sscanf (temp, "%ld %*12c %9s", &oldcnt, oldufd); if ((strcmp(ufd, oldufd) != 0)) error ("hog: file sequence error"); dif = count - oldcnt; printf ("%s old=%6ld new=%6ld difference=%6ld\n", ufd, oldcnt,count,dif); total = total + count; n += 1; found = 1; /* } */ } if (!found) printf ("%s not found\n", user); else { printf("\n%d entries found\n", n); printf("Total of %ld blocks for %s\n", total, user); } } }