      INTEGER AP,ARTNO
      INTEGER GETARG,INDEX0,ARCHI0,DELIV0
      INTEGER ARTFD,INDFD
      INTEGER REFOR0,OPEN
      INTEGER ARTNA0(102),HEADL0(102)
      INTEGER AAAAA0(13)
      DATA AAAAA0/189,238,229,247,243,189,175,233,238,228,229,248,0/
      INDFD=OPEN(AAAAA0,3)
      IF((INDFD.NE.-3))GOTO 10000
        CALL ERROR('can''t open index file.')
10000 AP=1
      GOTO 10003
10001 AP=AP+(1)
10003 IF((GETARG(AP,ARTNA0,102).EQ.-1))GOTO 10002
        ARTFD=REFOR0(ARTNA0,HEADL0)
        IF((ARTFD.NE.-3))GOTO 10004
          CALL SETERR(1000)
          GOTO 10002
10004   ARTNO=INDEX0(HEADL0,INDFD)
        IF((ARTNO.NE.-3))GOTO 10005
          CALL RMTEMP(ARTFD)
          CALL SETERR(1000)
          GOTO 10002
10005   IF((ARCHI0(ARTFD,ARTNO).NE.-3))GOTO 10006
          CALL RMTEMP(ARTFD)
          CALL SETERR(1000)
          GOTO 10002
10006   IF((DELIV0(ARTFD,ARTNO).NE.-3))GOTO 10007
          CALL RMTEMP(ARTFD)
          CALL SETERR(1000)
          GOTO 10002
10007   CALL RMTEMP(ARTFD)
      GOTO 10001
10002 CALL CLOSE(INDFD)
      CALL SWT
      END
      INTEGER FUNCTION ARCHI0(ARTFD,ARTNO)
      INTEGER ARTFD
      INTEGER ARTNO
      INTEGER ARCH(102)
      INTEGER AUTHOR(33),LDATE(32)
      INTEGER ARCHFD
      INTEGER CREATE
      INTEGER AAAAB0(22)
      INTEGER AAAAC0(4)
      DATA AAAAB0/189,238,229,247,243,189,175,225,242,244,233,227,236,22
     *9,243,175,225,242,244,170,233,0/
      DATA AAAAC0/170,178,238,0/
      CALL REWIND(ARTFD)
      CALL ENCODE(ARCH,102,AAAAB0,ARTNO)
      ARCHFD=CREATE(ARCH,3)
      IF((ARCHFD.NE.-3))GOTO 10008
        CALL REMARK('can''t open archive copy file.')
        ARCHI0=-3
        RETURN
10008 CALL DATE(3,AUTHOR)
      CALL DATE(7,LDATE)
      CALL PRINT(ARCHFD,'Article *i by *s on *s*2n.',ARTNO,AUTHOR,LDATE)
      CALL FCOPY(ARTFD,ARCHFD)
      CALL PRINT(ARCHFD,AAAAC0)
      CALL CLOSE(ARCHFD)
      ARCHI0=-2
      RETURN
      END
      INTEGER FUNCTION DELIV0(ARTFD,ARTNO)
      INTEGER ARTFD
      INTEGER ARTNO
      INTEGER LEN,NLPOS
      INTEGER GETLIN,SCOPY,VFYUSR
      INTEGER SUBFD,BOXFD
      INTEGER OPEN
      INTEGER BOX(102),SUBNA0(102)
      INTEGER AUTHOR(33),LDATE(32)
      INTEGER AAAAD0(19)
      INTEGER AAAAE0(17)
      INTEGER AAAAF0(4)
      DATA AAAAD0/189,238,229,247,243,189,175,243,245,226,243,227,242,23
     *3,226,229,242,243,0/
      DATA AAAAE0/189,238,229,247,243,189,175,228,229,236,233,246,229,24
     *2,249,175,0/
      DATA AAAAF0/170,178,238,0/
      SUBFD=OPEN(AAAAD0,1)
      IF((SUBFD.NE.-3))GOTO 10009
        CALL REMARK('can''t open subscriber list.')
        DELIV0=-3
        RETURN
10009 CALL DATE(3,AUTHOR)
      CALL DATE(7,LDATE)
      LEN=SCOPY(AAAAE0,1,BOX,1)+1
      NLPOS=GETLIN(SUBNA0,SUBFD)
      GOTO 10012
10010 NLPOS=GETLIN(SUBNA0,SUBFD)
10012 IF((NLPOS.EQ.-1))GOTO 10011
        SUBNA0(NLPOS)=0
        IF((VFYUSR(SUBNA0).EQ.-2))GOTO 10013
          GOTO 10010
10013   CALL SCOPY(SUBNA0,1,BOX,LEN)
        BOXFD=OPEN(BOX,2)
        IF((BOXFD.NE.-3))GOTO 10014
          CALL PRINT(-15,'*s: can''t deliver*n.',SUBNA0)
          DELIV0=-3
          RETURN
10014   CALL REWIND(ARTFD)
        CALL WIND(BOXFD)
        CALL PRINT(BOXFD,'Article *i by *s on *s*2n.',ARTNO,AUTHOR,LDATE
     *)
        CALL FCOPY(ARTFD,BOXFD)
        CALL PRINT(BOXFD,AAAAF0)
        CALL CLOSE(BOXFD)
      GOTO 10010
10011 CALL CLOSE(SUBFD)
      DELIV0=-2
      RETURN
      END
      INTEGER FUNCTION INDEX0(HEADL0,INDFD)
      INTEGER HEADL0(1)
      INTEGER INDFD
      INTEGER I,NUMBER,LEN
      INTEGER CTOI,GETLIN,ENCODE
      INTEGER DAT(9),TIM(9),NAM(33),LINE(102)
      INTEGER AAAAG0(19)
      DATA AAAAG0/170,180,233,174,160,170,243,160,170,243,160,170,172,18
     *1,243,160,170,243,0/
      CALL REWIND(INDFD)
10015 IF((GETLIN(LINE,INDFD).EQ.-1))GOTO 10016
        I=1
        NUMBER=CTOI(LINE,I)+1
      GOTO 10015
10016 CALL DATE(1,DAT)
      CALL DATE(2,TIM)
      CALL DATE(3,NAM)
      LEN=ENCODE(LINE,102,AAAAG0,NUMBER,NAM,DAT,TIM,HEADL0)
      IF((LEN.LE.80))GOTO 10017
        CALL PRINT(-15,'Headline too long: *s.',HEADL0)
        INDEX0=-3
        RETURN
10017 CALL PUTLIN(LINE,INDFD)
      CALL FLUSH$(INDFD)
      INDEX0=NUMBER
      RETURN
      END
      INTEGER FUNCTION REFOR0(ARTNA0,HEADL0)
      INTEGER ARTNA0(1),HEADL0(1)
      INTEGER I,J,L,BLCOU0
      INTEGER GETLIN,ALLBL0,LENGTH
      INTEGER ARTFD,RAWFD
      INTEGER MKTEMP,OPEN
      INTEGER LINE(102)
      INTEGER AAAAH0(4)
      INTEGER AAAAI0(14)
      INTEGER AAAAJ0(4)
      INTEGER AAAAK0(4)
      DATA AAAAH0/160,170,243,0/
      DATA AAAAI0/160,170,163,248,170,163,172,172,173,248,170,178,238,0/
      DATA AAAAJ0/170,163,238,0/
      DATA AAAAK0/160,170,243,0/
      RAWFD=OPEN(ARTNA0,1)
      IF((RAWFD.NE.-3))GOTO 10018
        CALL PRINT(-15,'*s: cannot open*n.',ARTNA0)
        REFOR0=-3
        RETURN
10018 ARTFD=MKTEMP(3)
      IF((ARTFD.NE.-3))GOTO 10019
        CALL REMARK('can''t open temporary file.')
        REFOR0=-3
        RETURN
10019 CONTINUE
10020   L=GETLIN(LINE,RAWFD)
      IF((L.EQ.-1))GOTO 10021
      IF((ALLBL0(LINE).EQ.0))GOTO 10021
      GOTO 10020
10021 CONTINUE
      IF((L.NE.-1))GOTO 10022
        CALL PRINT(-15,'*s: empty file*n.',ARTNA0)
        CALL RMTEMP(ARTFD)
        REFOR0=-3
        RETURN
10022 I=1
10023 IF((LINE(I).NE.160))GOTO 10024
        I=I+(1)
      GOTO 10023
10024 CALL SCOPY(LINE,I,HEADL0,1)
      CALL PRINT(ARTFD,AAAAH0,LINE)
      J=LENGTH(LINE)-1
      GOTO 10027
10025 J=J-(1)
10027 IF((J.LE.0))GOTO 10026
        IF((LINE(J).EQ.160))GOTO 10028
          GOTO 10026
10028 GOTO 10025
10026 CALL PRINT(ARTFD,AAAAI0,I-1,J-I+1)
10029   L=GETLIN(LINE,RAWFD)
      IF((L.EQ.-1))GOTO 10030
      IF((ALLBL0(LINE).EQ.0))GOTO 10030
      GOTO 10029
10030 CONTINUE
      BLCOU0=0
10031 IF((L.EQ.-1))GOTO 10032
        IF((ALLBL0(LINE).NE.1))GOTO 10033
          BLCOU0=BLCOU0+(1)
          GOTO 10034
10033     IF((BLCOU0.LE.0))GOTO 10035
            CALL PRINT(ARTFD,AAAAJ0,BLCOU0)
10035     BLCOU0=0
          CALL PRINT(ARTFD,AAAAK0,LINE)
10034   L=GETLIN(LINE,RAWFD)
      GOTO 10031
10032 CALL CLOSE(RAWFD)
      CALL REWIND(ARTFD)
      REFOR0=ARTFD
      RETURN
      END
      INTEGER FUNCTION ALLBL0(LINE)
      INTEGER LINE(1)
      INTEGER I
      I=1
      GOTO 10038
10036 I=I+(1)
10038 IF((LINE(I).EQ.0))GOTO 10037
      IF((LINE(I).EQ.138))GOTO 10037
        IF((LINE(I).EQ.160))GOTO 10039
          ALLBL0=0
          RETURN
10039 GOTO 10036
10037 ALLBL0=1
      RETURN
      END
C ---- Long Name Map ----
C archive                        archi0
C headline                       headl0
C artname                        artna0
C allblank                       allbl0
C deliver                        deliv0
C subname                        subna0
C indexentry                     index0
C blcount                        blcou0
C reformat                       refor0
