[news.software.nntp] expire enhancements

heather@babbage.seas.ucla.edu (Heather Burris/) (08/02/90)

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 <the rest> -e 21 <other opts>

A cursory look at the source code indicates that a list of structures 
mapping news category/group to expiration period would have to be crafted
in to implement such a thing.  I think the work involved in doing so would
be well warrented, considering that running multiple expires back-to-back 
takes an exceedingly long amount of time. It appears to me that
rebuilding the history file is a large part of the time.

If no one has implemented this yet, I'll plan to get to it soon, but I thought
I'd check before reinventing the wheel. Also, if anyone has an opinion
on whether it is or isn't a good idea, let me know.

Heather Burris
Operations Manager, SEASnet, UCLA

merlyn@iwarp.intel.com (Randal Schwartz) (08/02/90)

In article <948@lee.SEAS.UCLA.EDU>, heather@babbage (Heather Burris/) writes:
| If no one has implemented this yet, I'll plan to get to it soon, but I thought
| I'd check before reinventing the wheel. Also, if anyone has an opinion
| on whether it is or isn't a good idea, let me know.

Cnews has it.  Dunno if you can steal it to work Bnews.  Cnews expire
allows specification down to the newsgroup level.  ("Yup, let's expire
all those alt.sex.wanteds in exactly 6.9 days..." :-)

Just another Cnews admin,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/

tim@Data-IO.COM (The Daemon's Slave) (08/03/90)

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 <the rest> -e 21 <other opts>


  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@Data-IO.COM>   |   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

davison%drivax@uunet.uu.net (Wayne Davison) (08/03/90)

heather@babbage.seas.ucla.edu (Heather Burris/) wrote:
> Have any of you enhanced expire to accept different expiration periods
> for different news categories on the same command line?

Yes, before I switched to C news last year, I modified the B news expire
to accept the following syntax:

	expire -E 15 -e 15 -n junk:1,talk:7,soc:7,comp.sys.ibm.pc:3,all

which allows you to specify a global expire time (15) and override it on
an individual group basis with the ':<days>' syntax.  The patch was very
simple, since all that had to be done was to modify the news-group match
code to set the expire time to the indicated value if present, otherwise
set it to the command-line specified value (which was saved in a special
variable).  I tested the patch and sent it out to the twelve people that
requested it when I offered it to the public.  I no longer have the code
here, but I still have the names of the twelve people that got the patch
a year ago March.  I can contact them and then get back to you if you're
interested.
-- 
Wayne Davison            \  /| / /|\/ /| /(_)     davison%drivax@uunet.uu.net
davison@drivax.UUCP     (_)/ |/ /\|/ / |/  \         ...!uunet!drivax!davison
                           (W   A  Y   N   e)

stealth@caen.engin.umich.edu (Mike Pelletier) (08/08/90)

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 <the rest>


Upgrade to C-news.  I promise you, you won't regret it.
Expire is just one of many things that are much better than B-news.

--
Michael V. Pelletier            | "We live our lives with our hands on the
 CAEN UseNet News Administrator |  rear-view mirror, striving to get a better
 Systems Group Programmer       |  view of the road behind us.  Imagine what's
                                |  possible if we look ahead and steer..."