[net.news.b] Expire with DBM bug

ggr@pyuxmm.UUCP (06/17/83)

If you use DBM, you may notice your dbm files growing steadily larger.
Articles that are cancelled never get removed from the database.
These changes to expire (2.10) fix this by re-creating the dbm files
as the history file is being re-built instead of trying to
delete entries that are being removed.
They also fix another bug -- xerror() was declared with too few
parameters, so messages came out without the arguments.

				=== Guy Riddle == BTL Piscataway ===

73d72
< 	datum	key;
150c149
< 	dbminit(ARTFILE);
---
> 	dbminit(NARTFILE);	/* your dbminit should create non-existent files */
228a228,229
> 				*p1 = 0;
> 				remember(afline);
260a262
> 				remember(h.ident);
308,312d309
< # ifdef DBM
< 			key.dptr = h.ident;
< 			key.dsize = strlen(key.dptr) +1;
< 			delete(key);
< # endif
315a313
> 			remember(h.ident);
338a337,354
> #ifdef DBM
> 		strcat(ARTFILE, ".pag");
> 		strcat(OARTFILE, ".pag");
> 		strcat(NARTFILE, ".pag");
> 		unlink(OARTFILE);
> 		link(ARTFILE, OARTFILE);
> 		unlink(ARTFILE);
> 		link(NARTFILE, ARTFILE);
> 		unlink(NARTFILE);
> 		strcpy(rindex(ARTFILE, '.'), ".dir");
> 		strcpy(rindex(OARTFILE, '.'), ".dir");
> 		strcpy(rindex(NARTFILE, '.'), ".dir");
> 		unlink(OARTFILE);
> 		link(ARTFILE, OARTFILE);
> 		unlink(ARTFILE);
> 		link(NARTFILE, ARTFILE);
> 		unlink(NARTFILE);
> #endif
402c418
< xerror(message)
---
> xerror(message, a1, a2, a3)
405c421,423
< 	printf("expire: %s.\n", message);
---
> 	printf("expire: ");
> 	printf(message, a1, a2, a3);
> 	printf("\n");
434a453,471
> }
> 
> remember(article)
> 	char	*article;
> {
> 	static long	number;
> 	datum		lhs, rhs;
> 
> #ifdef DBM
> 	lhs.dptr = article;
> 	lhs.dsize = strlen(article)+1;
> 
> 	number++;
> 
> 	rhs.dptr = (char *) &number;
> 	rhs.dsize = sizeof(number);
> 
> 	store(lhs, rhs);
> #endif