mrapple@quack.sac.ca.us (Nick Sayer) (09/10/90)
I'm sure this has been done, but just for anyone out there who wants it, here it is. The grabheaders.c file I found in ~/news/misc wasn't up to date with the changes made to the history file, and had a bug anyway (BTW: article.c is also not up to date). The bug is in the processing of the From: line. If a news article doesn't have a "@" in it, grabheader dumps core. This is because the "if (cp)" has two statements after it, but no braces. The fix is to encompas the indented part after the if in braces. The incompatability problem is that the history file now stores the "ctime" (seconds since epoch) instead of mm/dd/yy hh:mm:ss. This patch outputs the "Received-date:" field in the old history format. It probably OUGHT to output ctime() format, but this would mess up the "delay" script which makes use of grabheaders. *** grabheaders.c.OLD Sun Sep 9 18:29:27 1990 --- grabheaders.c Sun Sep 9 19:54:04 1990 *************** *** 10,16 **** #include <ctype.h> #include <sys/time.h> ! #define NULL 0 #define daysec (24L*60L*60L) main() --- 10,16 ---- #include <ctype.h> #include <sys/time.h> ! /* #define NULL 0 - This should be in stdio.h */ #define daysec (24L*60L*60L) main() *************** *** 37,54 **** while (fgets(buffer, BUFSIZ, Hfile) != NULL) { register char *p, *file; p = index(buffer, '\t'); if (p == NULL) continue; file = index(p+1, '\t'); if (file == NULL || file[1] == '\n') continue; *file = '\0'; - t = getdate(p, &now); if ( (t+daysec*14L) < now.time) continue; - strcpy(datestr, p); p = file; while (*++p != ' ' && *p != '\n') if (*p == '.') --- 37,58 ---- while (fgets(buffer, BUFSIZ, Hfile) != NULL) { register char *p, *file; + struct tm *tmd; p = index(buffer, '\t'); if (p == NULL) continue; + t = atol(p); + tmd=gmtime(&t); + sprintf(datestr,"%.2d/%.2d/%.2d %.2d:%.2d:%.2d GMT", + tmd->tm_mon+1,tmd->tm_mday,tmd->tm_year, + tmd->tm_hour,tmd->tm_min,tmd->tm_sec); file = index(p+1, '\t'); if (file == NULL || file[1] == '\n') continue; *file = '\0'; if ( (t+daysec*14L) < now.time) continue; p = file; while (*++p != ' ' && *p != '\n') if (*p == '.') *************** *** 69,75 **** buffer[0] != '\n') { if (strncmp(buffer, "From: ", 5) == 0) { register char *cp = index(buffer, '@'); ! if (cp) while (*++cp && *cp != '.' && *cp != ' ') if (isupper(*cp)) *cp = tolower(*cp); --- 73,79 ---- buffer[0] != '\n') { if (strncmp(buffer, "From: ", 5) == 0) { register char *cp = index(buffer, '@'); ! if (cp!=NULL) { while (*++cp && *cp != '.' && *cp != ' ') if (isupper(*cp)) *cp = tolower(*cp); *************** *** 77,82 **** --- 81,87 ---- while (*++cp && *cp != ' ') if (islower(*cp)) *cp = toupper(*cp); + } } fputs(buffer, stdout); } -- Nick Sayer | Disclaimer: N6QQQ [44.2.1.17 soon] | "Just because you're reading my post doesn't mrapple@quack.sac.ca.us | mean we're gonna take long showers together." 209-952-5347 (Telebit) | -- Gunnery Sgt. Thomas Highway