From:	CRDGW2::CRDGW2::MRGATE::"SMTP::DECWRL.DEC.COM::SIMPACT!JEH" 19-OCT-1989 18:25
To:	MRGATE::"ARISIA::EVERHART"
Subj:	new uuxqt_dcl.com, part 1 of 1

Message-Id: <8910191939.AA06178@decwrl.dec.com>
Received: from decwrl.dec.com by DRYCAS.CLUB.CC.CMU.EDU; Thu, 19 Oct 89 15:42
 EDT
Received: by decwrl.dec.com; id AA06178; Thu, 19 Oct 89 12:39:36 -0700
Received: by simpact.com (DECUS UUCP w/Smail); Thu, 19 Oct 89 12:04:16 PDT
Date: Thu, 19 Oct 89 12:04:16 PDT
From: Jamie Hanrahan <jeh@simpact.com>
Subject: new uuxqt_dcl.com, part 1 of 1
To: vmsnet@DRYCAS.CLUB.CC.CMU.EDU

$! ...................... Cut between dotted lines and save. .....................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.03 20-Oct-1988.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user JEH
$! on 19-OCT-1989 12:02:14.31.
$!
$! It contains the following 1 file:
$!        UUXQT_DCL.COM
$!
$!==============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.03 20-Oct-1988 requires VMS V4.4 or higher."
$ EXIT 44 
$VERSION_OK:
$ GOTO START
$
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY

b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) );
s_file_spec := GET_INFO( COMMAND_LINE, "output_file" );SET( OUTPUT_FILE, b_part
, s_file_spec ); 
b_errors := CREATE_BUFFER( "{Errors}" );i_errors := 0; 
pat_beg_1 := ANCHOR & "-+-+-+ Beginning";
pat_beg_2 := LINE_BEGIN & "+-+-+-+ Beginning";
pat_end := ANCHOR & "+-+-+-+-+ End";
pat_trail := " " & LINE_END;POSITION( BEGINNING_OF( b_part ) ); LOOP b 
:= SEARCH( pat_trail, FORWARD); EXITIF b=0; POSITION( END_OF( b ) )
; LOOP MOVE_HORIZONTAL( -1 ); EXITIF CURRENT_CHARACTER <> ' '; ERASE_CHARACTER
( 1 ); EXITIF CURRENT_OFFSET=0; ENDLOOP; ENDLOOP; POSITION( BEGINNING_OF
( b_part ) ); i_append_line := 0; LOOP EXITIF MARK( NONE ) = END_OF( b_part )
; s_x := ERASE_CHARACTER( 1 ); 
  IF s_x = "+" THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip <
> 0 THEN 
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF; ENDIF; 
  IF s_x = "-" THEN r_skip := SEARCH( pat_end, FORWARD, EXACT ); IF r_skip <
> 0 THEN 
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip := MARK( NONE )
; r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip <> 0 THEN POSITION
( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET ); MOVE_VERTICAL( 1 )
; MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) ); ENDIF; ERASE
( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF; 
  IF s_x = "V" THEN 
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 1; MOVE_VERTICAL( 1 ); ENDIF; 
  IF s_x = "X" THEN 
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; 
  IF s_x <> "" THEN i_errors := i_errors + 1; s_text := CURRENT_LINE; POSITION
( b_errors ); 
    COPY_TEXT( "The following line could not be unpacked properly:" )
; SPLIT_LINE; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part )
; MOVE_VERTICAL( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP 
  r_x := SEARCH( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x )
; ERASE_CHARACTER( 1 ); 
  IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII
( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; ENDLOOP; IF i_errors = 0 THEN SET
( NO_WRITE, b_errors, ON ); ELSE POSITION( BEGINNING_OF( b_errors ) ); 
  COPY_TEXT( FAO( "The following !UL errors were detected while unpacking !AS"
, i_errors, s_file_spec ) ); SPLIT_LINE; 
  SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" );ENDIF; EXIT; 
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!,passed." )
$ RETURN
$
$START:
$ FILE_IS = "UUXQT_DCL.COM"
$ CHECKSUM_IS = 1901025835
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ !`009`009`009`009`009`009`009UUXQT_DCL.COM
X$ SET NOVERIFY
X$ verbose = 0`009`009! 1 or 0
X$ GOTO START
X$ !
X$ !`009This command procedure executes in a subprocess SPAWNed by
X$ !`009UUXQT.EXE . `032
X$ !`009
X$ !`009P1`009- logical name of mailbox in which to receive commands
X$ !`009
X$ !`009UUXQT interprets the lines in the X. file, processes them in`032
X$ !`009ways appropriate for image- rather than DCL-based code (e.g.`032
X$ !`009translates Unix file names to VMS, converts mail addresses),`032
X$ !`009then passes them to this procedure via the mailbox.  The records
X$ !`009which we'll read in the mailbox are similar to those in the X file.
X$ !`009They are of the form`032
X$ !`009
X$ !`009<type> <argument>
X$ !`009
X$ !`009<type> is a single character.  It is separated from the <argument>
X$ !`009by one space; that is, the argument starts with the third character
X$ !`009in the mailbox record.  Some arguments may contain imbedded spaces.`032
X$ !`009
X$ !`009The following <types> are recognized:
X$ !`009
X$ !`009type`009argument`009interpretation
V$ !`009-------`009---------------`009------------------------------------------
X--
X$ !`0090`009X.filename`009invalid X.file -- an F check failed, or other
X$ !`009`009`009`009problems were discovered by uuxqt. `032
X$ !`0091`009X.filename`009valid X.file . `032
X$ !`009A`009addressee`009mail addressee for command`032
X$ !`009I`009filename`009name of input file for command (VMS filename)
X$ !`009O`009filename`009name of output file for command (VMS filename)
X$ !`009C`009command`009`009command to be executed locally.  Must be`032
X$ !`009`009`009`009last in a command sequence
X$ !`009/`009(none)`009`009"end of X.file" indication
X$ !
X$ !`009uuxqt reads the entire X file, then (if it's valid) sends a type-1`032
X$ !`009message followed by (optional, depending on the command) A, I, and O`032
X$ !`009messages, followed by the C message.  Upon receipt of the C message
X$ !`009we begin executing the command (so uuxqt has to send us everything
X$ !`009else the command will need before sending the C). `032
X$ !
X$ !`009If we die while processing a command we don't want uuxqt to begin`032
X$ !`009processing the next X file, assuming that we're still around.  So after
X$ !`009sending us the C, uuxqt sends us a / command, and waits until we've
X$ !`009read it before looking for the next X file.  We don't read the / until
X$ !`009we're done with the C command and ready for the next X file (0 or 1
X$ !`009command).  This precludes any overlap in processing between us and`032
X$ !`009uuxqt, but that's okay because uuxqt does very little work. `032
X$ !
X$ !`009At the moment the only commands we support are rmail and rnews. `032
X$
X$ !`009Note to future implementors:  If this beast dies, UUXQT.EXE will
X$ !`009hang on its next mailbox write, so we have to be *very* robust. `032
X$
X$ START:
X$
X$`009COMPRESS = "$UUCP_BIN:COMPRESS.EXE"
X$`009SAY = "WRITE SYS$OUTPUT"
X$`009BABBLE = "IF (verbose) THEN WRITE SYS$OUTPUT"
X$`009SAY "UUXQT_DCL starting ", f$time(), " mailbox name is ", p1
X$`009err = "Can't open mailbox"
X$`009OPEN/READ/ERROR=ERROR_EXIT MBX 'p1
X$
X$ INIT_JOB:
X$`009command = ""
X$`009addressee = ""
X$`009infile = ""
X$`009outfile = ""
X$`009xfile = ""
X$`009begin_xfile = 1
X$`009end_xfile = 0
X$
X$ READ_LOOP:
X$`009err = "Unexpected EOF or error on mailbox read"
X$`009ON ERROR THEN GOTO ERROR_CONT
X$`009BABBLE "  Reading mailbox"
X$`009READ/END=NORMAL_EXIT/ERROR=ERROR_EXIT MBX cmd_line
X$
X$`009! parse the message
X$
X$`009cmd = f$extr(0,1,cmd_line)
X$`009arg = f$extr(2,255,cmd_line)
X$`009BABBLE "  ...command is <", cmd, ">, arg is <", arg, ">"
X$
X$`009IF (begin_xfile) THEN GOTO WANT_BEGIN
X$`009IF (end_xfile) THEN GOTO WANT_END
X$`009ON ERROR THEN GOTO ERROR_CONT
X$`009IF (cmd .eqs. "0" .or. cmd .eqs. "1" .or. cmd .eqs. "/") -
X`009`009THEN GOTO UNEXP_CMD
X$`009GOTO MBX_'cmd
X$
X$ ERROR_CONT:
X$`009SAY -
X "Error status ", $status, ", ", f$message($status), ", continuing"
X$`009SAY err
X$`009GOTO INIT_JOB
X$
X$ ERROR_EXIT:
X$`009SAY -
X "Error status ", $status, ", ", f$message($status), ", aborting"
X$`009SAY err
X$`009EXIT 4
X$
X$ NORMAL_EXIT:
X$`009SAY "Received EOF on mailbox read, exiting"
X$`009EXIT 1
X$
X$ !----------------------------------------------------------------------
X$
X$ UNEXP_CMD:
V$`009SAY "* Error while in xfile ", xfile, " cmd is <", cmd, ">, expected one o
Xf <AIOC> (ignoring)"
X$`009GOTO READ_LOOP
X$
X$ WANT_BEGIN:
X$`009IF (cmd .eqs. "0") THEN GOTO MBX_0
X$`009IF (cmd .eqs. "1") THEN GOTO MBX_1
V$`009SAY "* Error while outside of xfile, cmd is <", cmd, ">, expected one of <
X01> (ignoring)"
X$`009GOTO READ_LOOP
X$
X$ WANT_END:
X$`009IF (cmd .eqs. "/") THEN GOTO INIT_JOB
V$`009SAY "* Error at end of xfile ", xfile, " cmd is <", cmd, ">, expected </>
X (ignoring)"
X$`009GOTO READ_LOOP
X$
X$ MBX_0:
X$`009SAY "* Bad X file ", arg, " moving to the dump"
X$`009RENAME/LOG 'arg' UUCP_DUMP:X.*
X$`009GOTO INIT_JOB
X$
X$ MBX_1:
X$`009SAY "  Begin X file ", arg, " at ", f$time()
X$`009xfile = arg
X$`009begin_xfile = 0
X$`009GOTO READ_LOOP
X$
X$ MBX_I:
X$`009BABBLE "  ...Input file is ", arg
X$`009infile = arg
X$`009GOTO READ_LOOP
X$
X$ MBX_O:
X$`009BABBLE "  ...Output file is ", arg
X$`009outfile = arg
X$`009GOTO READ_LOOP
X$
X$ MBX_A:
X$`009BABBLE "  ...Addressee is ", arg
X$`009addressee = arg
X$`009GOTO READ_LOOP
X$
X$ MBX_C:
X$`009BABBLE "  ...Command is ", arg
X$`009end_xfile = 1
X$`009command = arg
X$      `032
X$`009IF (f$edit(command, "UPCASE,TRIM") .EQS. "RMAIL") THEN GOTO DO_RMAIL
X$`009IF (f$edit(command, "UPCASE,TRIM") .EQS. "RNEWS") THEN GOTO DO_RNEWS
X$
V$`009SAY "* Error, unsupported command <", command, "> in xfile ", xfile, " (ig
Xnoring)"
X$`009GOTO INIT_JOB
X$
X$ !----------------------------------------------------------------------
X$
X$ DO_RMAIL:
X$`009SET PROCESS/PRIVILEGE=(SYSPRV, DETACH, NETMBX, BYPASS)
X$`009addr = addressee
X$`009IF (f$edit(addressee,"UPCASE") .EQS. "POSTMASTER") THEN -
X`009`009addr = "UUCP_POSTMASTER"
X$`009ON ERROR THEN GOTO FAILED_RMAIL
X$`009save_ver = f$verify(1)
X$`009MAIL/PROTOCOL=UUCP_MAILSHR 'infile' "''addr'"
X$`009save_ver = f$verify(save_ver)
X$`009SET NOON
X$`009SET PROCESS/PRIVILEGE=(NOSYSPRV, NODETACH, NONETMBX, NOBYPASS)
X$`009DELETE 'infile';0
X$`009DELETE 'xfile'`009`009! this one comes to us with a version number
X$`009GOTO READ_LOOP
X$
X$ FAILED_RMAIL:
X$`009save_ver = f$verify(save_ver)
X$`009saved_status = $status
V$`009SAY "Attempt to send mail to <", addr, "> failed with status ", saved_stat
Xus
X$
V$ ! If it is older than a few days, then we give up on it and pass it on to the
X`032
X$ ! local postmaster.
X$`009IF (F$CVTIME(F$FILE_ATTRIBUTES(xfile,"CDT")).LES. `009`009-
X`009    F$CVTIME("''F$FILE_ATTRIBUTES(xfile,"RDT")'-4-00:00:00"))  `009-
X`009`009THEN GOTO FAILED_RMAIL_1
X$ !
X$ ! Note that we are simply leaving the infile in the spool directory.
X$ ! This is deliberately done so that we don't have to invent another
X$ ! mechanism to keep track of which X file goes which 'infile'.  Yes
X$ ! we could always read the X file to locate it's 'infile', but this
X$ ! can get sort of hairy, and that code is currently internal to UUXQT
X$ ! itself.
X$`009SET NOON
X$`009SET PROCESS/PRIVILEGE=(NOSYSPRV, NODETACH, NONETMBX, NOBYPASS)
X$`009RENAME/LOG 'xfile' UUCP_SPOOL:REMAIL_X
X$`009GOTO READ_LOOP
X$
X$ FAILED_RMAIL_1:
X$`009ON ERROR THEN GOTO FAILED_RMAIL_2
V$`009SAY "* (FAILED_RMAIL) Error sending ",infile," to ",addressee,", forwardin
Xg to local postmaster"
X$`009subject = "Couldn't send this to "+addressee+", status ''saved_status'"
X$`009save_ver = f$verify(1)
X$`009MAIL 'infile' uucp_postmaster /SUBJECT=&subject
X$`009save_ver = f$verify(save_ver)
X$`009GOTO FAILED_RMAIL_COMMON
X$
X$ FAILED_RMAIL_2:
X$`009save_ver = f$verify(save_ver)
X$`009ON ERROR THEN GOTO FAILED_RMAIL_COMMON
V$`009SAY "* (FAILED_RMAIL_2) Error sending ",infile," to postmaster thru normal
X mail"
X$`009subject = "UUCP mail dlvry err, file <"+infile+">, to <"+addressee+">"
X$`009save_ver = f$verify(1)
X$`009MAIL sys$input: uucp_postmaster /SUBJECT=&subject
XThe file named in the subject line could not be delivered to the indicated
Xaddressee.  Please review UUXQT_DCL.LOG and UUXQT_BATCH.LOG .  The offending
Xfile (and its Xfile) have been moved to the UUCP_DUMP: directory.
X$
X$FAILED_RMAIL_COMMON:
X$`009save_ver = f$verify(save_ver)
X$`009SET NOON
X$`009SET PROCESS/PRIVILEGE=(NOSYSPRV, NODETACH, NONETMBX, NOBYPASS)
X$`009RENAME/LOG 'infile';0 UUCP_DUMP:
V$`009RENAME/LOG 'xfile' UUCP_DUMP:`009`009! this one comes to us with a version
X number
X$`009GOTO READ_LOOP
X$
X$ !----------------------------------------------------------------------
X$
X$ DO_RNEWS:
X$`009newsbatch = F$PARSE("UUCP_RCVDNEWS:NEWS_BATCH",,infile,,"SYNTAX_ONLY")
X$`009batch_log = "NEWS_LOG:RNEWS_"+(f$parse(newsbatch,,,"TYPE")-".")
X$`009ON WARNING THEN GOTO FAILED_RNEWS_1
X$`009RENAME/LOG 'infile';0 'newsbatch'
X$
X$`009SET PROCESS/PRIVILEGE=(SYSPRV, CMKRNL)
X$
X$`009SUBMIT/NOPRINT/LOG='batch_log'`009`009-
X`009`009/USER='f$logi("NEWS_MGR_UN")'`009-
X`009       `009/PARAMETER='newsbatch'`009`009-
X`009`009/QUEUE=NEWS_BATCH_QUEUE`009`009-
X`009`009UUCP_BIN:NEWS_RNEWS`009
X$
X$`009SET PROCESS/PRIVILEGE=(NOSYSPRV, NOCMKRNL)
X$
X$`009DELETE 'xfile'`009`009! this one comes to us with a version number
X$`009GOTO READ_LOOP                                      `032
X$
X$ FAILED_RNEWS_1:
X$`009SET PROCESS/PRIVILEGE=(NOSYSPRV, NOCMKRNL)
X$`009ON ERROR THEN GOTO FAILED_RNEWS_2
X$`009SAY "* (FAILED_RNEWS_1) Error starting NEWS_RNEWS for ", infile
V$`009MAIL/SUBJECT="UUCP NEWS dlvry err, file <''infile'>, to <''addressee'>" sy
Xs$input: uucp_postmaster
VThe file named in the subject line could not be dispatched to the NEWS system`0
X32
Xfor processing.  Please review UUXQT_DCL.LOG and UUXQT_BATCH.LOG .  The`032
Xoffending Xfile has been moved to the UUCP_DUMP: directory; the news batch
Xfile is in UUCP_RCVDNEWS: .
X$
X$`009GOTO FAILED_RMAIL_COMMON
X$
X$ FAILED_RNEWS_2:
V$`009SAY "* (FAILED_RNEWS_2) Error notifying postmaster of inability to process
X news batch ", infile
X$`009GOTO FAILED_RMAIL_COMMON
$ GOSUB UNPACK_FILE
$ EXIT
