Notes on Zip under MVS Language Environment (LE).

First see README.MVS.  This note describes just one beta test on OS/390
V2R5 using IBM's C compiler (5647A01), V2R4.  The major difference is
the use of LE on the beta site, together with some MVS native mode
fixes.  Changes have not been tested on CMS.

Some of the notes are to clarify things that were not clear from the
MANUAL or README.MVS.

1.  By default, IBM C generates the same csect name for each input
    source.  The prelink stage does not rename them and the linkage
    editor throws away all but the first occurrence of each duplicate.
    Oops, my code just disappeared :(.

    To get around this "feature", compile with the CSECT option to
    force sensible names on the code and data sections of each csect.
    The name of the static data csect defaults to the source name in
    lower case, the code csect defaults to the source name in upper
    case.  These csect names still have to be unique, they cannot be
    the same as function names.  Of course, several csects have a
    function which is the same name as the source in lower case, not
    exactly an unusual occurrence.  Therefore to make the csect name
    unique, some of the sources have

    #ifdef MVS
    #  pragma csect(STATIC,xxxx_s)
    #endif

    Where xxxx is an abbreviation of the source name.  There has to be
    a better way!

2.  The prelink step always gets cond code 4.  It complains about
    unresolved references, ignore it unless the linker also complains.
    Prelink also complains about duplicate @@PPA2 sections and so does
    the linker, but it seems to do no harm.  Compile and link steps
    should get 0, just prelink gets 4.  See JCL at the bottom.

3.  Under MVS native mode (not Open Edition), tmpnam() returns a quoted
    name of 5 qualifiers.  The first is a HLQ chosen according to the
    MVS LE algorithm (see below), the other qualifiers are time stamps.
    If running on MVS and tmpnam() returns a quoted name with at leat
    one '.', it is only safe to let the user change the high level
    qualifier.  Therefore -b insists on a single qualifier without '.'
    in the MVS native environment.

4.  In Open Edition (OE) mode, the manual says that tmpnam() returns a
    fully qualified name in directory TMPDIR or /tmp if TMPDIR is not
    set.  There is no point in zip trying to override that name so -b
    is ignored in MVS OE mode (untested).  The user should specify
    environment variable TMPDIR instead.

5.  The MVS LE algorithm for choosing the high level qualifier for
    native filenames is interesting, as in "May you live in interesting
    times".  The HLQ varies according to the environment the program is
    running in, sometimes it is userid, sometimes it is TSO prefix.
    See OS/390 C/C++ Programming Guide, Using a Data Set Name,
    somewhere around section 2.9.

    If in doubt, use fully qualified and quoted names.  Instead of
    archive.zip, use 'prefix.archive.zip'.  For input files, instead of
    filename, use 'prefix.filename'.  For PARM= in JCL, double up the
    quotes.  You even have to quote filenames in stdin.

6.  If your PARM includes any '/', make sure the PARM starts with '/'.
    LE assumes anything before the first '/' is LE run time parameters.
    It does no harm to always code a leading '/' for LE parms.

7.  JCL limits a PARM= to 100 characters total with approx. 65 on a
    single line.  Alas the syntax for continuing PARM= always embeds an
    extra ',' somewhere in the parameters that the program finally
    gets.  No workaround, limit your PARM to a single line.  With the
    extra quotes around filenames, that does not leave much room.  In
    most cases, you will have to use '-@' to read the list of filenames
    from SYSIN (stdin), it will not fit on a single PARM line.

8.  Filenames can be dataset names or you can refer to a ddname with
    'DD:name', case insensitive for external files, case sensitive for
    OE files.  You can even specify 'dd:name(mem)'.  No wildcards, to
    zip a complete pds you have to specify each member individually.
    Directory recursion in OE does not appear to work at the moment.

9.  Zip attempts to map MVS filenames to Unix style names.  It did not
    work correctly for quoted names, fixed.  Although you can pick up
    an external (non-OE) file with a name using any case, be aware that
    the mapping to a Unix style name faithfully follows the case you
    supply.

10. The archive file was being created with recfm=V and lrecl=32760.
    32760 is not valid for recfm=V under MVS, I originally changed it
    to lrecl=32756.  Then zip broke trying to fseek() over a record
    boundary, I do not know whether this was a zip or LE bug.  Trial
    and error showed that recfm=U with byteseek seems to work on MVS.
    No BDW or RDW, just a byte stream.  The blocksize is always 6144.

    NOTE: This is an incompatible change from the previous beta,
          archive files used to be recfm=V.  That should not matter
          because we just transfer the data, ignoring BDW and RDW
          anyway.

11. Zip used to complain about preallocated but empty archives, wrong
    length records, no signature etc.  The usual IBM/360 problem of no
    end of file marker in a new, unopened dataset.  Fixed, see routine
    readzipfile in zipfile.c for the gory details.  PARM= works fine.

12. Several source files have records that are more than 80 bytes long.
    It works if you transfer to mainframe datasets with a larger lrecl,
    I used recfm=fb,lrecl=120 for the .C and .H files.  To compile with
    anything longer than 72 bytes, you need MVS C options NOMARGINS and
    NOSEQUENCE (NOMAR,NOSEQ).

13. cmsmvs was still using zname instead of name for open.  Fixed.

14. zip has to jump through a lot of hoops to see if an existing
    zipfile actually contains data.  A side effect of this is that
    creating a zipfile with the RLSE parameter is a waste of time.

Keith Owens <kaos@ocs.com.au>.  Not a maintainer, just a beta tester.
Mon Sep 14 19:31:30 EST 1998


Sample JCL to compile Zip under MVS LE.  You might need a large region,
I used REGION=128M on the job card.  Also watch the output lines,
75,000 with OPT(2), 100,000+ with OPT(2) replaced with DEF(DEBUG).  You
need to allocate prefix.ZIP.C.OBJ (recfm=FB, lrecl=80) and
prefix.ZIP.LOAD (recfm=U, blksize is site defined).

//CBC    JCLLIB ORDER=CBC.SCBCPRC
//ZIP EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(ZIP)',
//    OUTFILE='prefix.ZIP.C.OBJ(ZIP),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//CRYPT EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(CRYPT)',
//    OUTFILE='prefix.ZIP.C.OBJ(CRYPT),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//TTYIO EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(TTYIO)',
//    OUTFILE='prefix.ZIP.C.OBJ(TTYIO),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//TREES EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(TREES)',
//    OUTFILE='prefix.ZIP.C.OBJ(TREES),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//DEFLATE EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(DEFLATE)',
//    OUTFILE='prefix.ZIP.C.OBJ(DEFLATE),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//FILEIO EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(FILEIO)',
//    OUTFILE='prefix.ZIP.C.OBJ(FILEIO),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//GLOBALS EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(GLOBALS)',
//    OUTFILE='prefix.ZIP.C.OBJ(GLOBALS),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//UTIL EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(UTIL)',
//    OUTFILE='prefix.ZIP.C.OBJ(UTIL),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//CRC32 EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(CRC32)',
//    OUTFILE='prefix.ZIP.C.OBJ(CRC32),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//CRCTAB EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(CRCTAB)',
//    OUTFILE='prefix.ZIP.C.OBJ(CRCTAB),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//ZIPFILE EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(ZIPFILE)',
//    OUTFILE='prefix.ZIP.C.OBJ(ZIPFILE),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//ZIPUP EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(ZIPUP)',
//    OUTFILE='prefix.ZIP.C.OBJ(ZIPUP),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//CMSMVS EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(CMSMVS)',
//    OUTFILE='prefix.ZIP.C.OBJ(CMSMVS),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//MVS EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
//    INFILE='prefix.ZIP.C(MVS)',
//    OUTFILE='prefix.ZIP.C.OBJ(MVS),DISP=SHR',
//    CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
//    CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
//PLINK   EXEC  PROC=EDCPL,
//    OUTFILE='prefix.ZIP.LOAD(ZIP),DISP=SHR',
//    PREGSIZ=6M,
//    PPARM='NONCAL,MAP,MEMORY',
//    LPARM='LIST,MAP,XREF'
//PLKED.SYSIN   DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(ZIP)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(CRYPT)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(TREES)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(DEFLATE)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(FILEIO)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(GLOBALS)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(UTIL)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(CRC32)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(CRCTAB)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(ZIPFILE)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(ZIPUP)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(MVS)
//              DD  DISP=SHR,DSN=prefix.ZIP.C.OBJ(CMSMVS)
//LKED.SYSLIB   DD  DISP=SHR,DSN=CEE.SCEELKED
//SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(2,2))
//

Sample JCL to zip the mainframe .C and .H files as ASCII (-a).  Delete
any existing archive first, point the temporary file at a particular
prefix (-b), use 'prefix.ARCHIVE.ZIP' for the archive file, read the
list of files to zip from stdin (SYSIN).

//DELETE  EXEC PGM=IDCAMS
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  *
 DELETE prefix.ARCHIVE.ZIP
 SET MAXCC = 0
//ZIP     EXEC PGM=ZIP,
// PARM='/-a -v -b temppref ''prefix.ARCHIVE.ZIP'' -@'
//STEPLIB  DD  DSN=prefix.ZIP.LOAD,DISP=SHR
//SYSPRINT DD  SYSOUT=*
//SYSOUT   DD  SYSOUT=*
//CEEDUMP  DD  SYSOUT=*
//ZIPC     DD  DISP=SHR,DSN=prefix.ZIP.C
//ZIPH     DD  DISP=SHR,DSN=prefix.ZIP.H
//SYSIN    DD  *
dd:zipc(api)
dd:zipc(cms)
dd:zipc(cmsmvs)
dd:zipc(crctab)
dd:zipc(crc32)
dd:zipc(crypt)
dd:zipc(deflate)
dd:zipc(fileio)
dd:zipc(globals)
dd:zipc(mktime)
dd:zipc(mvs)
dd:zipc(trees)
dd:zipc(ttyio)
dd:zipc(util)
dd:zipc(zip)
dd:zipc(zipcloak)
dd:zipc(zipfile)
dd:zipc(zipnote)
dd:zipc(zipsplit)
dd:zipc(zipup)
dd:ziph(api)
dd:ziph(cmsmvs)
dd:ziph(crypt)
dd:ziph(cstat)
dd:ziph(ebcdic)
dd:ziph(mvs)
dd:ziph(revision)
dd:ziph(stat)
dd:ziph(tailor)
dd:ziph(ttyio)
dd:ziph(zip)
dd:ziph(ziperr)
dd:ziph(zipup)
