#include #include #define MAXUFDS 500 #define USRLEN 70 /* NOTE: look for literal 70's in format strings if changing USRLEN */ /* HOGBLK 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]USE.TMP, created by the command file [2,31] DISKUSE.CMD. HOGBLK compares version 1 and version 2 of the file and reports the differences in number of blocks used per user. USAGE: hogblk [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, totdif=0; int usersw=0; int alllist, userlist; char *user= "ENTIRE DISK "; char *fufd, ufd[10], oldufd[10]; char *ufdfile = "[1,1]USE.TMP;2 "; /* filespec buffer */ char *oldfile = "[1,1]USE.TMP;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], temp2 [133]; int index(); tiatt(); /* attach terminal so CNTL/O works */ /* process arguments */ if (argc > 3) error ("hogblk usage: hog [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("hogblk: 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("hogblk: 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); /* do listing if desired */ if (lsw) { n = 0; while (fgetss(temp, 132, in) != NULL) { /* above reads data from line */ fgetss(temp2, 132, old); if ((alllist) || (userlist && ( (index(temp, user)) != -1)) ) { sscanf (temp, "%ld %*12c %9s", &count, ufd); sscanf (temp2, "%ld %*12c %9s", &oldcnt, oldufd); if ((strcmp(ufd, oldufd) != 0)) printf("eof or sequence error at %s\n", ufd); dif = count - oldcnt; if (dif != 0) printf ("%s old=%6ld new=%6ld difference=%6ld\n", ufd, oldcnt, count, dif); total = total + count; totdif = totdif + dif; 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); printf("Net change of %ld blocks\n", totdif); } } }