Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!mit-eddie!uw-beaver!sumax!amc-gw!pilchuck!tim From: tim@Data-IO.COM (The Daemon's Slave) Newsgroups: news.software.nntp Subject: Re: expire enhancements Message-ID: <1502@pilchuck.Data-IO.COM> Date: 2 Aug 90 18:26:57 GMT References: <948@lee.SEAS.UCLA.EDU> Organization: Data I/O Corporation; Redmond, WA Lines: 291 In <948@lee.SEAS.UCLA.EDU> Heather Burris/ writes: >Have any of you enhanced expire to accept different expiration periods >for different news categories on the same command line? I would like >to do (something like) the following: >expire -n junk control -e 1 -n alt talk -e 14 -n -e 21 Quite a few years ago someone modified expire to read a file for expiration times for individual groups. I'm still using this stuff in the current version of Bnews (2.11.19) with no problems. Below (in a shar file) is an example of my expiration file for individual groups followed by the diffs to add this capability. The diffs should fit right into your current version of Bnews with little or no trouble. Format of the file is "group-name expiration-time-in-days" The "all" at the end tells expire to use the "-e" flag for any groups not listed in this file. #!/bin/sh # # ################################################################### # # --------CUT---------CUT---------CUT---------CUT--------CUT--------- # # # # This is a shell archive. These archives are packed by the program # # packmail(1). If you have the program unshar(1), I suggest you use # # it. If you don't, remove anything before the cut line and then # # feed to sh(1). To extract files using the second method: # # # # 1) Make a directory for the files. # # 2) Write a file, such as "file.shar", containing # # this archive file into the directory. # # 3) Type "sh file.shar". Do not use csh. # # # # ################################################################### # # # # echo 'Start of pack.out, part 01 of 01:' echo 'x - expdays' sed 's/^X//' > expdays << '/' Xalt.sources 6 Xalt 3 Xcomp.sys.ibm 5 Xcomp.sys.sun 5 Xcomp.os.vax 5 Xcomp.lang 5 Xcomp.mail.maps 3 Xmisc.consumers 5 Xmisc.forsale 5 Xmisc.jobs 5 Xmisc.wanted 5 Xmisc 3 Xrec.auto 5 Xrec.aviation 5 Xrec.food 5 Xrec.ham-radio 5 Xrec.radio.shortwave 5 Xrec.models 5 Xrec.sport 5 Xrec.travel 5 Xrec 3 Xsci.electronics 5 Xsci 3 Xsoc.net-people 5 Xsoc 3 Xtalk.rumors 4 Xtalk 3 Xjunk 3 Xall / echo 'x - XDIFF' sed 's/^X//' > XDIFF << '/' X*** ../src.orig/expire.c Mon Jan 15 13:22:26 1990 X--- expire.c Mon Jan 15 07:46:49 1990 X*************** X*** 62,67 **** X--- 62,70 ---- X int frflag = 0; /* expire specific user */ X int doupdateactive = 0; /* update ACTIVE file */ X int dontexec = 0; /* don't exec rnews -U */ X+ #ifdef EXPDAY X+ int expday = 0; /* read the expiration days file */ X+ #endif /* EXPDAY */ X char baduser[BUFLEN]; X extern char filename[], nbuf[]; X double atof(); X*************** X*** 83,88 **** X--- 86,98 ---- X FILE *nexthistfile(); X #endif /* !DBM */ X X+ #ifdef EXPDAY X+ struct { X+ char *pat; X+ long incr; X+ } nga[LBUFLEN * 2]; X+ #endif /* EXPDAY */ X+ X long expincr; X long dropincr; X long atol(); X*************** X*** 272,279 **** X--- 282,299 ---- X dropincr = HISTEXP; X fprintf(stderr, "History expiration time < article expiration time. Default used.\n"); X } X+ #ifdef EXPDAY X if (ngpat[0] == ',') X+ readexpdays(); X+ else { X+ nga[0].pat = ngpat; X+ nga[0].incr = expincr; X+ nga[1].pat = NULL; X+ } X+ #else /* EXPDAY */ X+ if (ngpat[0] == ',') X (void) strcpy(ngpat, "all,"); X+ #endif /* EXPDAY */ X if (arpat[0] == ',') X (void) strcpy(arpat, "all,"); X (void) ftime(&Now); X*************** X*** 284,289 **** X--- 304,314 ---- X if (verbose) { X printf("expire: nohistory %d, rebuild %d, doarchive %d\n", X nohistory, dorebuild, doarchive); X+ #ifdef EXPDAY X+ if (expday) X+ printf("newsgroups: all + expdays file\n"); X+ else X+ #endif /* EXPDAY */ X printf("newsgroups: %s\n",ngpat); X if (doarchive) X printf("archiving: %s\n",arpat); X*************** X*** 401,407 **** X p1 = index(nbuf, '\n'); X if (p1 != NULL) X *p1 = '\0'; X! if (!ngmatch(nbuf, ngpat)) X continue; X X /* Change a group name from X--- 426,436 ---- X p1 = index(nbuf, '\n'); X if (p1 != NULL) X *p1 = '\0'; X! #ifdef EXPDAY X! if ((expincr = getincr(nbuf)) < 0) X! #else /* EXPDAY */ X! if (!ngmatch(nbuf, ngpat)) X! #endif /* EXPDAY */ X continue; X X /* Change a group name from X*************** X*** 522,528 **** X grpsleft[0] = '\0'; X goto checkdate; X } X! if (!ngmatch(nbuf, ngpat) || X (exptime > today && !dorebuild && X !frflag && !usepost && recdate[0] != ' ')) X goto keephist; X--- 551,561 ---- X grpsleft[0] = '\0'; X goto checkdate; X } X! #ifdef EXPDAY X! if (((expincr = getincr(nbuf)) < 0) || X! #else /* EXPDAY */ X! if (!ngmatch(nbuf, ngpat) || X! #endif /* EXPDAY */ X (exptime > today && !dorebuild && X !frflag && !usepost && recdate[0] != ' ')) X goto keephist; X*************** X*** 871,876 **** X--- 904,913 ---- X printf("updating active file %s\n", ACTIVE); X ohfd = xfopen(ACTIVE, "r"); X nhfd = xfopen(NACTIVE, "w"); X+ #ifdef EXPDAY X+ if (expday) X+ strcpy(ngpat,"all,"); X+ #endif /* EXPDAY */ X do { X long n; X long maxart, minart; X*************** X*** 1274,1276 **** X--- 1311,1359 ---- X rmlock(); X exit(i); X } X+ X+ #ifdef EXPDAY X+ readexpdays() X+ { X+ char buf[BUFLEN], ngbuf[BUFLEN]; X+ extern char *EXPDAYFILE; X+ FILE *f; X+ int i, n; X+ long incr; X+ X+ f = xfopen(EXPDAYFILE, "r"); X+ i = 0; X+ while (fgets(buf, sizeof buf, f) != NULL) { X+ n = sscanf(buf, "%s %d", ngbuf, &incr); X+ if (n < 1) X+ continue; X+ if (n == 1) X+ nga[i].incr = expincr; X+ else X+ nga[i].incr = incr * DAYS; X+ nga[i].pat = malloc(strlen(ngbuf) + 1); X+ strcpy(nga[i].pat, ngbuf); X+ if(verbose) X+ printf("Group = %s, Expday = %d\n",nga[i].pat,nga[i].incr / DAYS); X+ i++; X+ } X+ nga[i].pat = NULL; X+ fclose(f); X+ expday++; X+ } X+ X+ getincr(group) X+ char *group; X+ { X+ int i; X+ X+ for (i = 0; nga[i].pat != NULL; i++) X+ if (ngmatch(group, nga[i].pat)) { X+ strcpy(ngpat,nga[i].pat); X+ if (verbose > 1) X+ printf("Pattern %s incr-exp %d days\n", ngpat, nga[i].incr / DAYS); X+ return (nga[i].incr); X+ } X+ return -1; X+ } X+ #endif /* EXPDAY */ X*** ../src.orig/iparams.h Wed Nov 25 08:31:56 1987 X--- iparams.h Mon Jan 8 11:04:42 1990 X*************** X*** 10,15 **** X--- 10,18 ---- X X /* external declarations specific to inews */ X extern char nbuf[LBUFLEN], *ARTICLE, *INFILE, *ALIASES, *PARTIAL; X+ #ifdef EXPDAY X+ extern char *EXPDAYFILE; X+ #endif X #ifndef ROOTID X extern int ROOTID; X #endif X*** ../src.orig/pathinit.c Wed Feb 22 17:34:06 1989 X--- pathinit.c Mon Jan 8 11:05:18 1990 X*************** X*** 88,93 **** X--- 88,94 ---- X X #ifdef EXP X char *OLDNEWS; X+ char *EXPDAYFILE; X #endif /* EXP */ X X #ifdef READ X*************** X*** 183,188 **** X--- 184,190 ---- X Sprintf(ACTIVE, "%s/active", LIB); X X #ifdef EXP X+ Sprintf(EXPDAYFILE, "%s/expdays", LIB); X (void) strcpy(bfr, SPOOL); X p = rindex(bfr, '/'); X if (p) { / echo 'Part 01 of pack.out complete.' exit -- Internet: | Tim Rosmus (Sys Admin) ...sun!fluke!thebes-----\ | Data I/O Corporation ...uunet-------------------!pilchuck!tim | 10525 Willows Road N.E. ...uw-beaver!hpubvwa----/ | Redmond, WA (206)881-6444