home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
viscobv7.zip
/
vac22os2
/
ibmcobol
/
macros
/
iwzmsav.lx
< prev
next >
Wrap
Text File
|
1997-12-17
|
20KB
|
709 lines
/* Reinvoking as "REXX %0 %1 %2 %3 %4 %5 %6 %7 %8 %9" 2>nul
@goto runit */
/*********************************************************************/
/* Licensed Material - Property of IBM */
/* 5639-B92 , 5639-D65 (C) Copyright IBM Corp., 1997, 1998 */
/* All rights reserved. */
/* US Government Users Restricted Rights - Use, duplication or */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */
/*********************************************************************/
trace off;
signal on novalue;
parse source opsys . whoami rest;
/* cobolroot is now set by iwzmIR.CMD */
if opsys = 'OS/2' then
do;
env = 'OS2ENVIRONMENT';
callit = '@Call';
call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs';
call SysLoadFuncs;
end;
else
do;
env = 'ENVIRONMENT';
callit = '@Rexx';
end;
tempdir = value('TMP',,env);
tempout = SysTempFileName(tempdir'\TM?????.OUT');
tempout2 = SysTempFileName(tempdir'\T2?????.OUT');
xx = Get_MVSINFO();
if xx <> 0 then
exit 16;
call Set_MVSINFO_Vars;
if tracemod = '*' |,
wordpos(translate(substr(whoami,lastpos('\',whoami)+1)),tracemod) > 0 then
do;
if trace > 3 then trace results;
if trace > 4 then trace ?;
end;
parse arg the_input_args;
call traceit 1 'Entry' '!'the_input_args'!';
trysave = 'no';
trytemp = 'no';
didprot = 'no';
protsavetype = '';
tmpsave = random(99999);
tmpsave = substr('00000'tmpsave,length(tmpsave),6);
tmpsave = value('TMP',,env)'\CS'tmpsave'.MVS';
'set messages on';
'check';
'extract changes into changes';
'extract name into filename';
call traceit 2 'Save for' filename;
if filesys = 'SDU' then
timeout = 'SDU';
else
do;
if writetimeout = '' | writetimeout < 1 then
timeout = 1;
else
timeout = writetimeout;
end;
parse arg theargs;
newargs = '';
inquote = 'no';
sepchar = '01'x;
if length(theargs) > 0 then
do;
do ii = 1 to length(theargs);
thechar = substr(theargs,ii,1);
select;
when thechar = '"' then
do;
if inquote = 'yes' then
inquote = 'no';
else
inquote = 'yes';
newargs = newargs||thechar;
end;
when thechar == ' ' then
do;
if inquote = 'yes' then
newargs = newargs||sepchar;
else
newargs = newargs||thechar;
end;
otherwise
newargs = newargs||thechar;
end;
end;
end;
do ii = 1 to 12;
thearg.ii = word(newargs,ii);
thearg.ii = translate(thearg.ii,' ',sepchar);
end;
a1 = thearg.1;
savetype = 'save';
if a1 <> '' then
do;
if substr(a1,1,1) <> '/' then
do;
savetype = 'saveas';
savename = a1;
end;
else
savename = filename;
end;
else
savename = filename;
if savetype = 'save' & protsave <> 'NO' then
do;
'extract docnum into docnum';
'extract global.protsave_'docnum 'into savestat';
'extract global.protsave_saveall into saveallstat';
if savestat = 'protsave' then
do;
call message 01;
'alarm';
call traceit 1 'Error exit';
exit -6;
end;
if length(filename) < 3 then
call errmsg 02 filename;
if substr(filename,2,2) <> ':\' then
call errmsg 02 filename;
usedrive = substr(filename,1,2);
usedrive = translate(usedrive);
parse upper var filename filedrive '\' dsname '\' member;
if dsname = '' then
call errmsg 02 filename;
if member <> '' then
do;
parse var member member '.' memext;
if memext <> '' then
memext = '.'memext;
if member = '' then
call errmsg 02 filename;
hqual = '';
if numdrive > 0 then
do;
do ii = 1 to numdrive;
if usedrive = drive.ii then
do;
hqual = highqual.ii;
leave;
end;
end;
end;
if hqual = '' then
call errmsg 03 filename;
dsname = hqual'.'dsname;
'extract docnum into docnum';
'extract global.tempdsn_'docnum 'into tempsaved';
'extract global.mvsrecfm_'docnum 'into mvsrecfm';
'extract global.mvslrecl_'docnum 'into mvslrecl';
extract_rc = rc;
if extract_rc <> 0 then
call errmsg 04;
parse var tempsaved tempsaved '/' maxrecd;
tempsaved2 = tempsaved;
if maxrecd = '' then
maxrecd = 99999998;
tempsaved = strip(tempsaved,'B',"'");
tmpdrv = '';
if tempdata <> '' then
do;
if numdrive > 0 then
do;
do ii = 1 to numdrive;
if tempdata = drive.ii & trans.ii = 'text,crlf' then
do;
tmpdrv = drive.ii;
temphqual = highqual.ii;
len = length(temphqual) + 2;
temprest = substr(tempsaved,len);
leave;
end;
end;
end;
end;
else
do;
parse upper var tempsaved temphqual '.' temprest;
if numdrive > 0 then
do;
do ii = 1 to numdrive;
if temphqual = highqual.ii & trans.ii = 'text,crlf' then
do;
tmpdrv = drive.ii;
leave;
end;
end;
end;
end;
if tmpdrv = '' then
call errmsg 05;
'extract elements into numlines';
if numlines > 99999998 then
call errmsg 06;
maxstor = (numlines + 1) * mvslrecl;
if maxstor > ((2 ** 31) - 1) then
call errmsg 07;
if numlines >= maxrecd then /* allow for one more for timestamp */
do;
call message 08;
'sshow';
xx = SysSleep(1);
iwzmtso = '+IGYFINFO' tempsaved2 'TDR' tempmult numlines;
call traceit 2 'Before IGYFINFO';
if mvscomm = 'YES' then
do;
iwzmtso = substr(iwzmtso,2);
call iwzmvws.cmd iwzmtso '>'tempout;
end;
else
address cmd callit 'iwzmscm.cmd' callit 'iwzmtso.cmd !!??'tempout'??'iwzmtso;
call traceit 2 'After IGYFINFO';
read_stem.0 = 0;
xx = linein(tempout,1,0);
do forever;
if lines(tempout) = 0 then
leave;
read_stem.0 = read_stem.0 + 1;
nn = read_stem.0;
read_stem.nn = linein(tempout);
if substr(read_stem.nn,1,2) = '??' then
read_stem.nn = substr(read_stem.nn,3);
end;
xx = stream(tempout,'C','CLOSE');
address cmd '@erase' tempout;
if read_stem.0 = 0 then
call errmsg 09;
parse upper var read_stem.1 rcode recfm lrecl dsorg seqnum alias badhex memexist tempdsn rest;
if rcode <> 'OK' then
do;
if rcode = '' then
rcode = '??';
call lpexmsg rcode rest;
if read_stem.0 > 1 then
do;
do ii = 2 to read_stem.0;
if read_stem.ii <> '' then
call lpexmsg read_stem.ii;
end;
end;
call errmsg 10;
end;
'extract docnum into docnum';
'set global.tempdsn_'docnum tempdsn;
end;
tempsave = tmpdrv'\'temprest;
didprot = 'yes';
end;
end;
if didprot = 'yes' then
do;
thedate = date('U');
thetime = time();
timestamp = substr(thedate,1,2)||substr(thedate,4,2)||substr(thedate,7,2);
timestamp = timestamp||substr(thetime,1,2)||substr(thetime,4,2)||substr(thetime,7,2);
'mark set @@iwzmsav@@';
'bottom';
addedtime = 'no';
if (substr(mvsrecfm,1,1) = 'F' & mvslrecl >= 12) |,
(substr(mvsrecfm,1,1) = 'V' & mvslrecl >= 16) then
do;
addedtime = 'yes';
'extract autoparse into autoparse';
'extract recording into recording';
'set autoparse off';
'set recording off';
'insert' timestamp;
end;
'bottom';
'extract linenumber into numrec';
'mark set @@iwzmsavb@@';
call traceit 2 'Before save to temp' tempsave;
'lxn save' tempsave;
save_rc = rc;
call traceit 2 'Save to temp return code' save_rc;
call traceit 2 'After save to temp' tempsave;
'set name' filename;
if addedtime = 'yes' then
do;
'mark find @@iwzmsavb@@';
'mark clear @@iwzmsavb@@';
'extract linenumber into numrec2';
if numrec2 <> numrec then
call errmsg 11;
'extract content into content';
if content <> timestamp then
call errmsg 12;
'delete';
'set recording' recording;
'set autoparse' autoparse;
end;
'mark find @@iwzmsav@@';
'mark clear @@iwzmsav@@';
end;
else
do;
'lxn save' theargs;
save_rc = rc;
end;
trysave = 'yes';
if didprot = 'yes' then
do;
if save_rc = 0 then
do;
'extract docnum into docnum';
'set global.protsave_'docnum 'protsave';
if mvsrecfm = 'F' | mvsrecfm = 'V' then
userecfm = mvsrecfm||'B';
else
userecfm = mvsrecfm;
iwzmtso = '+IGYFMSAV' tempsaved dsname member userecfm mvslrecl numrec timestamp language;
call traceit 2 'Before iwzmSAV.CMD';
if savestat <> 'quitsave' & saveallstat <> 'saveall' then
do;
protsavetype = 'asynch';
if opsys = 'OS/2' then
address cmd '@start /c /min /i iwzmsav.cmd' protsavetype timeout tempsave filename member docnum changes iwzmtso;
else
address cmd '@start /min /i rexx iwzmsav.cmd' protsavetype timeout tempsave filename member docnum changes iwzmtso;
end;
else
do;
protsavetype = 'synch';
address cmd callit 'iwzmscm.cmd' callit 'iwzmsav.cmd' protsavetype timeout tempsave filename member docnum changes iwzmtso;
iwzmsav_rc = rc;
if iwzmsav_rc <> 0 then
save_rc = -6;
'set global.protsave_'docnum 'null';
end;
call traceit 2 'After iwzmSAV.CMD';
end;
end;
else
address cmd callit 'iwzmscm.cmd' callit 'iwzmcls.cmd save' savename 'check';
if save_rc = -6 then
do;
call tempsave;
call errmsg;
end;
if save_rc >= 0 & didprot = 'yes' & protsavetype = 'asynch' then
call message 13;
if save_rc = 0 then
call traceit 1 'Normal exit';
else
call traceit 1 'Error exit';
exit save_rc;
/* */
errmsg:
parse arg the_msg;
call tempsave;
if the_msg <> '' then
do;
call lpexmsg;
call message the_msg;
end;
call lpexmsg;
call message 14;
'alarm';
'alarm';
call traceit 1 'Error exit';
exit -6;
/* */
tempsave:
if trytemp = 'yes' then
return;
trytemp = 'yes';
call message 15;
call traceit 2 'Before save to workstation';
'lxn save' tmpsave;
savet_rc = rc;
call traceit 2 'After save to workstation';
'set name' filename;
if savet_rc <> 0 then
call message 16;
else
call message 17 tmpsave;
'set changes' changes;
return;
/* */
lpexmsg:
parse arg lpex_msg;
if trace > 2 then
call traceit 3 '--->' lpex_msg;
'msg' lpex_msg;
return;
/* */
message:
parse arg iwz_message_num,
iwz_message_arg1 '\\',
iwz_message_arg2 '\\',
iwz_message_arg3 '\\',
iwz_message_arg4 '\\',
iwz_message_arg5 '\\',
iwz_message_arg6 '\\',
iwz_message_arg7 '\\',
iwz_message_arg8;
select;
when language = 'ENG' then
call message_eng;
when language = 'JPN' then
call message_jpn;
otherwise
call message_eng;
end;
return;
/* */
message_eng:
select;
when iwz_message_num = 1 then do;
call lpexmsg 'A protected save is still running';
end;
when iwz_message_num = 2 then do;
call lpexmsg 'Cannot understand filename' iwz_message_arg1;
end;
when iwz_message_num = 3 then do;
call lpexmsg 'Cannot determine high level qualifier for' iwz_message_arg1;
end;
when iwz_message_num = 4 then do;
call lpexmsg 'Cannot determine name of temporary save data set';
end;
when iwz_message_num = 5 then do;
call lpexmsg 'No drive defined for temporary save data set';
end;
when iwz_message_num = 6 then do;
call lpexmsg 'Cannot support more that 99999998 records';
end;
when iwz_message_num = 7 then do;
call lpexmsg 'Cannot save - requires at least 2 gigabytes on MVS';
end;
when iwz_message_num = 8 then do;
call lpexmsg 'Allocating a larger temporary data set';
end;
when iwz_message_num = 9 then do;
call lpexmsg 'iwzmSAV.LX internal error - IGYFINFO return nothing';
end;
when iwz_message_num = 10 then do;
call lpexmsg 'Error allocating temporary data set';
end;
when iwz_message_num = 11 then do;
call lpexmsg 'ERROR - cannot locate added temporay line';
end;
when iwz_message_num = 12 then do;
call lpexmsg 'ERROR - unknown added temporary line contents';
end;
when iwz_message_num = 13 then do;
call lpexmsg 'Running final protected save processing asynchronously';
end;
when iwz_message_num = 14 then do;
call lpexmsg 'Save failed, select "Windows->Macro log" to see failure messages';
end;
when iwz_message_num = 15 then do;
call lpexmsg 'The save request failed, will attempt to save to the workstation';
end;
when iwz_message_num = 16 then do;
call lpexmsg 'Was not able to save to workstation';
end;
when iwz_message_num = 17 then do;
call lpexmsg 'File was saved to workstation file' iwz_message_arg1;
end;
otherwise
call lpexmsg 'Invalid message number' iwz_message_num;
end;
return;
/* */
message_jpn:
call lpexmsg 'Japanese message';
select;
when iwz_message_num = 1 then do;
call lpexmsg 'A protected save is still running';
end;
when iwz_message_num = 2 then do;
call lpexmsg 'Cannot understand filename' iwz_message_arg1;
end;
when iwz_message_num = 3 then do;
call lpexmsg 'Cannot determine high level qualifier for' iwz_message_arg1;
end;
when iwz_message_num = 4 then do;
call lpexmsg 'Cannot determine name of temporary save data set';
end;
when iwz_message_num = 5 then do;
call lpexmsg 'No drive defined for temporary save data set';
end;
when iwz_message_num = 6 then do;
call lpexmsg 'Cannot support more that 99999998 records';
end;
when iwz_message_num = 7 then do;
call lpexmsg 'Cannot save - requires at least 2 gigabytes on MVS';
end;
when iwz_message_num = 8 then do;
call lpexmsg 'Allocating a larger temporary data set';
end;
when iwz_message_num = 9 then do;
call lpexmsg 'iwzmSAV.LX internal error - IGYFINFO return nothing';
end;
when iwz_message_num = 10 then do;
call lpexmsg 'Error allocating temporary data set';
end;
when iwz_message_num = 11 then do;
call lpexmsg 'ERROR - cannot locate added temporay line';
end;
when iwz_message_num = 12 then do;
call lpexmsg 'ERROR - unknown added temporary line contents';
end;
when iwz_message_num = 13 then do;
call lpexmsg 'Running final protected save processing asynchronously';
end;
when iwz_message_num = 14 then do;
call lpexmsg 'Save failed, select "Windows->Macro log" to see failure messages';
end;
when iwz_message_num = 15 then do;
call lpexmsg 'The save request failed, will attempt to save to the workstation';
end;
when iwz_message_num = 16 then do;
call lpexmsg 'Was not able to save to workstation';
end;
when iwz_message_num = 17 then do;
call lpexmsg 'File was saved to workstation file' iwz_message_arg1;
end;
otherwise
call lpexmsg 'Invalid message number' iwz_message_num;
end;
return;
Get_MVSINFO:
Procedure expose env cobolroot mvsinfo. whoami tempdir trace
rtn = 0
null = '0000'x
crlf = '0D0A'x
mvsinfo. = ''
mvsinfoQ = translate('iwzm_MVSINFO.DAT_YALE');
oldq = rxqueue('Set',mvsinfoQ) /* switch to mvsinfo queue */
if queued() = 0 then do /* if Q is missing we'll */
qname = rxqueue('Create',mvsinfoQ) /* create it and put a bad */
if qname = mvsinfoQ then push 'Sven' /* timestamp on it, else */
else x=rxqueue('Delete',qname) /* it was in use (we hope) */
end /* so we'll assume we can */
parse pull mvsstuff; push mvsstuff /* get/replace Q contents */
parse value mvsstuff with ts (null) . cobolroot (null) mvsstuff /* get */
/* timestamp and cobolroot */
if ts <> 'Sven' then do;
mvsinfo = cobolroot'\MACROS\MVSINFO.DAT'
bad_mvsinfo = ' **' whoami '****'crlf' **error*' mvsinfo,
'is unavailable, missing or empty **'
x=SysFileTree(mvsinfo,'ts','F') /* get MVSINFO.DAT's timestamp */
if ts.0 <> 1 then do
say bad_mvsinfo
return 12;
end
parse var ts.1 v0 v1 v2 .
timestamp ='mvsinfo.dat.timestamp' v0 v1 v2
end;
else
timestamp = 'Yale'
if timestamp <> ts then do /* timestamps match? */
pull mvsstuff /* no, remove bad contents */
rtn = "iwzmIR.CMD"() /* ask for new stuff */
if rtn = 0 then do
parse pull mvsstuff; push mvsstuff /* get/replace Q contents */
/* remove timestamp and */
/* cobolroot */
parse value mvsstuff with . (null) . cobolroot ( null) mvsstuff
end
end
qname = rxqueue('Set',oldq) /* restore normal queue */
do while (mvsstuff<>'') & (rtn=0) /* mvsinfo. structure */
parse value mvsstuff with key val (null) mvsstuff
if mvsinfo.key = '' then do /* e.g. mvsinfo.TYPE='' */
mvsinfo.KEYS = mvsinfo.KEYS key /* no substitution for KEYS */
mvsinfo.key.1 = val /* e.g. mvsinfo.TYPE.1=val */
mvsinfo.key = 1 /* e.g. mvsinfo.TYPE=1 */
end
else do
x = mvsinfo.key + 1 /* e.g. mvsinfo.TYPE+1 */
mvsinfo.key.x = val /* e.g. mvsinfo.TYPE.2=val */
mvsinfo.key = x /* e.g. mvsinfo.TYPE=2 */
end
end
return rtn
Set_MVSINFO_Vars:
parse var mvsinfo.CLOSECMD.1 closecmd;
parse var mvsinfo.CLOSEFILE.1 closefile;
parse var mvsinfo.FILESYS.1 filesys accessmon testaccess;
parse var mvsinfo.FSSTARTCMD.1 fsstartcmd;
parse var mvsinfo.FSSTOPCMD.1 fsstopcmd;
parse var mvsinfo.HEADER.1 header;
parse var mvsinfo.JOBLOG.1 joblog;
parse var mvsinfo.MAXCMD.1 maxcmd;
parse var mvsinfo.LANGUAGE.1 language;
parse var mvsinfo.MOUNTCMD.1 mountcmd;
parse var mvsinfo.MVSCOMM.1 mvscomm;
parse var mvsinfo.iwzmEDT.1 iwzmedt;
parse var mvsinfo.NFS.1 nfs;
parse var mvsinfo.NULLSTDIN.1 nullstdin;
parse var mvsinfo.OUTSHOW.1 outshow;
parse var mvsinfo.PROTSAVE.1 protsave tempmult;
parse var mvsinfo.PWD.1 pwd pwdasis pwdt pwde;
parse var mvsinfo.READTIMEOUT.1 readtimeout;
parse var mvsinfo.REXECCMD.1 rexeccmd;
parse var mvsinfo.SDU.1 sdu;
parse var mvsinfo.SIGYCLST.1 sigyclst;
parse var mvsinfo.SYSPROC.1 sysproc;
parse var mvsinfo.SYSTEM.1 system;
parse var mvsinfo.TEMPDRIVE.1 tempdrive;
parse var mvsinfo.TEMPDATA.1 tempdata;
parse var mvsinfo.TESTFILE.1 testfile;
parse var mvsinfo.TRACE.1 trace tracekeep;
parse var mvsinfo.TRACECMD.1 tracecmd;
parse var mvsinfo.TRACEMOD.1 tracemod;
parse var mvsinfo.UMOUNTCMD.1 umountcmd;
parse var mvsinfo.USERID.1 userid;
parse var mvsinfo.WORKSYS.1 worksys;
parse var mvsinfo.WRITETIMEOUT.1 writetimeout;
parse var mvsinfo.DRIVE numdrive;
if numdrive = '' then
numdrive = 0;
do ii = 1 to numdrive;
parse var mvsinfo.DRIVE.ii,
drive.ii highqual.ii trans.ii mapping.ii sidefile.ii;
end;
parse var mvsinfo.TYPE numtype;
if numtype = '' then
numtype = 0;
do ii = 1 to numtype;
parse var mvsinfo.TYPE.ii type.ii ext.ii;
end;
return
/* */
Traceit:
parse arg iwz_trc_level iwz_trc_message;
if iwz_trc_level > trace then
return;
if pwd <> '********' & pwd <> '++++++++' & pwd <> '========' then
do;
do forever;
if pos(pwd,iwz_trc_message) = 0 then
leave;
parse var iwz_trc_message iwz_trc_message1 (pwd) iwz_trc_message2;
iwz_trc_message = iwz_trc_message1||'********'||iwz_trc_message2
end;
end
iwz_trc_message = date('O') time('L') whoami':' iwz_trc_message;
xx = lineout(tempdir'\iwzmTRC.TRC',iwz_trc_message);
xx = stream(tempdir'\iwzmTRC.TRC','C','CLOSE');
if tracecmd <> '' then
interpret tracecmd;
return;
/* */
sayit:
parse arg iwz_sayit_arg;
if trace > 2 then
call traceit 3 '--->' iwz_sayit_arg;
say iwz_sayit_arg;
return;
/*
:runit
@rexx %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
@rem */