newsgroup based expiry(2.3)

Richard Michael Todd rmtodd at mailhost.ecn.ou.edu
Sat Oct 23 23:15:11 UTC 1999


In message <1rd7u89p2r.fsf at haey.ifi.uio.no>you write:
>
>Perhaps creating a tool which moves articles from one storage class to
>another based on the new storage.conf is a better solution, though.

It's not a terribly good solution, since moving articles about requires
a history/overview rebuild.  I have had to do it on occasion, though,
hence the following code, which some of you may find useful.

>Richard's problem can be solved by strengthening the
>storage.conf-parser.  Or perhaps he can do some work on his
>storage.conf-generator to use wildmats to alleviate the problem.

The former would be preferable.  My code does try to use wildmats in
constructing the storage.conf lines to minimize the length, but the problem
with that is that if the wildmats are at too high a level, you get more
stuff put in the storage area than you really wanted, which sorta defeats
the purpose of fine-grained control.

Anyway, here's refile.c:
/*
** Collect propagation stats (# of articles with delay in a given range) for
** each host.
*/

/* include foo needed by libinn/storage manager */
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include "configdata.h"
#include "clibrary.h"
#include "libinn.h"
#include "macros.h"
#include "paths.h"
#include "qio.h"
#include <syslog.h>  

char *ME;

void
ProcessLine(char *line)
{
    char *dateptr;
    char *tokenptr;
    char *dp1;
    char *dp2;
    int len,i;
    ARTHANDLE *art;
    ARTHANDLE newart;
    char *path;
    char *pathseg;
    char *p1, *p2;
    TOKEN token, newtoken;
    char *arttmp;
    time_t arrived;

    tokenptr = line;
    
    /* zap newline at end of tokenptr, if present. */
    len = strlen(tokenptr);
    if (tokenptr[len-1] == '\n') {
	tokenptr[len-1] = '\0';
    }

    token = TextToToken(tokenptr);
    if ((art = SMretrieve(token, RETR_ALL)) == NULL) return;

    len = art->len;
    arrived = art->arrived;
    arttmp = NEW(char, len);
    memcpy(arttmp, art->data, len);
    SMfreearticle(art);
    if (!SMcancel(token)) {
	fprintf(stderr, "%s: cant cancel %s:%s\n", ME, tokenptr, SMerrorstr);
	return;
    }

    newart.data = arttmp;
    newart.len = len;
    newart.arrived = (time_t) 0; /* set current time */
    newart.token = (TOKEN *)NULL;

    newtoken = SMstore(newart);
    if (newtoken.type == TOKEN_EMPTY) {
	fprintf(stderr, "%s: cant store article:%s\n", ME, SMerrorstr);
	return;
    }
    DISPOSE(arttmp);
    printf("refiled %s ",TokenToText(token));
    printf("to %s\n", TokenToText(newtoken));
    return;
}

void usage(void) {
    fprintf(stderr, "Usage: %s [-d directory] [-h hopcount] [-t timedelta]\n");
    exit(1);
}

main(int argc, char **argv)
{
    int		c;
    int 	one = 1;
    char	buff[SMBUF];

    openlog(argv[0], L_OPENLOG_FLAGS | LOG_PID, LOG_INN_PROG);

    if (ReadInnConf() < 0) { exit(1); }

    ME = argv[0];

    if (!SMsetup(SM_PREOPEN, &one) || !SMsetup(SM_RDWR, (void *)&one)) {
	fprintf(stderr, "can't init storage manager");
	exit(1);
    }
    if (!SMinit()) {
	fprintf(stderr, "Can't init storage manager: %s", SMerrorstr);
    }
    while (fgets(buff, SMBUF, stdin)) {
	ProcessLine(buff);
    }
    exit(0);
}



More information about the inn-workers mailing list