void DoArticle(History *h, const char *id, char *nglist, char *dist, char *npath, int headOnly, char *artType, char *cSize) { int r = 0; if (RequeueOpt) { char path[PATH_MAX]; ArticleFileName(path, (int)sizeof(path), h, ARTFILE_FILE_REL); printf("SOUT\t%s\t%lld,%ld\t%s\t%s\t%s\t%s\t%d\t%s\t%s\n", path, (long long)h->boffset, (long)h->bsize, id, nglist, dist, npath, headOnly, artType, cSize ); ++LoadCount; } else { History htmp; if ((r = HistoryLookupByHash(h->hv, &htmp)) == 0) { if (UnExpireOpt) { uint32 pos = HistoryPosLookupByHash(h->hv, &htmp); htmp.exp &= ~EXPF_EXPIRED; if (pos != -1 && ForReal && htmp.iter == h->iter && htmp.boffset == h->boffset) HistoryStoreExp(&htmp, (HistIndex)pos); } ++LoadDupCount; } else { if (ForReal && !UnExpireOpt) HistoryAdd(id, h); ++LoadCount; } } if (VerboseOpt > 1 || (VerboseOpt && r != 0)) printf("\tMessage %d,%d %s %s\n", h->boffset, h->bsize, ((r == 0) ? "dup" : "add"), id); }
int LookupHash(hash_t hv, const char *msgid, History *ph) { History h; int rv = 0; if (msgid) fprintf(LogFo, "%60s\t", msgid); else fprintf(LogFo, "%08x.%08x\t", hv.h1, hv.h2); if (ph != NULL || HistoryLookupByHash(hv, &h) == 0) { char buf[8192]; if (ph != NULL) memcpy(&h, ph, sizeof(h)); if (ForceOpt || ( !H_EXPIRED(h.exp) && h.iter != (unsigned short)-1 && (h.boffset || h.bsize) ) ) { int headOnly = (int)(h.exp & EXPF_HEADONLY); ArticleFileName(buf, sizeof(buf), &h, ARTFILE_FILE); if (HeadOnly == 0 && headOnly) { fprintf(LogFo, "Article stored as header-only, use -h\n"); rv = 1; } else { rv = DumpArticle(buf, &h, msgid); } } else if (h.boffset || h.bsize) { fprintf(LogFo, "Article expired\n"); rv = 1; } else { fprintf(LogFo, "Article pre-expired\n"); rv = 1; } } else { fprintf(LogFo, "Article not found in history\n"); rv = 1; } return(rv); }
int DILookup(char *id) { hash_t hv; History h; int r = 0; char *p; if (id[0] == '<' && (p = strchr(id, '>')) != NULL) { *++p = 0; hv = hhash(id); } else if (id[0] == 'D' && id[1] == '.') { int32 dummy; char *p = strchr(id, '/'); if (p && p[1] == 'B' && p[2] == '.') { /* * dqueue data format */ if ((id = strchr(p, '<')) != NULL && strchr(id, '>') != NULL) { *(strchr(id, '>') + 1) = 0; hv = hhash(id); } else { fprintf(stderr, "argument error: %s\n", id); exit(1); } } else { /* * hash code format 1 */ if (sscanf(id + 2, "%x/%x.%x", &dummy, &hv.h1, &hv.h2) != 3) { fprintf(stderr, "argument error: %s\n", id); exit(1); } } } else if (strncmp(id, "DUMP ", 5) == 0) { if (sscanf(id + 5, "%x.%x", &hv.h1, &hv.h2) != 2) { fprintf(stderr, "argument error: %s\n", id); exit(1); } } else if (sscanf(id, "%x.%x", &hv.h1, &hv.h2) != 2) { /* * hash code format 2 */ fprintf(stderr, "argument error: %s\n", id); exit(1); } if (HistoryLookupByHash(hv, &h) == 0) { char tbuf1[64]; char tbuf2[64]; char buf[1024]; if (QuietOpt) return(r); { struct tm *tp; time_t t; t = h.gmt * 60; tp = localtime(&t); strftime(tbuf1, sizeof(tbuf1), "%d-%b-%Y %H:%M:%S", tp); if (H_EXPIRED(h.exp)) { if (h.iter == (unsigned short)-1) sprintf(tbuf2, "rejected"); else sprintf(tbuf2, "expired"); } else { sprintf(tbuf2, "valid"); } } if (h.boffset || h.bsize) { ArticleFileName(buf, sizeof(buf), &h, ARTFILE_FILE_REL); printf(" [%s hv=%08x.%08x spool=%02x gm=%d ex=%d off=%d len=%d f=%s]" " GM=(%s) EX=(%s)\n", buf, h.hv.h1, h.hv.h2, (int)H_SPOOL(h.exp), (int)h.gmt, (int)h.exp, (int)h.boffset, (int)h.bsize, ((h.exp & EXPF_HEADONLY) ? "H" : ""), tbuf1, tbuf2 ); } else { ArticleFileName(buf, sizeof(buf), &h, ARTFILE_DIR_REL); printf(" [%s/NOFILE hv=%08x.%08x gm=%d ex=%d f=%s] GM=(%s) EX=(%s) (pre-expired)\n", buf, h.hv.h1, h.hv.h2, (int)h.gmt, (int)h.exp, ((h.exp & EXPF_HEADONLY) ? "H" : ""), tbuf1, tbuf2 ); } } else { printf("Not Found: %s (%08x.%08x)\n", id, hv.h1, hv.h2); r = 1; } return(r); }