From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 10-AUG-1989 16:16
To:	MRGATE::"ARISIA::EVERHART"
Subj:	VMS_SHARE (7.1-004) 2/8

Message-Id:  <8908101948.AA05007@crdgw1.ge.com>
Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu, 10 AUG 89 11:47:50 PDT
Received: from NSFnet-Relay.AC.UK by KL.SRI.COM with TCP; Thu, 10 Aug 89 11:28:48 PDT
Received: from oak.cc.kcl.ac.uk by NSFnet-Relay.AC.UK   via Janet with NIFTP
           id aa09515; 10 Aug 89 18:17 BST
Date: 		Thu, 10 AUG 89 18:17:48 GMT
From: UDAA055%oak.cc.kcl.ac.uk@NSFnet-Relay.AC.UK
To: info-vax <@NSFnet-Relay.AC.UK:info-vax@kl.sri.com>
Subject:        VMS_SHARE (7.1-004) 2/8
Sender: "JANET UDAA055@UK.AC.KCL.CC.OAK" <UDAA055%oak.cc.kcl.ac.uk@NSFnet-Relay.AC.UK>
Mailer:         Janet_Mailshr V3.4 (23-May-1989)

-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
Xto VMS_SHARE would cause unexpected actions and usually cause VMS_SHARE to`0
V32
Xfail.
X
X
X
X2.3 Spurious Rejection of certain files`009`009`009(7.1-002)
X
XVMS_SHARE contains code to reject any attempt to include the output files in
V`032
Xthe packed archive on the grounds that packing an archive into itself is not
V`032
Xsensible. However the code for this check was faulty due to an undocumented`
V032
X'feature' of the f$integer lexical which returns 1 if a string starts with`0
V32
XT or Y (in other words, does a conversion from boolean to integer where T,Y
V =`032
X1 and F, N = 0). This caused some perfectly valid filenames to be rejected o
Vn
Xthe grounds that they had the same name as the output file.
X
XAs an example, if the output file is specified as 'V' then invalid input fil
Ves
Xwould be anything starting with this name followed by a number, such as 'V.1
V',
X'V.2' etc. The bug also caused files 'V.T' and 'V.Y' to be invalid.`032
X
XThe code has now been fixed by avoiding the use of f$integer until the strin
Vg`032
Xhas been checked with f$type to make sure it really is a number.
X
X
X
X2.4 Movement Of Generated CUT HERE line`009`009`009(7.1-003)
X
XThe inclusion of the verification option (SHARE_VERIFY) was inadvertently`03
V2
Xplaced BEFORE rather than AFTER the ' ...   CUT HERE   ... ' line in the`032
Xgenerated share file. It has now been moved to its proper place ensuring tha
Vt`032
Xcutting on the indicated line does not remove the VERIFY option.
X
X
X
X2.5 Angle Brackets in Directory names`009`009`009(7.1-004)
X
XIf the parameters to VMS_SHARE, or the current default directory, contained`
V032
Xangle brackets around directory specifications (For example, <TEST> rather`0
V32
Xthan the more normal `091TEST`093) then VMS_SHARE treated each file as inval
Vid`032
Xbecause it was not designed to handle the <> notation, which is perfectly`03
V2
Xvalid VMS syntax.
X
XThis problem has been cured by ensuring that all occurrences of <..> notatio
Vn`032
Xare translated to the more normal `091..`093 notation before processing the`
V032
Xfilenames. The way in which this is done relys on a little known feature of`
V032
Xthe f$parse lexical function:
X
X   f$parse(P1,"`091`093")  will translate any <..> directory to `091..`093
X
X   f$parse(P1,"<>")  will translate any `091..`093 directory to <..>
X
XHowever if P1 contains a version number the conversion is not done! (WHY thi
Vs`032
Xshould be so is a mystery at this time)
X
X
X
X2.6 Check for correct VMS version in created share file`009(7.1-004)
X
XThe check for a minimum revision of VMS was incorrect. The current version,`
V032
Xobtained with f$getsyi("VERSION") was being checked against "4.4" instead of
V`032
X"V4.4".
X
X
X
X2.7 Check for correct VMS version in main procedure`009(7.1-004)
X
XNo check was made in the main VMS_SHARE procedure for the correct minimum`03
V2
Xrevision of VMS required. This would cause it to fail if run on a pre-VMS 4.
V4`032
Xsystem. A check has now been included.
X
X
X
X2.8 Information on errors in HELP`009`009`009(7.1-004)
X
XExplanations of the error codes for both VMS_SHARE and PAKMAIL have been`032
Xincluded into the HELP files for the utilities. There are also some minor`03
V2
Xeditorial changes to the help text.
X
X
X
X2.9 User Guide`009`009`009`009`009`009(7.1-004)
X
XA preliminary user guide is issued with this release. This describes the`032
Xrationale behind VMS_SHARE, from the user's viewpoint and details of how to`
V032
Xuse both VMS_SHARE and PAKMAIL. Details of unpacking share files are include
Vd`032
Xalso.
X
X
X
X2.10 Location of Break Point`009`009`009`009(7.1-004)
X
XCorrected the check for a null buffer in the routine which locates the optim
Vum`032
Xbreak point for a share file part.
X
X
X2.11 Part Separator Insertion
X
XCorrected the check for the right part separator, GOTO/label or special flag
V`032
Xlines, by only checking the line below the separation point and not the line
Vs`032
Xon either side.  This ensures that the GOTO/LABEL code is only used when the
V`032
Xsplit point immediately precedes DCL code.
X
X
X
X3. KNOWN PROBLEMS
X
XThere are no known problems at this time.
X
X
X
X
XAndy Harper
X9-AUG-1989
$ CALL UNPACK VMS_SHARE.BUGS;11 460132356
$ create/nolog 'f'
X$ v = 'f$verify(f$trnlnm("SHARE_VERIFY"))'
X$! Purpose:
X$!`009Package a series of files into a format that can be mailed across
X$!      most networks without damage.
X$!
X$! Parameters:
X$!`009P1 = a comma separated list of file specifications which are to be
X$!`009     packaged together.  Only files in or below the current`032
X$!`009     subdirectory are permitted.
X$!
X$!`009P2 = The name of an output share file. Any version number specified
X$!`009     here is ignored and the next highest version created. The file
X$!`009     may not appear in the input list.
X$!
X$! Privileges:
X$!`009None required
X$!
X$! Environment:
X$!`009Requires at least VMS 4.4 in order to use GOSUB
X$!
X$! Revision History:
X$!`0097.0`009Andy Harper`0099-May-1989`009Complete rewrite
X$!`0097.1`009Andy Harper`00915-Jun-1989`009Add file exclusion
X$!`0097.1-001`009Andy Harper`00929-JUN-1989`009Minor bug fixes
X$!`0097.1-002 Andy Harper`00917-JUL-1989`009Further minor bug fixes
X$!`0097.1-003 Andy Harper`00931-Jul-1989`009Move '-- CUT ---' line !!!
X$!`0097.1-004 Andy Harper`0091-Aug-1989`009Deal with <> brackets
X$!`009`009`009`009`009`009& fix VMS version checks
X$!
X$! Comments:
X$!`009We use a little known feature of f$parse to translate the
X$!`009brackets in directory names from <..> to `091...`093
X$!`009The format  f$parse(xx,"`091`093")  forces the brackets to `091..`093
X$!`009The 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"),"`091`093") - ";"
X$ default = f$parse("","`091`093") - ".;"
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$ if f$getsyi("VERSION") .lts. "V4.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"),"`091`093") - ";"
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(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$`032
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,"`091`093") - ";" + 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$`032
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$
X$! CHECK FILE IS WITHIN OR BELOW CURRENT SUBDIRECTORY, REMOVE LEADING STUFF
X$  x = file_name
X$  check = x - f$parse(x,,,"VERSION") - P2
X$  if f$type(check) .eqs. "INTEGER" then $ if check .gt. 0 then goto igsh
X$  x = x - (default-"`093")
X$  c = f$extract(0,1,x)
X$  if c .nes. "`093" .and. c .nes. "." then $ goto cantarchive
X$  x = "`091" + x - "`091`093"
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 V4.4 at leas
Vt"
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! +         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! +  AUTHOR:                                                           +
X! +         (C) ANDY HARPER, KINGS COLLEGE LONDON, UK     1989         +
X! +                                                                    +
X! +  CREDITS:                                                          +
X! +         James Gray for the first version of VMS_SHARE              +
X! +         Michael Bednarek for the original idea and prototype       +
X! +                                                                    +
X! +--------------------------------------------------------------------+
X!
X!
X`012
X! +--------------------------------------------------------------------+
X! + Initialisation routine to set up global constant values            +
X! +--------------------------------------------------------------------+
X
XPROCEDURE Init_Constants;
X
X   FAC_name       := "VMS_SHARE";`009! Facility name/version
X   FAC_vers       := "7.1-004  3-AUG-1989";
+-+-+-+-+-+-+-+-  END  OF PART 2 +-+-+-+-+-+-+-+-

