free(dipf);
if (ipf) {
- DUMPV("%d", ipf->counts.,read_ok);
- DUMPV("%d", ipf->counts.,read_blank);
- DUMPV("%d", ipf->counts.,read_err);
- DUMPV("%d", ipf->counts.,nooffer_missing);
+ DUMPV("%d", ipf->counts.,events[read_ok]);
+ DUMPV("%d", ipf->counts.,events[read_blank]);
+ DUMPV("%d", ipf->counts.,events[read_err]);
+ DUMPV("%d", ipf->counts.,events[nooffer_missing]);
}
fprintf(f,"\n");
if (ipf) {
ArtState state; const char *const *statename;
for (state=0, statename=artstate_names; *statename; state++,statename++) {
#define RC_DUMP_FMT(x) " " #x "=%d"
-#define RC_DUMP_VAL(x) ,ipf->counts.counts[state][RC_##x]
+#define RC_DUMP_VAL(x) ,ipf->counts.results[state][RC_##x]
fprintf(f,"input %s counts %-11s"
RESULT_COUNTS(RC_DUMP_FMT,RC_DUMP_FMT) "\n",
wh, *statename
const char *data, const char *how) {
warn("corrupted file: %s, offset %lu: %s: in %s",
ipf->path, (unsigned long)offset, how, sanitise(data,-1));
- ipf->counts.read_err++;
- if (ipf->counts.read_err > max_bad_data_initial +
- (ipf->counts.read_ok + ipf->counts.read_blank) / max_bad_data_ratio)
+ ipf->counts.events[read_err]++;
+ if (ipf->counts.events[read_err] > max_bad_data_initial +
+ (ipf->counts.events[read_ok] + ipf->counts.events[read_blank])
+ / max_bad_data_ratio)
crash("too much garbage in input file! (%d errs, %d ok, %d blank)",
- ipf->counts.read_err, ipf->counts.read_ok, ipf->counts.read_blank);
+ ipf->counts.events[read_err], ipf->counts.events[read_ok],
+ ipf->counts.events[read_blank]);
return OOP_CONTINUE;
}
if (data[0]==' ') {
if (strspn(data," ") != recsz) X_BAD_DATA("line partially blanked");
- ipf->counts.read_blank++;
+ ipf->counts.events[read_blank]++;
return OOP_CONTINUE;
}
tokentextbuf[tokenlen]= 0;
if (!IsToken(tokentextbuf)) X_BAD_DATA("token wrong syntax");
- ipf->counts.read_ok++;
+ ipf->counts.events[read_ok]++;
art= xmalloc(sizeof(*art) - 1 + midlen + 1);
memset(art,0,sizeof(*art));
RCI_max
} ResultCountIndex;
+typedef enum {
+ read_ok, read_blank, read_err, nooffer_missing,
+ ECI_max
+} EventCountIndex;
/*----- transmission buffers -----*/
/*----- core operational data structure types -----*/
typedef struct {
- int counts[art_MaxState][RCI_max];
- int read_ok, read_blank, read_err, nooffer_missing;
+ int results[art_MaxState][RCI_max];
+ int events[ECI_max];
} Counts;
struct InputFile {
void article_done(Article *art, int whichcount) {
if (whichcount>=0 && !art->missing)
- art->ipf->counts.counts[art->state][whichcount]++;
+ art->ipf->counts.results[art->state][whichcount]++;
if (whichcount == RC_accepted) update_nocheck(1);
else if (whichcount == RC_unwanted) update_nocheck(0);
case 335: /* IHAVE says send it */
GET_ARTICLE(-1);
assert(art->state == art_Unchecked);
- art->ipf->counts.counts[art->state][RC_accepted]++;
+ art->ipf->counts.results[art->state][RC_accepted]++;
art->state= art_Wanted;
LIST_ADDTAIL(conn->priority, art);
break;
#define RCI_NOTHING(x) /* nothing */
#define RCI_TRIPLE_FMT(x) " " #x "=" RCI_TRIPLE_FMT_BASE
-#define RCI_TRIPLE_VALS(x) , RCI_TRIPLE_VALS_BASE(ipf->counts.counts, [RC_##x])
+#define RCI_TRIPLE_VALS(x) ,RCI_TRIPLE_VALS_BASE(ipf->counts.results, [RC_##x])
-#define CNT(art,rc) (ipf->counts.counts[art_##art][RC_##rc])
+#define CNT(art,rc) (ipf->counts.results[art_##art][RC_##rc])
char *inprog= completed
? xasprintf("%s","") /* GCC produces a stupid warning for printf("") ! */
RESULT_COUNTS(RCI_NOTHING, RCI_TRIPLE_FMT)
,
completed?"completed":"processed", what, spec,
- ipf->counts.read_ok, ipf->counts.read_blank, ipf->counts.read_err,
- inprog, autodefer, ipf->counts.nooffer_missing,
+ ipf->counts.events[read_ok], ipf->counts.events[read_blank],
+ ipf->counts.events[read_err],
+ inprog, autodefer, ipf->counts.events[nooffer_missing],
CNT(Unchecked,sent) + CNT(Unsolicited,sent)
, CNT(Unchecked,sent), CNT(Unsolicited,sent),
CNT(Wanted,accepted) + CNT(Unsolicited,accepted)
LIST_REMOVE(art->ipf->queue, art);
art->missing= 1;
- art->ipf->counts.nooffer_missing++;
+ art->ipf->counts.events[nooffer_missing]++;
article_done(art,-1);
return 1;
}
(abort(),-1);
if (!artdata) art->missing= 1;
- art->ipf->counts.counts[art->state][ artdata ? RC_sent : RC_missing ]++;
+ art->ipf->counts.results[art->state][ artdata ? RC_sent : RC_missing ]++;
if (conn->stream) {
if (artdata) {
XMIT_LITERAL("\r\n");
assert(art->state == art_Unchecked);
- art->ipf->counts.counts[art->state][RC_sent]++;
+ art->ipf->counts.results[art->state][RC_sent]++;
LIST_ADDTAIL(conn->sent, art);
}
}