      SUBROUTINE MAIN
      INTEGER GETPAT, S, GETLIN, MATCH
      LOGICAL*1 HDRPAT(100), BUF(512)
      LOGICAL*1 HDPTRN(11)
      DATA HDPTRN(1)/37/,HDPTRN(2)/77/,HDPTRN(3)/97/,HDPTRN(4)/105/,HDPT
     *RN(5)/108/,HDPTRN(6)/32/,HDPTRN(7)/102/,HDPTRN(8)/114/,HDPTRN(9)/1
     *11/,HDPTRN(10)/109/,HDPTRN(11)/0/
      CALL QUERY(45Husage:  malfix <old_mail_file >new_mail_file.)
      IF (.NOT.(GETPAT(HDPTRN, HDRPAT) .EQ. -3))GOTO 23000
      CALL ERROR(29HSomething wrong with pattern.)
23000 CONTINUE
23002 IF (.NOT.(GETLIN(BUF, 1) .NE. -1))GOTO 23003
      IF (.NOT.(MATCH(BUF, HDRPAT) .EQ. 1))GOTO 23004
      CALL REFRMT(BUF, 2)
      GOTO 23005
23004 CONTINUE
      CALL PUTLIN(BUF, 2)
23005 CONTINUE
      GOTO 23002
23003 CONTINUE
      RETURN
      END
      SUBROUTINE REFRMT(BUF, UNIT)
      LOGICAL*1 BUF(100), USER(40), DATE(40), TIME(40), HEADER(4)
      INTEGER JUNK, GETWRD, I
      LOGICAL*1 DATEHD(7)
      LOGICAL*1 FROMHD(7)
      LOGICAL*1 PST(7)
      DATA DATEHD(1)/68/,DATEHD(2)/97/,DATEHD(3)/116/,DATEHD(4)/101/,DAT
     *EHD(5)/58/,DATEHD(6)/32/,DATEHD(7)/0/
      DATA FROMHD(1)/70/,FROMHD(2)/114/,FROMHD(3)/111/,FROMHD(4)/109/,FR
     *OMHD(5)/58/,FROMHD(6)/32/,FROMHD(7)/0/
      DATA PST(1)/32/,PST(2)/45/,PST(3)/32/,PST(4)/80/,PST(5)/83/,PST(6)
     */84/,PST(7)/0/
      DATA HEADER/1, 1, 10, 0/
      I = 1
      JUNK = GETWRD(BUF, I, USER)
      JUNK = GETWRD(BUF, I, USER)
      JUNK = GETWRD(BUF, I, USER)
      JUNK = GETWRD(BUF, I, DATE)
      JUNK = GETWRD(BUF, I, TIME)
      CALL PUTLIN(HEADER, UNIT)
      CALL PUTLIN(DATEHD, UNIT)
      CALL PUTLIN(DATE, UNIT)
      CALL PUTCH(32, UNIT)
      CALL PUTLIN(TIME, UNIT)
      CALL PUTLIN(PST, UNIT)
      CALL PUTCH(10, UNIT)
      CALL PUTLIN(FROMHD, UNIT)
      CALL PUTLIN(USER, UNIT)
      CALL PUTCH(10, UNIT)
      RETURN
      END
