home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2338 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  2.4 KB

  1. From: blarson@blars
  2. Newsgroups: news.software.b,news.software.nntp,news.newusers.questions,alt.sources
  3. Subject: Re: Need to send articles to a new site
  4. Message-ID: <147@blars>
  5. Date: 18 Dec 90 06:44:36 GMT
  6.  
  7. In article <1990Dec14.162617.5428@ssd.kodak.com> dcox@tweety.ssd.kodak.com (Don Cox (253-7121)) writes:
  8. >How do I send all of the articles available in a select newsgroup to
  9. >a new site that I just agreed to be a newsfeed for?
  10.  
  11. Here's a quick & dirty program I wrote to generate a file for use by
  12. the C-News batcher from a "sendgroups" file.  "sendgroups" is like a
  13. simplified .newsrc, each line is newsgroup: <last-article-seen> .
  14. Just put newsgroup: on a new line to add another group.  Crossposted
  15. articles will be sent multiple times, but C news handles this fine.
  16. This does require a couple of routines from the C news library.
  17.  
  18.  
  19. #include <stdio.h>
  20. char *index();
  21. char *strsave();
  22.  
  23. char *progname;
  24.  
  25. main(argc, argv)
  26. int argc;
  27. char **argv;
  28. {
  29.     FILE *act, *f, *fn;
  30.     int i, l, first, last;
  31.     char line[1024], actline[1024];
  32.     char *cp, *group, *gd;
  33.  
  34.     progname = argv[0];
  35.     if((act = fopen("/usr/lib/news/active", "r")) == NULL) {
  36.     fprintf(stderr, "Can't open active\n");
  37.     exit(1);
  38.     }
  39.     if((f = fopen("sendgroups", "r")) == NULL) {
  40.     fprintf(stderr, "Can't open sendgroups\n");
  41.     exit(1);
  42.     }
  43.     if((fn = fopen("sendgroups.new", "w")) == NULL) {
  44.     fprintf(stderr, "Can't open sendgroups.new\n");
  45.     exit(1);
  46.     }
  47.     while(fgets(line, 1024, f) != NULL) {
  48.     if((cp = index(line, ':')) != NULL) {
  49.         l = cp - line;
  50.         *cp++ = '\0';
  51.         group = strsave(line);
  52.         i = atoi(cp) + 1;
  53.         fseek(act, 0, 0);
  54.         while(fgets(line, 1024, act) != NULL) {
  55.         if(strncmp(line, group, l) == 0 &&
  56.             (line[l]==' ' || line[l]=='\t')) {
  57.             sscanf(line, "%*s %d %d\n", &last, &first);
  58.             if(i <= last) {
  59.                 gd = strsave(group);
  60.             cp = gd;
  61.             while(cp = index(cp, '.')) *cp++ = '/';
  62.             if(i < first) i = first;
  63.                 for(; i <= last; i++) {
  64.                     printf("/usr/spool/news/%s/%d\n", gd, i);
  65.                 }
  66.             free(gd);
  67.             }
  68.             fprintf(fn, "%s: %d\n", group, last);
  69.             break;
  70.         }
  71.         }
  72.         free(group);
  73.     }
  74.     }
  75.     fclose(f);
  76.     fclose(fn);
  77.     rename("sendgroups", "sendgroups.old");
  78.     rename("sendgroups.new", "sendgroups");
  79. }
  80.  
  81. errunlock()
  82. {
  83. }
  84.  
  85. -- 
  86. blarson@usc.edu
  87.         C news and rn for os9/68k!
  88. -- 
  89. Bob Larson (blars)    blarson@usc.edu            usc!blarson
  90.     Hiding differences does not make them go away.  Accepting
  91.     differences makes them unimportant.
  92.  
  93.