Path: utzoo!utgpu!news-server.csri.toronto.edu!me!eastick Newsgroups: news.software.nntp From: eastick@me.utoronto.ca (Doug Eastick) Message-ID: <90May31.221409edt.19688@me.utoronto.ca> Date: 1 Jun 90 02:14:16 GMT References: <1983@dali> Organization: University of Toronto, Department of Mechanical Engineering Subject: (none) For those who want to log the delay (in seconds) of articles to reach their sites, you can apply the following patch to add the INT field after the date. Note: accuracy of the number depends on the GMT-ness of the posting machine (Real big assumption about NTP). I haven't noticed much performance degradation. Enjoy. -------- diff -r -c c.official/libcnews/time.c cnews/libcnews/time.c *** c.official/libcnews/time.c Tue Apr 24 17:12:12 1990 --- cnews/libcnews/time.c Tue Apr 24 17:01:09 1990 *************** *** 13,24 **** * N.B.: no trailing newline is written. */ void ! timestamp(fp, timep) FILE *fp; time_t *timep; /* if non-null, return time() here for later use */ { struct timeb ftnow; char ms[STRLEN("123") + SIZENUL]; ftime(&ftnow); if (timep != NULL) --- 13,27 ---- * N.B.: no trailing newline is written. */ void ! timestamp(fp, timep, delay) FILE *fp; time_t *timep; /* if non-null, return time() here for later use */ + char *delay; /* possible delay */ { struct timeb ftnow; char ms[STRLEN("123") + SIZENUL]; + time_t del; + extern time_t getdate(); ftime(&ftnow); if (timep != NULL) *************** *** 27,30 **** --- 30,46 ---- (void) fprintf(fp, "%.15s.", ctime(&ftnow.time) + 4); (void) ltoza(ms, (long)ftnow.millitm, 3); /* 3 digits of output */ (void) fputs(ms, fp); + /* + * calculate the transmission delay + */ + if (delay != NULL) { + del = getdate(delay, &ftnow); + if (del < 0) + del = 0; + else + del = *timep - del; + } else { + del = 0; + } + (void) fprintf(fp, " %ld", del); } diff -r -c c.official/relay/hdrdefs.c cnews/relay/hdrdefs.c *** c.official/relay/hdrdefs.c Tue Apr 24 17:13:28 1990 --- cnews/relay/hdrdefs.c Tue Apr 24 14:51:27 1990 *************** *** 26,31 **** --- 26,32 ---- static const char ngsnm[] = "Newsgroups:"; /* filing, clone for Xref */ static const char pathnm[] = "Path:"; /* rejection, extend (damn) */ static const char subjnm[] = "Subject:"; /* for ctl. msgs. */ + static const char datenm[] = "Date:"; /* for delays. */ /* optional headers */ static const char appnm[] = "Approved:"; /* for mod. groups */ *************** *** 55,60 **** --- 56,63 ---- pathnm, STRLEN(pathnm), offsetof(struct headers, h_path) }; static const struct hdrdef subjhdr = { subjnm, STRLEN(subjnm), offsetof(struct headers, h_subj) }; + static const struct hdrdef datehdr = { + datenm, STRLEN(datenm), offsetof(struct headers, h_date) }; static const struct hdrdef apphdr = { appnm, STRLEN(appnm), offsetof(struct headers, h_approved) }; *************** *** 86,91 **** --- 89,95 ---- &ngshdr, &pathhdr, /* modified by hdrmunge.c (emithdr()) */ &subjhdr, + &datehdr, /* start optional headers */ &apphdr, &ctlhdr, /* NCMP */ *************** *** 126,131 **** --- 130,136 ---- register struct headers *hdrs; { hdrs->h_subj = NULL; + hdrs->h_date = NULL; hdrs->h_ngs = NULL; hdrs->h_distr = NULL; hdrs->h_ctlcmd = NULL; /* NCMP */ *************** *** 143,148 **** --- 148,154 ---- register struct headers *hdrs; { nnfree(&hdrs->h_subj); + nnfree(&hdrs->h_date); nnfree(&hdrs->h_ngs); nnfree(&hdrs->h_distr); nnfree(&hdrs->h_ctlcmd); /* NCMP */ diff -r -c c.official/relay/hdrparse.c cnews/relay/hdrparse.c *** c.official/relay/hdrparse.c Tue Apr 24 17:13:30 1990 --- cnews/relay/hdrparse.c Tue Apr 24 14:53:31 1990 *************** *** 81,86 **** --- 81,91 ---- hdrs->h_expiry = strsave(DEFEXP); } + if (hdrs->h_date == NULL || hdrs->h_date[0] == '\0') { + nnfree(&hdrs->h_date); + hdrs->h_date = strsave(DEFEXP); + } + if (hdrs->h_subj == NULL) hdrs->h_subj = strsave(""); hackoldctl(hdrs); /* NCMP */ diff -r -c c.official/relay/headers.h cnews/relay/headers.h *** c.official/relay/headers.h Tue Apr 24 17:13:31 1990 --- cnews/relay/headers.h Tue Apr 24 15:07:53 1990 *************** *** 16,21 **** --- 16,22 ---- */ struct headers { char *h_subj; /* subject: only needed for controls, -> h_ctlcmd */ + char *h_date; char *h_ngs; /* newsgroups: used in filing, sys matching & all.all.ctl matching */ char *h_distr; /* distribution for transmit */ char *h_ctlcmd; /* control command (NCMP) */ diff -r -c c.official/relay/history.c cnews/relay/history.c *** c.official/relay/history.c Tue Apr 24 17:13:26 1990 --- cnews/relay/history.c Tue Apr 24 15:35:19 1990 *************** *** 181,187 **** register struct article *art; boolean startlog; { ! register char *msgid, *expiry; time_t now; msgid = strsave(nullify(art->h.h_msgid)); --- 181,187 ---- register struct article *art; boolean startlog; { ! register char *msgid, *expiry, *date; time_t now; msgid = strsave(nullify(art->h.h_msgid)); *************** *** 188,197 **** sanitise(msgid); /* RFC 1036 forbids whitespace in msg-ids */ expiry = strsave(nullify(art->h.h_expiry)); sanitise(expiry); subsanitise(expiry); if (startlog) { ! timestamp(stdout, &now); if (printf(" %s + %s", sendersite(nullify(art->h.h_path)), msgid) == EOF) fulldisk(art, "stdout"); --- 188,199 ---- sanitise(msgid); /* RFC 1036 forbids whitespace in msg-ids */ expiry = strsave(nullify(art->h.h_expiry)); sanitise(expiry); + date = strsave(nullify(art->h.h_date)); + sanitise(date); subsanitise(expiry); if (startlog) { ! timestamp(stdout, &now, date); if (printf(" %s + %s", sendersite(nullify(art->h.h_path)), msgid) == EOF) fulldisk(art, "stdout"); diff -r -c c.official/relay/ihave.c cnews/relay/ihave.c *** c.official/relay/ihave.c Tue Apr 24 17:13:34 1990 --- cnews/relay/ihave.c Tue Apr 24 14:58:57 1990 *************** *** 191,197 **** if (histent == NULL || (fap->a_files = findfiles(histent)) == NULL) fap->a_files = "no.such.article!"; ! timestamp(stdout, &now); /* start log line */ if (printf(" %s %c %s", sendersite(nullify(fap->h.h_path)), (proto == PROTO_IHAVE? 'i': 's'), fap->h.h_msgid) == EOF) fulldisk(fap, "stdout"); --- 191,197 ---- if (histent == NULL || (fap->a_files = findfiles(histent)) == NULL) fap->a_files = "no.such.article!"; ! timestamp(stdout, &now, NULL); /* start log line */ if (printf(" %s %c %s", sendersite(nullify(fap->h.h_path)), (proto == PROTO_IHAVE? 'i': 's'), fap->h.h_msgid) == EOF) fulldisk(fap, "stdout"); diff -r -c c.official/relay/procart.c cnews/relay/procart.c *** c.official/relay/procart.c Tue Apr 24 17:13:35 1990 --- cnews/relay/procart.c Wed Apr 25 10:06:09 1990 *************** *** 80,86 **** insart(artp); /* logs accepted art.s during transmission */ if (artp->a_status&ST_JUNKED) { /* yer welcome, henry */ artp->a_status &= ~ST_JUNKED; ! timestamp(stdout, (time_t *)NULL); (void) printf(" %s j %s junked due to groups `%s'\n", sendersite(nullify(artp->h.h_path)), artp->h.h_msgid, artp->h.h_ngs); --- 80,86 ---- insart(artp); /* logs accepted art.s during transmission */ if (artp->a_status&ST_JUNKED) { /* yer welcome, henry */ artp->a_status &= ~ST_JUNKED; ! timestamp(stdout, (time_t *)NULL, (char *)NULL); (void) printf(" %s j %s junked due to groups `%s'\n", sendersite(nullify(artp->h.h_path)), artp->h.h_msgid, artp->h.h_ngs); *************** *** 339,345 **** prefuse(art) register struct article *art; { ! timestamp(stdout, (time_t *)NULL); (void) printf(" %s - %s ", sendersite(nullify(art->h.h_path)), art->h.h_msgid); } --- 339,345 ---- prefuse(art) register struct article *art; { ! timestamp(stdout, (time_t *)NULL, (char *)NULL); (void) printf(" %s - %s ", sendersite(nullify(art->h.h_path)), art->h.h_msgid); } diff -r -c c.official/relay/relaynews.c cnews/relay/relaynews.c *** c.official/relay/relaynews.c Tue Apr 24 17:13:37 1990 --- cnews/relay/relaynews.c Tue Apr 24 15:00:23 1990 *************** *** 112,118 **** #ifdef MANYERRORS (void) putc('\n', stderr); /* leave a blank line */ /* prints "Jun 5 12:34:56" */ ! timestamp(stderr, (time_t *)NULL); (void) putc('\n', stderr); #endif } --- 112,118 ---- #ifdef MANYERRORS (void) putc('\n', stderr); /* leave a blank line */ /* prints "Jun 5 12:34:56" */ ! timestamp(stderr, (time_t *)NULL, (char *)NULL); (void) putc('\n', stderr); #endif } diff -r -c c.official/relay/regress/master/art1 cnews/relay/regress/master/art1 *** c.official/relay/regress/master/art1 Tue Apr 24 17:13:00 1990 --- cnews/relay/regress/master/art1 Tue Apr 24 15:35:36 1990 *************** *** 1,5 **** --- 1,6 ---- Path: host!user From: user@host + Date: 13 May 1989 Message-ID: <#1@host> Newsgroups: test.a diff -r -c c.official/relay/regress/master/art2 cnews/relay/regress/master/art2 *** c.official/relay/regress/master/art2 Tue Apr 24 17:13:01 1990 --- cnews/relay/regress/master/art2 Tue Apr 24 15:35:43 1990 *************** *** 1,5 **** --- 1,6 ---- Path: host!user From: user@host + Date: 14 May 1989 Message-ID: <#2@host> Newsgroups: test.b diff -r -c c.official/relay/regress/master/art3 cnews/relay/regress/master/art3 *** c.official/relay/regress/master/art3 Tue Apr 24 17:13:01 1990 --- cnews/relay/regress/master/art3 Tue Apr 24 15:35:51 1990 *************** *** 1,5 **** --- 1,6 ---- Path: host!user From: user@host + Date: 15 May 1989 Message-ID: <#3@host> Newsgroups: test.a,test.b diff -r -c c.official/relay/regress/master/art4 cnews/relay/regress/master/art4 *** c.official/relay/regress/master/art4 Tue Apr 24 17:13:01 1990 --- cnews/relay/regress/master/art4 Tue Apr 24 15:35:58 1990 *************** *** 1,5 **** --- 1,6 ---- Path: host!user From: user@host + Date: 16 May 1989 Message-ID: <#4@host> Newsgroups: test.c diff -r -c c.official/relay/regress/master/art5 cnews/relay/regress/master/art5 *** c.official/relay/regress/master/art5 Tue Apr 24 17:13:02 1990 --- cnews/relay/regress/master/art5 Tue Apr 24 15:36:07 1990 *************** *** 1,5 **** --- 1,6 ---- Path: host!user From: user@host + Date: 20 May 1989 Message-ID: <#5@host> Newsgroups: test.c Control: cancel <#4@host>