donald (04/07/83)
For those of you that don't keep up with netnews regularly and are deluged with a flood of net.misc articles full of a 5-week old discussion on Vegemite, here's the solution. This program can be used to update your .newsrc so that it indicates that you have read everything to date. Individual newsgroups can be conveniently updated by using the ! operator while editing .newsrc with vi. /* * PROGRAM: newsrc * AUTHOR: Don Chan (...utcsrgv!donald) April 4, 1983 * * Filter to update lines in a .newsrc to indicate that all articles * to date have been read (useful after a long absence from netnews). * * USAGE: * May be called from the shell: * newsrc <.newsrc >new ; mv new .newsrc * or from vi (by editing .newsrc) by using the ! operator on lines. * * Lines on the standard input of the form 'X:...' and 'X!...' * (where X is a newsgroup) are transformed to lines 'X: 1-N' and * 'X! 1-N', respectively, and placed on the standard output. * (N is the last numbered article in newsgroup X) * Lines not of that form are copied unmolested. * * The number of articles in newsgroup X is found by determining * the size of the stat file '/usr/spool/news/.X' (where '.X' might * have to be truncated to 14 chars because it's a filename). * If N can't be determined (e.g. stat file doesn't exist), N=1 is * assumed. * */ #define MAX 80 #define PREFIX "/usr/spool/news/." #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> main() { char sizefile[MAX], line[MAX], delim, *endPtr, *index(); int endPrefix; struct stat stbuf; sizefile[0] = '\0'; strcat(sizefile,PREFIX); endPrefix = strlen(sizefile); while ( fgets(line,MAX+1,stdin) != NULL ) { /* find ':' or '!' delimiter, if any */ endPtr = index(line,':'); if (endPtr == 0) endPtr = index(line,'!'); if (endPtr == 0) /* no delimiter on line; leave line alone */ fputs(line,stdout); else { delim = *endPtr; *endPtr = '\0'; /* chop at delimiter */ printf("%s%c 1",line,delim); line[13] = '\0'; /* chop at 14th char */ strcat(sizefile,line); if (stat(sizefile,&stbuf) == 0 && stbuf.st_size != 1) printf("-%d\n",stbuf.st_size); else putchar('\n'); sizefile[endPrefix] = '\0'; } } }
presley (04/08/83)
Of course, once you get 2.10 netnews on your system, the following will do just as well to update your .newsrc to say you've read everything up to now. cd; sed "s/ /: 1-/" </usr/lib/netnews/active >.newsrc -- * Joe Presley
ss (04/08/83)
know that this isn't the place for a discussion, but as to the .newsrc updater program - why not just do a readnews -n all -p >/dev/null? Sid Shapiro -- {decvax,linus}!wivax!ss -- Wang Institute ss.Wang-Inst@UDel-Relay -- (617)649-9731
mark (04/13/83)
You can indeed do readnews -p > /dev/null but it will take a while. You certainly want to & it, and it will hog a lot of system resources copying all that news to nowhere. 2.10 does a check to see if stdout is /dev/null and doesn't bother to print the news in that case. It just records it as read. This is much faster but still worth &'ing.