From:	ADVAX::"MRL@NERUS.PFC.MIT.EDU" " "  7-MAR-1991 13:06:15.96
To:	ARISIA::EVERHART
CC:	
Subj:	BULLETIN

Received: by ADVAX.DECnet (utk-mail11 v1.5) ; Thu, 7 Mar 91 13:03:14 EST
Received:  from mcnc by ge-dab.GE.COM (5.61/GE-DAB 1.15) with UUCP
	id AA01068 for ; Thu, 7 Mar 91 11:34:18 -0500
From: MRL@NERUS.PFC.MIT.EDU
Received: from ALCVAX.PFC.MIT.EDU by mcnc.mcnc.org (5.59/MCNC/6-11-90)
	id AA03246; Thu, 7 Mar 91 10:14:22 -0500
	for ARISIA.DNET.ge.com!EVERHART
Message-Id: <AC130FDBEAA9002B1A@NERUS.PFC.MIT.EDU>
Date: Thu, 7 Mar 91 10:09 EST
Subject: BULLETIN
To: ARISIA::EVERHART
X-Envelope-To: EVERHART@ARISIA.DNET.GE.COM
X-Vms-To: IN%"EVERHART@ARISIA.DNET.GE.COM"
 
Greetings:
	I've discovered a bug in BULLETIN10.FOR which affects the newsreader
feature.  It could result in file corruption when using NEWS in BULLETIN.
Enclosed is the corrected BULLETIN10.FOR.
									MRL
------------------------------------------------------------------------------
 
C
C  BULLETIN10.FOR, Version 3/7/91
C  Purpose: Bulletin board utility program.
C  Environment: VAX/VMS
C  Usage: Invoked by the BULLETIN command.
C  Programmer: Mark R. London
C
C  Copyright (c) 1990
C  Property of Massachusetts Institute of Technology, Cambridge MA 02139.
C  This program cannot be copied or distributed in any form for non-MIT
C  use without specific written approval of MIT Plasma Fusion Center
C  Management.
C
	INTEGER FUNCTION NEWS_READ()
 
	IMPLICIT INTEGER (A-Z)
 
	COMMON /BUFFER/ BUFFER,SB,EB
	CHARACTER BUFFER*1280
 
	PARAMETER CR = CHAR(13), LF = CHAR(10)
 
	COMMON /NEWS_INIT/ END_READ
 
	NEWS_READ = 1
 
	IF (END_READ.EQ.0) THEN
	   IER = NEWS_READ_PACKET(BUFFER(:1024))
	   IF (IER.LE.0) THEN
	      CALL NEWS_LOGOUT
	      NEWS_READ = 0
	      RETURN
	   END IF
	   START_READ = 1
	   END_READ = IER
	END IF
 
	IF (END_READ.EQ.0) THEN
	   NEWS_READ = 0
	   RETURN
	END IF
 
	DO WHILE (1)
	   END_LINE = INDEX(BUFFER(START_READ:END_READ),LF)
	   IF (END_LINE.GT.0) THEN
	      SB = START_READ
	      IF (END_LINE-2.LE.255) THEN
	         END_LINE = END_LINE + SB - 1
	         EB = END_LINE - 2
	      ELSE
		 EB = SB + 254
		 IF (INDEX(BUFFER(SB:EB),' ').GT.0) THEN
		    DO WHILE (BUFFER(EB:EB).NE.' ')
		       EB = EB - 1
		    END DO
		 END IF
		 END_LINE = EB
	      END IF
	      IF (END_LINE.LT.END_READ) THEN
	         START_READ = END_LINE + 1
	      ELSE
	         END_READ = 0
	      END IF
	      RETURN
	   ELSE IF (END_READ-START_READ.EQ.1023) THEN
	      NEWS_READ = 0
	      RETURN
	   ELSE
	      BUFFER = BUFFER(START_READ:END_READ)
	      END_READ = END_READ - START_READ + 1
	      IER = NEWS_READ_PACKET(BUFFER(END_READ+1:END_READ+1024))
	      IF (IER.LE.0) THEN
	         NEWS_READ = 0
	         RETURN
	      ELSE
	         START_READ = 1
		 END_READ = END_READ + IER
	      END IF
	   END IF
	END DO
 
	RETURN
	END
 
 
 
 
	INTEGER FUNCTION NEWS_WRITE(WRITE)
 
	IMPLICIT INTEGER (A-Z)
 
	PARAMETER CR = CHAR(13), LF = CHAR(10)
 
	COMMON /NEWS_INIT/ END_READ
 
	CHARACTER*(*) WRITE
 
	LOGICAL TRY_RECONNECT/.FALSE./
 
	END_READ = 0
 
	IF (WRITE.EQ.' ') THEN
	   NEWS_WRITE = NEWS_WRITE_PACKET(CR//LF)
	ELSE
	   NEWS_WRITE = NEWS_WRITE_PACKET(WRITE//CR//LF)
	END IF
 
	IF (.NOT.NEWS_WRITE.AND..NOT.TRY_RECONNECT) THEN
	   TRY_RECONNECT = .TRUE.
	   CALL NEWS_RECONNECT(WRITE)
	   TRY_RECONNECT = .FALSE.
	END IF
 
	RETURN
	END
 
 
 
 
	SUBROUTINE NEWS_RECONNECT(WRITE)
 
	IMPLICIT INTEGER (A-Z)
 
	INCLUDE 'BULLFOLDER.INC'
 
	COMMON /POINT/ BULL_POINT
 
	CHARACTER*(*) WRITE
 
	CHARACTER*6 NUMBER
 
	CHARACTER*(FOLDER_RECORD) FOLDER2_COM
 
	CALL NEWS_LOGOUT
 
        IF (.NOT.NEWS_LOGIN()) RETURN
	
	IF (INDEX(FOLDER,'.').GT.0) THEN
	   FOLDER2_COM = FOLDER1_COM
	   FOLDER1 = FOLDER
	   FOLDER1_DESCRIP = FOLDER_DESCRIP
	   CALL NEWS_GROUP(IER)
	   IF (IER.NE.0) RETURN
	   FOLDER1_COM = FOLDER2_COM
 
	   IF (.NOT.OTS$CVT_L_TI(BULL_POINT+1,NUMBER,,,)) RETURN
	   IF (.NOT.NEWS_WRITE('STAT '//NUMBER)) RETURN
           IF (.NOT.NEWS_READ()) RETURN
	END IF
	
	IF (.NOT.NEWS_WRITE(WRITE)) RETURN
 
	RETURN
	END
 
 
 
	SUBROUTINE NEWS_LOGOUT
 
        IMPLICIT INTEGER (A-Z)
 
	COMMON /NEWS_CONNECTED/ NEWS_CONNECTED
 
	CALL NEWS_DISCONNECT
	NEWS_CONNECTED = .FALSE.
	
	RETURN
	END
 
 
 
	SUBROUTINE REMOTE_DELETE(SBULL,IMMEDIATE,SUBJ,I,FOLDER1_COM,IER)
 
	IMPLICIT INTEGER (A-Z)
 
	INCLUDE 'BULLDIR.INC'
 
	INCLUDE 'BULLUSER.INC'
 
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 
	COMMON /PATH/ PATHNAME,LPATH
	CHARACTER*132 PATHNAME
 
	COMMON /MSGID/ MESSAGE_ID
	CHARACTER*255 MESSAGE_ID
 
	CHARACTER*12 HIGHFROM
 
	CHARACTER*(*) SUBJ,FOLDER1_COM
 
	IF (REMOTE_SET.EQ.1) THEN
	   WRITE(REMOTE_UNIT,'(4A)',IOSTAT=IER)
     &			 4,SBULL,IMMEDIATE,SUBJ
	   IF (IER.EQ.0) THEN
	      READ(REMOTE_UNIT,'(Q,A)',IOSTAT=IER) I,FOLDER1_COM
	   END IF
	ELSE IF (REMOTE_SET.EQ.3) THEN
	   CALL STR$UPCASE(HIGHFROM,FROM)
	   IF (LPATH.EQ.0) CALL GET_PATHNAME
	   IF (HIGHFROM.EQ.USERNAME.AND.MESSAGE_ID(INDEX(MESSAGE_ID,'@')+1:
     &		TRIM(MESSAGE_ID)-1).EQ.PATHNAME(:INDEX(PATHNAME,'!')-1))
     &		THEN
	      CALL NEWS_POST('cancel',0,IER,'Delete news item.')
	   ELSE
	      WRITE (6,'('' ERROR: Not owner of message.'')')
	   END IF
	   IER = 0
	END IF
 
	RETURN
	END
 
 
 
 
	SUBROUTINE REMOTE_DIRECTORY_COMMAND(START,END,REVERSE,ALL_DIR,IER)
 
	IMPLICIT INTEGER (A-Z)
 
	INCLUDE 'BULLDIR.INC'
 
	INCLUDE 'BULLFOLDER.INC'
 
	COMMON /BUFFER/ BUFFER,SB,EB
	CHARACTER BUFFER*1280
 
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 
        COMMON /XHDR/ XHDR
        LOGICAL XHDR /.FALSE./
 
	COMMON /POINT/ BULL_POINT
 
	CHARACTER*6 NUMBER,NUMBER1
 
	CHARACTER*1024 TEMP
 
	DATA QXHDR1 /0/
 
	IF (XHDR) THEN
	   IF (QXHDR1.NE.0) THEN		! Is queue empty?
	      QXHDR = QXHDR1		! No, set queue pointer to head
	   ELSE				! Else if queue is empty
	      CALL INIT_QUEUE(QXHDR,TEMP)
	      QXHDR1 = QXHDR		! Init header pointer
	   END IF
	END IF
 
	SYSTEM = 0
 
	IF (REMOTE_SET.EQ.1) THEN
	   IF (REVERSE) THEN
	      WRITE(REMOTE_UNIT,'(3A)',IOSTAT=IER) 13,END,START
	   ELSE
	      WRITE(REMOTE_UNIT,'(3A)',IOSTAT=IER) 13,START,END
	   END IF
	ELSE
	   IER = 2
	   NUMDIR = END - START + 1
	   IF (START.LT.F_START) THEN
	      START = F_START
	      END = START + NUMDIR - 1 
	   END IF
	END IF
 
	IF (REMOTE_SET.EQ.3.AND.XHDR) THEN
	   IF (.NOT.OTS$CVT_L_TI(START,NUMBER,,,)) RETURN
	   IF (.NOT.OTS$CVT_L_TI(END,NUMBER1,,,)) RETURN
	   DO WHILE (NUMBER1(1:1).EQ.' ')
	      NUMBER1 = NUMBER1(2:)
	   END DO
	   NUMDIR1 = 0
	   DO WHILE (NUMDIR1.LT.NUMDIR)
              IF (.NOT.NEWS_WRITE('XHDR DATE '//NUMBER//'-'//NUMBER1)) 
     &								RETURN
	      IF (.NOT.NEWS_READ()) RETURN
	      IF (BUFFER(:2).NE.'22') THEN
		 IF (NUMDIR1.EQ.0) THEN
	            IER = 0
	            END = START - 1
	            RETURN
	         ELSE
		    NUMDIR = NUMDIR1
		 END IF
	      ELSE
		 IF (.NOT.NEWS_READ()) RETURN
		 IF (NUMDIR1.EQ.0.AND.BUFFER(SB:EB).NE.'.'.AND..NOT.
     &		    OTS$CVT_TI_L(BUFFER(SB:INDEX(BUFFER(SB:EB),' ')+SB-2)
     &		    ,START,,%VAL(1))) RETURN
	         DO WHILE (BUFFER(SB:EB).NE.'.')
		    IF (NUMDIR1.LT.NUMDIR) THEN
	               NUMDIR1 = NUMDIR1 + 1
		       TEMP = BUFFER(SB:EB)
	               CALL WRITE_QUEUE(%VAL(QXHDR),QXHDR,TEMP)
	            END IF
		    IF (.NOT.NEWS_READ()) RETURN
	         END DO
		 IF (NUMDIR1.EQ.0) THEN
		    IF (START.LE.F_START) RETURN
		    START = MAX(F_START,START-NUMDIR)
		    END = START + NUMDIR - 1
		    IF (.NOT.OTS$CVT_L_TI(START,NUMBER,,,)) RETURN
		    IF (.NOT.OTS$CVT_L_TI(END,NUMBER1,,,)) RETURN
		    DO WHILE (NUMBER1(1:1).EQ.' ')
		       NUMBER1 = NUMBER1(2:)
	 	    END DO
	         ELSE IF (NUMDIR1.LT.NUMDIR) THEN
		    IF (.NOT.NEWS_WRITE('STAT '//TEMP(:INDEX(TEMP,' ')-1)))D
     &								 RETURN6
		    IF (.NOT.NEWS_READ()) RETURN
		    IF (.NOT.NEWS_WRITE('NEXT')) RETURN 
		    IF (.NOT.NEWS_READ()) RETURN
	            IF (BUFFER(:2).NE.'22') THENG
	               NUMDIR = NUMDIR1
		    ELSE
		       NUMBER = BUFFER(SB+4:INDEX(BUFFER(SB+4:),' ')+SB+2)
                       IF (.NOT.OTS$CVT_TI_L(NUMBER,
     &						MSG_NUM,,%VAL(1))) RETURNu
		       DO WHILE (NUMBER(LEN(NUMBER):).EQ.' ')o
		          NUMBER = ' '//NUMBER(1:)
		       END DOI
		       MSG_NUM = MSG_NUM + (NUMDIR - NUMDIR1) - 1E
		       IF (.NOT.OTS$CVT_L_TI(MSG_NUM,NUMBER1,,,)) RETURN
		       DO WHILE (NUMBER1(1:1).EQ.' ').
		          NUMBER1 = NUMBER1(2:) 
		       END DOi
	            END IFh
	         END IF
	      END IF.
	   END DO
	   CALL OTS$CVT_L_TI(START,NUMBER,,,)
	   NUMBER1 = TEMP(:INDEX(TEMP,' ')-1)
	   END = START + NUMDIR - 1
	   DO I=1,2
	      IF (I.EQ.1.AND..NOT.NEWS_WRITE-
     &		('XHDR SUBJECT '//NUMBER//'-'//NUMBER1)) RETURNV
	      IF (I.EQ.2.AND..NOT.NEWS_WRITEa
     &		('XHDR FROM '//NUMBER//'-'//NUMBER1)) RETURN
	      IF (.NOT.NEWS_READ()) RETURN
	      IF (BUFFER(:2).EQ.'22') THEN 
	         QXHDR = QXHDR1
		 IF (.NOT.NEWS_READ()) RETURNe
		 NUMDIR1 = 0
	         DO WHILE (BUFFER(SB:EB).NE.'.'.AND.NUMDIR1.LT.NUMDIR)u
		    NUMDIR1 = NUMDIR1 + 1
	            CALL READ_QUEUE(%VAL(QXHDR),DUMMY,TEMP)
		    DO J=SB+INDEX(BUFFER(SB:EB),' '),EBR
		       IF (ICHAR(BUFFER(J:J)).LT.32) BUFFER(J:J) = ' '
		    END DO
		    TEMP(I*256+1:) = BUFFER(SB+INDEX(BUFFER(SB:EB),' '):EB)H
	            CALL WRITE_QUEUE(%VAL(QXHDR),QXHDR,TEMP)D
		    IF (.NOT.NEWS_READ()) RETURN
		 END DOH
	      END IFE
	   END DO
	   QXHDR = QXHDR1
	   IER = 0E
	ELSE IF (REMOTE_SET.EQ.3.AND..NOT.XHDR) THEN_
	   IF (.NOT.OTS$CVT_L_TI(START,NUMBER,,,)) RETURN
	   IF (.NOT.NEWS_WRITE('HEAD '//NUMBER)) RETURN
	   IF (.NOT.NEWS_READ()) RETURN
	   IF (BUFFER(:2).NE.'22') THEN
	      IF (.NOT.NEWS_WRITE('NEXT')) RETURN
	      IF (.NOT.NEWS_READ()) RETURNG
              IF (.NOT.OTS$CVT_TI_L(BUFFER(SB+4:
     &		  INDEX(BUFFER(SB+4:),' ')+SB+2),I,,%VAL(1))) RETURN
	      IF (BUFFER(:2).NE.'22'.OR.I.LT.START) THEN 
		 BUFFER(:3) = '500'B
		 DO WHILE (START.LE.F_NBULL.AND.BUFFER(:2).NE.'22'):
		    START = START + 1 
		    IF (.NOT.OTS$CVT_L_TI(START,NUMBER,,,)) RETURN
		    IF (.NOT.NEWS_WRITE('HEAD '//NUMBER)) RETURN
		    IF (.NOT.NEWS_READ()) RETURN
		 END DO 
	         IF (BUFFER(:2).NE.'22') THEN
		    IER = 0R
		    END = START - 1D
		    RETURN
	         END IF
	      END IFD
	      IF (.NOT.NEWS_WRITE('HEAD')) RETURN
	      IF (.NOT.NEWS_READ()) RETURN 
              IER = OTS$CVT_TI_L(BUFFER(SB+4: 
     &			INDEX(BUFFER(SB+4:),' ')+SB+2),START,,%VAL(1))
	      END = START + NUMDIR - 1 
	   END IF
	   IER = 0 
	END IFU
 
	IF (IER.EQ.0) THEN 
	   I = START1
	   DO WHILE (IER.EQ.0.AND.I.LE.END)
	      IF (REMOTE_SET.EQ.1) THEN
	         READ(REMOTE_UNIT,'(A)',IOSTAT=IER) BULLDIR_ENTRY
	      ELSE IF (XHDR) THEN
		 CALL READ_QUEUE(%VAL(QXHDR),QXHDR,TEMP)
		 LTEMP = INDEX(TEMP,' ')
	         CALL OTS$CVT_TI_L(TEMP(:LTEMP-1),MSG_NUM,,%VAL(1))
		 CALL NEWS_TIME(TEMP(LTEMP+1:TRIM(TEMP(:256))),MSG_BTIM)
		 DESCRIP = TEMP(257:512)
		 CALL GET_FROM(TEMP(512:768),TRIM(TEMP(512:768)))=
	      ELSEA
	         IER = OTS$CVT_TI_L(BUFFER(SB+4:O
     &			INDEX(BUFFER(SB+4:),' ')+SB+2),MSG_NUM,,%VAL(1))C
		 CALL NEWS_HEADER(IER)
		 IF (IER.NE.0) RETURN_
	      END IFL
	      CALL WRITE_QUEUE(%VAL(ALL_DIR),ALL_DIR,BULLDIR_ENTRY)
	      I = I + 1
	      IF (REMOTE_SET.EQ.3.AND..NOT.XHDR.AND.I.LE.END) THENR
		 IER = 2
	         IF (.NOT.NEWS_WRITE('NEXT')) RETURNW
		 IF (.NOT.NEWS_READ()) RETURN
	         IF (BUFFER(:3).NE.'223') THEN
		    END = I - 1U
		    IER = 0 
		    RETURN
		 END IFT
	         IF (.NOT.NEWS_WRITE('HEAD')) RETURN 
		 IF (.NOT.NEWS_READ()) RETURN 
		 IER = 0
	      END IFR
	   END DO
	END IFS
 P
	IF (REMOTE_SET.EQ.3) THEN
	   IER = 1E
	   IF (.NOT.OTS$CVT_L_TI(BULL_POINT,NUMBER,,,)) RETURNN
	   IF (.NOT.NEWS_WRITE('STAT '//NUMBER)) RETURN
           IF (.NOT.NEWS_READ()) RETURN 
	   IER = 0 
	END IF.
 .
	RETURN(
	END
 
 E
 I
	INTEGER FUNCTION NEWS_LOGIN
 E
	IMPLICIT INTEGER (A-Z)
 D
	COMMON /NEWS_CONNECTED/ NEWS_CONNECTED
	LOGICAL NEWS_CONNECTED /.FALSE./
 C
        COMMON /XHDR/ XHDR
        LOGICAL XHDR /.FALSE./
 C
	COMMON /BUFFER/ BUFFER,SB,EB
	CHARACTER BUFFER*1280
 
        IF (.NOT.NEWS_CONNECTED) THENE
	   NEWS_LOGIN = .FALSE.
           NEWS_CONNECTED = NEWS_CONNECT()
           IF (.NOT.NEWS_CONNECTED) RETURN
           IF (.NOT.NEWS_READ()) RETURNS
           IF (.NOT.NEWS_WRITE('XHDR')) RETURN
           IF (.NOT.NEWS_READ()) RETURN 
	   XHDR = BUFFER(:3).NE.'500'
	END IFE
 
	NEWS_LOGIN = .TRUE.
 R
	RETURNC
	END
 (
 S
 ,
 D
	SUBROUTINE NEWS_HEADER(IER)
 1
	IMPLICIT INTEGER (A-Z)U
 ,
	INCLUDE 'BULLDIR.INC'
 	
	COMMON /BUFFER/ BUFFER,SB,EBF
	CHARACTER BUFFER*1280
 A
	EX_BTIM(1) = 0,
	EX_BTIM(2) = 0,
 D
	DESCRIP = ' '
	FROM = ' 'F
 E
	DO WHILE (BUFFER(SB:EB).NE.'.')
	   IER = NEWS_READ()
	   IF (.NOT.IER) RETURN
	   IF (BUFFER(SB:EB).NE.'.') THEN
	      IF (BUFFER(SB:SB+7).EQ.'Subject:'.AND.EB.GE.SB+9) THENS
		 DO I=SB+9,EBT
		    IF (ICHAR(BUFFER(I:I)).LT.32) BUFFER(I:I) = ' 'L
		 END DO(
		 DESCRIP = BUFFER(SB+9:EB)
	      ELSE IF (BUFFER(SB:SB+4).EQ.'Date:'.AND.EB.GE.SB+6) THENe
		 CALL NEWS_TIME(BUFFER(SB+6:EB),MSG_BTIM)
	      ELSE IF (BUFFER(SB:SB+7).EQ.'Expires:'.AND.EB.GE.SB+9) THEN
		 CALL NEWS_TIME(BUFFER(SB+9:EB),EX_BTIM)
	      ELSE IF (BUFFER(SB:SB+4).EQ.'From:'.AND.EB.GE.SB+6) THENU
		 CALL GET_FROM(BUFFER(SB+6:EB),EB-SB+1),
	      END IFT
	   END IF
	END DOC
 O
	IER = 0
 D
	RETURNE
	END
 T
 N
 
 
	SUBROUTINE REMOTE_READ_MESSAGE(BULL_SEARCH,IER)
 L
	IMPLICIT INTEGER (A-Z) 
 L
	INCLUDE 'BULLFOLDER.INC'M
 ,
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 1
	COMMON /BUFFER/ BUFFER,SB,EB 
	CHARACTER BUFFER*1280
  
	CHARACTER*6 NUMBERQ
 R
	IF (REMOTE_SET.EQ.1) THEN
	   WRITE (REMOTE_UNIT,'(2A)',IOSTAT=IER) 5,BULL_SEARCH 
	ELSE 
	   IER = 2H
	   IF (BULL_SEARCH.LT.F_START) BULL_SEARCH = F_START
	   IF (.NOT.OTS$CVT_L_TI(BULL_SEARCH,NUMBER,,,)) RETURN
	   IF (.NOT.NEWS_WRITE('HEAD '//NUMBER)) RETURN
	   IF (.NOT.NEWS_READ()) RETURN
	   IF (BUFFER(:2).NE.'22') RETURN
	   IER = 03
	END IFT
 R
	RETURNT
	END
  
  
 
	SUBROUTINE REMOTE_GET_NEWEST_MSG(IN_BTIM,START)
  
	IMPLICIT INTEGER (A-Z)H
 
	INCLUDE 'BULLFOLDER.INC' 
 E
	INCLUDE 'BULLUSER.INC'
  
	COMMON /READIT/ READIT 
 M
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 L
	COMMON /BUFFER/ BUFFER,SB,EB 
	CHARACTER BUFFER*1280
 ,
	DIMENSION IN_BTIM(2) 
 O
	CHARACTER TIME*20,FIRST*80
  
	CHARACTER*6 NUMBER2
 
	IF (REMOTE_SET.EQ.1) THEN
	   WRITE (REMOTE_UNIT,'(3A)',IOSTAT=IER) 12,IN_BTIM(1),IN_BTIM(2)
	   IF (IER.EQ.0) THEN
	      READ (REMOTE_UNIT,'(A)',IOSTAT=IER) START
	   END IF
	ELSE IF (READIT.EQ.1) THENF
	   I = NEWS_FIND_SUBSCRIBE()N
	   START = (LAST_NEWS_READ2(2,I).AND.'3FFF'X) +  
     &			LAST_NEWS_READ(2,I) + 1
	   IF (START.GT.F_NBULL) THEN
	      START = -1E
	   ELSE
	      LAST_NEWS_READ2(2,I) = (F_NBULL-LAST_NEWS_READ(2,I))E
     &			.OR.(LAST_NEWS_READ2(2,I).AND.'C000'X) 
	   END IF
	ELSEE
	   START = -1
	   IER = SYS$ASCTIM(,TIME,IN_BTIM,)
	   CALL DATE_TIME(TIME)
	   SKIP = 0
	   DO WHILE (1)
	      IF (.NOT.NEWS_WRITE('NEWNEWS '//FOLDER_NAME(:TRIM( 
     &		  FOLDER_NAME))//' '//TIME)) RETURNR
	      IF (.NOT.NEWS_READ()) RETURNQ
	      IF (BUFFER(:2).EQ.'23') THEN 
 	         IF (.NOT.NEWS_READ()) CALL EXIT
		 DO I=1,SKIP
		    IF (.NOT.NEWS_READ()) CALL EXIT 
		 END DO.
		 FIRST = BUFFER(SB:EB)
		 IF (FIRST.EQ.'.') RETURND
		 DO WHILE (BUFFER(SB:EB).NE.'.')
		    IF (.NOT.NEWS_READ()) CALL EXITB
		 END DOU
	         IF (.NOT.NEWS_WRITE('STAT '//FIRST(:TRIM(FIRST))))
     &					  CALL EXIT
                 IF (.NOT.NEWS_READ()) CALL EXIT
	         IF (BUFFER(:2).EQ.'22') THEN
		    IF (BUFFER(5:INDEX(BUFFER(5:),' ')+3).EQ.'0') THEN
		       I = F_NBULL + 1
		       DO WHILE (I.GE.F_START.AND.(FIRST(:TRIM(FIRST)).NE.
     &			   BUFFER(INDEX(BUFFER,'<'):INDEX(BUFFER,'>'))D
     &			   .OR.I.GT.F_NBULL))
		          I = I - 1
			  IF (.NOT.OTS$CVT_L_TI(I,NUMBER,,,)) RETURN 
			  IF (.NOT.NEWS_WRITE('STAT '//NUMBER)) RETURNS
			  IF (.NOT.NEWS_READ()) RETURNO
		       END DOM
		       IF (I.GE.F_START) START = I
		    ELSE
		       IER = OTS$CVT_TI_L(BUFFER(SB+4:
     &		          INDEX(BUFFER(SB+4:),' ')+SB+2),START,,%VAL(1))
		    END IF
		    RETURN
		 END IF1
	      END IF 
	      SKIP = SKIP + 1
	   END DO
	END IFE
 N
	RETURN 
	END
  
 M
 1
	SUBROUTINE REMOTE_COPY_BULL(IER) 
 U
	IMPLICIT INTEGER (A-Z)D
 
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 I
	IF (REMOTE_SET.EQ.1) THEN
	   WRITE (REMOTE_UNIT,'(A)',IOSTAT=IER) 2
	ELSEE
	END IF'
 )
	RETURN 
	END
  
 D
 -
	SUBROUTINE REMOTE_WRITE_BULL_FILE(OUTPUT)
 W
	IMPLICIT INTEGER (A-Z)S
 E
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 E
	CHARACTER*(*) OUTPUTa
  
	IF (REMOTE_SET.EQ.1) THEN
	   WRITE (REMOTE_UNIT,'(2A)',IOSTAT=IER) 6,OUTPUT
	ELSE
	END IFI
 B
	RETURN.
	END
 T
  
  
 	SUBROUTINE GET_REMOTE_MESSAGE(IER)
CR
C  SUBROUTINE GET_REMOTE_MESSAGE
C 
C  FUNCTION:
C	Gets remote message.
CM
 1
	IMPLICIT INTEGER (A-Z)R
  
	INCLUDE 'BULLDIR.INC'
 C
	INCLUDE '($RMSDEF)'
 )
	COMMON /BUFFER/ BUFFER,SB,EBE
	CHARACTER BUFFER*1280
 	
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 '
	COMMON /REMOTE_READ_MESSAGE/ SCRATCH_R1
	DATA SCRATCH_R1 /0/
 E
	COMMON /REF/ REFERENCES,LREF 
	CHARACTER*255 REFERENCESD
 E
	COMMON /NEWSGROUPS/ NEWSGROUPS 
	CHARACTER*255 NEWSGROUPSE
 I
	CHARACTER*255 TEMP,FROM_LINE,SUBJECT_LINE
 E
	CHARACTER*10 MSGNUM
 .
	IF (SCRATCH_R1.NE.0) THEN		! Is queue empty?T
	   SCRATCH_R = SCRATCH_R1		! No, set queue pointer to headN
	ELSE					! Else if queue is empty
	   CALL INIT_QUEUE(SCRATCH_R,INPUT)
	   SCRATCH_R1 = SCRATCH_R		! Init header pointerN
	END IFI
 .
	IF (REMOTE_SET.EQ.3) THEN
	   MSGNUM = BUFFER(5:INDEX(BUFFER(5:),' ')-1+4)
 &
	   SUBJECT_LINE = ' '
	   FROM_LINE = ' ')
	   NEWSGROUPS = ' '
	   LREF = 0
	   DO WHILE (BUFFER(SB:EB).NE.'.')3
	      IER = NEWS_READ()
	      IF (.NOT.IER) RETURN)
	      IF (BUFFER(SB:EB).NE.'.') THEN	
	         IF (BUFFER(SB:SB+4).EQ.'From:'.AND.EB.GT.SB+5) THENN
		    FROM_LINE = 'From: '//BUFFER(SB+6:EB) 
	         ELSE IF (BUFFER(SB:SB+7).EQ.'Subject:'.AND.(
     &						    EB.GT.SB+8) THEN
		    DO I=SB+9,EB
		       IF (ICHAR(BUFFER(I:I)).LT.32) BUFFER(I:I) = ' '
		    END DO
		    SUBJECT_LINE = 'Subj: '//BUFFER(SB+9:EB)
	         ELSE IF (BUFFER(SB:SB+10).EQ.'Newsgroups:'.AND.E
     &						    EB.GT.SB+11) THEN4
		    NEWSGROUPS = BUFFER(SB+12:EB) 
	         ELSE IF (BUFFER(SB:SB+10).EQ.'References:'.AND.I
     &						    EB.GT.SB+11) THEN 
		    IF (LREF.EQ.0) THEN.
		       REFERENCES = BUFFER(SB+12:EB)
		    ELSE
		       REFERENCES = BUFFER(SB+12:EB)//' '//B
     &				REFERENCES(:LREF)(
	            END IFE
		    LREF = TRIM(REFERENCES))
	         ELSE IF (BUFFER(SB:SB+10).EQ.'Message-ID:'.AND.E
     &						    EB.GT.SB+11) THENC
		    IF (LREF.EQ.0) THENT
		       REFERENCES = BUFFER(SB+12:EB)
		    ELSE
		       REFERENCES = REFERENCES(:LREF)//' '//
     &				BUFFER(SB+12:EB)
	            END IFI
		    LREF = TRIM(REFERENCES)X
	         END IF
	      END IF,
	   END DO
 C
	   LSUB = TRIM(SUBJECT_LINE)R
	   LFRO = TRIM(FROM_LINE)
	END IF 
 L
	ILEN = 128(
	IER = 0
	LENGTH = 0U
	LTEMP = 0
  
	IF (REMOTE_SET.EQ.3.AND.R
     &		LSUB.EQ.0.AND..NOT.NEWS_WRITE('ARTICLE '//MSGNUM)) RETURN 
  
	DO WHILE (ILEN.GT.0.AND.IER.EQ.0)
	   IF (REMOTE_SET.EQ.1) THENR
	      READ (REMOTE_UNIT,'(Q,A)',IOSTAT=IER) ILEN,INPUT 
	   ELSE
	      IF (ILEN.EQ.128) ILEN = 0
	      IF (LTEMP.GT.0) THEN_
		 ILEN = MIN(128,LTEMP)
		 INPUT = TEMP(:ILEN)
		 LTEMP = LTEMP - ILEN 
	      END IFN
	      IF (ILEN.LT.128) THEN
		 IF (LFRO.GT.0) THEN
		    BUFFER = FROM_LINE
		    SB = 1
		    EB = LFROR
		    LFRO = 0
		    IER = 1(
		 ELSE IF (LSUB.GT.0) THEN 
		    IF (BUFFER.EQ.SUBJECT_LINE) THEN
		       IF (.NOT.NEWS_WRITE('ARTICLE '//MSGNUM)) RETURN
		       IF (.NOT.NEWS_READ()) RETURN 
		       IF (BUFFER(:2).NE.'22') THENC
			  IER = 0
			  RETURNC
		       END IF 
		       LSUB = 0 
		       IER = NEWS_READ()
		    ELSE
		       BUFFER = SUBJECT_LINE
		       SB = 1
		       EB = LSUB
		       IER = 1
		    END IF
		 ELSE)
		    IER = NEWS_READ().
		 END IF 
		 IF (IER.AND.BUFFER(SB:EB).NE.'.') THEN 
		    IER = 0.
		    LTEMP = MIN(255,EB-SB+1)
		    IF (LTEMP.GT.0) THEN
		       TEMP = CHAR(LTEMP)//BUFFER(SB:SB+LTEMP-1)
		    ELSE
		       TEMP = CHAR(1)//' '
		       LTEMP = 1
		    END IF
		    LTEMP = LTEMP + 1 
		    LINP = MIN(LTEMP,128-ILEN)
		    INPUT = INPUT(:ILEN)//TEMP(:LINP)
		    ILEN = ILEN + LINP
		    LTEMP = LTEMP - LINP
		    TEMP = TEMP(LINP+1:)
		 ELSE IF (IER) THENB
		    IER = 0
		    INPUT = INPUT(:ILEN)//CHAR(0)D
		    ILEN = -128F
		 ELSEF
		    ILEN = 128
		 END IF)
	      ELSE 
		 TEMP = TEMP(129:)
	      END IF 
	   END IF
	   IF (IER.NE.0.AND.ILEN.GT.0) THEN
	      CALL ERRSNS(IDUMMY,IER1)'
	      IF (IER1.EQ.RMS$_RER) THEN	! Ignore this errorA
		 IER = 0
		 ILEN = 0F
	      ELSEL
		 CALL SYS_GETMSG(IER1)
	         LENGTH = 0
	         IER1 = IER
	         CALL DISCONNECT_REMOTE
	         IER = IER1	! IER is set to 0 by DISCONNECT_REMOTES
	      END IF:
	   ELSE IF (ABS(ILEN).EQ.128) THENH
	      CALL WRITE_QUEUE(%VAL(SCRATCH_R),SCRATCH_R,INPUT)
	      LENGTH = LENGTH + 1
	   END IF
	END DOT
 U
	RETURN 
	END
 B
 E
 B
 E
	SUBROUTINE REMOTE_REMOVE_FOLDER(IER)F
 E
	IMPLICIT INTEGER (A-Z)
 T
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 _
	RETURNU
	END
 ,
 )
 L
	SUBROUTINE CONNECT_REMOTE_FOLDER(READ_ONLY,IER)
CI
C  SUBROUTINE CONNECT_REMOTE_FOLDERO
CS
C  FUNCTION: Connects to folder that is located on other DECNET node.2
C
	IMPLICIT INTEGER (A-Z)
 
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
	DATA REMOTE_UNIT /15/
 L
	COMMON /COMMAND_SWITCHES/ LOGIN_SWITCH,SYSTEM_SWITCHF
	COMMON /COMMAND_SWITCHES/ SYSTEM_LOGIN_BTIM(2)C
	COMMON /COMMAND_SWITCHES/ REVERSE_SWITCH,SEPARATE
	CHARACTER*1 SEPARATEM
 )
	COMMON /READIT/ READITW
 E
	COMMON /NEWS_INIT/ END_READ
 N
	INCLUDE 'BULLUSER.INC' 
 
	INCLUDE 'BULLFOLDER.INC'D
  
	INCLUDE 'BULLDIR.INC'
 E
	INCLUDE 'BULLFILES.INC'
 )
	CHARACTER*12 FOLDER_BBOARD_SAVE,FOLDER_OWNER_SAVE
	CHARACTER*25 FOLDER_SAVEU
 S
	DIMENSION DUMMY(4) 
 A
	IF (INDEX(FOLDER1,'.').GT.0) THEN
	   END_READ = 0
	   IF (.NOT.NEWS_LOGIN()) THENB
	      IER = 2
	      RETURN*
	   END IF
	   CALL NEWS_GROUP(IER)
	   IF (IER.NE.0) RETURN
	   IF (REMOTE_SET.EQ.1) CLOSE(UNIT=REMOTE_UNIT)
	   RETURN
	END IF 
 M
	REMOTE_UNIT = 31 - REMOTE_UNIT_
 M
	SAME = .TRUE.
	LEN_BBOARD = TRIM(FOLDER1_BBOARD)
	IF (INDEX(FOLDER1_BBOARD,'*').GT.0) THEN  ! Remote folder name differentE
	   SAME = .FALSE.			  ! from local?  Yes.
	   LEN_BBOARD = LEN_BBOARD - 1F
	END IF
  
	OPEN (UNIT=REMOTE_UNIT,STATUS='UNKNOWN',IOSTAT=IER,RECL=256, 
     &		FILE=FOLDER1_BBOARD(3:LEN_BBOARD)//'::"TASK=BULLETIN1"')
 S
	IF (IER.EQ.0) THEN 
	   IF (.NOT.SAME) THEND
	      FOLDER1_FILE = FOLDER_FILEE
	      FOLDER_FILE = FOLDER_DIRECTORY(:TRIM(FOLDER_DIRECTORY))
     &		//FOLDER1)
	      REMOTE_SET_SAVE = REMOTE_SET 
	      REMOTE_SET = .FALSE.W
	      CALL OPEN_BULLDIR
	      CALL READDIR(0,IER)
	      CALL CLOSE_BULLDIR 
	      REMOTE_SET = REMOTE_SET_SAVE 
	      FOLDER_FILE = FOLDER1_FILE 
	      FOLDER_SAVE = FOLDER1
	      FOLDER1 = BULLDIR_HEADER(13:)
	   END IF
	   SYSLOG = .FALSE.
	   IF (READIT.EQ.1) THEN
	      WRITE (REMOTE_UNIT,'(2A)',IOSTAT=IER) 1,'SYSTEM?'
	      READ(REMOTE_UNIT,'(A)',IOSTAT=IER) IER1
	      IF (IER1) THENF
	         WRITE (REMOTE_UNIT,'(2A)',IOSTAT=IER) 1,FOLDER1//'+'
		 SYSLOG = .TRUE.
	      END IF.
	   END IF
	   IF (.NOT.SYSLOG) THENU
	      WRITE (REMOTE_UNIT,'(2A)',IOSTAT=IER) 1,FOLDER1
	   END IF
	   FOLDER_OWNER_SAVE = FOLDER1_OWNER
	   FOLDER_BBOARD_SAVE = FOLDER1_BBOARDT
	   FOLDER_NUMBER_SAVE = FOLDER1_NUMBERD
	   IF (IER.EQ.0) THEN
	      IF (SYSLOG) THENO
	         READ(REMOTE_UNIT,'(7A)',IOSTAT=IER)IER1,READ_ONLY,
     &		   DUMMY(1),DUMMY(2),DUMMY(3),DUMMY(4),FOLDER1_COM
	      ELSER
	         READ(REMOTE_UNIT,'(5A)',IOSTAT=IER)IER1,READ_ONLY,
     &		   DUMMY(1),DUMMY(2),FOLDER1_COM
	      END IF 
	   END IF
	   IF (.NOT.SAME) FOLDER1 = FOLDER_SAVE
	   FOLDER1_BBOARD = FOLDER_BBOARD_SAVE1
	   FOLDER1_NUMBER = FOLDER_NUMBER_SAVE1
	   FOLDER1_OWNER = FOLDER_OWNER_SAVE1
	END IF 
 
	IF (IER.NE.0.OR..NOT.IER1) THEN
	   CLOSE (UNIT=REMOTE_UNIT)
	   REMOTE_UNIT = 31 - REMOTE_UNIT
	   IF (IER.EQ.0.AND.FOLDER_NUMBER_SAVE.GE.0.AND.T
     &	       TEST_BULLCP().NE.2) THEN			! Not BULLCP process'
	      IF (TEST2(BRIEF_FLAG,FOLDER_NUMBER_SAVE) 
     &		  .OR.TEST2(SET_FLAG,FOLDER_NUMBER_SAVE)) THEN
	         CALL OPEN_BULLUSER_SHARED
	         CALL READ_USER_FILE_KEYNAME(USERNAME,IER)E
	         CALL CLR2(BRIEF_FLAG,FOLDER_NUMBER_SAVE)
	         CALL CLR2(SET_FLAG,FOLDER_NUMBER_SAVE)
	         IF (IER.EQ.0) REWRITE (4) USER_ENTRY
	         CALL CLOSE_BULLUSERT
	      END IF
	   END IF
	   IER = 2O
	ELSEA
	   CLOSE (UNIT=31-REMOTE_UNIT)t
Ce
C  If remote folder has returned a last read time for the folder,'
C  and if in /LOGIN mode, or last selected folder was a differentA
C  folder, or folder specified with "::", then update last read time.
C
	   IF (((FOLDER_NUMBER.NE.FOLDER1_NUMBER.OR.READIT.EQ.1)/
     &		.AND.(DUMMY(1).NE.0.OR.DUMMY(2).NE.0))
     &		.OR.FOLDER1_NUMBER.EQ.-1) THEN
	      LAST_READ_BTIM(1,FOLDER1_NUMBER+1) = DUMMY(1)
	      LAST_READ_BTIM(2,FOLDER1_NUMBER+1) = DUMMY(2)
	      IF (SYSLOG) THENT
	         LAST_SYS_BTIM(1,FOLDER1_NUMBER+1) = DUMMY(3)
	         LAST_SYS_BTIM(2,FOLDER1_NUMBER+1) = DUMMY(4)
	      END IFs
	   END IF
	   IER = 0U
	END IF_
 N
	RETURN 
	END
 1
 S
 T
	SUBROUTINE REMOTE_GET_HEADER(BULLETIN_NUM,ICOUNT,IER)
 .
	IMPLICIT INTEGER (A-Z)B
 E
	INCLUDE 'BULLDIR.INC'
 +
	INCLUDE 'BULLFOLDER.INC''
 
	COMMON /COMMAND_LINE/ INCMD
	CHARACTER*132 INCMD
 0
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 =
	COMMON /BUFFER/ BUFFER,SB,EBE
	CHARACTER BUFFER*1280
 E
	COMMON /MSGID/ MESSAGE_ID
	CHARACTER*255 MESSAGE_IDQ
 r
	COMMON /NEXT/ NEXTT
	LOGICAL NEXT /.FALSE./F
 :
	COMMON /NEWGROUP/ NEWGROUP 
 L
	CHARACTER*6 NUMBER)
 .
	CHARACTER IN_BTIM(2)&
 	
	IF (REMOTE_SET.EQ.1) THEN
	   IF (ICOUNT.GE.0) THEN 
	      WRITE (REMOTE_UNIT,'(2A)',IOSTAT=IER) 8,ICOUNT 
	   ELSE
	      WRITE (REMOTE_UNIT,'(3A)',IOSTAT=IER) 8,-1,MSG_KEY 
	   END IF
	   IF (IER.EQ.0) THEN
	      IF (ICOUNT.EQ.0) THEN
	         READ (REMOTE_UNIT,'(2A)',IOSTAT=IER) ICOUNT,BULLDIR_HEADER
	      ELSE IF (ICOUNT.EQ.-1) THEN
                 READ (REMOTE_UNIT,'(2A)',IOSTAT=IER1) IER,BULLDIR_ENTRY
	         IF (IER1.GT.0) THEN)
	            CALL ERROR_AND_EXIT
	         ELSE IF (IER.NE.0) THEN	
	            CALL CONVERT_ENTRY_FROMBINE
	         END IF
	         RETURN
	      ELSEI
	         READ (REMOTE_UNIT,'(2A)',IOSTAT=IER) ICOUNT,BULLDIR_ENTRY1
	      END IF 
	   END IF
	   IF (IER.GT.0) THEN
	      CALL ERROR_AND_EXIT
	   ELSE IF (ICOUNT.EQ.1) THEN
	      CALL CONVERT_HEADER_FROMBIN
	   ELSE
	      CALL CONVERT_ENTRY_FROMBIN 
	   END IF
	ELSE IF (REMOTE_SET.EQ.3) THEN 
	   IF (ICOUNT.EQ.0) THENC
	      NBULL = F_NBULL
	      ICOUNT = 1=
	      RETURN)
	   ELSE IF (ICOUNT.EQ.-1) THENR
	      IER = 2
	      CALL GET_MSGBTIM(MSG_KEY,IN_BTIM)
	      CALL REMOTE_GET_NEWEST_MSG(IN_BTIM,START)
	      IF (START.EQ.-1) RETURN
              IF (.NOT.NEWS_WRITE('HEAD')) CALL ERROR_AND_EXIT
              IF (.NOT.NEWS_READ()) CALL ERROR_AND_EXIT
	   ELSE
	      IER = 2
	      IF (NEXT.AND..NOT.NEWGROUP) THENT
	         IF (.NOT.NEWS_WRITE('NEXT')) CALL ERROR_AND_EXIT
		 IF (.NOT.NEWS_READ()) CALL ERROR_AND_EXIT
	         IF (BUFFER(:3).NE.'223') RETURNN
	         IF (.NOT.NEWS_WRITE('HEAD')) CALL ERROR_AND_EXIT
		 IF (.NOT.NEWS_READ()) CALL ERROR_AND_EXIT
	      ELSE 
		 IF (ICOUNT.LT.F_START) ICOUNT = F_START
		 IF (ICOUNT.GT.F_NBULL) ICOUNT = F_NBULL
	         IF (.NOT.OTS$CVT_L_TI(ICOUNT,NUMBER,,,)) RETURN 
	         IF (.NOT.NEWS_WRITE('HEAD '//NUMBER)) 
     &						CALL ERROR_AND_EXIT 
	         IF (.NOT.NEWS_READ()) CALL ERROR_AND_EXIT
	      END IF 
	      IF (BUFFER(:2).NE.'22') THEN 
	         DO WHILE (NEXT.AND.NEWGROUP.AND.ICOUNT.GT.F_START)
		    ICOUNT = ICOUNT - 1D
	            IF (.NOT.OTS$CVT_L_TI(ICOUNT,NUMBER,,,)) RETURN
	            IF (.NOT.NEWS_WRITE('HEAD '//NUMBER))
     &						CALL ERROR_AND_EXITL
	            IF (.NOT.NEWS_READ()) CALL ERROR_AND_EXIT
		    IF (BUFFER(:2).EQ.'22') NEXT = .FALSE.
	         END DO
	         IF (INCMD(:4).EQ.'BACK'.AND.ICOUNT.GE.F_START) THENU
	            IF (.NOT.NEWS_WRITE('LAST')) CALL ERROR_AND_EXIT 
		    IF (.NOT.NEWS_READ()) CALL ERROR_AND_EXIT 
	            IF (BUFFER(:3).NE.'223') RETURN
	            IF (.NOT.NEWS_WRITE('HEAD')) CALL ERROR_AND_EXITN
	            IF (.NOT.NEWS_READ()) CALL ERROR_AND_EXIT
		 ELSE IF (INCMD(:4).NE.'READ'.AND..NOT.NEXT) THEN.
                    IF (.NOT.NEWS_WRITE('NEXT')) CALL ERROR_AND_EXIT
                    IF (.NOT.NEWS_READ()) CALL ERROR_AND_EXIT 
                    IF (BUFFER(:3).NE.'223') RETURN0
                    IF (.NOT.NEWS_WRITE('HEAD')) CALL ERROR_AND_EXIT
                    IF (.NOT.NEWS_READ()) CALL ERROR_AND_EXIT:
	         END IF
	      END IFT
	      IF (BUFFER(:2).NE.'22') RETURNT
	      IER = OTS$CVT_TI_L(BUFFER(5:INDEX(BUFFER(5:),' ')+3),
     &							ICOUNT,,%VAL(1))
	      IF (.NOT.IER) RETURNE
	      START = ICOUNTF
	      BULLETIN_NUM = START
	   END IF
	   NEWGROUP = .FALSE.
	   MESSAGE_ID = BUFFER(INDEX(BUFFER,'<'):INDEX(BUFFER,'>'))
	   IER = 0E
	   CALL NEWS_HEADER(IER)
	   IF (IER.GT.0) THEN
	      CALL ERROR_AND_EXIT
	   ELSE
	      CALL CONVERT_ENTRY_FROMBINr
	   END IF
	   BLOCK = STARTN
	   MSG_NUM = STARTM
	   SYSTEM = 0
	   IF (ICOUNT.NE.-1) THEN
	      ICOUNT = ICOUNT + 1
	   ELSE
	      IER = START
	   END IF
	END IFC
 
	RETURNC
	END
 I
 E
 S
 E
 O
        SUBROUTINE GET_MSGBTIM(MSG_KEY,BTIM)
 S
        IMPLICIT INTEGER (A-Z)
 T
        INTEGER BTIM(2)R
 I
        CHARACTER*8 MSG_KEY,INPUTD
 N
	INPUT = MSG_KEY
 I
        DO I=1,8
           INPUT(9-I:9-I) = MSG_KEY(I:I)
        END DO
 '
        CALL LIB$MOVC3(8,%REF(INPUT),BTIM(1))_
 E
        RETURN
	END
 A
 R
  
	SUBROUTINE NEWS_GROUP(IER)D
 Y
	IMPLICIT INTEGER (A-Z)E
 '
	INCLUDE 'BULLFOLDER.INC'D
 0
	COMMON /BUFFER/ BUFFER,SB,EBE
	CHARACTER BUFFER*1280
 R
	COMMON /NEWGROUP/ NEWGROUPN
 _
	IER = NEWS_WRITE('GROUP '//FOLDER1_DESCRIP(:TRIM(FOLDER1_DESCRIP)))
	IF (.NOT.IER) RETURNE
 N
	IER = NEWS_READ()
	IF (.NOT.IER) RETURNU
 _
	IF (BUFFER(:3).EQ.'411') THEN
	   CALL OPEN_BULLNEWS_SHAREDI
	   CALL READ_FOLDER_FILE_KEYNAME_TEMP(FOLDER1,IER1)
	   IF (IER1.EQ.0) DELETE (7)S
	   CALL CLOSE_BULLFOLDER
           RETURNN
	END IF 
 
	NEWGROUP = .TRUE.
 I
	BUFFER = BUFFER(5:)
 N
	IER = OTS$CVT_TI_L(BUFFER(:INDEX(BUFFER,' ')-1),F1_END,,%VAL(1))D
	IF (.NOT.IER) RETURN)
	BUFFER = BUFFER(INDEX(BUFFER,' ')+1:)
	IER = OTS$CVT_TI_L(BUFFER(:INDEX(BUFFER,' ')-1),F1_START,,%VAL(1))=
	IF (.NOT.IER) RETURN(
	BUFFER = BUFFER(INDEX(BUFFER,' ')+1:)
	IER = OTS$CVT_TI_L(BUFFER(:INDEX(BUFFER,' ')-1),F1_NBULL,,%VAL(1)) 
	IF (.NOT.IER) RETURN
	BUFFER = BUFFER(INDEX(BUFFER,' ')+1:)
 S
	IER = 0
  
	RETURNT
	END
 E
 E
 T
	SUBROUTINE NEWS_TIME(INTIME,BTIM)
 L
	IMPLICIT INTEGER (A-Z)F
 E
	CHARACTER*(*) INTIMEL
 R
	CHARACTER*20 TIME
 F
	I = 1
	LTIME = TRIM(INTIME)(
	DO WHILE (I.LE.LTIME.AND.(ICHAR(INTIME(I:I)).LT.ICHAR('0').OR.1
     &		  ICHAR(INTIME(I:I)).GT.ICHAR('9')))
	   I = I + 1 
	END DOI
 )
	IF (I.GT.LTIME) THEN 
	   CALL SYS_BINTIM('-',BTIM) 
	   RETURN
	END IFS
  
	CALL STR$UPCASE(TIME,INTIME(I:))F
  
	DO J = 1,2S
	   I = 1
	   DO WHILE (TIME(I:I).NE.' ')I
	      I = I + 1
	   END DO
	   TIME(I:I) = '-'S
	END DOD
 _
	IF (TIME(I+1:I+1).EQ.'9'.OR.TIME(I+1:I+1).EQ.'8') THEND
	   TIME = TIME(:I)//'19'//TIME(I+1:)F
	ELSEQ
	   TIME = TIME(:I)//'20'//TIME(I+1:) 
	END IFD
 M
	I = 1
	DO J = 1,2T
	   DO WHILE (TIME(I:I).NE.' '.AND.I.LE.LEN(TIME))
	      I = I + 1
	   END DO
	   I = I + 1 
	END DOE
 R
	CALL SYS_BINTIM(TIME(:I-2),BTIM)E
 O
	RETURN 
        END1
 U
 (
 F
	SUBROUTINE NEWS_LISTI
 
	IMPLICIT INTEGER (A-Z)S
 )
	INCLUDE 'BULLFOLDER.INC' 
 D
	COMMON /BUFFER/ BUFFER,SB,EB1
	CHARACTER BUFFER*1280
 E
	IF (.NOT.NEWS_LOGIN()) RETURN
  
	IF (.NOT.NEWS_WRITE('LIST')) RETURN
	IF (.NOT.NEWS_READ()) RETURN 
	IF (BUFFER(:3).NE.'215') RETURN
 E
	CALL OPEN_BULLNEWS_SHARED	! Open folder fileF
 E
	NEWS_FOLDER1_BBOARD = '::' 
  
	CALL READ_FOLDER_FILE_KEYNUM_TEMP(1000,IER1)r
	IF (IER1.NE.0) THEN
	   NEWS_FOLDER1 = 'a'
	   NEWS_FOLDER1_NUMBER = 1000
	   NEWS_F1_END = 1001
	   WRITE (7,IOSTAT=IER) NEWS_FOLDER1_COMA
	END IF 
	IF (NEWS_F1_END.LT.1001) NEWS_F1_END = 1001
	NEWS_F_END = NEWS_F1_ENDE
	LAST_READ = NEWS_FOLDER1_NUMBER
	DO WHILE (NEWS_READ().AND.BUFFER(SB:EB).NE.'.')
	   FLEN = INDEX(BUFFER(SB:),' ') - 1Y
	   NEWS_FOLDER1 = BUFFER(SB:MIN(25,FLEN)+SB-1)
	   IF (IER1.EQ.0) THEN
	      CALL READ_FOLDER_FILE_KEYNAME_TEMP(NEWS_FOLDER1,IER)l
	   END IF
	   SP = FLEN+SB+1
	   EP = INDEX(BUFFER(SP:),' ')+SP-2
	   IER2 = OTS$CVT_TI_L(BUFFER(SP:EP),NEWS_F1_NBULL,,%VAL(1)) 
	   SP = EP + 2w
	   EP = INDEX(BUFFER(SP:),' ')+SP-2
	   IER2 = OTS$CVT_TI_L(BUFFER(SP:EP),NEWS_F1_START,,%VAL(1))/
	   CALL SYS_BINTIM('-',NEWS_F1_NEWEST_BTIM)
	   IF (IER.NE.0.OR.IER1.NE.0) THEN 
	      IF (FLEN.GT.25) THEN,
	         NEWS_FOLDER1_DESCRIP = BUFFER(SB+25:FLEN+SB-1)
	      ELSE 
	         NEWS_FOLDER1_DESCRIP = ' '
	      END IFS
	      IER = 0
	      DO WHILE (IER.EQ.0.AND.IER1.EQ.0)
		 DO WHILE (REC_LOCK(IER))U
	            READ (7,KEY=NEWS_F_END,KEYID=1,IOSTAT=IER)_
	         END DO
		 IF (IER.EQ.0) NEWS_F_END = NEWS_F_END + 1
	      END DOO
	      NEWS_FOLDER1_NUMBER = NEWS_F_ENDE
	      WRITE (7,IOSTAT=IER) NEWS_FOLDER1_COM
	      IF (IER.EQ.0) NEWS_F_END = NEWS_F_END + 1
	   ELSE IF (F1_START.NE.NEWS_F1_START.OR.
     &		    F1_NBULL.NE.NEWS_F1_NBULL) THEN/
	      REWRITE (7,IOSTAT=IER) NEWS_FOLDER1_COM
	      DO I = LAST_READ+1,NEXT_READ-1M
		 DO WHILE (REC_LOCK(IER))		! Delete non-existant
	            READ (7,KEY=I,KEYID=1,IOSTAT=IER)	! newsgroups6
	         END DO
		 IF (IER.EQ.0) DELETE (UNIT=7)		  
	      END DO 
	      LAST_READ = NEXT_READ
	   END IF
	END DO,
 A
	CALL READ_FOLDER_FILE_KEYNUM_TEMP(1000,IER1)E
	NEWS_F1_END = NEWS_F_END=
	REWRITE (7) NEWS_FOLDER1_COM
  
	CALL CLOSE_BULLNEWS
  
	RETURNN
        END
  
  
	SUBROUTINE LOWERCASE(INPUT)
 =
	CHARACTER*(*) INPUT
 R
	DO I=1,LEN(INPUT)
	   IF (INPUT(I:I).GE.'A'.AND.INPUT(I:I).LE.'Z') THEN2
	      INPUT(I:I) = CHAR(ICHAR(INPUT(I:I)) - ICHAR('A') + ICHAR('a')) 
	   END IF
	END DON
 X
	RETURN 
	END
 I
 I
 N
	SUBROUTINE NEWS_POST(FILENAME,FILEOPEN,IER,SUBJECT)
  
	IMPLICIT INTEGER (A-Z)E
 N
	INCLUDE 'BULLNEWS.INC' 
 D
	INCLUDE 'BULLFOLDER.INC'=
 )
	INCLUDE 'BULLUSER.INC' 
  
	COMMON /BUFFER/ BUFFER,SB,EBE
	CHARACTER BUFFER*1280
 R
	COMMON /REF/ REFERENCES,LREFN
	CHARACTER*255 REFERENCESO
 R
	COMMON /PATH/ PATHNAME,LPATH 
	CHARACTER*132 PATHNAMEM
  
	COMMON /COMMAND_LINE/ INCMD
	CHARACTER*132 INCMD
 (
	COMMON /MSGID/ MESSAGE_ID
	CHARACTER*255 MESSAGE_IDN
  
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 R
	COMMON /NEWSGROUPS/ NEWSGROUPS_
	CHARACTER*255 NEWSGROUPS 
  
	CHARACTER*(*) FILENAME,SUBJECTI
 T
	CHARACTER TODAY*23,MSGID*23,ZONE*5
  
	DIMENSION NOW(2),GMT(2)
 (
	IER = 1
  
	IF (FILENAME.NE.'cancel') THEN(
	   IF (.NOT.FILEOPEN) THENA
	      OPEN (UNIT=3,FILE=FILENAME,STATUS='OLD',IOSTAT=IER1)N
	      IF (IER1.NE.0) RETURN
	   END IF
 (
	   IER1 = 0
	   DO WHILE (IER1.EQ.0)
	      READ (3,'(A)',IOSTAT=IER1) BUFFER
	      IF (IER1.NE.0) GO TO 900R
	      IF (TRIM(BUFFER).GT.0) IER1 = 1
	   END DO
 N
	   REWIND (UNIT=3)E
	END IF)
 L
	IF (.NOT.NEWS_LOGIN()) GO TO 900I
 I
	IF (LPATH.EQ.0) CALL GET_PATHNAME
 I
	IF (.NOT.NEWS_WRITE('POST')) GO TO 900 
	IF (.NOT.NEWS_READ()) GO TO 900
	IF (BUFFER(:3).NE.'340') THEN
	   WRITE (6,'('' ERROR: Posting not allowed.'')')
	   GO TO 900D
	END IF 
  
	IF (REMOTE_SET.GE.3) THEN
	   IF (TRIM(NEWSGROUPS).GT.0.AND.INCMD(:2).EQ.'RE') THENE
	      IF (.NOT.NEWS_WRITE('Newsgroups: '//W
     &	          NEWSGROUPS(:TRIM(NEWSGROUPS)))) GO TO 900
	   ELSE IF (REMOTE_SET.EQ.4) THEN
	      IF (.NOT.NEWS_WRITE('Newsgroups: '//.
     &	          FOLDER1_DESCRIP(:TRIM(FOLDER1_DESCRIP)))) GO TO 900
	   ELSE
	      IF (.NOT.NEWS_WRITE('Newsgroups: '// 
     &	          FOLDER_DESCRIP(:TRIM(FOLDER_DESCRIP)))) GO TO 900
	   END IF
	   NEWSGROUPS = ' '
	END IFR
	IF (.NOT.NEWS_WRITE('Path: '//PATHNAME(:LPATH))) GO TO 900R
	IF (.NOT.NEWS_WRITE('From: '//PATHNAME(INDEX(PATHNAME,'!')+1:
     &	   TRIM(PATHNAME))//'@'//PATHNAME(:INDEX(PATHNAME,'!')-1)))
     &	   GO TO 900L
	IF (.NOT.NEWS_WRITE('Subject: '//SUBJECT(:TRIM(SUBJECT))))O
     &	   GO TO 900F
 N
	IF (INCMD(:2).EQ.'RE') THEN
	   IF (.NOT.NEWS_WRITE('References: '//REFERENCES(:LREF)))L
     &	      GO TO 900
	END IF 
  
	CALL SYS$ASCTIM(,TODAY(:23),,)A
 E
	IF (LZONE.EQ.0) THEN 
	   IF (SYS_TRNLNM_SYSTEM('LISP$TIME_ZONE',ZONE)) THEN
	      IER = OTS$CVT_TI_L(ZONE(:TRIM(ZONE)),DIFF,,%VAL(1))
	      IF (DIFF.LT.0) THEN
		 PAST = .TRUE.
	         ZONE = ZONE(2:) 
	      ELSE IF (DIFF.GT.12) THEN
		 PAST = .TRUE.
		 DIFF = 24 - DIFFT
	         IER = OTS$CVT_L_TI(DIFF,ZONE(1:2),,,)	
		 IF (ZONE(1:1).EQ.' ') ZONE = ZONE(2:)
	      ELSE 
	         PAST = .FALSE.
	      END IF 
	      IER = SYS_BINTIM('0 '//ZONE(:TRIM(ZONE))//':00',GMT)=
	      IER = SYS$GETTIM(NOW)
	      IF (PAST) THEN 
	         IER = LIB$ADDX(NOW,GMT,GMT)F
	      ELSEH
	         IER = LIB$SUBX(NOW,GMT,GMT)E
	      END IFO
	      IER = SYS$ASCTIM(,TODAY,GMT,)
	      ZONE = 'GMT'S
	   ELSE IF (.NOT.SYS_TRNLNM_SYSTEM('MULTINET_TIMEZONE',ZONE) 
     &         .AND..NOT.SYS_TRNLNM_SYSTEM('PMDF_TIMEZONE',ZONE)) THEN
	      ZONE = 'GMT'D
	   END IF
	   LZONE = TRIM(ZONE)
	END IFM
 T
	MSGID = TODAY(:2)//TODAY(4:6)//TODAY(10:11)//'.'//
     &		TODAY(13:14)//TODAY(16:17)//TODAY(19:20)//TODAY(22:23)
	IF (MSGID(1:1).EQ.' ') MSGID = MSGID(2:)I
	IF (.NOT.NEWS_WRITE('Message-ID: <'//MSGID(:TRIM(MSGID))//O
     &	    '@'//PATHNAME(:INDEX(PATHNAME,'!')-1)//'>')) GO TO 900E
 N
	TODAY = TODAY(:2)//' '//TODAY(4:6)//' '//TODAY(10:20)
	IF (TODAY(1:1).EQ.' ') TODAY = TODAY(2:)O
 R
	IF (LORGAN.EQ.0) THEN
	   LORGAN = TRIM(ORGANIZATION)F
	   IF (LORGAN.EQ.0) THENR
	      IF (.NOT.SYS_TRNLNM_SYSTEM('BULL_NEWS_ORGANIZATION',I
     &					ORGANIZATION)) THEN
	         LORGAN = -1
	      ELSEE
	         LORGAN = TRIM(ORGANIZATION)B
	      END IF1
	   END IF
	END IFE
 U
	IF (LORGAN.GT.0) THEN
	   IF (.NOT.NEWS_WRITE('Organization: '//ORGANIZATION(:LORGAN)))L
     &		GO TO 900C
	END IFF
 E
	IF (.NOT.NEWS_WRITE('Date: '//TODAY(:TRIM(TODAY))//' '//I
     &		ZONE(:LZONE))) GO TO 900
 S
	IF (FILENAME.EQ.'cancel') THEN'
	   IF (.NOT.NEWS_WRITE('Control: cancel '
     &		//MESSAGE_ID(:TRIM(MESSAGE_ID)))) RETURN
	   IF (.NOT.NEWS_WRITE('.')) RETURN
	   IF (.NOT.NEWS_READ()) RETURN
	   IF (BUFFER(:3).EQ.'240') IER = 0
	   RETURN
	END IFR
 O
	IF (.NOT.NEWS_WRITE(' ')) GO TO 900
 F
	IER1 = 0A
	DO WHILE (IER1.EQ.0)R
	   READ (3,'(Q,A)',IOSTAT=IER1) ILEN,BUFFER
	   IF (BUFFER(:ILEN).EQ.'.') THEN
	      BUFFER = '..'
	      ILEN = 2E
	   END IF
	   IF (IER1.EQ.0.AND..NOT.NEWS_WRITE(BUFFER(:ILEN))) GO TO 900T
	END DOE
 F
	IF (.NOT.NEWS_WRITE('.')) GO TO 900
	IF (.NOT.NEWS_READ()) GO TO 900
	IF (BUFFER(:3).EQ.'240') IER = 0	
 C
900	IF (FILENAME.NE.'cancel'.AND..NOT.FILEOPEN) CLOSE (UNIT=3)
  
	RETURNM
	END
 
  
 L
	SUBROUTINE GET_PATHNAME
 E
	IMPLICIT INTEGER (A-Z) 
 $
	INCLUDE 'BULLUSER.INC'
 
	COMMON /PATH/ PATHNAME,LPATHO
	CHARACTER*132 PATHNAMEI
  
	IF (NEWS_GETHOSTNAME(PATHNAME).EQ.-1) THEN-
	   IF (.NOT.SYS_TRNLNM_SYSTEM('ARPANET_HOST_NAME',PATHNAME).AND.)
     &	    .NOT.SYS_TRNLNM_SYSTEM('INTERNET_HOST_NAME',PATHNAME)) THEN
	      WRITE (6,'('' ERROR: Cannot find local host name.'')') 
	      RETURNI
	   END IF
	END IFE
	   
	PATHNAME = PATHNAME(:TRIM(PATHNAME))//'!'
     &			//USERNAME(:TRIM(USERNAME))
	CALL LOWERCASE(PATHNAME)R
	LPATH = TRIM(PATHNAME)
 
	RETURNN
	END
 S
 
 
 P
	SUBROUTINE NEWS2BULL)
 I
	IMPLICIT INTEGER (A-Z)
 
	INCLUDE 'BULLFOLDER.INC'E
 
	COMMON /COMMAND_LINE/ INCMD
	CHARACTER*132 INCMD
 U
	COMMON /BUFFER/ BUFFER,SB,EBI
	CHARACTER BUFFER*1280
 S
	EXTERNAL BULLETIN_SUBCOMMANDS
 E
	CHARACTER TIME*20,FIRST*80,FOLDER_SAVE*25
 !
	CHARACTER*6 NUMBERE
 N
	DIMENSION SAVE_F_NEWEST_BTIM(2)
  
	CALL ALLPRIVE
 Y
	CALL NEWS_LIST1
 
	CALL INIT_QUEUE(FOLDER_Q1,FOLDER_COM)
 '
	FOLDER_Q = FOLDER_Q1E
  
	CALL OPEN_BULLFOLDER_SHARED		! Get folder file=
 )
	NUM_FOLDERS = 0
	IER = 0
	DO WHILE (IER.EQ.0)			! Find folders with news feed
	   CALL READ_FOLDER_FILE(IER)
	   IF (IER.EQ.0) THEN
	      SLIST = INDEX(FOLDER_DESCRIP,'<')
	      IF (SLIST.GT.0) THENE
		 IF ((INDEX(FOLDER_DESCRIP,'@').LE.SLIST.OR.
     &		      FOLDER_DESCRIP(SLIST+1:SLIST+1).EQ.'@').AND.
     &		     INDEX(FOLDER_DESCRIP,'.').GT.SLIST) THEN 
		    NUM_FOLDERS = NUM_FOLDERS + 1X
	   	    CALL WRITE_QUEUE(%VAL(FOLDER_Q),FOLDER_Q,FOLDER_COM)E
	         END IF
	      END IFE
	   END IF
	END DOX
 F
	CALL CLOSE_BULLFOLDER			! We don't need file anymoreP
 E
	IF (NUM_FOLDERS.EQ.0.OR..NOT.NEWS_LOGIN()) CALL EXIT_
 E
	FOLDER_Q = FOLDER_Q1E
	POINT_FOLDER = 0E
	FILEOPEN = .FALSE.T
	DO WHILE (POINT_FOLDER.LT.NUM_FOLDERS)P
	   IF (.NOT.FILEOPEN) THEN 
	      POINT_FOLDER = POINT_FOLDER + 1
	      CALL READ_QUEUE(%VAL(FOLDER_Q),FOLDER_Q,FOLDER_COM)
	      CALL SELECT_FOLDER(.FALSE.,IER)
	      SAVE_F_NEWEST_BTIM(1) = F_NEWEST_BTIM(1),
	      SAVE_F_NEWEST_BTIM(2) = F_NEWEST_BTIM(2)R
	      FOLDER_SAVE = FOLDERD
	      FOLDER_DESCRIP = FOLDER_DESCRIP(INDEX(FOLDER_DESCRIP,'<')+1:)
	      FOLDER_DESCRIP = FOLDER_DESCRIP(:INDEX(FOLDER_DESCRIP,'>')-1)
	      IF (FOLDER_DESCRIP(1:1).EQ.'@'.AND.IER) THENS
	         OPEN (UNIT=3,FILE=FOLDER_DESCRIP(2:TRIM(FOLDER_DESCRIP))
     &			,STATUS='OLD',IOSTAT=IER1) 
		 IF (IER1.EQ.0) THEN
	            READ (3,'(A)',IOSTAT=IER1) FOLDER_DESCRIP
		    IF (IER1.NE.0) CLOSE (UNIT=3)K
	            IF (IER1.EQ.0) FILEOPEN = .TRUE. 
		 END IFI
	      ELSET
	         IER1 = 0
	      END IF 
	   END IF
	   IF (IER.AND.IER1.EQ.0) THEN,
	      FOLDER_NUMBER = -1E
	      FOLDER1 = FOLDER_DESCRIP(:TRIM(FOLDER_DESCRIP))
	      CALL SELECT_FOLDER(.FALSE.,IER)
	      IF (IER) THEN
	         CALL REMOTE_GET_NEWEST_MSG(SAVE_F_NEWEST_BTIM,START)
		 IF (START.GE.F_START) THEN=
	            CALL OTS$CVT_L_TI(START,NUMBER,,,)(
	            INCMD = 'COPY/ORIGINAL '//FOLDER_SAVE(:TRIM(I
     &			FOLDER_SAVE))//' '//NUMBER//'-LAST'
	            CALL CLI$DCL_PARSE(INCMD,BULLETIN_SUBCOMMANDS)(
		    CALL MOVE(.FALSE.)
	         END IF
	      END IFE
	      IF (FILEOPEN) THENC
	         READ (3,'(A)',IOSTAT=IER1) FOLDER_DESCRIPL
		 IF (IER1.NE.0) CLOSE (UNIT=3)
	         IF (IER1.NE.0) FILEOPEN = .FALSE.M
	      END IFE
	   END IF
	END DOR
 5
	CALL EXIT
	END
 M
  
 T
	SUBROUTINE DATE_TIME(TIME)R
 2
	IMPLICIT INTEGER (A-Z)C
 A
	CHARACTER*36 MONTHA
	DATA MONTH/'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'/A
 R
	CHARACTER*(*) TIME
 M
	NMONTH = (INDEX(MONTH,TIME(4:6))+2)/3
 
	IF (TIME(1:1).EQ.' ') TIME(1:1) = '0'
 A
	TIME = TIME(10:11)//CHAR(ICHAR('0')+NMONTH/10)//CHAR(ICHAR('0')+A
     &		 MOD(NMONTH,10))//TIME(1:2)//' '//TIME(13:14)//M
     &		 TIME(16:17)//TIME(19:20)M
 E
	RETURN)
	END
  
 F
 N
	SUBROUTINE ALLPRIV 
  
        IMPLICIT INTEGER (A-Z)
 '
	COMMON /PRIVILEGES/ PROCPRIV(2),NEEDPRIV(2)
 
	PROCPRIV(1) = -1 
	PROCPRIV(2) = -1I
	NEEDPRIV(1) = -1 
	NEEDPRIV(2) = -1S
 =
	RETURNF
	END
  
  
 R
	SUBROUTINE NEWS_NEW_FOLDER 
 I
	IMPLICIT INTEGER (A-Z)
  
	INCLUDE 'BULLFOLDER.INC'T
 E
	READ (7,IOSTAT=IER,KEYEQ=1000,KEYID=1) NEWS_FOLDER_COMI
 L
	NEWS_FOLDER1 = FOLDER1A
	NEWS_FOLDER1_DESCRIP = FOLDER1_DESCRIP(26:)
 
        DO WHILE (IER.EQ.0)9
	   READ (7,IOSTAT=IER,KEYEQ=NEWS_F_END,KEYID=1)
	   IF (IER.EQ.0) NEWS_F_END = NEWS_F_END + 1 
        END DO
 
        NEWS_FOLDER1_NUMBER = NEWS_F_END
	CALL SYS_BINTIM('-',NEWS_F1_NEWEST_BTIM)E
        WRITE (7,IOSTAT=IER) NEWS_FOLDER1_COM
  
	READ (7,KEYEQ=1000,KEYID=1) NEWS_FOLDER1_COM 
	NEWS_F1_END = NEWS_F_END_
	REWRITE (7) NEWS_FOLDER1_COM.
 S
	RETURNe
	END
  
 .
  
	SUBROUTINE SUBSCRIBED
 R
	IMPLICIT INTEGER (A-Z))
 G
	INCLUDE 'BULLUSER.INC' 
  
	INCLUDE 'BULLFOLDER.INC's
 /
	COMMON /REMOTE_FOLDER/ REMOTE_SET,REMOTE_UNIT
 S
	IF (REMOTE_SET.NE.3) THEN
	   WRITE (6,'('' ERROR: Selected folder is not a news folder.'')')T
	   RETURN
	END IF 
 R
	I = 1
	DO WHILE (LAST_NEWS_READ2(1,I).NE.NEWS_FOLDER_NUMBER.AND.
     &		LAST_NEWS_READ2(1,I).NE.0.AND.I.LE.FOLDER_MAX)
	   I = I + 1&
	END DO 
 L
	IF (I.GT.FOLDER_MAX) THEN
	   WRITE (6,'('' ERROR: Cannot subscribe.  You have '',
     &		    '' reached the news folder limit of '',I,''.'')') 
     &		    FOLDER_MAX
	   RETURN
	ELSE IF (LAST_NEWS_READ2(1,I).EQ.NEWS_FOLDER_NUMBER) THEN
	   WRITE (6,'('' You are already subscribed to '',A,''.'')')L
     &			FOLDER_NAME(:TRIM(FOLDER_NAME))
	   RETURN
	ELSER
	   WRITE (6,'('' You are now subscribed to '',A,''.'')')S
     &			FOLDER_NAME(:TRIM(FOLDER_NAME))
	END IF 
 (
	LAST_NEWS_READ2(1,I) = NEWS_FOLDER_NUMBER
	IF (F_START.LE.F_NBULL) THENT
	   LAST_NEWS_READ2(2,I) = F_NBULL - (F_START - 1)
	   LAST_NEWS_READ(2,I) = F_START - 1 
	ELSEA
	   LAST_NEWS_READ2(2,I) = 0
	   LAST_NEWS_READ(2,I) = F_NBULL:
	END IF)
 '
	RETURN=
	END
 I
 =
 S
	SUBROUTINE UNSUBSCRIBEP
 )
	IMPLICIT INTEGER (A-Z)I
 D
	INCLUDE 'BULLUSER.INC'E
 H
	INCLUDE 'BULLFOLDER.INC'N
 G
	I = NEWS_FIND_SUBSCRIBE()
  
	IF (I.GT.FOLDER_MAX) THEN
	   WRITE (6,'('' ERROR: You are not subscribed to '',A,''.'')')
     &			FOLDER_NAME(:TRIM(FOLDER_NAME))
	   RETURN
	ELSEY
	   WRITE (6,'('' You are now no longer subscribed to '',A,''.'')') 
     &			FOLDER_NAME(:TRIM(FOLDER_NAME))
	END IF:
 /
	DO J=I,FOLDER_MAX-1
	   LAST_NEWS_READ(1,J) = LAST_NEWS_READ(1,J+1)O
	   LAST_NEWS_READ(2,J) = LAST_NEWS_READ(2,J+1) 
	END DOS
 (
	LAST_NEWS_READ(1,FOLDER_MAX) = 0-
	LAST_NEWS_READ(2,FOLDER_MAX) = 0 
  
	RETURNA
	END
 N
 (
 H
	SUBROUTINE NEWS_GET_NEWEST_MESSAGE(IER)
 T
	IMPLICIT INTEGER (A-Z)/
 '
	INCLUDE 'BULLUSER.INC'Y
 1
	INCLUDE 'BULLFOLDER.INC'O
 R
	I = NEWS_FIND_SUBSCRIBE()
 O
	IER = LAST_NEWS_READ(2,I) + 1
 (
	IF (I.GT.FOLDER_MAX.OR.IER.GT.F_NBULL) THEN
	   IER = 0_
	   RETURN
	END IF
  
	RETURNG
	END
 )
 H
 
	SUBROUTINE NEWS_UPDATE_NEWEST_MESSAGE(NUMBER)
 G
	IMPLICIT INTEGER (A-Z)
  
	INCLUDE 'BULLUSER.INC'E
 I
	INCLUDE 'BULLFOLDER.INC'H
 
	I = NEWS_FIND_SUBSCRIBE()
 z
	IF (I.GT.FOLDER_MAX) RETURN
 L
	IF (NUMBER.GT.LAST_NEWS_READ(2,I)) THEN
	   LAST_NEWS_READ(2,I) = NUMBER
	   LAST_NEWS_READ2(2,I) =
     &		(F_NBULL-NUMBER).OR.(LAST_NEWS_READ2(2,I).AND.'C000'X)
	END IFN
 N
	RETURN(
	END
  
 c
 '
  
 &
	SUBROUTINE NEWS_GET_SUBSCRIBE(SUBNUM,SUBMSG) 
 (
	IMPLICIT INTEGER (A-Z)U
 
	INCLUDE 'BULLUSER.INC' 
 U
	IF (SUBNUM.EQ.0) THEN
	   COUNT = 00
	   SUBMSG = LAST_NEWS_READ(2,1)
	   RETURN
	ELSE IF (SUBNUM.EQ.-1) THEN
	   DO J=COUNT,FOLDER_MAX-1
	      LAST_NEWS_READ(1,J) = LAST_NEWS_READ(1,J+1)
	      LAST_NEWS_READ(2,J) = LAST_NEWS_READ(2,J+1)
	   END DO
 E
	   LAST_NEWS_READ(1,FOLDER_MAX) = 0
	   LAST_NEWS_READ(2,FOLDER_MAX) = 0
	ELSED
	   COUNT = COUNT + 1S
	END IF'
 G
	IF (COUNT.LE.FOLDER_MAX) THEN
	   SUBNUM = LAST_NEWS_READ2(1,COUNT)E
	   SUBMSG = LAST_NEWS_READ(2,COUNT)
	ELSE.
	   SUBNUM = 0
	END IF=
 
	RETURNR
	END
 
 
 
 
	SUBROUTINE NEWS_NEW_NOTIFICATION(MESSAGES)E
CA
C  SUBROUTINE NEW_NOTIFICATION
C
 
	IMPLICIT INTEGER (A-Z)P
 O
	INCLUDE 'BULLFOLDER.INC'
 
	INCLUDE 'BULLUSER.INC'H
 E
	COMMON /READIT/ READITN
 S
	COMMON /POINT/ BULL_POINT
 N
	COMMON /LOGIN_BTIM/ LOGIN_BTIM_SAVE(2)_
 L
	CHARACTER*1 DUMMY
 T
	MESSAGES = .FALSE.N
  
	IF (.NOT.SYS_TRNLNM('BULL_NEWS_SERVER',DUMMY)) RETURN
  
	CALL NEWS_GET_SUBSCRIBE(0,MSGNUM)
	IF (MSGNUM.EQ.0) RETURN
 E
	CALL OPEN_BULLNEWS_SHARED
	SUBNUM = 1M
 T
	DO WHILE (SUBNUM.GT.0)E
	   IER = 1E
	   DO WHILE (SUBNUM.NE.0.AND.IER.NE.0)N
	      CALL NEWS_GET_SUBSCRIBE(SUBNUM,MSGNUM)
	      IF (SUBNUM.NE.0) THEN
	         CALL READ_FOLDER_FILE_KEYNUM(SUBNUM,IER)
		 IF (IER.EQ.0.AND.
     &			MSGNUM.GT.F_NBULL.AND.F_START.LE.F_NBULL) THENT
		    CALL NEWS_UPDATE_NEWEST_MESSAGE(F_START)
	         ELSE IF (IER.NE.0) THEN,
		    SUBNUM = -1
		 ELSE IF (MSGNUM.GE.F_NBULL) THENS
		    IER = 1I
		 END IFC
	      END IFY
	      IF (IER.EQ.0.AND.SUBNUM.GT.0) THENL
		 IF (READIT.EQ.1) THEN
		    IF (.NOT.TEST_BRIEF_FLAG(NEWS_FOLDER_NUMBER).AND. 
     &		        .NOT.TEST_SET_FLAG(NEWS_FOLDER_NUMBER)) THEN
		       IER = 1
		    ELSE IF (.NOT.TEST_BRIEF_FLAG(NEWS_FOLDER_NUMBER).OR.F
     &			.NOT.TEST_SET_FLAG(NEWS_FOLDER_NUMBER).OR.,
     &			NEW_FLAG(2).NE.-1) THEN
	               DIFF = COMPARE_BTIM(LOGIN_BTIM_SAVE,F_NEWEST_BTIM)
		       IF (DIFF.GT.0) IER = 1'
		    END IF
		 END IFX
	      END IF,
	   END DO
	   IF (READIT.EQ.0.AND.SUBNUM.GT.0) THEN 
	      WRITE (6,'('' There are new messages in folder '',R
     &		     A,''.'',$)') FOLDER_DESCRIP(1:TRIM(FOLDER_DESCRIP))
	      MESSAGES = .TRUE.
	   ELSE IF (SUBNUM.GT.0) THEN
	      IF (TEST_BRIEF_FLAG(NEWS_FOLDER_NUMBER)
     &		  .AND.TEST_SET_FLAG(NEWS_FOLDER_NUMBER)) THEN
		 WRITE (6,'('' There are new messages in folder ''
     &		     A,''.'',$)') FOLDER_DESCRIP(1:TRIM(FOLDER_DESCRIP))
	      ELSE+
		 CALL CLOSE_BULLNEWS
	         CALL SELECT_FOLDER(.FALSE.,IER1)
		 IF (IER1) THENE
		    CALL LOGIN_FOLDERV
	            IF (BULL_POINT.NE.-1) THEN 
		     IF (.NOT.TEST_BRIEF_FLAG(NEWS_FOLDER_NUMBER)) THENE
		       SAVE_BULL_POINT = BULL_POINT 
		       REDO = .TRUE.
		       DO WHILE (REDO)
		          REDO = .FALSE.
		          CALL READNEW(REDO)
			  IF (REDO) CALL REDISPLAY_DIRECTORY.
			  BULL_POINT = SAVE_BULL_POINT(
		       END DOR
		     END IF(
		    END IF
		 END IF	
		 CALL OPEN_BULLNEWS_SHARED
	      END IF0
	   END IF
	END DOR
  
	CALL CLOSE_BULLNEWS
 D
	RETURNP
	END
 F
 E
 N
	LOGICAL FUNCTION TEST_SET_FLAG(NUMBER)R
 Q
	IMPLICIT INTEGER (A-Z)	
 D
	INCLUDE 'BULLUSER.INC' 
  
	IF (NUMBER.GE.0.AND.NUMBER.LE.FOLDER_MAX) THEN.
	   TEST_SET_FLAG = TEST2(SET_FLAG,NUMBER)
	   RETURN
	END IF=
 L
	I = NEWS_FIND_SUBSCRIBE()
 P
	TEST_SET_FLAG = BTEST(LAST_NEWS_READ2(2,I),14) 
  
	RETURNN
	END
  
 A
 R
 T
	LOGICAL FUNCTION TEST_BRIEF_FLAG(NUMBER)
 I
	IMPLICIT INTEGER (A-Z)=
  
	INCLUDE 'BULLUSER.INC'_
 S
	IF (NUMBER.GE.0.AND.NUMBER.LE.FOLDER_MAX) THENI
	   TEST_BRIEF_FLAG = TEST2(BRIEF_FLAG,NUMBER)
	   RETURN
	END IFS
 
	I = NEWS_FIND_SUBSCRIBE()
 (
	TEST_BRIEF_FLAG = BTEST(LAST_NEWS_READ2(2,I),15)E
 
	RETURN 
	END
  
  
 D
	INTEGER FUNCTION NEWS_FIND_SUBSCRIBE() 
 E
	IMPLICIT INTEGER (A-Z)F
 E
	INCLUDE 'BULLUSER.INC'E
  
	INCLUDE 'BULLFOLDER.INC'F
 E
	I = 1
	DO WHILE (LAST_NEWS_READ2(1,I).NE.NEWS_FOLDER_NUMBERD
     &					.AND.I.LE.FOLDER_MAX)
	   I = I + 1 
	END DO(
 E
	NEWS_FIND_SUBSCRIBE = I
 Z
	RETURNC
	END
 3
 O
 A
 D
	SUBROUTINE NEWS_SET_USER_FLAG(NOTIFY,READNEW,BRIEF)
 C
	IMPLICIT INTEGER (A-Z)N
 T
	INCLUDE 'BULLUSER.INC')
 )
	I = NEWS_FIND_SUBSCRIBE()
 T
	IF (I.GT.FOLDER_MAX) THEN
	   WRITE (6,'('' ERROR: NEWS FOLDER is not subscribed.'')')
	   RETURN
	END IF)
 I
	IF (NOTIFY.EQ.1) THEN
	   WRITE (6,'('' ERROR: NOTIFY cannot be set for news folder.'')')
	   RETURN
	END IFI
 
	IF (READNEW.EQ.1) LAST_NEWS_READ2(2,I) = IBSET(LAST_NEWS_READ2(2,I),14)
	IF (READNEW.EQ.0) LAST_NEWS_READ2(2,I) = IBCLR(LAST_NEWS_READ2(2,I),14)
	IF (BRIEF.EQ.1) LAST_NEWS_READ2(2,I) = IBSET(LAST_NEWS_READ2(2,I),15)
	IF (BRIEF.EQ.0) LAST_NEWS_READ2(2,I) = IBCLR(LAST_NEWS_READ2(2,I),15)
	E
	RETURN7
	END
