Changes file for VNEWS.

July,  1991 [Version 1.40 release]

The following list is just things which have changed between the
beta and the current version.

VNEWS.CLD - remove (list) from MARK qualifier.
CMD.FOR - don't delete message if user fooled with headers.  Tell user
	  where he can get his message.
NNTP.FOR - fix bugs in subscribing code.
NEWS.FOR - reinstate NEWGROUPS command.  Fix newgroups handling to be 
	   more sublime.
CMD.FOR - fix bug in From vs. OldFrom handling.
STR_STRIP_RE.FOR - don't know why this ever worked. rewrote. 
NEWS.FOR - make more polite and informative. 
CMD.FOR - major massive performance fix to make vnews as fast as it was
          before

March, 1991 [Version 1.4 beta 1]

	note: major contributors to this version: jms (Joel Snyder,
	jms@arizona.edu), pr (Pat Rankin, rankin@eql.caltech.edu),
	jfem (John 'Fast-Eddie' McMahon, mcmahon@tgv.com),
	jg (Jim Gerland, gerland@ubvm), paf (Peter A Fox,
	fox@solar.astro.yale.edu), eg (Ehud Gavron,
	gavron@vesta.sunquest.com)

  Module SRV.FOR - In Srv_Recv, there was an error checking return
	status, and in returning if there was an error.
	Fixed. jms/910320
	(also pointed out by pwf@vx.acs.umn.edu, Paul Falker)
	In Cmd, if the command is 'QUIT,' then instead of waiting
	for a response, simply close the connection. jms,others/910325
	Added support for AUTHINFO commands. jms,jg/910414
	Simplify new code. pr/910416
	Added code to call socket_perror to enhance debugging. jfem/910430
	Bugfix in authinfo commands to help with FORTRAN failure to
	support recursion, etc. pr,jms/910620

  Modules READ_NEWS, NEWS, NEWS.DEF, and CMD - If the server doesn't
	allow posting, then remember this (new common
	block variable "posting_allowed") and modify all
	future menus and help printouts. jms/910320
	Add Group_Header subroutine. pr,jg/910325
	Add Z command. pr/910325
	Add Y,N commands. jms/910330
	Add Cancel command. jms/910331
	Cosmetic fixes. pr/910414
	Changed %T to %D in F$FAO. jfem/910414
	Fixed m/g command. pr/910619
	Added F, S commands.  Added /c switch. jms/910705

   Module CMD.FOR - Create a unique Message_ID: for each message when
	sending to the server. jms/910320
	Make detection of "Re:" in subject lines less sensitive
	to case and character. pr/910325  
	Make subjects of '500' more robust. pr/910325
	Bugfix in filenames. pr/910325
	Bugfix and enhancements in moving groups. pr/910325
	Check to see if files exist before deleting them.  Delete
	all versions of output file.  Jim Rapp/910326
	Modify Fld to be NwsGrpSz. jg/910326
	Trim trailing blanks from some fields. jg/910326
	Add the Y and N commands, which turn off confirmation
	of the C command. jms,paf/910327.  Also, changes in
	NEWS.DEF (add NOASK logical) and in READ_NEWS.
	Fix problem with some buggy server returnning wrong status
	code. jms/910327.
	Added Cancel command (C). jms,LHWong/910331. (cancel code
	from Lam Wong, LHWong@csa2.lbl.gov)
	Fixed 'post' with distribution error so you don't have to start
	over. jms/910331
	Try 500 fix again. I'm not a happy camper. jms/910416
	Adjust column layout for d/g command. pr/910416
	Add more informative messages. jfem/910430
	Don't erase st% status message. jfem/910430
	Make CMD_SPAWN smarter to try and reuse subprocesses. pr/910619
	Fix Cmd_Article_Restore. pr/910619
	Add in logic to deal with validate_headers.  Remove much header
	writing, in favor of putting it in later. jms/910704
	Add F, R/c and F/c commands. jms/910705
	Properly deal with followup-Tos directed to poster. jms/910705
	Add S command (cmd_articlesend). jms/910705 

  New Module Validate_Headers - validates and updates headers in
	articles before posting.  This is based on Gavron's "Fascist"
	mode, where the user isn't allowed to screw with things that
	the Fascist news software things he shouldn't.  In particular,
	users aren't given the chance to play with Message-ID,
	Date, References, Path, Organization, and News-Software.  We
	do some nice stuff---if the user changes From, then we
	automatically include a Sender (RFC1036). jms/910704

  NEW Module RFC_Date (and changes to CMD.FOR) - Change to use dates
	compliant with RFCs 822, 1036, and 1123. jms/910620  

  NEW Module Edit_File (and changes to CMD.FOR) - Change to use Edit_File
	subroutine for more powerful editing. pr/910325.

  New Module SITE_SPECIFIC.DEF - moved all site specific stuff to
	this single include file, with much stronger documentation
	for lazy installers (like me!).  Also, moved ALL logical
	name translations for external parameters into this
	module.  Implies changes in GET_INIT, NEWS, EDIT_FILE,
	and DECNETLIB.  jms/910329
	Added NNTP_TIMEZONE variable/logical name. jms/910624
	Added NewsRC_Loc variable. jms/910624\
	Added NNTP_REPLY logical name for Reply-to: headers. jms/910705

   Module NEWS - A call to SYS$FAO was incorrectly coded.  Fix to include
	the output argument.  jms/910320
	Add a call to SMG_final to clean up at end. paf/910326.
	Add calls to establish exit handlers. paf/910326.
	Update error messages to be a little more helpful. jfem/910430
	Keep some basic stats about usags. Includes changes to CMD.FOR and
	READ_NEWS.FOR, as well as new common blocks in NEWS.DEF. jms/910430
	Update to work with kept subprocesses (pr,jms/910619)
	Add new switch /AUTOCATCHUP. jms/910620

  NEW Module CMULIB - emulation library for CMU TEK TCP/IP.  
	Files CMULIB.FOR and CMULIB.DEF were added to the kit at the 
	suggestion of David Paschall-Zimbel.  These subroutines provide 
	a "look-alike" socket library for CMU TCP/IP and were written 
	by Mike Iglesias at U California Irvine.  
	Added shutdown() subroutine. jms/910328
	Added inet_addr() subroutine. jms/910330

  New Module GETHOSTBYNAME.C - GetHostByName needed, and CMU TEK TCP/IP
	doesn't have it.  However, Bruce Miller happened to be vagranting
	nearby, so he wrote it.  bm17+/910500

  New Module HtoNs - Host to Network (short) conversion routine.
	Needed by CMU and DECnet (even though it never gets called).

  New Module DECNETLIB - emulation library for DECNET.  Written by
	Peter Fox.  Also, substantial changes in GET_INIT.FOR
	to accomodate DECnet.
	Added shutdown() subroutine. jms/910328
	Lots of little bugs in DECNETLIB fixed. jms/910501

  New Module PSCLIB - emulation library for Process Software Corp's
	TCPWARE.  Many thanks to Martin Egger (egger@id.unibe.ch) for
	the updates to this and makefile. to make it all work. jms/910619

  Module NEW_VERSION - now called VERSION.COM, this generates VERSION.FOR
	given an argument which is the version number for VNEWS.
	The version number comes from the first line of the
	MAKEFILE.  Several minor bugfixes in VERSION.COM.
	jms,pr/910320,910327

   Makefile - completely new.  Credit to jg,jms/910324.
	Add support for UCX. jms/910326 (untested!)
	Other changes to clean up. pr/910327.
	Add support for TCPware. jms/910619

   Module NEWS.DEF - added constants for maximum group size, and upped 
	hardcoded values for maximum number of groups and size
	of range.  Included comments to discuss how to up these
	in the future.  jms,pr,jg/910324
	Changed sizes of some constants and variable sizes so
	that VNEWS would compile under FORTRAN-HPO.  Thanks to
	mcnair@utkvx.utk.edu & others. jms/910619

   Module USER_OPEN.DEF - moved things around to support FOrtran-HPO.
	Thanks to mcnair@utkvx.utk.edu & others. jms/910619

   New Modules DEBUG.DEF, NETWORK.DEF - moved some constants and data
	structures out to their own .DEF files to reduce collisions
	in some modules. jms/910328
	Added concept of NNTP_Transport global in network.def so that
	network code can be smarter about itself. Only used right now
	for DECnet. jms/910501

   Module GROUP_FIND.FOR - optimize call to TrimLg out of tight loop.
	pr/910325
	Further optimize to not do a MATCH_WILD if no wildcard
	charcters present. pr/910327

   Module SMG.FOR (and associated changes in CMD.FOR and other places)
	Change handling of broadcast trapping. pr/910325
	Add new SMG_Final subroutine. paf/910326.
	Bugfix - don't print blank broadcasts. paf/910326.
	Re-write broadcast trapping code to use queue. Messages are
	delayed a little longer, but they now come out in a nicer
	manner.  jms/910620

   Module SMG.FOR, NEWS.FOR, NEW VNEWS_CLD.CLD  - add a better DCL interface 
	to VNEWS. pr/910325
	Add /AUTOCATCHUP switch to VNEWS. jms/910620

   Module CLOSE_NEWSRC.FOR - optimize to not include messages which aren't
	on the server. pr/910325
	Make sure we close the file. jms/910327
	Support for NewsRC_Loc logical name. jms/910624

   Module OPEN_NEWSRC.FOR - Better handle errors in .newsrc file. pr/910325
	Make sure we don't have more than MX_Group groups. jfem/910430
	Support for NewsRC_Loc logical name. jms/910624

   NEW Module GETPERSONALNAME.FOR - Gets personal name, first from a
	logical name (NNTP_NAME), then from the MAILUAF, and
	then from the SYSUAF.
	Trim trailing nulls. jms/910327

   Module GETUSERDIRECTORY.FOR - remove code which gets personal name,
	and created new GETPERSONALNAME. jms/910325
	Bugfix to put in proper size for UAI$_DEFDEV (from 
	$GETUAI in SYS-317. jms,jg/910326.

   Module GETUSERNAME.FOR - massive bugs. rewritten from scratch. Include
	new ITEMLIST.DEF. jms/910326

   Module TRANSLOG.FOR (and all subroutines that call it) - Simplified 
	all code in VNEWS which does logical name translations:
	now, all translations are done process/job/group/system
	in that order, in all access modes.

   Module GET_INIT.FOR - Move all site specific things to a new
	include file, site_specific.def. jms/910325
	Change to use gethostbyname() instead of ugly numeric
	IP address. pr/910325

   Module SEND_MAIL.FOR, NEWS.FOR - disable installed privileges; re-enable
	them only while sending mail; necessary to securely install 
	VNEWS with SYSPRV in order to work-around a PMDF problem.
	Pat Rankin (rankin@eql.caltech.edu) pr/910325
	Make the mail sending process more robust. jms/910325
	Make mail believe in your COPY_SELF flags (either Reply or 
	Send, since it's not clear what these are...) jms/910705

   Module NNTP.FOR - variety of bug fixes. pr/910325.
	Change to move query_groups to a separate subroutine. pr/910325
	Bugfix to prior bugfix. pr/910416
	Removed 'newgroups' command, claimed to be obsolete. jms/910430
	(actually a change to news.for to not call this routine)

   Module Mark_XREF_AS_READ.FOR - bugfix to correct group size. jg/910326
	Additional bugfix on sizes. pr/910414 (a3)

   New Module DELETE_FILE.FOR - deletes a file.  Replaces calls several
	places in VNEWS code to LIB$DELETE_FILE.  This checks to
	see if the file already exists, and writes out an error
	message if it cannot be deleted. jms/910326
	Update per suggestion pr to delete all versions. jms/910414

   New Module HANDLER.FOR - adds a ^Y handler for VNEWS.  This implies
	an entry point for exit code, so we changed NEWS.FOR to
	call quit_news() when it's all done. paf/910327
	This could use a lot of careful work.
	Fix bugs in SMG_FINAL (thanks to pr); create global state variables
	so we know what kind of exiting we have to do; also implied several
	updates to QUIT_NEWS() and the creation of a new HANDLER.DEF.

   New Module AUTH.FOR - add support for AUTHINFO commands. Includes changes
	to NEWS.DEF, SITE_SPECIFIC.DEF.  Also, stuck NNTP.H at the end
	for future reference. Thanks to Jim Gerland for pointing the
	way on this. jms/910331,910410. (a3)

   Module GETINTEGER.FOR - Alain Cedelle (cedelle@yin.irisa.fr) provided
	a new GET_INTEGER which tends not to overflow integer values.
	This required changes in CMD.FOR and NNTP.FOR. 910416

   NEW module 47compat.for - Warren Massey (massey@travis.llnl.gov) wanted
	a VMS 4.7 compatibility mode, so I kludged up a quick one.

--------------------------------------------------------------------------

C 19-APR-1990 [Version 1.3-4]
C
C	Module CLOSE_NEWSRC.FOR - Modified to write only active entries
C				  out to the new XX.NEWSRC, user is informed
C                                 about dead groups.
C                                 * Kevin Oberman (oberman@icdc.llnl.gov)
C
C				- Do not write ranges for unsubscribed
C				  newsgroups, or ranges which exceed current
C				  active articles.
C				  * John McMahon (fasteddy@dftnic.gsfc.nasa.gov)
C
C	Module CMD.FOR - Header line added to posts and followups which contain
C                        the software version and name.	
C			 * John McMahon (fasteddy@dftnic.gsfc.nasa.gov)
C
C                      - Save filenames will have illegal characters filtered
C			 out.  (C++ becomes C__)
C                        * Kevin Oberman (oberman@icdc.llnl.gov)
C
C		       - d/g command contains letters to indicate active,
C			 subscribed and postable flags instead of 'y' and 'n'.
C                        Group number added to d/g command.
C                        * Kevin Oberman (oberman@icdc.llnl.gov)
C
C		       - Capital M command added to allow user to sort XX.NEWSRC
C	                 file.
C                        * Kevin Oberman (oberman@icdc.llnl.gov)
C
C	Module GROUP_FIND - Will match groups using wildcard patterns.
C			    Allows use of '*' and '%' in the go command.
C			    * John McMahon (fasteddy@dftnic.gsfc.nasa.gov)
C
C	Module NEWS - Two versions of XX.NEWSRC are now kept.  The version
C		      prior to the session (XX.OLDNEWSRC) and the one written
C		      out at the end (XX.NEWSRC).
C		      * John McMahon (fasteddy@dftnic.gsfc.nasa.gov)
C
C	Module NNTP - Active flag setting logic cleaned up.
C                     * Kevin Oberman (oberman@icdc.llnl.gov)
C
C	Module READ_NEWS - backup command fixed to prevent user from backing up
C			   to a nonexistant group (g=0).  Move command added.
C                          * Kevin Oberman (oberman@icdc.llnl.gov)
C
C	Module SMG - Added Catchup, Yes and 1st article keys.
C                    * Kavan Ratnatunga (kavan@amarna.gsfc.nasa.gov)
C
C	Module VERSION - Added quick and dirty subroutine to return the
C                        current version.  This module is still created
C                        by the NEW_VERSION.COM program.
C		         * John McMahon (fasteddy@dftnic.gsfc.nasa.gov)
C
C 16-Apr-1990 - John 'Fast-Eddie' McMahon (fasteddy@dftnic.gsfc.nasa.gov)
C
C				[Version 1.3-3]
C
C	Module CLOSE_NEWSRC.FOR - Added error branch for NEWSRC write command.
C				  Errors could cause user to end up with a 
C				  blank XX.NEWSRC file.  The error branch
C				  deletes the bogus file and informs the
C				  user that changes have been lost.
C
C	Module CMD.FOR - Path was modified (again) to consist of nodename!user
C			 at suggestion of Jim Gerland.  Some routines moved
C			 around to get path to appear at the top of posts and
C			 followups.
C
C                      - Null lines in .SIGNATURE files would cause a out
C                        of bounds error while reading the file in.
C
C                      - Null lines in MAIL$OUT files would cause a out
C                        of bounds error while reading the file in.
C
C	Module NNTP.FOR - A 'q' command during newgroup processing now tells
C			  the user to include a switch for sub, or unsub.
C
C			  Changed the error handler in NNTP_GET_NEW_GROUPS
C			  so the user gets a slightly friendlier message
C			  on a 503 (NEWGROUPS failure).
C
C	Module GETUSERDIRECTORY.FOR - The itmlist array referenced 5 array
C                                      elements when only four were defined.
C
C 12-MAR-1990 - John 'Fast-Eddie' McMahon (fasteddy@dftnic.gsfc.nasa.gov)
C
C                               [Version: 1.3-2]
C
C		NNTP_GET_Active_File was modified to add new commands to the
C		subscription handling routine.  The commands added were:
C			<cr> = do not subscribe
C			h or ? = help
C			q/s = quit, subscribe to remaining groups
C			q/u = quit, do not subscribe to remaining groups
C
C		Buf in NNTP_Get_Active_File was getting corrupted by the 
C		subscription routine, so a spare was added.  Some other minor 
C		logic fixes were made to complete the routine I installed in 
C		1.3-1.
C
C		CMD_Articlefollowup was modified to generate the References:
C		header during followup.  The previous header (if exists) is
C		copied and the current MessageID: is tacked on the end.
C
C		Copying the Path: header during followups was removed in
C		CMD_Articlefollowup.
C
C		The boolean flags in CMD_ARTICLEFOLLOWUP are initialized
C		properly with every call now.  It was possible to get stuck
C		in mail reply mode if you did that first, then tried a 
C		followup to the article.
C
C		In READ_NEWS, the 'g' command will warn you when your are
C		being subscribed to a group.  Also, a bug that caused you to
C		subscribe to the group you were leaving (instead of entering)
C		was removed.
C
C 27-FEB-1990 - John 'Fast-Eddie' McMahon (fasteddy@dftnic.gsfc.nasa.gov)
C
C                               [Version: 1.3-1]
C
C		NNTP_Get_Active_File was modified to check the Active newsgroups
C		versus what is stored in XX.NEWSRC.  A group in the Active list
C		and not in XX.NEWSRC is defined as a new group, and the user is
C		prompted about subscribing.  This fixes the problem of a user
C		never being notified about new newsgroups because their server
C		doesn't support the NNTP NEWGROUPS command.  Side-effect:  
C		XX.NEWSRC will now contain every newsgroup ever seen by VNEWS
C		regardless of the user subscribing or not.  This does not
C		increase the size of XX.NEWSRC by much.
C
C		Mark_Xref_As_Read was modified not to crash with a Fortran
C		conversion error when the article contained no headers.  The
C		NNTP XHDR command does not return '(None)' when there are no
C		headers at all.  The routine attempted to process a line
C		containing a '.' and garbage as a Xref: line.  The routine now
C		checks for a '.' first, and returns immediately if that
C		condition occurs.
C
C 12/22/1989 - Changed the CMD_ARTICLEFOLLOWUP routine to correctly deal
C	      with Followup-To field. Before, the followup line had been
C	      ignored when posting a followup article. - JMH
C
C 9/11/1989 - Version for MULTINET created. Code is essentially identical
C	      to the WINS version except that the netclose() call had to
C	      be elimiated. Logical names have been changed around so that
C	      they all begin with NNTP_. - JMH
C
C  8/6/1989 - Changed the post/followup routine to allow for aborting,
C	      listing, and editing before sending to server. - JMH
C
C  8/3/1989 - Made a number of changes. Removed the up_dn_priv and
C             get_mail_control routines because they are not needed.
C             Instead, I've made the UserPersonalName to be the OWNER
C             field in the sysuaf (no privileges are needed to get this
C             info). The UserMailDirectory is not needed anymore - instead,
C             I've made the signature file exist by default in SYS$LOGIN
C             and renamed the specification from SIGNATURE.MAI to .SIGNATURE
C             to keep more in line with rn.
C
C             The file CONFIG.DAT is no longer needed. The definitions in
C             that file are now "hard coded" into the program and can be
C             overridden with various logical names. When compiling for
C             the first time it is necessary to specify information in the
C             file GET_INIT.FOR. New logical names ORGANIZATION, and 
C             ARPANET_HOST_NAME (which is usually predefined anyway) can
C             be used to dynamically change the settings.
C
C             The system-wide logical name NEWSDIR is no longer necessary
C             and the CLD file has been modified to reflect this. The
C             default location for the image is now SYS$SYSTEM.
C
C             The PRINT_NEWS.COM file is no longer needed because the
C             code has been incorporated into the main program. - JMH
C
C 5/19/1989 - Mail reply now works with callable mail interface (5.x only).
C             The V4.x version of CMD_ARTICLEPOST.FOR has been renamed
C             CMD_ARTICLEPOST_V4.FOR. The makefile has been written so that 
C             the correct module will compile depending on which version of 
C             VMS you are running. - JMH
C
C 5/18/1989 - Changed GET_MAIL_CONTROL to work for version 5.x. 
C             The V4.x version has been renamed GET_MAIL_CONTROL_V4.FOR. 
C             Use that file for compiling under 4.x. The makefile has 
C             been written so that the correct module will compile
C             depending on which version of VMS you are running. - JMH
C
C 5/12/1989 - Added 'killfile' capability (command 'K'). - JMH
C
C 5/11/1989 - Changed 'kill' function so that it will kill articles (with
C             (/pattern option) even when no articles have been selected.
C             Also updated the help display to show this and the fact that
C             'directory' command will take an optional parameter. - JMH
C
C 5/10/1989 - NEWS will now take a parameter on the command line. This
C             allows you to select a newsgroup to start with. - JMH
C 
C 5/9/1989  - Added test for logical name NNTP_SERVER so that the user can
C             define an alternate nntp server. Logical name must be in the
C             format of the Internet number rather than hostname.
C             Example: 128.102.29.20  - JMH
C
C 4/20/1989 - Added test for logical name NAME so that the user can define
C             a different personal name than the mail personal name. If the
C             logical name does not exist, the mail personal name will be
C             used.  - JMH
C
C 06-Feb-1988   M. Warner Losh
C               - Fixed the mail command so that it now works as expected.
C               - Fixed problem with very large numbers nuking the program.
C
C 12-Oct-1988   M. Warner Losh
C               - Changed the "Hit return for MORE" stuff to take up just
C                 one line.  More articles fit on one screen now.
C
C 29-Sep-1988   M. Warner Losh
C               - Added the print command.  This command will execute the
C                 symbol "NEWS_PRINT", if it exists, otherwise it will
C                 use "PRINT".  This is spawned, once the program exits,
C                 similar to the way that MAIL does things.
C
C 27-Sep-1988   M. Warner Losh
C               - Removed the stop after the bad status returned from
C                 the newgroups command.  Our local NNTP deamon doesn't
C                 gronk this well.
C               - Fixed the line eater problem.  Our NNTP server seems to
C                 munch the first line that it doesn't recognize as a header.
C
C 9/9/88  - Added Cmd_ArticleMail (entry to section Cmd_ArticlePost)
C           to reply to an article by mail. The entire article is 
C           included (like followup). - JMH
C
C 9/8/88  - Subroutine Cmd_ArticlePost now deletes the input file
C           as well as the output file. - JMH
C
C 9/7/88  - Changed posting routine (Cmd_ArticlePost) to allow for
C           tpu editor if the logical name VISUAL or EDITOR is defined 
C           as 'EDIT/TPU'. If it is not defined, or is defined as
C           'EDIT/EDT' then the edt editor is used. - JMH
C
C 8/17/88 - Changed pattern searching ('/') routine to search for
C           strings regardless of case. (using STR$Upcase).
C           Added '?' as a synonym for help.
C           Added Cmd_Spawn subroutine to spawn a single command or
C           an interactive subprocess. - JMH
C
C 8/16/88 - Added '/' for pattern searching (Cmd_ArticleFindSubj) - JMH
C
C 8/16/88 - Added keypad help subroutine (Keypad_Help) and defined
C           some keypad function keys (in SMG_Routines.FOR) - JMH
C
C 8/12/88 - XX.NEWSRC now purges itself down to one version  - JMH
C
C 8/2/88  - Added newsgroup restore subroutine (Cmd_ArticleRestore).
C           Changed subroutine Xhdr to not bomb when XHDR does
C           exist on a particular server.
C           Removed MAIL$EDIT dependencies (fails for TPU).
C           Changed Cmd_ArticleSameSubj to look for a pattern in
C           the subject header, not just the exact subject header. - JMH
C
C************************************************************************

        PROGRAM NEWS

        Include 'News.Def/list'
        Include 'SMG.Def/list'
	Include 'Debug.Def/list'

C External Routines

        Integer                 CLI_Get_Value
        Integer                 CLI_Present
        Integer                 GetUserName
        Integer                 GetUserDirectory
	Integer			GetPersonalName
        Integer                 Open_Newsrc
        Integer                 Srv_Cmd
        Integer                 Srv_Connect
        Integer                 Srv_Recv
        Integer                 TransLog

C Local Definitions

        Character *512          Buf
        Integer   *4            Lg
        Integer                 Status          ! Status of various commands.

C Security precaution -- should do this with LIB$INITIALIZE
C pr/910325.  Vnews 1.4

	call Disable_Installed_Privs()

C Begin News

        Debug = .false.                 ! Debug is off

        Range_Free_List = 0             ! Initialize Range item free list
        Group_Count = 0                 ! Initialize next group
        Range_Count = 0                 ! Initialize next range
        Header_Count = 0                ! Number of /Header fields
	NoAsk = .FALSE.			! Ask on Catchup (jms/910327/V1.4)

C
C     Parse command before doing anything else [pr]
C	Added to VNEWS 1.4 910325
C
	call VNews_Cli_Init()
	Lg = 0

C Get /Header parameter telling us what header lines to print

	Header_Present = Cli_Present('HEADER')
	If (Header_Present) Then
	  Status = 1
	  Do While (Status)
	    Header_Count = Header_Count + 1
	    Status = Cli_Get_Value('HEADER', Header(Header_Count), Lg)
	  EndDo
	  Header_Count = Header_Count - 1
	EndIf

C Get followup command mark character

	Status = Cli_Get_Value('MARK', Mark_Character, Lg)
	If (.not. Status) Then
	  Mark_Character = '>'
	EndIf

C Get parameter for newsgroup to be read

	GroupSelect = Cli_Present('GROUP')
	If (GroupSelect) Then
	  Status = Cli_Get_Value('GROUP', NewsGroup, Lg)
	  If (Status) Then
	    Call Down_Case (NewsGroup)
	  Endif
	EndIf
C
C     -- end of DCL command parsing --
C	end of VNEWS 1.4 addition 910325
C


C Get our user name

        Status = GetUserName (UserName)
        If (.not. Status) Then
          Call SMG_All_Print ('Error obtaining your username', '|')
          Stop
        EndIf

C Get our .news directory and personal name

        Status = GetUserDirectory (UserDirectory) 
        If (.not. Status) Then
          Call SMG_All_Print
     $      ('Error obtaining your login directory', '|')
          Stop
        EndIf
	Status = GetPersonalName ( UserPersonalName )
        If (.not. Status) Then
          Call SMG_All_Print
     $      ('Error obtaining your personal name', '|')
          Stop
        EndIf

        Call Ctrl_C                     ! Initialize control C handler

        Call SMG_Initialize             ! Initialize screen routines

        Call Version                    ! Print out the version

        Call Get_Init                   ! Get configuration values

C Read users XX.NEWSRC file

        Call SMG_All_Print ('Reading your XX.Newsrc file...', '|')
        Call SMG_All_Print (' ', '|')

        Status = Open_Newsrc()

C Added a ^Y handler to jump to quit_news() once newsrc has been read in.
C paf,jms/910327. vnews 1.4

	call Declare_Handler		! ^Y handler for VNEWS

C Connect to server

        Call SMG_All_Print
     $    ('Connecting to remote news server...', '|')
        Status = Srv_Connect()
        If (.not. Status) Then
          Call SMG_All_Print
     $      (
     $       ' Can not connect to remote news server!',
     $       '|'
     $      )
          Stop
        EndIf

C Get initial signon line
C Fix bug in call to sys$fao. 910320/jms

        Status = Srv_Recv (Buf, Lg)
        If (.not. Status) Then
          CALL SYS$FAO (
     $      'Error receiving data from news server, status = !UL',,
     $      Buf,
     $      %VAL (Status))
          Call SMG_All_Print (Buf, '|')
          Stop
        EndIf

        If (Lg .gt. 0) Then
          Call SMG_All_Print (Buf (1:Lg), '|')
        EndIf

C Determine if posting is allowed. Set the Posting_Allowed global,
C or die if neither 200 or 201 appear (RFC977 pg 8) 900622/jms

	If (Buf(1:3) .eq. '200') Then
	   Posting_Allowed = .TRUE.
	Else If (Buf(1:3) .eq. '201') Then
	   Posting_Allowed = .FALSE.
	Else
	   Call SMG_All_Print ('Cannot proceed', '|')
	   Stop
	End If

        Call SMG_All_Print (' ', '|')

C Get the active file from the remote host.

        Call SMG_All_Print ('Retrieving active file...', '|')
        Call NNTP_Get_Active_File ()

C Now get list of groups created since XX.NEWSRC created

        If (Newsrc_Is_Open) Then
          Call SMG_All_Print (' ', '|')
          Call SMG_All_Print
     $      (
     $       'Last News execution at ' // Newsrc_CDT_VMS // '.',
     $       '|'
     $      )

          Call SMG_All_Print (' ', '|')
          Call SMG_All_Print ('Retrieving new groups...', '|')

          Call NNTP_Get_New_Groups ()
        End If

C prompt about subsribing for each new group (nntp.for)

	Call Query_New_Groups()

C Go and read all the news that we have.

        Call Read_News ()

C Clean up and Exit

	Call Quit_News ()

        End

	SUBROUTINE Quit_News()
C+++
C All done. Close out and finish off.
C---

        Include 'News.Def/list'
        Include 'SMG.Def/list'

C External Routines

        Integer                 Delete_File     
        Integer                 LIB$Rename_File     
        Integer                 Close_Newsrc
        Integer                 Srv_Cmd
        Integer                 Srv_Connect
        Integer                 Srv_Recv
        Integer                 TransLog

C Local Definitions

        Character *512          Buf
        Integer   *4            Lg
        Integer                 Status          ! Status of various commands.
        Logical                 File_Exists     ! For NEWS_PRINT
C Disconnect from server

        Status = Srv_Cmd ('quit', Buf, Lg)
        If (.not. Status) Then
	  Call SMG_All_Print 
	1	('Server failed, still trying to clean up...', '|')
C	  Stop
        EndIf

        Call SMG_All_Print (' ', '|')
        Call SMG_All_Print
     $    ('Closing News server connection...', '|')
C        Call SMG_All_Print (Buf(1:Lg), '|')	! ignore. Couldn't be that
						! interesting. vnews 1.4

C Update xx.newsrc

        Call SMG_All_Print (' ', '|')
        Call SMG_All_Print ('Updating XX.Newsrc...', '|')
        Status = Close_Newsrc ()
        If (.not. Status) Then
          Print '(A)', ' Error closing XX.NEWSRC'
          Stop
        End If

C
C Purge the XX.NEWSRC file so that we only have the current version
C JMH 8/12/88
C
c
c	VNEWS 1.3-4	John McMahon
c
c	Rename the old XX.NEWSRC file to XX.OLDNEWSRC as safety factor.
c

	Call SMG_All_Print
     $   ('Purging old version of XX.NEWSRC and XX.OLDNEWSRC...', '|')

c do the current version first (the one we just wrote)

        Status = LIB$Rename_File ('SYS$LOGIN:XX.NEWSRC',
     $   'SYS$LOGIN:OLD.NEWSRC')

c now the older copy

        Status = LIB$Rename_File ('SYS$LOGIN:XX.NEWSRC',
     $   'SYS$LOGIN:OLD.OLDNEWSRC')

c now do a purge of the rest of the files...
C vnews 1.4/jms/910326 Use new Delete_File subroutine.

        Call Delete_File ('SYS$LOGIN:XX.NEWSRC;*')
        Call Delete_File ('SYS$LOGIN:XX.OLDNEWSRC;*')

C
C Rename the current OLD.NEWSRC to XX.NEWSRC version one.
C JMH 8/12/88
C

        Status = LIB$Rename_File ('SYS$LOGIN:OLD.NEWSRC',
     $   'SYS$LOGIN:XX.NEWSRC;1')
        Status = LIB$Rename_File ('SYS$LOGIN:OLD.OLDNEWSRC',
     $   'SYS$LOGIN:XX.OLDNEWSRC;1')

C
C Print the current SYS$LOGIN:NEWS_PRINT.TXT file (if it exists).
C
C vnews 1.4/jms/910325. Move logical name translations to get_init.
C vnews 1.4/paf/910326. Call SMG_Final to clean up SMG stuff.
C vnews 1.4/paf/910326. Call Cancel_Handler to cancel exit handler.
C
        Inquire 
     $          (
     $           File = 'SYS$LOGIN:NEWS_PRINT.TXT',
     $           Exist = File_Exists
     $          )

	Call SMG_All_Print
     $   ('VNEWS Ends.', '|')

	Call SMG_Final

	Call Cancel_Handler

C
C PrintCommand is defined in SITE_SPECIFIC.DEF and GET_INIT.FOR
C
        If (File_Exists) Then
 	    Call STR$Trim (PrintCommand, PrintCommand, Lg)
            Call LIB$Do_Command (PrintCommand(1:Lg))
	Endif

	Call Exit

	Return

	END
