From:	MERC::"uunet!WKUVX1.BITNET!FILESERV-Mgr"  6-JUL-1992 17:27:15.93
To:	galaxy::gleeve
CC:	
Subj:	VMS_SHARE.001-OF-005

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-011  26-Jun-1992
$!   On  5-JUL-1992 16:33:16.78   By user GOATHUNTER (@WKUVX1.BITNET)
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 5 PARTS, TO KEEP EACH PART
$!  BELOW 60 BLOCKS
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. [.VMS_SHARE]AAAREADME.1ST;1
$!       2. [.VMS_SHARE]PAKMAIL.COM;1
$!       3. [.VMS_SHARE]PAKMAIL.HLP;1
$!       4. [.VMS_SHARE]PAKNEWS.COM;1
$!       5. [.VMS_SHARE]TEST.TXT;1
$!       6. [.VMS_SHARE]VMS_SHARE.COM;1
$!       7. [.VMS_SHARE]VMS_SHARE.HLP;1
$!       8. [.VMS_SHARE]VMS_SHARE.RELEASE_NOTES;1
$!       9. [.VMS_SHARE]VMS_SHARE.TECHNICAL_INFO;1
$!      10. [.VMS_SHARE]VMS_SHARE.USER_GUIDE;1
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ x = P1 - f$parse(P1,,,"version")
$ y = f$search(x)
$ if y .eqs. "" then $ goto file_absent
$ x = f$integer(f$parse(P1,,,"version")-";")
$ y = f$integer(f$parse(y,,,"version")-";")
$ if x .gt. y then $ goto file_absent
$ if f$mode() .eqs. "INTERACTIVE" then $ goto file_interactive
$ if x .eq. y then e "-W-EXISTS, File ''P1' exists. Skipped."
$ if x .ne. y then e "-W-NEWERVERSION, of File ''P1' exists. Skipped."
$file_delete:
$ delete 'f'*
$ exit
$file_interactive:
$ if x .eq. y then e "-W-EXISTS, File ''P1' exists."
$ if x .ne. y then e "-W-NEWERVERSION, of File ''P1' exists."
$ read/error=file_delete/end=file_delete-
  /prompt="Create new version [y/n]: " -
  sys$command x
$ if .not. x then $ e "-W-SKIPPED, File ''P1' skipped."
$ if .not. x then $ goto file_delete
$ P1 = P1 - f$parse(P1,,,"version")
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
XI've made a number of unauthorized, but handy changes/bug fixes to VMS_SHARE
V.`20
XThese changes are as follows:
X
XV7.2-008
X
XThe file size can be provided as a third parameter to the command procedure.
V`20
XIf omitted, the usual logical name is searched for.
X
XThe parts produced by VMS_SHARE are now named as follows:
X
X`09share-file.nnn-of-mmm
X
Xwhich makes processing the parts in order via other command procedures a who
Vle
Xlot easier.
X
XV7.2-009
X
XThe algorithm that check for within a sub-tree broke when the tree was roote
Vd
Xin the MFD (`5B000000`5D).
X
XV7.2-010
X
XThe algorithm that checked for the existance of a VMS_SHARE package had to b
Ve
Xupdated for the new part type format.
X
XV7.2-011
X
XI do development between work between many different systems.  The share fil
Ve
Xhas been changed to detect newer versions and, if run in interactive mode, A
VSK
Xif a newer version is to be created.  In all other modes, the behavior is
Xidentical to earlier version of VMS_SHARE.
X
XIf you have any problems, suggestions, or questions contact:
X
XDick Munroe
XDoyle, Munroe Consultants, Inc.
X267 Cox St.
XHudson, Ma. 01749
X(508) 568-1618
X(FAX) (508) 562-1133
Xmunroe@dmc.com
$ CALL UNPACK [.VMS_SHARE]AAAREADME.1ST;1 1465279809
$ create 'f'
X$! Purpose:
X$!`09To mail out a series of files produced by VMS_SHARE to a series
X$!`09of recipients.
X$!
X$! Parameters:
X$!
X$!`09P1 = name (or list ) of recipient(s). Can be logical or distribution
X$!           list.
X$!
X$!`09`09If sending to a distribution list, it is necessary to define
X$!`09`09a logical pointing to the file and then give that logical as
X$!`09`09the recipient name.  This avoids problems with DCL's handling
X$!`09`09of quotes and '@' symbols.
X$!
X$!
X$!`09P2 = file spec of package - "`5Bdirectory`5Dfile" without VMS_SHARE suf
Vfix!
X$!
X$!
X$!`09P3 = no of parts of the package
X$!
X$! `09`09This procedure adds the VMS_SHARE suffix and sends files
X$!`09`09called  "`5Bdirectory`5Dfile''nn'"   nn from 1-> 'P3'
X$!
X$!`09P4 = Comment to add to mail subject line
X$!
X$!
X$! Privileges:
X$!`09Whatever is necessary to access e-mail and the relevant network.
X$!
X$!
X$! Environment:
X$!`09Nothing special.  VMS_SHARE must exist of course in order to
X$!`09produce the software package.
X$!
X$! Revision History:
X$!`091.0`09Andy Harper`096-DEC-1988`09Original version
X$!`091.1`09Andy Harper`0919-DEC-1988`09Allow P4 to be mail subject
X$!`091.2`09Andy Harper`095-JAN-1989`09Return exit status
X$!`091.3`09Andy Harper`0916-JUN-1989`09Remove "OF_''mm'" extension
X$!`091.4`09Andy Harper`093-AUG-1989`09use READ, check EOF status
X$!`091.5`09Dick Munroe`0907-Apr-1991`09Look for nnn-of-mmm as a
X$!`09`09`09`09`09`09package name.
X$!
X$!
X$
X$
X$! SET UP STANDARD EXIT CODES
X$ ss$_normal= 1
X$ ss$_abort = 44
X$
X$
X$! MAKE SURE WE HAVE ALL THE PARAMETERS
X$get_recipient:
X$ if P1 .nes. "" then $ goto end_get_recipient
X$ read/prompt="_mail address of recipient "/end=exit sys$command P1
X$ goto get_recipient
X$end_get_recipient:
X$
X$package_location:
X$ if P2 .nes. "" then $ goto end_package_location
X$ read/prompt="_Enter package directory and base filename "/end=exit sys$com
Vmand P2
X$ goto package_location
X$end_package_location:
X$ P2 = f$parse(P2,,,,"SYNTAX_ONLY") - f$parse(P2,,,"VERSION")
X$ if f$parse(P2,,,"TYPE") .nes. "." then $ P2 = P2 + "_"
X$
X$
X$get_parts:
X$ if P3 .nes. "" then $ goto end_get_parts
X$ read/prompt="_Enter number of parts "/end=exit sys$command P3
X$ goto get_parts
X$end_get_parts:
X$
X$
X$! SET UP USEFUL SYMBOLS
X$ em="write sys$error ""%" +f$parse(f$environment("PROCEDURE"),,,"NAME")+"""
V,"
X$ package = f$parse(P2,,,"NAME")
X$ l = f$length(P3)
X$
X$
X$! IS THERE A SET OF FILES THAT MATCHES THE SPECIFICATION??
X$ if f$search("''P2'%%%-of-%%%.0") .eqs. "" then $ goto nopackage
X$
X$
X$! DO A QUICK CHECK TO MAKE SURE ALL REQUIRED FILES ARE THERE!!!!!
X$ part = 0
X$ OK = "TRUE"
X$check:
X$   part = part+1
X$   if part .gt. P3 then $ goto end_check
X$   xxx = f$fao("!3ZL",part)+ "-of-" + f$fao("!3ZL",p3)
X$   if f$search("''P2'''xxx'.0") .nes. "" then $ goto check
X$   em "-E-NOPART, Part ''part' of ''package' is missing!"
X$   OK = "FALSE"
X$   goto check
X$end_check:
X$
X$
X$! WERE ALL THE PARTS FOUND? IF NOT, NOW'S THE TIME TO FIND OUT!
X$ if .not. OK then $ goto abandon
X$
X$
X$! LOOP AROUND EACH PART AND SEND
X$ part = 0
X$loop:
X$   part = part+1
X$   if part .gt. P3 then $ exit ss$_normal
X$   n = f$fao("!3ZL/!3ZL",part,f$integer(p3))
X$   xxx = f$fao("!3ZL",part)+ "-of-" + f$fao("!3ZL",f$integer(p3))
X$   em "-I-SENDPART, sending part ", part, " of ", package
X$   mail/noedit/noself/subject="''package' ''P4' ''n'" 'P2''xxx' 'P1'
X$   if $status then $ goto loop
X$   exit $status`09! Return status from mail if it failed
X$
X$
X$nopackage:
X$  em "-E-NOPACKAGE, Cant find any files for ''package'."
X$  exit ss$_abort
X$abandon:
X$  em "-E-ABANDON, One or more missing parts. Send abandoned."
X$exit:
X$  exit ss$_abort
$ CALL UNPACK [.VMS_SHARE]PAKMAIL.COM;1 1262206637
$ create 'f'
X! Version 1.4
X!     -- Andy Harper, Kings College London, UK
X1 PAKMAIL
XSends a series of files produced by VMS_SHARE across the E-mail
Xsystem to a specified set of recipients.`20
X
XFormat:
X     $ PAKMAIL recipient filespec parts `5Bcomment`5D
X2 Errors
XThese errors can be returned from PAKMAIL.
X3 ABANDON
XOne or more of the parts of the package could not be found. Prior
Xmessages should give the specific parts that could not be found.
XSee NOPART.`20
X3 MAIL_errors
XPAKMAIL uses the MAIL utility to send the parts. Consequently
Xerrors may be issued by the MAIL utility under certain
Xconditions. Consult the MAIL reference manual and/or system
Xmessages reference manual for details of these.`20
X3 NOPACKAGE
XNo files could be found for the package at all so it is highly
Xprobable that the name of the package has been given incorrectly.
X3 NOPART
XIndicates that a particular part of the package cannot be found.
XGiven a filespec of '`5Bdir`5Dfile.type', the parts of the package
Xshould exist as:`20
X   `5Bdir`5Dfile.type_1
X   `5Bdir`5Dfile.type_2
X   ...
X3 SENDPART
XAn informational message to indicate that a particular part of
Xthe package is being sent.`20
X2 Example
X     $ PAKMAIL FRED `5B.TEST`5DPACKAGE 25
X          Send all 25 parts of a VMS_SHARE created series of files
X          that comprise the package "PACKAGE". Files have a generic
X          prefix of "`5B.TEST`5DPACKAGE" and  each will have its TYPE
X          suffixed by the VMS_SHARE convention of 'nn'
X2 Filespec
XThe directory and fixed constant part of the files containing the
XVMS_SHARE'd package. The part number is appended to the TYPE part
Xof the name.`20
X
XFor instance, the name "`5B.TEST`5DBURBLE.SHAR" refers to the files:
X
X     `5B.TEST`5DBURBLE.SHAR_nn
X
X'nn' being the part number.
X2 Comment
XSpecifies an optional comment to be inserted into the MAIL /SUBJECT
Xheader line, between the package name and the number of
Xthe part.`20
X
XFor example, without this parameter, the /SUBJECT line looks like
Xthis:`20
X   Subject:   VMS_SHARE  1/4
X
XWith it set to the string "(Version 7 Pre-release)", the /SUBJECT
Xline looks like this:`20
X   Subject:   VMS_SHARE (Version 7 Pre-Release) 1/4
X2 Parts
XSpecifies the number of parts making up the complete package to
Xbe sent. This defines the total number of files to be sent.`20
X
XThere is no default for this.
X2 Recipient
XThe mail address of the recipient. This may be anything which can
Xbe used on the MAIL command line. Because of the way MAIL parses
Xaddresses and the way DCL treats @ symbols, care is needed when
Xspecifying addresses which are distribution lists (usually
Xprefixed by @) or which contain double quotes.`20
X3 Distribution_Lists
XUse of distribution lists directly on the MAIl command line does
Xnot work as DCL gets at the '@' symbol before MAIL does!  It must
Xbe done by pointing a logical name at the distribution list,
Xincluding the '@' and then using the logical name as the
Xrecipient.`20
X
XFor instance, to simulate:
X
X   $ PAKMAIL @FRIENDS   ....
X
XDo:
X
X   $ DEFINE FRIENDS "@FRIENDS.DIS"
X   $ CREATE FRIENDS.DIS
X   ..... insert friends here
X   `5EZ
X   $ PAKMAIL FRIENDS .....
X3 Quoted_usernames
XUsernames must be specified in exactly the same form as they
Xwould be used on the MAIL command line, as in:`20
X
X   $ MAIL MESSAGE.TXT NET%"""FRED@MIT"""
X
XThis is important only when addresses containing double quotes
Xare used; essentially, individual quotes are doubled and a new
Xset placed around the lot.`20
X
XFor instance, to simulate:
X
X   $ PAKMAIL  EARN%"FRED@CARNEGIE"
X
XDo:
X   $ PAKMAIL  EARN%"""FRED@CARNEGIE"""
X
XAlternatively, define a logical name that contains the original
Xform of address:`20
X
X   $ DEFINE BROTHER EARN%"""FRED@CARNEGIE"""
X   $ PAKMAIL BROTHER   ...
X2 VMS_SHARE
XVMS_SHARE packages a series of files into the special format. See
Xthe help on that utility for specific information.`20
$ CALL UNPACK [.VMS_SHARE]PAKMAIL.HLP;1 1650067911
$ create 'f'
X$! Purpose:
X$!`09To mail out a series of files produced by VMS_SHARE to a news group
X$!`09(by default, VMSNET.SOURCES")
X$!
X$! Parameters:
X$!
X$!`09P1 = file spec of package - "`5Bdirectory`5Dfile" without VMS_SHARE suf
Vfix!
X$!
X$!`09P2 = news subject line
X$!
X$!`09P3 = news group to which files will be posted.
X$!
X$! Privileges:
X$!`09Whatever is necessary to access news and the relevant network.
X$!
X$!
X$! Environment:
X$!`09Nothing special.  VMS_SHARE must exist of course in order to
X$!`09produce the software package.
X$!
X$! Revision History:
X$!  1.000 Dick Munroe 07-Apr-91
X$!`09Original version created, based on PAKMAIL by Andy Harper.
X$!
X$!  1.001 Dick Munroe 29-Apr-91
X$!`09Change to news subject to force use of numbers something that can
X$!`09be seen by archiving packages.
X$!
X$
X$
X$! SET UP STANDARD EXIT CODES
X$ ss$_normal= 1
X$ ss$_abort = 44
X$
X$
X$! MAKE SURE WE HAVE ALL THE PARAMETERS
X$ if P3 .eqs. "" then p3 := vmsnet.sources
X$
X$package_location:
X$ if P1 .nes. "" then $ goto end_package_location
X$ read/prompt="_Enter package directory and base filename "/end=exit sys$com
Vmand P1
X$ goto package_location
X$end_package_location:
X$ P1 = f$parse(P1,,,,"SYNTAX_ONLY") - f$parse(P1,,,"VERSION")
X$ if f$parse(P1,,,"TYPE") .nes. "." then $ P1 = P1 + "_"
X$
X$! SET UP USEFUL SYMBOLS
X$ em="write sys$error ""%" +f$parse(f$environment("PROCEDURE"),,,"NAME")+"""
V,"
X$ package = f$parse(P1,,,"NAME")
X$
X$
X$! IS THERE A SET OF FILES THAT MATCHES THE SPECIFICATION??
X$ if f$search("''P1'%%%-of-%%%.0") .eqs. "" then $ goto nopackage
X$
X$! LOOP AROUND EACH PART AND SEND
X$ part = 0
X$loop:
X$   part = part+1
X$   xxx = f$search(p1+"%%%-of-%%%.0",0)
X$   if xxx .eqs. "" then exit ss$_normal
X$   yyy = f$element(0,";",(xxx - p1))
X$   subject = p2
X$   if subject .eqs. "" then subject = package
X$   subject = subject + ", part " + f$element(0,"-",yyy) + " OF " + f$elemen
Vt(2,"-",yyy)`20
X$   news/noscreen -
X`09post`09/subject="''subject'"-
X`09`09/newsgroup=('p3') -
X`09`09/noedit -
X`09'xxx'
X$   deck
XYES
X$   eod
X$   if $status then $ goto loop
X$   exit $status`09! Return status from mail if it failed
X$
X$
X$nopackage:
X$  em "-E-NOPACKAGE, Cant find any files for ''package'."
X$  exit ss$_abort
X$abandon:
X$  em "-E-ABANDON, One or more missing parts. Send abandoned."
X$exit:
X$  exit ss$_abort
$ CALL UNPACK [.VMS_SHARE]PAKNEWS.COM;1 1881979721
$ create 'f'
X    `09`09`09V M S _ S H A R E     TEST FILE
X
X---------------------------------------- Test printable characters
Xabcdefghijklmnopqrstuvwxyz`09! All lower case letter, in order
XABCDEFGHIJKLMNOPQRSTUVWXYZ`09! All upper case letters, in order
X0123456789`09`09`09! All digits in order
X`60  ! Backwords quote
X`7E  ! Tilde
X!  ! Exclamation mark
X@  ! at sign
X#  ! Hash or pound sign
X$  ! Dollar sign
X%  ! Percent sign
X`5E  ! Caret
X&  ! Ampersand
X*  ! asterisk
X(  ! Left round bracket
X)  ! Right round bracket
X-  ! minus
X+  ! plus
X=  ! equals
X`7B  ! left brace
X`7D  ! right brace
X`5B  ! left square bracket
X`5D  ! right square bracket
X:  ! colon
X"  ! Double quote
X`7C  ! vertical bar
X;  ! semicolon
X'  ! single quote
X\  ! backslash
X>  ! greater than
X<  ! less than
X,  ! comma
X.  ! period
X?  ! question mark
X/  ! slash
X---------------------------------------- Test single blank line
X
X---------------------------------------- Test trailing blanks, non split lin
Ves
XHere are some lines with trailing blanks      `20
Xand another    `20
X---------------------------------------- Test trailing blanks, split lines
X1234567890123456789012345678901234567890123456789012345678901234567890123456
V78901234567890123456789012345678901234567890123456789012345678901234567890
X1234567890    x     x     x     x     x     x     x     x     x     x     x
V     x     x    `20
X1234567890   x     x     x     x     x     x     x     x     x     x     x
V     x     x    `20
X1234567890  x     x     x     x     x     x     x     x     x     x     x
V     x     x      `20
X1234567890 x     x     x     x     x     x     x     x     x     x     x
V     x     x     `20
X1234567890x     x     x     x     x     x     x     x     x     x     x
V     x     x     `20
X
X
X    `09`09END OF  V M S _ S H A R E  TEST FILE
$ CALL UNPACK [.VMS_SHARE]TEST.TXT;1 942494529
$ create 'f'
X$ v = 'f$verify(f$trnlnm("SHARE_VERIFY"))'
X$! Purpose:
X$!`09Package a series of files into a format that can be mailed across
X$!      most networks without damage.
X$!
X$! Parameters:
X$!`09P1 = a comma separated list of file specifications which are to be
X$!`09     packaged together.  Only files in or below the current`20
X$!`09     subdirectory are permitted.
X$!
X$!`09P2 = The name of an output share file. Any version number specified
X$!`09     here is ignored and the next highest version created. The file
X$!`09     may not appear in the input list.
X$!
X$!`09P3 = Number of blocks per part.  If omitted, the value defaults to
X$!`09     the translation of SHARE_PART_SIZE.  If this is absent, then
X$!`09     the default value of 0 is used.
X$!
X$! Privileges:
X$!`09None required
X$!
X$! Environment:
X$!`09Requires at least VMS 4.4 in order to use GOSUB
X$!
X$! Revision History:
X$!`097.0`09Andy Harper`099-May-1989`09Complete rewrite
X$!`097.1`09Andy Harper`0915-Jun-1989`09Add file exclusion
X$!`097.2`09Andy Harper`0920-FEB-1990`09Various bug fixes
X$!`097.2-001`09Andy Harper`0920-FEB-1990`09Version check fix.
X$!`097.2-002`09Andy Harper`0920-FEB-1990`09Remove /nolog from sharefile.
X$!`097.2-003`09Andy Harper`0920-FEB-1990`09Rename 'buff' to 'b' in`20
X$!`09`09`09`09`09`09  share file to save space.
X$!`097.2-004`09Andy Harper`0920-FEB-1990`09Properly check part separator
X$!`09`09`09`09`09`09  to stop spurious matches.
X$!`097.2-005`09Andy Harper`0921-FEB-1990`09Use Hex encoding
X$!`097.2-006`09Andy Harper`0921-FEB-1990`09Replace EXIT by QUIT
X$!`097.2-007`09Andy Harper`0921-FEB-1990`09Divert tpu o/p to NL: if not`20
X$!`09`09`09`09`09`09  verifying when share file
X$!`09`09`09`09`09`09  unpacked.
X$!
X$!      7.2-008 Dick Munroe`0907-Apr-1991`09Allow the specification of a
X$!`09`09`09`09`09`09part size in the command line.
X$!`09`09`09`09`09`09Rename the emitted parts as
X$!`09`09`09`09`09`09nnn-of-mmm which makes them a
X$!`09`09`09`09`09`09LOT easier to keep track of.
X$!`097.2-009 Dick Munroe`0929-Apr-1991`09The algorithm for determining
X$!`09`09`09`09`09`09in sub-tree fails when starting
X$!`09`09`09`09`09`09in `5B000000`5D.
X$!`097.2-010 Dick Munroe`0925-Jun-1992`09The igsh branch doesn't make`20
X$!`09`09`09`09`09`09any sense given that output
X$!`09`09`09`09`09`09files are now numbered .xxx as
X$!`09`09`09`09`09`09temporaries and .xxx-of-nnn as
X$!`09`09`09`09`09`09finals.
X$!`097.2-011 Dick Munroe`0926-Jun-1992`09Check for later versions of the
X$!`09`09`09`09`09`09file and ask to create new ones
X$!`09`09`09`09`09`09if necessary.
X$!
X$!
X$! Comments:
X$!`09We use a little known feature of f$parse to translate the
X$!`09brackets in directory names from <..> to `5B...`5D
X$!`09The format  f$parse(xx,"`5B`5D")  forces the brackets to `5B..`5D
X$!`09The format  f$parse(xx,"<>")  forces the brackets to <..>
X$
X$
X$
X$! INSULATE USER FROM EXTERNAL SYMBOL DEFINITIONS
X$ set = "set"
X$ set symbol/scope=(nolocal,noglobal)
X$
X$
X$! DEFINE ESSENTIAL SYMBOLS
X$ em="write sys$error ""%"+f$parse(f$environment("PROCEDURE"),,,"NAME")+ """
V,"
X$ temp = f$parse("SHARE_TEMP","SYS$SCRATCH:SHARE_TEMP.TMP_"+f$getjpi("","PID
V"))
X$ temp = f$parse(temp-f$parse(temp,,,"VERSION"),"`5B`5D") - ";"
X$ default = f$parse("","`5B`5D") - ".;"
X$
X$ set noon
X$ on control_y then $ goto abort
X$
X$
X$! MAKE SURE WE CAN RUN ON THIS VERSION OF VMS
X$ vers=f$getsyi("VERSION")
X$ if vers - f$extract(0,1,vers) .lts. "4.4" then $ goto ancient_VMS
X$
X$
X$! GET LIST OF FILES TO BE PACKAGED
X$get_filespec:
X$ if P1 .nes. "" then $ goto end_get_filespec
X$ read/prompt="Filespec : " sys$command P1
X$ goto get_filespec
X$end_get_filespec:
X$
X$
X$! GET NAME OF OUTPUT FILE
X$sharespec:
X$ if P2 .nes. "" then $ goto end_sharespec
X$ read/prompt="Share file : " sys$command P2
X$ goto sharespec
X$end_sharespec:
X$
X$
X$! MASSAGE FILE NAME TO FORCE SQUARE BRACKETS AROUND DIRECTORY NAME
X$ P2 = f$parse(P2-f$parse(P2,,,"VERSION"),"`5B`5D") - ";"
X$ if P2 .eqs. "" then $ goto nooutputdir
X$ if f$parse(P2,,,"TYPE") .nes. "." then $ P2 = P2 + "_"
X$
X$
X$! PICK UP PARAMETERS FROM USER, VIA LOGICALS. SET NECESSARY DEFAULTS
X$ Real_Name = f$trnlnm("SHARE_REAL_NAME")
X$ if Real_Name .nes. "" then $ Real_Name = "(" + Real_Name + ")"
X$
X$ Max_Part_Size = f$integer(p3)
X$ if Max_Part_Size .eq. 0 then -
X`09Max_Part_Size = f$integer(f$trnlnm("SHARE_PART_SIZE"))
X$ if Max_Part_Size .eq. 0 then $ Max_Part_Size = 30
X$ if Max_Part_Size .lt. 6 then $ Max_Part_Size = 6
X$
X$`20
X$ X_dir  = f$edit(f$trnlnm("SHARE_EXCLUDE_DIRS"), "UPCASE") + ","
X$ X_name = f$edit(f$trnlnm("SHARE_EXCLUDE_NAMES"),"UPCASE") + ","
X$ X_type = f$edit(f$trnlnm("SHARE_EXCLUDE_TYPES"),"UPCASE") + ",.DIR,"
X$
X$
X$! OPEN A FILE FOR PASSING PARAMETERS TO THE TPU CODE
X$ open/write/error=cantopen xx_share_params 'temp'
X$ write xx_share_params f$edit(f$getjpi("","USERNAME"),"TRIM")," ", Real_Nam
Ve
X$ write xx_share_params Max_Part_Size
X$ write xx_share_params P2
X$
X$
X$! INITIALIZE FOR SCANNING THE FILENAMES
X$ file_count = 0
X$ file_element = -1
X$
X$! GET NEXT ELEMENT FROM COMMA SEPARATED LIST OF WILDCARDED FILESPEC ELEMENT
VS
X$next_file_element:
X$ file_element = file_element + 1
X$ file = f$element(file_element,",",P1)
X$ if file .eqs. "," then $ goto no_more_files
X$
X$! MASSAGE FILE NAME/PATTERN TO FORCE SQUARE BRACKETS AROUND DIRECTORY NAME
X$ v = f$parse(file,,,"VERSION")
X$ file = f$parse(file-v,"`5B`5D") - ";" + v
X$
X$
X$! DO WE HAVE A FILE THAT MATCHES THIS SPECIFICATION???
X$ file_name = f$search(file)
X$ if file_name .eqs. "" then $ em "-W-FNF, ''file' not found. Ignored."
X$ if file_name .eqs. "" then $ goto next_file_element
X$
X$`20
X$! WE HAVE A VALID FILE SPEC SO GO DO SOME WORK ON IT.
X$fname:
X$ F_dir = f$parse(file_name,,,"DIRECTORY") +","
X$ F_name= f$parse(file_name,,,"NAME") + ","
X$ F_type= f$parse(file_name,,,"TYPE") + ","
X$ if file_name-f$parse(file_name,,,"VERSION") .nes. temp then $ -
X    if f$locate(F_dir,X_dir) .eq. f$length(X_dir) then $ -
X        if f$locate(F_name,X_name) .eq. f$length(X_name) then $ -
X            if f$locate(F_type,X_type) .eq. f$length(X_type) then $ -
X                gosub process_file
X$
X$
X$! LOCATE THE NEXT MATCHING FILENAME
X$ previous_file = file_name
X$ file_name = f$search(file)
X$ if file_name .nes. "" .and. file_name .nes. previous_file then $ goto fnam
Ve
X$ goto next_file_element
X$
X$
X$! NO MORE FILES, PROCESS THE LIST WE HAVE OBTAINED.
X$no_more_files:
X$ close xx_share_params
X$ if file_count .ne. 0 then $ goto dopacking
X$ em "-E-NOFILES, No files found."
X$ goto cleanup
X$
X$
X$
X$Process_File: ! file_name, P2 (sharefile), file_count, default
X$! Check that the file isn't from a previous packing pass.
X$  x = file_name
X$  check = x - p2
X$  if check .eqs. x then goto 50$
X$  x = check - f$parse(x,,,"VERSION")
X$  check = x - "-OF-"
X$  if check .eqs. x then goto 50$
X$  if f$type(check) .nes. "INTEGER" then goto 50$
X$  if f$length(check) .ne. 6 then goto 50$
X$  goto igsh
X$50$:
X$! CHECK FILE IS WITHIN OR BELOW CURRENT SUBDIRECTORY, REMOVE LEADING STUFF
X$  x = file_name
X$  x = x - (default - "`5B000000`5D" - "`5D")
X$  c = f$extract(0,1,x)
X$  if c .nes. "`5B" .and. c .nes. "`5D" .and. c .nes. "." then $ goto cantar
Vchive
X$  if c .eqs. "`5B" then x = x - "`5B`5D"
X$  if c .nes. "`5B" then x = "`5B" + x - "`5B`5D"
X$
X$  file_count = file_count + 1
X$  em "-I-SELECTED, Selected file ''file_count' - ''x'"
X$  checksum 'x'
X$  write xx_share_params x, " ", checksum$checksum
X$  return
X$
X$igsh:
X$  em "-W-SHRNOTPACK, Share file part ''file_name' discovered. Not packaged!
V"
X$  return
X$
X$cantarchive:
X$ em "-E-NOTINTREE, ''file_name' not within/below current dir."
X$ goto cleanup
X$
X$ancient_VMS:
X$ em "-E-OLDVMS, Cannot run on VMS ",f$getsyi("VERSION")," need 4.4 at least
V"
X$ goto cleanup
X$
X$cantopen:
X$ em "-E-NOPARFIL, Unable to open temporary parameter file ''temp'"
X$ goto reset_environment
X$
X$nooutputdir:
X$ em "-E-NOOUTDIR, Directory for output file ''P2' not found."
X$ goto cleanup
X$
X$abort:
X$ em "-F-ABORT, Abort detected. Packing abandoned."
X$cleanup:
X$ if f$trnlnm("xx_share_params") .nes. "" then $ close xx_share_params
X$ if f$search(temp) .nes. "" then $ delete /nolog /noconfirm 'temp';*
X$reset_environment:
X$ v = f$verify(v)
X$ exit 44
X$
X$
X$! WEVE GOT A LIST OF FILES TO PACK SO LETS DO IT NOW!
X$dopacking:
X$ edit/tpu/nosec/nodis/com=sys$input 'temp'
X! +--------------------------------------------------------------------+
X! + FACILITY:                                                          +
X! +         VMS_SHARE                                                  +
X! +                                                                    +
X! + PURPOSE:                                                           +
X! +         To package a series of plain text files into a format that +
X! +         can be successfully mailed through most networks without   +
X! +         damage:                                                    +
X! +                                                                    +
X! +         Characters prone to translation by mailers/networks are    +
X! +         encoded into a form that will (hopefully) not be altered   +
X! +         but we cannot recover if they ARE altered despite the      +
X! +         encoding. A checksum is included so we can at least detect +
X! +         corruption.                                                +
X! +                                                                    +
X! + RESTRICTIONS:                                                      +
X! +         Text files only, NOT binary or executables                 +
X! +                                                                    +
X! +         No retransmit protocol with mailers, so cannot recover     +
X! +         from mangled mail files such as missing lines, character   +
X! +         translations etc.                                          +
X! +                                                                    +
X! + VERSION:                                                           +
X! +         7.0-001   Pack multiple files into single part             +
X! +         7.0-002   Produce multiple parts < Some maximum size       +
X! +         7.0-003   Deal with subdirectories on output               +
X! +         7.0-004   Output packed TPU code to unpack files           +
X! +         7.0-005   Quote troublesome characters & trailing blanks   +
X! +         7.0-006   Wrap long lines                                  +
X! +                                                                    +
X! +         7.1-001   Various bug fixes for release                    +
X! +         7.1-002   Further minor bug fixes                          +
X! +         7.1-003   Fix position of CUT HERE line in share file      +
X! +         7.1-004   Support <> in directories and fix VMS version chk+
X! +                                                                    +
X! +         7.2       Various bug fixes                                +
X! +                                                                    +
X! +  AUTHOR:                                                           +
X! +         (C) ANDY HARPER, KINGS COLLEGE LONDON, UK     1990         +
X! +                                                                    +
X! +  CREDITS:                                                          +
X! +         James Gray for the first version of VMS_SHARE              +
X! +         Michael Bednarek for the original idea and prototype       +
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-
