home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / iwzmqt.lx < prev    next >
Text File  |  1997-12-17  |  9KB  |  287 lines

  1. /* Reinvoking as "REXX %0 %1 %2 %3 %4 %5 %6 %7 %8 %9"  2>nul
  2. @goto runit */
  3. /*********************************************************************/
  4. /* Licensed Material - Property of IBM                               */
  5. /* 5639-B92 , 5639-D65 (C) Copyright IBM Corp., 1997, 1998           */
  6. /* All rights reserved.                                              */
  7. /* US Government Users Restricted Rights - Use, duplication or       */
  8. /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */
  9. /*********************************************************************/
  10. trace off;
  11. signal on novalue;
  12. parse source opsys . whoami rest;
  13. /* cobolroot is now set by iwzmIR.CMD */
  14. if opsys = 'OS/2' then
  15.   do;
  16.   env = 'OS2ENVIRONMENT';
  17.   callit = '@Call';
  18.   call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs';
  19.   call SysLoadFuncs;
  20.   end;
  21. else
  22.   do;
  23.   env = 'ENVIRONMENT';
  24.   callit = '@Rexx';
  25.   end;
  26. tempdir = value('TMP',,env);
  27. tempout = SysTempFileName(tempdir'\TM?????.OUT');
  28. tempout2 = SysTempFileName(tempdir'\T2?????.OUT');
  29. xx = Get_MVSINFO();
  30. if xx <> 0 then
  31.   exit 16;
  32. call Set_MVSINFO_Vars;
  33. if tracemod = '*' |,
  34.   wordpos(translate(substr(whoami,lastpos('\',whoami)+1)),tracemod) > 0 then
  35.   do;
  36.   if trace > 3 then trace results;
  37.   if trace > 4 then trace ?;
  38.   end;
  39. parse arg the_input_args;
  40. call traceit 1 'Entry' '!'the_input_args'!';
  41. parse arg qtype rest;
  42. parse upper arg dummy dsname rest;
  43. parse upper var dsname dsn1 '(' member ')' dsn2;
  44. dsname = dsn1||dsn2;
  45. 'extract docnum into docnum';
  46. 'extract global.protsave_'docnum 'into savestat';
  47. if savestat = 'protsave' then
  48.   do;
  49.   call message 01;
  50.   'alarm';
  51.   call traceit 1 'Error exit';
  52.   exit 16;
  53.   end;
  54. if qtype = 'quit' then
  55.   do;
  56.   call message 02 dsname;
  57.   'set global.protsave_'docnum 'quitsave';
  58.   'lxn quit';
  59.   quit_rc = rc;
  60.   'set global.protsave_'docnum 'null';
  61.   if quit_rc = 1 then
  62.     'msg  ';
  63.   if quit_rc = 0 then
  64.     call traceit 1 'Normal exit';
  65.   else
  66.     call traceit 1 'Error exit - cancel';
  67.   exit quit_rc;
  68.   end;
  69. thecmd = 'DELETE' dsname;
  70. call message 03 dsname;
  71. 'sshow';
  72. xx = SysSleep(1);
  73. if opsys = 'OS/2' then
  74.   address cmd '@start /c /min /i iwzmtso !!'thecmd;
  75. else
  76.   address cmd '@start /min /i rexx iwzmtso !!'thecmd;
  77. 'lxn qquit';
  78. call traceit 1 'Normal exit';
  79. exit 0;
  80. /* */
  81. message:
  82. parse arg iwz_message_num,
  83.           iwz_message_arg1 '\\',
  84.           iwz_message_arg2 '\\',
  85.           iwz_message_arg3 '\\',
  86.           iwz_message_arg4 '\\',
  87.           iwz_message_arg5 '\\',
  88.           iwz_message_arg6 '\\',
  89.           iwz_message_arg7 '\\',
  90.           iwz_message_arg8;
  91. select;
  92.   when language = 'ENG' then
  93.     call message_eng;
  94.   when language = 'JPN' then
  95.     call message_jpn;
  96.   otherwise
  97.     call message_eng;
  98.   end;
  99. return;
  100. /* */
  101. message_eng:
  102. select;
  103.  
  104. when iwz_message_num = 1 then do;
  105. 'msg A protected save is running, retry quit after it completes';
  106. end;
  107.  
  108. when iwz_message_num = 2 then do;
  109. 'msg On exit will delete temporary' iwz_message_arg1 'on MVS';
  110. end;
  111.  
  112. when iwz_message_num = 3 then do;
  113. 'msg Deleting temporary' iwz_message_arg1 'on MVS, please wait';
  114. end;
  115.  
  116. otherwise
  117. call sayit 'Invalid message number' iwz_message_num;
  118. end;
  119. return;
  120. /* */
  121. message_jpn:
  122. 'msg Japanese message';
  123. select;
  124.  
  125. when iwz_message_num = 1 then do;
  126. 'msg A protected save is running, retry quit after it completes';
  127. end;
  128.  
  129. when iwz_message_num = 2 then do;
  130. 'msg On exit will delete temporary' iwz_message_arg1 'on MVS';
  131. end;
  132.  
  133. when iwz_message_num = 3 then do;
  134. 'msg Deleting temporary' iwz_message_arg1 'on MVS, please wait';
  135. end;
  136.  
  137. otherwise
  138. call sayit 'Invalid message number' iwz_message_num;
  139. end;
  140. return;
  141. Get_MVSINFO:
  142. Procedure expose env cobolroot mvsinfo. whoami tempdir trace
  143.  
  144. rtn = 0
  145. null = '0000'x
  146. crlf = '0D0A'x
  147. mvsinfo. = ''
  148. mvsinfoQ = translate('iwzm_MVSINFO.DAT_YALE');
  149.  
  150. oldq = rxqueue('Set',mvsinfoQ)   /* switch to mvsinfo queue */
  151. if queued() = 0 then do                   /* if Q is missing we'll */
  152.   qname = rxqueue('Create',mvsinfoQ)      /* create it and put a bad */
  153.   if qname = mvsinfoQ then push 'Sven'    /* timestamp on it, else */
  154.   else x=rxqueue('Delete',qname)          /* it was in use (we hope) */
  155.   end                                     /* so we'll assume we can */
  156. parse pull mvsstuff; push mvsstuff        /* get/replace Q contents */
  157. parse value mvsstuff with ts (null) . cobolroot (null) mvsstuff /* get */
  158.                                         /* timestamp and cobolroot */
  159. if ts <> 'Sven' then do;
  160.   mvsinfo = cobolroot'\MACROS\MVSINFO.DAT'
  161.   bad_mvsinfo = '    **' whoami '****'crlf'    **error*' mvsinfo,
  162.                 'is unavailable, missing or empty **'
  163.  
  164.   x=SysFileTree(mvsinfo,'ts','F')       /* get MVSINFO.DAT's timestamp */
  165.   if ts.0 <> 1 then do
  166.     say bad_mvsinfo
  167.     return 12;
  168.     end
  169.   parse var ts.1 v0 v1 v2 .
  170.   timestamp ='mvsinfo.dat.timestamp' v0 v1 v2
  171.   end;
  172. else
  173.   timestamp = 'Yale'
  174. if timestamp <> ts then do              /* timestamps match? */
  175.   pull mvsstuff                         /* no, remove bad contents */
  176.   rtn = "iwzmIR.CMD"()                /* ask for new stuff */
  177.   if rtn = 0 then do
  178.     parse pull mvsstuff; push mvsstuff    /* get/replace Q contents */
  179.                                         /* remove timestamp and     */
  180.                                         /* cobolroot                */
  181.     parse value mvsstuff with . (null) . cobolroot ( null) mvsstuff
  182.     end
  183.   end
  184. qname = rxqueue('Set',oldq)      /* restore normal queue */
  185.  
  186. do while (mvsstuff<>'') & (rtn=0)   /* mvsinfo. structure */
  187.   parse value mvsstuff with key val (null) mvsstuff
  188.   if mvsinfo.key = '' then do       /* e.g. mvsinfo.TYPE='' */
  189.     mvsinfo.KEYS = mvsinfo.KEYS key /* no substitution for KEYS */
  190.     mvsinfo.key.1 = val             /* e.g. mvsinfo.TYPE.1=val  */
  191.     mvsinfo.key = 1                 /* e.g. mvsinfo.TYPE=1      */
  192.     end
  193.   else do
  194.     x = mvsinfo.key + 1             /* e.g. mvsinfo.TYPE+1     */
  195.     mvsinfo.key.x = val             /* e.g. mvsinfo.TYPE.2=val */
  196.     mvsinfo.key = x                 /* e.g. mvsinfo.TYPE=2     */
  197.     end
  198.   end
  199.  
  200. return rtn
  201.  
  202. Set_MVSINFO_Vars:
  203.  
  204.  parse var mvsinfo.CLOSECMD.1 closecmd;
  205.  parse var mvsinfo.CLOSEFILE.1 closefile;
  206.  parse var mvsinfo.FILESYS.1 filesys accessmon testaccess;
  207.  parse var mvsinfo.FSSTARTCMD.1 fsstartcmd;
  208.  parse var mvsinfo.FSSTOPCMD.1 fsstopcmd;
  209.  parse var mvsinfo.HEADER.1 header;
  210.  parse var mvsinfo.JOBLOG.1 joblog;
  211.  parse var mvsinfo.MAXCMD.1 maxcmd;
  212.  parse var mvsinfo.LANGUAGE.1 language;
  213.  parse var mvsinfo.MOUNTCMD.1 mountcmd;
  214.  parse var mvsinfo.MVSCOMM.1 mvscomm;
  215.  parse var mvsinfo.iwzmEDT.1 iwzmedt;
  216.  parse var mvsinfo.NFS.1 nfs;
  217.  parse var mvsinfo.NULLSTDIN.1 nullstdin;
  218.  parse var mvsinfo.OUTSHOW.1 outshow;
  219.  parse var mvsinfo.PROTSAVE.1 protsave tempmult;
  220.  parse var mvsinfo.PWD.1 pwd pwdasis pwdt pwde;
  221.  parse var mvsinfo.READTIMEOUT.1 readtimeout;
  222.  parse var mvsinfo.REXECCMD.1 rexeccmd;
  223.  parse var mvsinfo.SDU.1 sdu;
  224.  parse var mvsinfo.SIGYCLST.1 sigyclst;
  225.  parse var mvsinfo.SYSPROC.1 sysproc;
  226.  parse var mvsinfo.SYSTEM.1 system;
  227.  parse var mvsinfo.TEMPDRIVE.1 tempdrive;
  228.  parse var mvsinfo.TEMPDATA.1 tempdata;
  229.  parse var mvsinfo.TESTFILE.1 testfile;
  230.  parse var mvsinfo.TRACE.1 trace tracekeep;
  231.  parse var mvsinfo.TRACECMD.1 tracecmd;
  232.  parse var mvsinfo.TRACEMOD.1 tracemod;
  233.  parse var mvsinfo.UMOUNTCMD.1 umountcmd;
  234.  parse var mvsinfo.USERID.1 userid;
  235.  parse var mvsinfo.WORKSYS.1 worksys;
  236.  parse var mvsinfo.WRITETIMEOUT.1 writetimeout;
  237.  
  238.  parse var mvsinfo.DRIVE numdrive;
  239.  if numdrive = '' then
  240.    numdrive = 0;
  241.  do ii = 1 to numdrive;
  242.    parse var mvsinfo.DRIVE.ii,
  243.              drive.ii highqual.ii trans.ii mapping.ii sidefile.ii;
  244.    end;
  245.  
  246.  parse var mvsinfo.TYPE numtype;
  247.  if numtype = '' then
  248.    numtype = 0;
  249.  do ii = 1 to numtype;
  250.    parse var mvsinfo.TYPE.ii type.ii ext.ii;
  251.    end;
  252.  
  253. return
  254.  
  255. /* */
  256. Traceit:
  257.  parse arg iwz_trc_level iwz_trc_message;
  258.  if iwz_trc_level > trace then
  259.    return;
  260.  if pwd <> '********' & pwd <> '++++++++' & pwd <> '========' then
  261.    do;
  262.    do forever;
  263.      if pos(pwd,iwz_trc_message) = 0 then
  264.        leave;
  265.      parse var iwz_trc_message iwz_trc_message1 (pwd) iwz_trc_message2;
  266.      iwz_trc_message = iwz_trc_message1||'********'||iwz_trc_message2
  267.      end;
  268.    end
  269.  iwz_trc_message = date('O') time('L') whoami':' iwz_trc_message;
  270.  xx = lineout(tempdir'\iwzmTRC.TRC',iwz_trc_message);
  271.  xx = stream(tempdir'\iwzmTRC.TRC','C','CLOSE');
  272.  if tracecmd <> '' then
  273.    interpret tracecmd;
  274. return;
  275.  
  276. /* */
  277. sayit:
  278.  parse arg iwz_sayit_arg;
  279.  if trace > 2 then
  280.    call traceit 3 '--->' iwz_sayit_arg;
  281.  say iwz_sayit_arg;
  282. return;
  283. /*
  284. :runit
  285. @rexx %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
  286. @rem */
  287.