home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / cnews2 / part07 < prev    next >
Text File  |  1989-06-29  |  26KB  |  786 lines

  1. Subject:  v19i084:  Cnews production release, Part07/19
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: utzoo!henry
  7. Posting-number: Volume 19, Issue 84
  8. Archive-name: cnews2/part07
  9.  
  10. : ---CUT HERE---
  11. echo 'contrib/rn.mod/better.way':
  12. sed 's/^X//' >'contrib/rn.mod/better.way' <<'!'
  13. XDate:  9 Jun 1989 1852-EDT (Friday)
  14. XFrom: csri.toronto.edu!moraes
  15. XReceived: by neat.ai.toronto.edu id 11723; Fri, 9 Jun 89 18:52:43 EDT
  16. XReply-To: moraes@csri.toronto.edu
  17. XX-Mailer: Mail User's Shell (6.3 6/25/88)
  18. XTo:    henry@utzoo, geoff@utstat.toronto.edu
  19. XSubject: rn fixes
  20. XCc:    moraes@csri.toronto.edu
  21. XMessage-Id: <89Jun9.185243edt.11723@neat.ai.toronto.edu>
  22. X
  23. XThese are the rn fixes to make it use the new active.times file to
  24. Xstop the startup problems when new newsgroups are created.
  25. X
  26. XIt seems fast, and reliable - also completely backward compatible, as
  27. Xfar as I can tell. Note that a new newsreader will now not be asked
  28. Xabout all the newsgroups - they can pick the ones they want later.
  29. X
  30. X    - moraes
  31. X
  32. X# To unbundle, sh this file
  33. Xecho README.rn 1>&2
  34. Xsed 's/^-//' >README.rn <<'!'
  35. XThe rn.mod file is a set of speedups for rn, which make use of a new file
  36. Xwhich C news can generate, called $NEWSCTL/active.times. This file contains
  37. Xthe creation times of the newsgroups, and solves the problem of rn stat'ing
  38. Xevery newsgroup spool directory to figure out if it is a new newsgroup or
  39. Xnot.
  40. X
  41. XThe changes to addng.c prevent rn stating all ~700 directories under
  42. X-/usr/spool/news every time the active file changes (this is known as "the rn
  43. Xhuddle").  This reduced start up time after touching active from 108 seconds
  44. Xelapsed on a Sun 3 to 5 seconds.
  45. X
  46. XThe theory behind the 700 stats in the newgroup huddle is apparently that if
  47. Xrn stats group/1, and it exists, then group must be a newly-created group.
  48. XWith rapid expiry, group/1 won't be around for long in most groups, causing
  49. Xrn to miss some new groups, and in "valuable" groups with long expiry times,
  50. Xgroup/1 will be around for a very long time, making rn spuriously think that
  51. Xthe old groups are new.
  52. X
  53. XTo get this to work - apply the diffs to rn. You may need some hand patching
  54. X-- our version of rn has been hacked to apply various local fixes and some U
  55. Xof Waterloo fixes. (The base U of Waterloo rn contains two other handy
  56. Xchanges:  a -q which disables the interrogation when the active file
  57. Xchanges, and a third answer during the interrogation: "q" means "I don't
  58. Xcare, just show me some news, right now".)
  59. X
  60. XThe main changes are to addng.c, and init.c, to use the new procedure
  61. Xchecknewgroups() for detecting new groups, instead of the earlier heuristic.
  62. X
  63. XCreate a active.times file from your active file using the act.to.times
  64. Xscript in the C News distribution. (C News 'newgroup' will keep it uptodate)
  65. X
  66. XTry it.
  67. X!
  68. Xecho rn.mod 1>&2
  69. Xsed 's/^-//' >rn.mod <<'!'
  70. X-*** /tmp/,RCSt1a11034    Fri Jun  9 18:36:21 1989
  71. X---- addng.c    Fri Jun  9 18:33:55 1989
  72. X-***************
  73. X-*** 39,44 ****
  74. X---- 39,50 ----
  75. X-  
  76. X-  #ifdef FINDNEWNG
  77. X-  /* generate a list of new newsgroups from active file */
  78. X-+ /*
  79. X-+  * The arguments are redundant - they used to be used in a heuristic to
  80. X-+  * determine new newsgroups. With C News active.times file, this is
  81. X-+  * unnecessary, since we use the faster, more reliable checknewgroups()
  82. X-+  * procedure.
  83. X-+  */
  84. X-  
  85. X-  bool
  86. X-  newlist(munged,checkinlist)
  87. X-***************
  88. X-*** 71,86 ****
  89. X-          fprintf(tmpfp,"%s\n",buf);
  90. X-                      /* then remember said newsgroup */
  91. X-          }
  92. X-- #ifdef FASTNEW
  93. X--         else {            /* not really a new group */
  94. X--         if (!munged) {        /* did we assume not munged? */
  95. X--             fclose(tmpfp);    /* then go back, knowing that */
  96. X--             UNLINK(tmpname);
  97. X--             free(tmpname);
  98. X--             return TRUE;    /* active file was indeed munged */
  99. X--         }
  100. X--         }
  101. X-- #endif
  102. X-      }
  103. X-  #ifdef DEBUGGING
  104. X-      else
  105. X---- 77,82 ----
  106. X-***************
  107. X-*** 106,127 ****
  108. X-      return FALSE;            /* do not call us again */
  109. X-  }
  110. X-  
  111. X-! /* return creation time of newsgroup */
  112. X-  
  113. X-  long
  114. X-  birthof(ngnam,ngsize)
  115. X-  char *ngnam;
  116. X-  ART_NUM ngsize;
  117. X-  {
  118. X--     long time();
  119. X-- 
  120. X--     /*
  121. X--      * This used to try and stat article 1 to find the newsgroup creating
  122. X--      * time. Almost never finds article 1, since it will always long gone.
  123. X--      * Nuke the stat() and speed up startup immensely.
  124. X--      */
  125. X--     /* not there, assume something good */
  126. X--     return (ngsize ? 0L : time(Null(long *)));
  127. X-  }
  128. X-  
  129. X-  bool
  130. X---- 102,229 ----
  131. X-      return FALSE;            /* do not call us again */
  132. X-  }
  133. X-  
  134. X-! /*
  135. X-!  * gets the group time, from the second field, simultaneously null terminating
  136. X-!  * after the first field in buf.
  137. X-!  */
  138. X-! static long
  139. X-! getgrptime(buf)
  140. X-! char *buf;
  141. X-! {
  142. X-!     char *s;
  143. X-!     
  144. X-!     s = index(buf, ' ');
  145. X-!     if (s == Nullch || *(s+1) == '\0')
  146. X-!         return 0L;
  147. X-!     *s++ = '\0';
  148. X-!     return(atol(s));
  149. X-! }
  150. X-  
  151. X-+ /*
  152. X-+  * Use the groups file (ACTIVE.times, typically /usr/lib/news/active.times) to
  153. X-+  * see if there are any new newsgroups
  154. X-+  */
  155. X-+ checknewgroups()
  156. X-+ {
  157. X-+     FILE *fp;
  158. X-+     long grptime;
  159. X-+     long ngrptime;
  160. X-+     long pos;
  161. X-+     long npos;
  162. X-+     char *s;
  163. X-+     char *grpfile;
  164. X-+     char tmpbuf[LBUFLEN];
  165. X-+ #define GROUPEXT ".times"
  166. X-+ 
  167. X-+     grpfile = safemalloc(strlen(filexp(ACTIVE)) + sizeof(GROUPEXT));
  168. X-+     strcpy(grpfile, filexp(ACTIVE));
  169. X-+     strcat(grpfile, GROUPEXT);
  170. X-+     
  171. X-+     fp = fopen(grpfile, "r");
  172. X-+     if (fp == (FILE *) NULL) {
  173. X-+     printf(cantopen, grpfile) FLUSH;
  174. X-+         return;
  175. X-+     }
  176. X-+ 
  177. X-+     pos = npos = lastpos;
  178. X-+     grptime = lastgrptime;
  179. X-+     if (lastnewgroup != Nullch)
  180. X-+     strcpy(tmpbuf, lastnewgroup);
  181. X-+     /*
  182. X-+      * In the general case, this 'if()' will be false, unless someone has
  183. X-+      * messed up the groups file, or this is the first time this person is
  184. X-+      * reading news
  185. X-+      */
  186. X-+     if (lastnewgroup == Nullch || fseek(fp, lastpos, 0) == -1 ||
  187. X-+         fgets(buf, LBUFLEN, fp) == NULL ||
  188. X-+     !strnEQ(buf, lastnewgroup, strlen(lastnewgroup))) {
  189. X-+         /* We need to check the file from the start - use time */
  190. X-+         if (fseek(fp, 0L, 0) == -1) {
  191. X-+             printf(cantseek, grpfile) FLUSH;
  192. X-+             fclose(fp);
  193. X-+             free(grpfile);
  194. X-+             return;
  195. X-+         }
  196. X-+         pos = npos = 0L;
  197. X-+         while (fgets(buf, LBUFLEN, fp) != Nullch) {
  198. X-+             buf[strlen(buf)-1] = '\0';
  199. X-+             ngrptime = getgrptime(buf);
  200. X-+             if (ngrptime > lastgrptime)
  201. X-+                 break;
  202. X-+             if (ngrptime == 0L)
  203. X-+                 continue;
  204. X-+             grptime = ngrptime;
  205. X-+             strcpy(tmpbuf, buf);
  206. X-+             pos = npos;
  207. X-+             npos = ftell(fp);
  208. X-+         }
  209. X-+         if (fseek(fp, pos, 0) == -1) {
  210. X-+             printf(cantseek, grpfile) FLUSH;
  211. X-+             fclose(fp);
  212. X-+             free(grpfile);
  213. X-+             return;
  214. X-+         }
  215. X-+         npos = pos;
  216. X-+     }
  217. X-+     /*
  218. X-+      * At this point, the file pointer is positioned at the start of the first
  219. X-+      * new group. This is the value of pos. Now start asking about new groups.
  220. X-+      */
  221. X-+     while (fgets(buf, LBUFLEN, fp) != Nullch) {
  222. X-+     buf[strlen(buf)-1] = '\0';
  223. X-+     ngrptime = getgrptime(buf);
  224. X-+     if (ngrptime == 0L)
  225. X-+         continue;
  226. X-+     grptime = ngrptime;
  227. X-+     strcpy(tmpbuf, buf);
  228. X-+     pos = npos;
  229. X-+     if (grptime > lastgrptime && find_ng(buf) == nextrcline)
  230. X-+         /* not in .newsrc and newer that last new newsgroup */
  231. X-+         get_ng(buf, TRUE);
  232. X-+     npos = ftell(fp);
  233. X-+     }
  234. X-+     lastpos = pos;
  235. X-+     lastgrptime = grptime;
  236. X-+     if (lastnewgroup != Nullch)
  237. X-+         free(lastnewgroup);
  238. X-+     lastnewgroup = savestr(tmpbuf);
  239. X-+     fclose(fp);
  240. X-+     free(grpfile);
  241. X-+ }
  242. X-+ 
  243. X-+     
  244. X-+ 
  245. X-+ /*
  246. X-+  * return creation time of newsgroup - procedure made redundant by C News
  247. X-+  * active.times and checknewgroups()
  248. X-+  */
  249. X-+ 
  250. X-+ /*ARGSUSED*/
  251. X-  long
  252. X-  birthof(ngnam,ngsize)
  253. X-  char *ngnam;
  254. X-  ART_NUM ngsize;
  255. X-  {
  256. X-  }
  257. X-  
  258. X-  bool
  259. X-*** /tmp/,RCSt1a11034    Fri Jun  9 18:36:24 1989
  260. X---- common.h    Fri Jun  9 18:30:10 1989
  261. X-***************
  262. X-*** 1,9 ****
  263. X-! /* $Header: /ai/car/src/rn/RCS/common.h,v 4.6 89/06/09 18:29:44 moraes Exp $
  264. X-   * 
  265. X-   * $Log:    common.h,v $
  266. X--  * Revision 4.6  89/06/09  18:29:44  moraes
  267. X--  * *** empty log message ***
  268. X--  * 
  269. X-   * Revision 4.5  89/06/05  21:59:37  moraes
  270. X-   * enabled -q option permanantly. New speed mods make it unnecessary for
  271. X-   * most people, but some people just want to see general/gradnews/ut.*
  272. X---- 1,6 ----
  273. X-! /* $Header: /ai/car/src/rn/RCS/common.h,v 4.5 89/06/05 21:59:37 moraes Exp $
  274. X-   * 
  275. X-   * $Log:    common.h,v $
  276. X-   * Revision 4.5  89/06/05  21:59:37  moraes
  277. X-   * enabled -q option permanantly. New speed mods make it unnecessary for
  278. X-   * most people, but some people just want to see general/gradnews/ut.*
  279. X-***************
  280. X-*** 292,299 ****
  281. X-              /* (Note: both VERBOSE and TERSE can be defined; -t
  282. X-               * sets terse mode.  One or the other MUST be defined.
  283. X-               */
  284. X-- #define QUICK        /* -q option - Don't ask about new newsgroups */
  285. X-- 
  286. X-  #ifndef pdp11
  287. X-  #   define CACHESUBJ    /* cache subject lines in memory */
  288. X-              /* without this ^N still works but runs really slow */
  289. X---- 289,294 ----
  290. X-*** /tmp/,RCSt1a11034    Fri Jun  9 18:36:25 1989
  291. X---- init.c    Fri Jun  9 18:30:10 1989
  292. X-***************
  293. X-*** 1,4 ****
  294. X-! /* $Header: /ai/car/src/rn/RCS/init.c,v 1.2 88/07/14 18:15:22 ken Exp $
  295. X-   *
  296. X-   * $Log:    init.c,v $
  297. X-   * Revision 1.2  88/07/14  18:15:22  ken
  298. X---- 1,4 ----
  299. X-! /* $Header: init.c,v 1.2 88/07/14 18:15:22 ken Exp $
  300. X-   *
  301. X-   * $Log:    init.c,v $
  302. X-   * Revision 1.2  88/07/14  18:15:22  ken
  303. X-***************
  304. X-*** 166,185 ****
  305. X-  
  306. X-  #ifdef FINDNEWNG
  307. X-      fstat(actfp->_file,&filestat);    /* did active file grow? */
  308. X-- #ifdef QUICK
  309. X-      /* maintain the old active file size, to avoid "new newsgroup" blather */
  310. X-      if (quick)
  311. X-      filestat.st_size = lastactsiz;
  312. X-- #endif
  313. X-      if (filestat.st_size != lastactsiz) {
  314. X-      long actsiz = filestat.st_size;    /* remember new size */
  315. X-      NG_NUM oldnext = nextrcline;    /* remember # lines in newsrc */
  316. X-- #ifdef FASTNEW
  317. X--     bool munged = writesoft || !lastactsiz;
  318. X--                     /* bad soft ptrs -> edited active */
  319. X-- #else
  320. X--     bool munged = TRUE;        /* just assume .newsrc munged */
  321. X-- #endif
  322. X-  
  323. X-  #ifdef VERBOSE
  324. X-      IF(verbose)
  325. X---- 166,177 ----
  326. X-***************
  327. X-*** 190,208 ****
  328. X-  #ifdef TERSE
  329. X-          fputs("\nNew newsgroups:\n",stdout) FLUSH;
  330. X-  #endif
  331. X-! #ifdef FASTNEW
  332. X-!     if (!munged) {            /* maybe just do tail of file? */
  333. X-!         fseek(actfp,lastactsiz-1,0);
  334. X-!         fgets(buf,LBUFLEN,actfp);
  335. X-!         munged = (*buf != '\n');
  336. X-!         if (!munged)
  337. X-!         munged = newlist(munged,FALSE);
  338. X-!     }
  339. X-! #endif
  340. X-!     if (munged) {            /* must we scan entire file? */
  341. X-!         fseek(actfp,0L,0);        /* rewind active file */
  342. X-!         newlist(munged,FALSE);      /* sure hope they use hashing... */
  343. X-!     }
  344. X-      lastactsiz = actsiz;        /* remember for .rnlast */
  345. X-      if (nextrcline != oldnext) {    /* did we add any new groups? */
  346. X-          foundany = TRUE;        /* let main() know */
  347. X---- 182,188 ----
  348. X-  #ifdef TERSE
  349. X-          fputs("\nNew newsgroups:\n",stdout) FLUSH;
  350. X-  #endif
  351. X-!     checknewgroups();
  352. X-      lastactsiz = actsiz;        /* remember for .rnlast */
  353. X-      if (nextrcline != oldnext) {    /* did we add any new groups? */
  354. X-          foundany = TRUE;        /* let main() know */
  355. X-*** /tmp/,RCSt1a11034    Fri Jun  9 18:36:26 1989
  356. X---- last.c    Fri Jun  9 17:06:01 1989
  357. X-***************
  358. X-*** 1,9 ****
  359. X-! /* $Header: /ai/car/src/rn/RCS/last.c,v 1.1 89/06/09 03:52:49 moraes Exp $
  360. X-   *
  361. X-   * $Log:    last.c,v $
  362. X--  * Revision 1.1  89/06/09  03:52:49  moraes
  363. X--  * Initial revision
  364. X--  * 
  365. X-   * Revision 4.3  85/05/01  11:42:16  lwall
  366. X-   * Baseline for release with 4.3bsd.
  367. X-   * 
  368. X---- 1,6 ----
  369. X-! /* $Header: last.c,v 4.3 85/05/01 11:42:16 lwall Exp $
  370. X-   *
  371. X-   * $Log:    last.c,v $
  372. X-   * Revision 4.3  85/05/01  11:42:16  lwall
  373. X-   * Baseline for release with 4.3bsd.
  374. X-   * 
  375. X-***************
  376. X-*** 26,37 ****
  377. X-      lastname = savestr(filexp(LASTNAME));
  378. X-      if ((tmpfp = fopen(lastname,"r")) != Nullfp) {
  379. X-      fgets(tcbuf,1024,tmpfp);
  380. X-!     tcbuf[strlen(tcbuf)-1] = '\0';
  381. X-      lastngname = savestr(tcbuf);
  382. X-      fgets(tcbuf,1024,tmpfp);
  383. X-      lasttime = atol(tcbuf);
  384. X-      fgets(tcbuf,1024,tmpfp);
  385. X-      lastactsiz = atol(tcbuf);
  386. X-      fclose(tmpfp);
  387. X-      }
  388. X-      else {
  389. X---- 23,52 ----
  390. X-      lastname = savestr(filexp(LASTNAME));
  391. X-      if ((tmpfp = fopen(lastname,"r")) != Nullfp) {
  392. X-      fgets(tcbuf,1024,tmpfp);
  393. X-!     tcbuf[strlen(tcbuf) - 1] = '\0';
  394. X-      lastngname = savestr(tcbuf);
  395. X-      fgets(tcbuf,1024,tmpfp);
  396. X-      lasttime = atol(tcbuf);
  397. X-      fgets(tcbuf,1024,tmpfp);
  398. X-      lastactsiz = atol(tcbuf);
  399. X-+     /*
  400. X-+      * The first time when new rn is used by a user who was using the old
  401. X-+      * rn, the lastgrptime is taken to be 'now', so the user is not
  402. X-+      * hassled with hundreds of newsgroups
  403. X-+      */
  404. X-+     if (fgets(tcbuf, 1024,tmpfp) != (char *) NULL)
  405. X-+         lastgrptime = atol(tcbuf);
  406. X-+     else 
  407. X-+         lastgrptime = time(0);
  408. X-+     if (fgets(tcbuf, 1024, tmpfp) != (char *) NULL) {
  409. X-+         tcbuf[strlen(tcbuf) - 1] = '\0';
  410. X-+         lastnewgroup = savestr(tcbuf);
  411. X-+     } else
  412. X-+         lastnewgroup = NULL;
  413. X-+     if (fgets(tcbuf, 1024, tmpfp) != (char *) NULL)
  414. X-+         lastpos = atol(tcbuf);
  415. X-+     else
  416. X-+         lastpos = 0;
  417. X-      fclose(tmpfp);
  418. X-      }
  419. X-      else {
  420. X-***************
  421. X-*** 38,43 ****
  422. X---- 53,67 ----
  423. X-      lastngname = nullstr;
  424. X-      lasttime = 0;
  425. X-      lastactsiz = 0;
  426. X-+     /*
  427. X-+      * The default for the new reader is not to show hundreds of new
  428. X-+      * newsgroups. The system admin should use newsetup to provide a
  429. X-+      * proper starting subset - the user can select new newsgroups by
  430. X-+      * hand. Much faster
  431. X-+      */
  432. X-+     lastgrptime = time(0);
  433. X-+     lastnewgroup = Nullch;
  434. X-+     lastpos = 0;
  435. X-      }
  436. X-  }
  437. X-  
  438. X-***************
  439. X-*** 47,54 ****
  440. X-  writelast()
  441. X-  {
  442. X-      if ((tmpfp = fopen(lastname,"w")) != Nullfp) {
  443. X-!     fprintf(tmpfp,"%s\n%ld\n%ld\n",
  444. X-!         (ngname==Nullch?nullstr:ngname),(long)lasttime,(long)lastactsiz);
  445. X-      fclose(tmpfp);
  446. X-      }
  447. X-      else
  448. X---- 71,81 ----
  449. X-  writelast()
  450. X-  {
  451. X-      if ((tmpfp = fopen(lastname,"w")) != Nullfp) {
  452. X-!     fprintf(tmpfp,"%s\n%ld\n%ld\n%ld\n%s\n%ld\n",
  453. X-!         (ngname==Nullch?nullstr:ngname),(long)lasttime,(long)lastactsiz,
  454. X-!         lastgrptime, 
  455. X-!         ((lastnewgroup == (char *) NULL) ? nullstr:lastnewgroup),
  456. X-!         lastpos);
  457. X-      fclose(tmpfp);
  458. X-      }
  459. X-      else
  460. X-*** /tmp/,RCSt1a11034    Fri Jun  9 18:36:27 1989
  461. X---- last.h    Fri Jun  9 05:32:16 1989
  462. X-***************
  463. X-*** 12,17 ****
  464. X---- 12,20 ----
  465. X-  EXT char *lastngname INIT(Nullch);    /* last newsgroup read, from .rnlast file */
  466. X-  EXT long lasttime INIT(0);    /* time last rn was started up */
  467. X-  EXT long lastactsiz INIT(0);    /* size of active file when rn last started up */
  468. X-+ EXT long lastgrptime INIT(0);    /* time the groups file was last changed */
  469. X-+ EXT char *lastnewgroup INIT(Nullch);    /* last new newsgroup */
  470. X-+ EXT long lastpos INIT(0);    /* pos. of last new newsgroup in groups file */
  471. X-  
  472. X-  void    last_init();
  473. X-  void    writelast();
  474. XNo differences encountered
  475. X!
  476. X
  477. X
  478. !
  479. echo 'expire/Makefile':
  480. sed 's/^X//' >'expire/Makefile' <<'!'
  481. XPROF = 
  482. XCOPTS = -O
  483. XCFLAGS = $(COPTS) -I../include $(PROF)
  484. XLINTFLAGS = -I../include
  485. XJUNKLINT = 'possible pointer align'
  486. XLDFLAGS = $(CFLAGS)
  487. XDBM = -ldbm
  488. XLIBS= ../libcnews.a
  489. XTHEM = expire histdups histinfo histslash mkdbm mkhistory \
  490. X    superkludge upact doexpire mkadir
  491. XDTR = README Makefile dircheck doexpire expire.c histdups histinfo.c \
  492. X    histslash.c lowest.c mkdbm.c mkhistory pgood superkludge tgood upact \
  493. X    mkadir
  494. X# =()<NEWSARTS = @<NEWSARTS>@>()=
  495. XNEWSARTS = /usr/spool/news
  496. X# =()<NEWSBIN = @<NEWSBIN>@>()=
  497. XNEWSBIN = /usr/lib/newsbin
  498. X# =()<NEWSCTL = @<NEWSCTL>@>()=
  499. XNEWSCTL = /usr/lib/news
  500. X# workaround for System V make bug
  501. XSHELL = /bin/sh
  502. X
  503. Xall:    $(THEM)
  504. X
  505. Xbininstall:    $(THEM) explist.proto
  506. X    -if test ! -d $(NEWSBIN)/expire ; then mkdir $(NEWSBIN)/expire; fi
  507. X    chmod +x $(THEM)
  508. X    cp $(THEM) $(NEWSBIN)/expire
  509. X
  510. Xnewsinstall:    explist.proto
  511. X    -if test ! -r $(NEWSCTL)/explist ; then cp explist.proto $(NEWSCTL)/explist ; fi
  512. X
  513. Xcmp:    $(THEM)
  514. X    -for f in $(THEM) ; do cmp $$f $(NEWSBIN)/expire/$$f ; done
  515. X
  516. Xexpire: expire.o $(LIBS)
  517. X    $(CC) $(LDFLAGS) expire.o $(LIBS) $(DBM) -o $@
  518. X
  519. Xhistinfo: histinfo.o $(LIBS)
  520. X    $(CC) $(LDFLAGS) histinfo.o $(LIBS) -o $@
  521. X
  522. Xlowest:    lowest.o $(LIBS)
  523. X    $(CC) $(LDFLAGS) lowest.o $(LIBS) -o $@
  524. X
  525. Xhistslash:    histslash.o $(LIBS)
  526. X    $(CC) $(LDFLAGS) histslash.o $(LIBS) -o $@
  527. X
  528. Xmkdbm:    mkdbm.o $(LIBS)
  529. X    $(CC) $(LDFLAGS) mkdbm.o $(LIBS) $(DBM) -o $@
  530. X
  531. Xlint:    expire.c
  532. X    lint -ha $(LINTFLAGS) expire.c 2>&1 | egrep -v $(JUNKLINT) | tee $@
  533. X
  534. Xexplist.proto:
  535. X    echo "# hold onto history lines 14 days, nobody gets >90 days" >$@
  536. X    echo "/expired/            x    14    -" >>$@
  537. X    echo "/bounds/            x    0-1-90    -" >>$@
  538. X    echo >>$@
  539. X    echo "# override later defaults for some groups of note" >>$@
  540. X    echo "sci.space.shuttle,rec.birds    x    7    @" >>$@
  541. X    echo >>$@
  542. X    echo "# big non-tech groups held long enough for a long weekend" >>$@
  543. X    echo "sci,rec,talk,soc,misc,alt    u    4    -" >>$@
  544. X    echo >>$@
  545. X    echo "# real noise gets thrown away fast" >>$@
  546. X    echo "news.groups            x    2    -" >>$@
  547. X    echo "junk,tor.news.stats        x    2    -" >>$@
  548. X    echo >>$@
  549. X    echo "# throw away some technical stuff not worth archiving" >>$@
  550. X    echo "comp.os.vms,comp.mail.maps    x    7    -" >>$@
  551. X    echo >>$@
  552. X    echo "# default:  7 days and archive" >>$@
  553. X    echo "all                x    7    @" >>$@
  554. X
  555. X# setup for regression test
  556. Xsetup:
  557. X    rm -f explist history active active.after history.proto
  558. X    rm -rf arts arch arch2 arch3 nbin
  559. X    >history.pag
  560. X    >history.dir
  561. X    echo "/expired/    x    0.08    -" >>explist
  562. X    echo '/bounds/    x    0.01-0.1-0.11    -' >>explist
  563. X    echo "bar,!bar.ugh    x    0.05    `pwd`/arch2" >>explist
  564. X    echo 'mod    m    0.1    @' >>explist
  565. X    echo 'mod    u    0.05    -' >>explist
  566. X    echo 'urp    x    0.01-0.05-0.1    -' >>explist
  567. X    echo "bletch    x    0.1    =`pwd`/arch3/bletch" >>explist
  568. X    echo 'all    x    0.1    @' >>explist
  569. X    mkdir nbin nbin/expire
  570. X    for f in $(THEM) ; do ln $$f nbin/expire/$$f ; done
  571. X    echo 'ln $$* >/dev/null 2>/dev/null' >nbin/newslock
  572. X    echo 'echo 10' >nbin/spacefor
  573. X    chmod +x nbin/* nbin/expire/*
  574. X    mkdir arts arts/foo arts/bar arts/bar/ugh arts/urp arch arch2
  575. X    mkdir arts/mod arts/mod/mod arts/mod/unmod arch3 arch3/bletch
  576. X    mkdir arts/bletch
  577. X    echo 'foo 00099 00000 y' >>active
  578. X    echo 'foo 00099 00001 y' >>active.after
  579. X    echo 'bar 00099 00000 m' >>active
  580. X    echo 'bar 00099 00099 m' >>active.after
  581. X    echo 'bar.ugh 00099 00000 m' >>active
  582. X    echo 'bar.ugh 00099 00099 m' >>active.after
  583. X    echo 'urp 00099 00000 n' >>active
  584. X    echo 'urp 00099 00007 n' >>active.after
  585. X    echo 'mod.mod 00013 00000 m' >>active
  586. X    echo 'mod.mod 00013 00013 m' >>active.after
  587. X    echo 'mod.unmod 00016 00000 y' >>active
  588. X    echo 'mod.unmod 00016 00016 y' >>active.after
  589. X    echo 'bletch 00099 00000 y' >>active
  590. X    echo 'bletch 00099 00099 y' >>active.after
  591. X    echo '<wont1>    9999~-    foo/1' >>history.proto
  592. X    echo :foo/1: >arts/foo/1
  593. X    echo 'Message-ID: <wont1>' >>arts/foo/1
  594. X    echo '<will2>    1000~-    foo/2' >>history.proto
  595. X    echo foo/2 >arts/foo/2
  596. X    echo '<will3>    1000~100    foo/3' >>history.proto
  597. X    echo foo/3 >arts/foo/3
  598. X    echo '<two4>    100    bar/4' >>history.proto
  599. X    echo :bar/4: >arts/bar/4
  600. X    echo 'Subject: yes' >>arts/bar/4
  601. X    echo '<will5>    100~    bar.ugh/5' >>history.proto
  602. X    echo :bar/ugh/5: >arts/bar/ugh/5
  603. X    echo >>arts/bar/ugh/5
  604. X    echo 'Subject: no' >>arts/bar/ugh/5
  605. X    echo '<gone6>    100~-    urp/6' >>history.proto
  606. X    echo urp/6 >arts/urp/6
  607. X    echo '<wont7>    9999~9999~xx~a    urp/7' >>history.proto
  608. X    echo :urp/7: >arts/urp/7
  609. X    echo 'Message-ID: <wont7>' >>arts/urp/7
  610. X    echo 'Expires: 9999' >>arts/urp/7
  611. X    echo '<gone8>    100~20000    urp/8' >>history.proto
  612. X    echo urp/8 >arts/urp/8
  613. X    echo '<gone9>    100~-    urp/9' >>history.proto
  614. X    echo '<wont10>    1000~20000    foo/10' >>history.proto
  615. X    echo :foo/10: >arts/foo/10
  616. X    echo 'Message-ID: <wont10>' >>arts/foo/10
  617. X    echo 'Expires: 20000' >>arts/foo/10
  618. X    echo 'Supersedes: <wont1>' >>arts/foo/10
  619. X    echo >>arts/foo/10
  620. X    echo '<will11>    100~20000    foo/11' >>history.proto
  621. X    echo foo/11 >arts/foo/11
  622. X    echo '<will12>    100~-    mod.mod/12' >>history.proto
  623. X    echo mod/mod/12 >arts/mod/mod/12
  624. X    echo '<wont13>    2000    mod.mod/13' >>history.proto
  625. X    echo :mod/mod/13: >arts/mod/mod/13
  626. X    echo 'Message-ID: <wont13>' >>arts/mod/mod/13
  627. X    echo '<gone14>    100~-    mod.unmod/14' >>history.proto
  628. X    echo mod/unmod/14 >arts/mod/unmod/14
  629. X    echo '<gone15>    2000    mod.unmod/15' >>history.proto
  630. X    echo mod/unmod/15 >arts/mod/unmod/15
  631. X    echo '<wont16>    9999~-    mod.unmod/16' >>history.proto
  632. X    echo :mod/unmod/16: >arts/mod/unmod/16
  633. X    echo 'Message-ID: <wont16>' >>arts/mod/unmod/16
  634. X    echo '<three17>    100~-    bletch/17' >>history.proto
  635. X    echo bletch/17 >arts/bletch/17
  636. X    egrep wont history.proto >history.after
  637. X    echo '<gone96>    5000~-    /' >>history.proto
  638. X    echo '<gone96>    5000~-' >>history.after
  639. X    echo '<gone97>    5000~-' >>history.proto
  640. X    echo '<gone97>    5000~-' >>history.after
  641. X    echo '<gone98>    5000~-    urp/98' >>history.proto
  642. X    echo '<gone98>    5000~-' >>history.after
  643. X    echo urp/98 >arts/urp/98
  644. X    echo '<multi99>    5000~-    bar/99, bar.ugh/99  foo/99 urp/99' >>history.proto
  645. X    echo '<multi99>    5000~-    bar.ugh/99 foo/99' >>history.after
  646. X    echo :foo/99:bar/99:bar/ugh/99:urp/99: >arts/foo/99
  647. X    echo 'Message-ID: <multi99>' >>arts/foo/99
  648. X    ln arts/foo/99 arts/bar/99
  649. X    ln arts/foo/99 arts/bar/ugh/99
  650. X    ln arts/foo/99 arts/urp/99
  651. X    cp history.proto history
  652. X
  653. X# regression test machinery
  654. XD = NEWSARTS=`pwd`/arts NEWSCTL=`pwd` NEWSBIN=`pwd`/nbin
  655. XRUN = $(D) ./expire -a `pwd`/arch -n 10000
  656. XFIXMIDFIELD = 's/    [0-9]*~*/    ~/;s/~    /~-    /;s/~xx~a//'
  657. XFIXPATHS = "s;`pwd`;P;g"
  658. Xgoodt:    expire setup    # do NOT run this unless you know what you're doing
  659. X    $(RUN) -t explist 2>&1 | sed $(FIXPATHS) >tgood
  660. X    chmod -w tgood
  661. Xgoodp:    expire setup    # do NOT run this unless you know what you're doing
  662. X    $(RUN) -p explist >pgood 2>&1
  663. X    chmod -w pgood
  664. Xdoit:    expire        # for debugging
  665. X    echo "$(RUN) -t explist" >$@
  666. X    chmod +x $@
  667. X
  668. X# the regression test proper
  669. Xr:    $(THEM) dircheck setup tgood pgood
  670. X    chmod +x dircheck $(THEM)
  671. X    $(RUN) -c explist
  672. X    : "okay, it's sane"
  673. X    $(RUN) -t explist >test.out 2>&1
  674. X    sed $(FIXPATHS) test.out | cmp - tgood
  675. X    : "okay, it seems to know what it's doing -- now, can it do it?"
  676. X    $(RUN) -p explist >test.out 2>test.stderr
  677. X    test ! -s test.stderr
  678. X    cmp test.out pgood
  679. X    test ! -f history.n
  680. X    cmp history.proto history.o
  681. X    egrep wont history.proto | ./dircheck arts
  682. X    egrep 'will|two|gone|three' history.proto | ./dircheck -n arts
  683. X    egrep will history.proto | ./dircheck arch
  684. X    egrep 'wont|two|gone|three' history.proto | ./dircheck -n arch
  685. X    egrep two history.proto | ./dircheck arch2
  686. X    egrep 'will|wont|gone|three' history.proto | ./dircheck -n arch2
  687. X    egrep three history.proto | ./dircheck arch3
  688. X    egrep 'will|wont|gone|two' history.proto | ./dircheck -n arch3
  689. X    test -f arts/foo/99
  690. X    test -f arts/bar/ugh/99
  691. X    test -f arch2/bar/99
  692. X    test ! -f arts/urp/99
  693. X    cmp history history.after
  694. X    : "that's it for expire, on to upact"
  695. X    $(D) ./upact
  696. X    cmp active active.after
  697. X    : "and for upact, on to mkhistory"
  698. X    awk -F'    ' 'NF > 2' history | sed $(FIXMIDFIELD) | sort >history.after
  699. X    rm -f history.pag history.dir
  700. X    $(D) ./mkhistory
  701. X    sort history | sed $(FIXMIDFIELD) | cmp - history.after
  702. X    test -r history.pag
  703. X    test -r history.dir
  704. X    : "and that's mkhistory done, finally try superkludge"
  705. X    test -r arts/foo/1
  706. X    test -r arts/foo/10
  707. X    $(D) ./superkludge foo
  708. X    test ! -r arts/foo/1
  709. X    test -r arts/foo/10
  710. X    : "success!"
  711. X
  712. Xtidy:
  713. X    rm -f junk history history.pag history.dir history.o active
  714. X    rm -f history.n* mon.out history.proto history.after test.out doit
  715. X    rm -f active.old active.new explist lint active.after test.stderr
  716. X    rm -rf arts arch arch2 arch3 nbin
  717. X
  718. Xclean:    tidy
  719. X    rm -f *.o expire histslash mkdbm histinfo lowest explist.proto
  720. X    rm -f dtr
  721. X
  722. Xspotless:    clean    # don't run this unless you know what you're doing
  723. X    rm -f pgood tgood
  724. X
  725. Xdtr:    $(DTR)
  726. X    makedtr $(DTR) >$@
  727. !
  728. echo 'expire/README':
  729. sed 's/^X//' >'expire/README' <<'!'
  730. XC News expire
  731. X
  732. XUnlike the old alpha C News expire, this one will accept B News history
  733. Xfiles... although that slows it down, and this hasn't been tested well.
  734. XBeware that the date in the middle field of the history line must be
  735. Xreadable to getdate(3), and rumor hath it that late B 2.11 dates are not.
  736. XTalk about stupid...  We don't care enough to do anything about this.
  737. XRebuilding your history file in C News format is preferable anyway.
  738. X
  739. XIt WON'T accept the old experimental C News four-field history files;
  740. Xwe recommend
  741. X
  742. X    awk -F'    ' '{ print $1 "    " $2 "~" $3 "    " $4 }'
  743. X
  744. X(those are tabs in the quotes after the -F and the empty-looking quotes
  745. Xin the awk program) as a conversion aid.
  746. X
  747. X"make r" will compile everything and run a complex set of regression tests,
  748. Xchecking the results automatically.  If nothing screams, there is a high
  749. Xprobability that expire, upact, mkhistory, and superkludge are working.
  750. X
  751. Xdircheck checks the results of expire regression testing.
  752. Xhistdups, histinfo, histslash, and mkdbm are parts of mkhistory.
  753. Xlowest is an optimized version of part of upact -- it's faster, but it's
  754. X    also the only thing in C News that needs to know how to read
  755. X    directories, which is a portability hassle, so it's not the default.
  756. Xpgood and tgood are regression-test output-should-look-like-this files.
  757. Xmkadir is what expire invokes to create archiving subdirectories.
  758. !
  759. echo 'expire/mkadir':
  760. sed 's/^X//' >'expire/mkadir' <<'!'
  761. X#! /bin/sh
  762. X# make directories for expire archiving
  763. X# $1 is overall archive dir, remaining args are successively deeper
  764. X# subdirectories under $1 (e.g. comp comp/lang comp/lang/c) (which may
  765. X# or may not already exist -- expire doesn't know or care).  Note, last
  766. X# argument therefore is slashed newsgroup name.
  767. X
  768. Xcase $# in
  769. X0|1)    echo "Usage: $0 archdir subdir ..." >&2 ; exit 2 ;;
  770. Xesac
  771. X
  772. Xcd $1
  773. Xshift
  774. X
  775. Xfor d
  776. Xdo
  777. X    if test ! -d "$d"
  778. X    then
  779. X        mkdir "$d" >/dev/null 2>/dev/null
  780. X    fi
  781. Xdone
  782. !
  783. echo done
  784.  
  785.  
  786.