Patch #1 to "fixactive": adds "show size" option
Dave Taylor
taylor at limbo.Intuitive.Com
Thu Mar 1 07:00:57 AEST 1990
The attached is a 'diff' which you can apply to the fixactive program
posted last night to add the capability of listing the bytes used for
each newsgroup on the disk, in the format of number-of-bytes / number-of-
articles newsgroupname, as in:
30521 /10 alt.activism
30455 /15 alt.aquaria
256377 /98 alt.atheism
26937 /7 alt.bbs
0 /0 alt.california
35724 /17 alt.callahans
0 /0 alt.co-ops
0 /0 alt.cobol
6057 /3 alt.config
30727 /18 alt.conspiracy
3968 /4 alt.cosuard
95048 /81 alt.cult-movies
0 /0 alt.cyb-sys
2549 /2 alt.cyberpunk
0 /0 alt.cyberpunk.movement
.. etc ..
It isn't a "patch" per se, I'm afraid, but you should be able to
have it work. If not, then perhaps someone could create and post
a "real" patch that accomplishes the changes listed here? Thanks!
-- Dave Taylor
Intuitive Systems
Mountain View, California
taylor at limbo.intuitive.com or {uunet!}{decwrl,apple}!limbo!taylor
-- Attachment: Diffs between fixactive-new.c and fixactive.c
Note: "<" is the new version and ">" is the original version as posted.
17d16
< #include <sys/stat.h>
51,52d49
< int size_only = FALSE;
<
60,61d56
< long space_used_by();
<
78c73
< while ((c = getopt(argc, argv, "a:h:nsv")) != EOF) {
---
> while ((c = getopt(argc, argv, "a:h:nv")) != EOF) {
83d77
< case 's' : size_only = TRUE; break;
124c118
< if (verbose && ! size_only)
---
> if (verbose)
137,139c131,132
< if (! size_only)
< printf("Read in %d groups total, of which %d are moderated.\n\n",
< groups, moderated);
---
> printf("Read in %d groups total, of which %d are moderated.\n\n",
> groups, moderated);
148,151c141,142
< if (! size_only) {
< printf("\r%s ", active[i].name);
< fflush(stdout);
< }
---
> printf("\r%s ", active[i].name);
> fflush(stdout);
153,160c144
< if (size_only) {
< long size;
< int articles;
<
< size = space_used_by(i, &articles);
< printf("%-10ld/%-5d\t%s\n", size, articles, active[i].name);
< }
< else if (reset_values_for(i)) {
---
> if (reset_values_for(i)) {
172,173d155
< else if (size_only)
< exit(0);
303,360d284
< long
< space_used_by(index, articles)
< int index, *articles;
< {
< /** Given group[index], open that particular directory and then
< sum up and return the number of bytes used by each of the
< articles in that particular group.
< **/
<
< DIR *dirp;
< struct dirent *dp;
< struct stat buffer;
< int i, j;
< char dirname[SLEN], directory_name[SLEN];
< long size = 0;
<
< /** first step is to get the right directory name... **/
<
< for (j=0, i=0; active[index].name[i] != '\0'; ) {
< if (active[index].name[i] == '.') {
< dirname[j++] = '/';
< i++;
< }
< else
< dirname[j++] = active[index].name[i++];
< }
< dirname[j] = '\0';
<
< /** now prepend the home directory for netnews... **/
<
< sprintf(directory_name, "%s/%s", news_home, dirname);
<
< /** and let's open this baby up! **/
<
< if ((dirp = opendir(directory_name)) == NULL) {
< fprintf(stderr, "Couldn't open directory '%s' for reading?\n",
< directory_name);
< perror("opendir");
< return(FALSE);
< }
<
< *articles = 0;
<
< (void) chdir(directory_name); /* move to this directory */
<
< while ((dp = readdir(dirp)) != NULL) {
< if (isdigit(dp->d_name[0])) {
< (void) stat(dp->d_name, &buffer);
< size += buffer.st_size;
< (*articles)++;
< }
< }
<
< (void) closedir(dirp);
<
< return( (long) size);
< }
<
373,374d296
< printf(
< " -s \tJust list newsgroups by diskspace used: no repair\n");
- - end of diff - -
More information about the Alt.sources.d
mailing list