Need to send articles to a new site

blarson at blars blarson at blars
Tue Dec 18 17:44:36 AEST 1990


In article <1990Dec14.162617.5428 at ssd.kodak.com> dcox at tweety.ssd.kodak.com (Don Cox (253-7121)) writes:
>How do I send all of the articles available in a select newsgroup to
>a new site that I just agreed to be a newsfeed for?

Here's a quick & dirty program I wrote to generate a file for use by
the C-News batcher from a "sendgroups" file.  "sendgroups" is like a
simplified .newsrc, each line is newsgroup: <last-article-seen> .
Just put newsgroup: on a new line to add another group.  Crossposted
articles will be sent multiple times, but C news handles this fine.
This does require a couple of routines from the C news library.


#include <stdio.h>
char *index();
char *strsave();

char *progname;

main(argc, argv)
int argc;
char **argv;
{
    FILE *act, *f, *fn;
    int i, l, first, last;
    char line[1024], actline[1024];
    char *cp, *group, *gd;

    progname = argv[0];
    if((act = fopen("/usr/lib/news/active", "r")) == NULL) {
	fprintf(stderr, "Can't open active\n");
	exit(1);
    }
    if((f = fopen("sendgroups", "r")) == NULL) {
	fprintf(stderr, "Can't open sendgroups\n");
	exit(1);
    }
    if((fn = fopen("sendgroups.new", "w")) == NULL) {
	fprintf(stderr, "Can't open sendgroups.new\n");
	exit(1);
    }
    while(fgets(line, 1024, f) != NULL) {
	if((cp = index(line, ':')) != NULL) {
	    l = cp - line;
	    *cp++ = '\0';
	    group = strsave(line);
	    i = atoi(cp) + 1;
	    fseek(act, 0, 0);
	    while(fgets(line, 1024, act) != NULL) {
		if(strncmp(line, group, l) == 0 &&
			(line[l]==' ' || line[l]=='\t')) {
		    sscanf(line, "%*s %d %d\n", &last, &first);
		    if(i <= last) {
		        gd = strsave(group);
			cp = gd;
			while(cp = index(cp, '.')) *cp++ = '/';
			if(i < first) i = first;
		    	for(; i <= last; i++) {
		    	    printf("/usr/spool/news/%s/%d\n", gd, i);
		    	}
			free(gd);
		    }
		    fprintf(fn, "%s: %d\n", group, last);
		    break;
		}
	    }
	    free(group);
	}
    }
    fclose(f);
    fclose(fn);
    rename("sendgroups", "sendgroups.old");
    rename("sendgroups.new", "sendgroups");
}

errunlock()
{
}

-- 
blarson at usc.edu
		C news and rn for os9/68k!
-- 
Bob Larson (blars)	blarson at usc.edu			usc!blarson
	Hiding differences does not make them go away.  Accepting
	differences makes them unimportant.




More information about the Alt.sources mailing list