[news.software.nntp] Patches to make 'rrn' check for new news.

ljz@fxgrp.UUCP (Lloyd Zusman) (05/18/88)

A few days ago I submitted a set of patches to 'rrn' that, when
applied, would enable the program to check for newly arrived news
without it having to be exited and restarted.  About 5 minutes later,
I sent out a frantic message warning you all not to use the patched
software, as it would trash your .newsrc file under certain
conditions.

Well, I have fixed the problem and am resubmitting new patches.  We
have used the new version here at my site for several days under
heavy and varied usage, and no one's .newsrc file is the worst for
it.

The way this works is as follows:

There is now a new command-line option to 'rrn': "-A" (which means
"check *A*gain for news").  Without this option, 'rrn' behaves as
it did before.  With this option set, the program will check with
the nntp server for newly arrived news when the user types 'n' at
the "Quit reading news? " prompt.  To be more precise, this check
is performed at the end of the main processing loop whenever the
'retry' variable is set to TRUE in the main() routine in 'rn.c'.

In order to make this more useful, the default reply to the
"Quit reading news? " prompt is always 'n' as long as -A is in
effect.  This allows you to just repeatedly hit <CR> or space at
this prompt to keep checking for new news.

I have bracketed all changes in the source code with

    #ifdef CHECKAGAIN

    #endif /* CHECKAGAIN */

(except in 'Configure' and 'config.h', where it is defined).

It goes without saying that you should be careful with this new version
until you are sure it works for you.

Good luck, and please let me know of any problems you might encounter.

    Lloyd Zusman
    Master Byte Software
    Los Gatos, California		Internet: ljz%fx.com@ames.arc.nasa.gov
    "We take things well in hand."	UUCP:     ...!ames!fxgrp!ljz

------------------------------- patches follow -------------------------------

*** Configure.orig	Sun May 15 17:23:27 1988
--- Configure	Sun May 15 21:42:06 1988
***************
*** 2074,2079 ****
--- 2074,2080 ----
  #$isrrn         SERVER          /* rrn server code */
  #$isrrn SERVER_HOST     "$rrnserver"
  #$isrrn SERVER_FILE	"$serverfile"
+ #define CHECKAGAIN	/* enables -A option: check again for new news */
  EOT
  
  CONFIG=true
*** common.h.orig	Sun May 15 17:00:33 1988
--- common.h	Mon May 16 11:41:54 1988
***************
*** 726,736 ****
--- 726,744 ----
      EXT int scanon INIT(0);				/* -S */
  #endif
  
+ #ifdef CHECKAGAIN
+     EXT bool check_again INIT(FALSE);	/* -A */
+ #endif /* CHECKAGAIN */
+ 
  EXT bool mbox_always INIT(FALSE);			/* -M */
  EXT bool norm_always INIT(FALSE);			/* -N */
  EXT bool checkflag INIT(FALSE);			/* -c */
  EXT bool suppress_cn INIT(FALSE);			/* -s */
  EXT int countdown INIT(5);	/* how many lines to list before invoking -s */
+ #ifdef CHECKAGAIN
+ EXT bool init_suppress_cn INIT(FALSE);			/* -s */
+ EXT int init_countdown INIT(5);
+ #endif /* CHECKAGAIN */
  EXT bool muck_up_clear INIT(FALSE);			/* -loco */
  EXT bool erase_screen INIT(FALSE);			/* -e */
  #ifdef CLEAREOL
*** config.h.orig	Sun May 15 17:32:53 1988
--- config.h	Sun May 15 21:42:20 1988
***************
*** 81,83 ****
--- 81,85 ----
  #define         SERVER          /* rrn server code */
  #define SERVER_HOST     ""
  #define SERVER_FILE	"/usr/new/lib/rn/nntp_server"
+ #define CHECKAGAIN	/* enables -A option: check again for new news */
+ 
*** rn.c.orig	Sun May 15 16:39:40 1988
--- rn.c	Mon May 16 11:42:07 1988
***************
*** 139,144 ****
--- 139,152 ----
  			}
  		    }
  #endif
+ #ifdef CHECKAGAIN
+ 		    /*
+ 		     * Never default to 'q' when -A is selected.
+ 		     */
+ 		    if (check_again)
+ 			dfltcmd = "npq";
+ 		    else
+ #endif /* CHECKAGAIN */
  		    dfltcmd = (retry ? "npq" : "qnp");
  #ifdef VERBOSE
  		    IF(verbose)
***************
*** 498,503 ****
--- 506,532 ----
  		    goto reask_newsgroup;
  		}
  	    }
+ #ifdef CHECKAGAIN
+ 	    if (retry && check_again) {
+ 		/*
+ 		 * If we're able to retry and -A is set, save the .newsrc
+ 		 * and get a new active file.  This has the effect of
+ 		 * detecting any new news that may have arrived.
+ 		 */
+ 		countdown = init_countdown;	/* make sure this looks like */
+ 		suppress_cn = init_suppress_cn;	/*  the first time through   */
+ 
+ 		if (actfp != Nullfp) {		/* get rid of old */
+ 		    fclose(actfp);		/*  active file   */
+ 		    actfp = Nullfp;
+ 		    UNLINK(active_name);
+ 	        }
+ 
+ 		write_rc();			/* write .newsrc back out */
+ 		ngdata_init();			/* get new active file */
+ 		rcstuff_init();			/* check for new news */
+ 	    }
+ #endif /* CHECKAGAIN */
  	} while (retry);
      }
  
*** sw.c.orig	Sun May 15 21:39:49 1988
--- sw.c	Mon May 16 14:24:37 1988
***************
*** 178,183 ****
--- 178,188 ----
  	    notincl("-/");
  #endif
  	    break;
+ #ifdef CHECKAGAIN
+ 	case 'A':
+ 	    check_again = upordown;
+ 	    break;
+ #endif /* CHECKAGAIN */
  	case 'c':
  	    checkflag = upordown;
  	    break;
***************
*** 316,321 ****
--- 321,335 ----
  		    countdown = 5;
  		suppress_cn = upordown;
  	    }
+ #ifdef CHECKAGAIN
+ 	    /*
+ 	     * Save these for future reference, since the originals
+ 	     * get altered.
+ 	     */
+ 	    init_countdown = countdown;
+ 	    init_suppress_cn = suppress_cn;
+ #endif /* CHECKAGAIN */
+ 
  	    break;
  	case 'S':
  #ifdef ARTSEARCH
***************
*** 374,379 ****
--- 388,396 ----
      
      fputs("\nCurrent switch settings:\n",stdout);
      printf("%c/ ", mp[strEQ(getval("SAVEDIR",SAVEDIR),"%p/%c")]);
+ #ifdef CHECKAGAIN
+     printf("%cA ", mp[check_again]);
+ #endif /* CHECKAGAIN */
      printf("%cc ", mp[checkflag]);
      printf("-C%d ", docheckwhen);
      printf("-d%s ", cwd);

ljz@fxgrp.UUCP (Lloyd Zusman) (05/18/88)

In the description of the 'rrn' patch I just sent out, I made a slight
error describing the new behavior.  In the text of my message, replace
the phrase "Quit reading news? " with "End of newsgroups--what next? "

This is only a change in my description of the patches, not in the
patches themselves.

--
    Lloyd Zusman
    Master Byte Software
    Los Gatos, California		Internet: ljz%fx.com@ames.arc.nasa.gov
    "We take things well in hand."	UUCP:     ...!ames!fxgrp!ljz