[comp.os.vms] Important TESTED patch for dxrn/mxrn

tp@mccall.com (Terry Poot) (05/24/91)

Sorry about the last one, this patch produces RFC822 compatible dates as 
best I can tell, and hopefully this will statisfy C news.

In case you don't know by now, a recent change to C news causes it to
discard all postings and followups from dxrn or mxrn if they are built
with GENERATE_EXTRA_FIELDS defined. The format of the Date: header is not
acceptable to the recent version of C news. This probably mostly affects
those ysing dxrn or mxrn to connect to an ANU News nntp server, as it
requires the message to contain Date: headers, whereas most unix based
nntp servers do not.

If you run dxrn or mxrn with GENERATE_EXTRA_FILEDS defined, I strongly
suggest you apply this pastch, as your articles are not being propagated
to the whole net, and will be dropped by even more sites as more of them
upgrade theif version of C news.

Please do not assume that you are unaffected if nobody has told you there
is a problem. The messages printed by C news when it encounters one of
these messages does not give enough information for the C news
administrator to contact you about the problem without doing a fair bit of
work to locate the offending article. Also, there is a great deal of
"somebody else probably told him by now" going on. C news does not attempt
to contact the offending site, but simply prints a message in a log file
and discards the article (meaning, of course, that many sites never receive
it at all, and thus can not warn you about it).

This patch is for dxrn/mxrn version 6.14-4, and assumes that you have
applied the "ANU-NEWS" patch included with that version, and which is 
needed to get the correct time in the first place, and has nothing
particularly to do with ANU News. Rick will be including it as a standard
part of the code in the future. That patch must be applied if your gmtime()
returns NULL, as it does with VAX C, and you define GENERATE_EXTRA_FIELDS.
You will also need to define TIMEZONE_ENV in config.h to be the name of
an environment variable (logical name or DCL symbol) that will contain a
valid timezone. As given, it sets it up properly for sites using DECUS
uucp.

If you have applied that patch (which applies correctly with an offset
(I think it was 38 lines) on 6.14-4), then apply this one to get the
Date: header formatted to C news' liking. If you have some other version
of dxrn/mxrn, and you build it with GENERATE_EXTRA_FIELDS defined, I'd
suggest you look at the patch and make similar changes. It shouldn't be
hard.

BTW, it has been suggested to me in email that it would be easier to fix
C news. The authors and proponents of C news don't consider this a problem,
they did it on purpose, and as far as I can tell, most of them really don't
care, since their articles aren't being dropped. The bottom line is that
they refuse to do anything about this, and since many sites run C news, 
the only practical option is to conform to their software. I would like to 
thank Kenneth Herron and Mark Davies specifically for calling this problem
to my attention (the only 2 that did, world wide, so like I said, don't
assume you don't have a problem just because nobody has told you you do).

I'll be submitting this patch to the vmsnet.sources moderator for posting
so that it will get into the archives and be available to anyone who might
later retrieve dxrn from those archives. I'll also send them to Rick Murphy
(the author) so that he can distribute them to any other places dxrn might
be made available, and include them in future releases. If you know someone
running dxrn that might not read any of these newsgroups, please forward
this to them. In fact, if you know someone not running C news, you might
let him know about the problem with it, so that he can try to find out if
his articles are being discarded. I highly doubt that dxrn/mxrn is the
only software generating things C news doesn't like.


*** compose.c_orig
--- compose.c
**************
*** 2407,2413
  
      return(genid);
  }
! #endif
  
  void
  followup()
--- 2407,2416 -----
  
      return(genid);
  }
! /*
!  *  generate a valid RFC822 date-time
!  */
! static char gendate[40];
  
  static char *gen_date()
  {
**************
*** 2409,2414
  }
  #endif
  
  void
  followup()
  {
--- 2412,2438 -----
   */
  static char gendate[40];
  
+ static char *gen_date()
+ {
+     time_t clockTime;
+     char *atime, *tz;
+     struct tm *cur_time;
+ 
+     (void) time(&clockTime);
+     cur_time = gmtime(&clockTime);
+     if(cur_time){
+         atime = asctime(cur_time);
+         tz = "GMT";
+     } else {
+         atime = asctime(localtime(&clockTime));
+         tz = getenv(TIMEZONE_ENV);
+     }
+     sprintf(gendate, "%3s, %2s %3s %2s %8s %s", atime, atime+8, atime+22, 
+         atime+11, tz);
+     return(gendate);
+ }
+ #endif
+ 
  void
  followup()
  {
**************
*** 2418,2429
      char *signature, *ptr;
      int OldPostingMode = PostingMode;
  
- #ifdef GENERATE_EXTRA_FIELDS
-     time_t clockTime;
-     char timeString[40];
-     struct tm *cur_time;
- #endif
- 
      if (ComposeActive) {
  	mesgPane(XRN_SERIOUS, "Only one composition pane at a time");
  	return;
--- 2442,2447 -----
      char *signature, *ptr;
      int OldPostingMode = PostingMode;
  
      if (ComposeActive) {
  	mesgPane(XRN_SERIOUS, "Only one composition pane at a time");
  	return;
**************
*** 2469,2490
  
  #ifdef GENERATE_EXTRA_FIELDS
      /* stuff to generate Message-ID and Date... */
!     (void) time(&clockTime);
!     cur_time = gmtime(&clockTime);
!     if(cur_time){
!         (void) strcpy(timeString, asctime(cur_time));
!         ptr = index(timeString, '\n');
!         *ptr = '\0';
!         (void) strcat(timeString, " GMT");
!     } else {
!         cur_time = localtime(&clockTime);
!         (void) strcpy(timeString, asctime(cur_time));
!         ptr = index(timeString, '\n');
!         *ptr = '\0';
!         (void) strcat(timeString, " ");
!         (void) strcat(timeString, getenv(TIMEZONE_ENV));
!     }
!     (void) sprintf(buffer, "Date: %s\n", timeString);
      (void) strcat(TempString, buffer);
      (void) sprintf(buffer, "Message-ID: %s\n", gen_id());
      (void) strcat(TempString, buffer);
--- 2487,2493 -----
  
  #ifdef GENERATE_EXTRA_FIELDS
      /* stuff to generate Message-ID and Date... */
!     (void) sprintf(buffer, "Date: %s\n", gen_date());
      (void) strcat(TempString, buffer);
      (void) sprintf(buffer, "Message-ID: %s\n", gen_id());
      (void) strcat(TempString, buffer);
**************
*** 2542,2553
      char *signature;
      int OldPostingMode = PostingMode;
  
- #ifdef GENERATE_EXTRA_FIELDS
-     time_t clockTime;
-     char *ptr, timeString[40];
-     struct tm *cur_time;
- #endif
- 
      if (ComposeActive) {
  	mesgPane(XRN_SERIOUS, "Only one composition pane at a time");
  	return;
--- 2545,2550 -----
      char *signature;
      int OldPostingMode = PostingMode;
  
      if (ComposeActive) {
  	mesgPane(XRN_SERIOUS, "Only one composition pane at a time");
  	return;
**************
*** 2589,2610
  
  #ifdef GENERATE_EXTRA_FIELDS
      /* stuff to generate Message-ID and Date... */
!     (void) time(&clockTime);
!     cur_time = gmtime(&clockTime);
!     if(cur_time){
!         (void) strcpy(timeString, asctime(cur_time));
!         ptr = index(timeString, '\n');
!         *ptr = '\0';
!         (void) strcat(timeString, " GMT");
!     } else {
!         cur_time = localtime(&clockTime);
!         (void) strcpy(timeString, asctime(cur_time));
!         ptr = index(timeString, '\n');
!         *ptr = '\0';
!         (void) strcat(timeString, " ");
!         (void) strcat(timeString, getenv(TIMEZONE_ENV));
!     }
!     (void) sprintf(buffer, "Date: %s\n", timeString);
      (void) strcat(TempString, buffer);
      (void) sprintf(buffer, "Message-ID: %s\n", gen_id());
      (void) strcat(TempString, buffer);
--- 2586,2592 -----
  
  #ifdef GENERATE_EXTRA_FIELDS
      /* stuff to generate Message-ID and Date... */
!     (void) sprintf(buffer, "Date: %s\n", gen_date());
      (void) strcat(TempString, buffer);
      (void) sprintf(buffer, "Message-ID: %s\n", gen_id());
      (void) strcat(TempString, buffer);
**************
*** 2657,2667
      art_num current = newsgroup->current;
      char buffer[10000];
      char *bufptr;
- #ifdef GENERATE_EXTRA_FIELDS
-     time_t clockTime;
-     char *ptr, timeString[40];
-     struct tm *cur_time;
- #endif
  
      if (ComposeActive) {
  	mesgPane(XRN_SERIOUS, "Only one composition pane at a time");
--- 2639,2644 -----
      art_num current = newsgroup->current;
      char buffer[10000];
      char *bufptr;
  
      if (ComposeActive) {
  	mesgPane(XRN_SERIOUS, "Only one composition pane at a time");
**************
*** 2722,2743
      (void) strcat(TempString, buffer);
  #ifdef GENERATE_EXTRA_FIELDS
      /* stuff to generate Message-ID and Date... */
!     (void) time(&clockTime);
!     cur_time = gmtime(&clockTime);
!     if(cur_time){
!         (void) strcpy(timeString, asctime(cur_time));
!         ptr = index(timeString, '\n');
!         *ptr = '\0';
!         (void) strcat(timeString, " GMT");
!     } else {
!         cur_time = localtime(&clockTime);
!         (void) strcpy(timeString, asctime(cur_time));
!         ptr = index(timeString, '\n');
!         *ptr = '\0';
!         (void) strcat(timeString, " ");
!         (void) strcat(timeString, getenv(TIMEZONE_ENV));
!     }
!     (void) sprintf(buffer, "Date: %s\n", timeString);
      (void) strcat(TempString, buffer);
      (void) sprintf(buffer, "Message-ID: %s\n", gen_id());
      (void) strcat(TempString, buffer);
--- 2699,2705 -----
      (void) strcat(TempString, buffer);
  #ifdef GENERATE_EXTRA_FIELDS
      /* stuff to generate Message-ID and Date... */
!     (void) sprintf(buffer, "Date: %s\n", gen_date());
      (void) strcat(TempString, buffer);
      (void) sprintf(buffer, "Message-ID: %s\n", gen_id());
      (void) strcat(TempString, buffer);



--
Terry Poot <tp@mccall.com>                   The McCall Pattern Company
(uucp: ...!rutgers!ksuvax1!deimos!mccall!tp) 615 McCall Road
(800)255-2762, in KS (913)776-4041           Manhattan, KS 66502, USA

stealth@engin.umich.edu (Mike Pelletier) (05/29/91)

In article <1991May24.082757@mccall.com> tp@mccall.com (Terry Poot) writes:
>Sorry about the last one, this patch produces RFC822 compatible dates as 
>best I can tell, and hopefully this will statisfy C news.
>
  [...]
>
>BTW, it has been suggested to me in email that it would be easier to fix
>C news.

Do you care to write software that will shuffle through all the possible
permutations of Date: lines and fix them up to something that might not even
be correct?  Why not just fix the source of the problem, which is your soft-
ware that is generating non-compliant Date: header lines.

> The authors and proponents of C news don't consider this a problem,
>they did it on purpose, and as far as I can tell, most of them really don't
>care, since their articles aren't being dropped. The bottom line is that
>they refuse to do anything about this, and since many sites run C news, 
>the only practical option is to conform to their software. I would like to 

Get it straight -- you're not conforming to their software, you're conforming
to internationally recognized standards for Date: line format.  Your software
was bad all along, and C-news has finally started enforcing the standard.
That's all there is to it.

-- 
Mike Pelletier             | "Wind & waves are breakdowns in the commitment of
The University of Michigan |  getting from here to there, but they are the con-
  College of Engineering   |  ditions for sailing.  Not something to eliminate,
Student/Systems Admin      |  but something to dance with."

tp@mccall.com (05/31/91)

>In article <1991May24.082757@mccall.com>, tp@mccall.com (Terry Poot) writes:
>> Sorry about the last one, this patch produces RFC822 compatible dates as 
>> best I can tell, and hopefully this will statisfy C news.

*Sigh*. I'm sorry, but I did it again. I just haven't had the time to put
into this to be careful about it. Anyway, my fix does work, but the patch I
posted was the version before the correct version. It won't work at all.
(Obviously, not too many people have applied the patch yet, because the
person that called my attention to it eyeballed it, and doesn't run
dxrn/mxrn himself.)

Anyway, here is a very short patch to fix dxrn/mxrn once and for all. Apply
this one AFTER my previous patch. I'm not going to post the whole big mess
to 4 newsgroups again. The first patch is useless without this one, apply
both in sequence to get a working version of dxrn/mxrn that will
interoperate with C news.


*** LSRC:[DXRN]COMPOSE.C;4
--- compose.c
**************
*** 2427,2434
          atime = asctime(localtime(&clockTime));
          tz = getenv(TIMEZONE_ENV);
      }
!     sprintf(gendate, "%3s, %2s %3s %2s %8s %s", atime, atime+8, atime+22, 
!         atime+11, tz);
      return(gendate);
  }
  #endif
--- 2427,2434 -----
          atime = asctime(localtime(&clockTime));
          tz = getenv(TIMEZONE_ENV);
      }
!     sprintf(gendate, "%.3s, %.2s %.3s %.2s %.8s %s", atime, atime+8, atime+4, 
!         atime+22, atime+11, tz);
      return(gendate);
  }
  #endif


-- 
Terry Poot <tp@mccall.com>                   The McCall Pattern Company
(uucp: ...!rutgers!ksuvax1!deimos!mccall!tp) 615 McCall Road
(800)255-2762, in KS (913)776-4041           Manhattan, KS 66502, USA