home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / iwzmmon.lxl < prev    next >
Text File  |  1998-02-27  |  8KB  |  235 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 input
  42. input = translate(input)
  43. parse var input inctn rest
  44. inctn = strip(inctn)
  45.  
  46. outctn = SysTempFileName(tempdir||'\IWZM????.CTN')
  47.  
  48. xx = linein(inctn,1,0);
  49. do forever;
  50.   if lines(inctn) = 0 then
  51.     leave;
  52.   inline = linein(inctn);
  53.  
  54.   select
  55.  
  56.     /* Want to change the name of the macro that the editor will use */
  57.     when pos('"macro shl.lxl"',inline) > 0 then
  58.       outline = '    "macro iwzmshl.lxl"'
  59.  
  60.     /* Make sure there are no references to the old .ctn file */
  61.     when pos(inctn,translate(inline)) > 0 then
  62.       do
  63.         outline = ''
  64.         namepos = pos(inctn,translate(inline))
  65.         if namepos > 1 then
  66.           outline = substr(inline,1,namepos-1)
  67.         outline = outline || outctn
  68.         if length(inline) >= namepos + length(inctn) then
  69.           outline = outline || substr(inline,namepos+length(inctn))
  70.       end
  71.  
  72.     Otherwise outline = inline
  73.   end /* select */
  74.  
  75.   call lineout outctn, outline
  76. end
  77.  
  78. rc = stream(inctn,'C','CLOSE'); /* close the input stream */
  79.  
  80. call lineout outctn /* close it */
  81.  
  82. 'macro' outctn
  83. rc = SysFileDelete(inctn); /* delete the input stream */
  84.                            /* WF will delete the output file */
  85.  
  86. call traceit 1 'Normal exit';
  87. exit 0;
  88.  
  89. Get_MVSINFO:
  90. Procedure expose env cobolroot mvsinfo. whoami tempdir trace
  91.  
  92. rtn = 0
  93. null = '0000'x
  94. crlf = '0D0A'x
  95. mvsinfo. = ''
  96. mvsinfoQ = translate('iwzm_MVSINFO.DAT_YALE');
  97.  
  98. oldq = rxqueue('Set',mvsinfoQ)   /* switch to mvsinfo queue */
  99. if queued() = 0 then do                   /* if Q is missing we'll */
  100.   qname = rxqueue('Create',mvsinfoQ)      /* create it and put a bad */
  101.   if qname = mvsinfoQ then push 'Sven'    /* timestamp on it, else */
  102.   else x=rxqueue('Delete',qname)          /* it was in use (we hope) */
  103.   end                                     /* so we'll assume we can */
  104. parse pull mvsstuff; push mvsstuff        /* get/replace Q contents */
  105. parse value mvsstuff with ts (null) . cobolroot (null) mvsstuff /* get */
  106.                                         /* timestamp and cobolroot */
  107. if ts <> 'Sven' then do;
  108.   mvsinfo = cobolroot'\MACROS\MVSINFO.DAT'
  109.   bad_mvsinfo = '    **' whoami '****'crlf'    **error*' mvsinfo,
  110.                 'is unavailable, missing or empty **'
  111.  
  112.   x=SysFileTree(mvsinfo,'ts','F')       /* get MVSINFO.DAT's timestamp */
  113.   if ts.0 <> 1 then do
  114.     say bad_mvsinfo
  115.     return 12;
  116.     end
  117.   parse var ts.1 v0 v1 v2 .
  118.   timestamp ='mvsinfo.dat.timestamp' v0 v1 v2
  119.   end;
  120. else
  121.   timestamp = 'Yale'
  122. if timestamp <> ts then do              /* timestamps match? */
  123.   pull mvsstuff                         /* no, remove bad contents */
  124.   rtn = "iwzmIR.CMD"()                /* ask for new stuff */
  125.   if rtn = 0 then do
  126.     parse pull mvsstuff; push mvsstuff    /* get/replace Q contents */
  127.                                         /* remove timestamp and     */
  128.                                         /* cobolroot                */
  129.     parse value mvsstuff with . (null) . cobolroot ( null) mvsstuff
  130.     end
  131.   end
  132. qname = rxqueue('Set',oldq)      /* restore normal queue */
  133.  
  134. do while (mvsstuff<>'') & (rtn=0)   /* mvsinfo. structure */
  135.   parse value mvsstuff with key val (null) mvsstuff
  136.   if mvsinfo.key = '' then do       /* e.g. mvsinfo.TYPE='' */
  137.     mvsinfo.KEYS = mvsinfo.KEYS key /* no substitution for KEYS */
  138.     mvsinfo.key.1 = val             /* e.g. mvsinfo.TYPE.1=val  */
  139.     mvsinfo.key = 1                 /* e.g. mvsinfo.TYPE=1      */
  140.     end
  141.   else do
  142.     x = mvsinfo.key + 1             /* e.g. mvsinfo.TYPE+1     */
  143.     mvsinfo.key.x = val             /* e.g. mvsinfo.TYPE.2=val */
  144.     mvsinfo.key = x                 /* e.g. mvsinfo.TYPE=2     */
  145.     end
  146.   end
  147.  
  148. return rtn
  149.  
  150. Set_MVSINFO_Vars:
  151.  
  152.  parse var mvsinfo.CLOSECMD.1 closecmd;
  153.  parse var mvsinfo.CLOSEFILE.1 closefile;
  154.  parse var mvsinfo.FILESYS.1 filesys accessmon testaccess;
  155.  parse var mvsinfo.FSSTARTCMD.1 fsstartcmd;
  156.  parse var mvsinfo.FSSTOPCMD.1 fsstopcmd;
  157.  parse var mvsinfo.HEADER.1 header;
  158.  parse var mvsinfo.JOBLOG.1 joblog;
  159.  parse var mvsinfo.MAXCMD.1 maxcmd;
  160.  parse var mvsinfo.LANGUAGE.1 language;
  161.  parse var mvsinfo.MOUNTCMD.1 mountcmd;
  162.  parse var mvsinfo.MVSCOMM.1 mvscomm;
  163.  parse var mvsinfo.iwzmEDT.1 iwzmedt;
  164.  parse var mvsinfo.NFS.1 nfs;
  165.  parse var mvsinfo.NULLSTDIN.1 nullstdin;
  166.  parse var mvsinfo.OUTSHOW.1 outshow;
  167.  parse var mvsinfo.PROTSAVE.1 protsave tempmult;
  168.  parse var mvsinfo.PWD.1 pwd pwdasis pwdt pwde;
  169.  parse var mvsinfo.READTIMEOUT.1 readtimeout;
  170.  parse var mvsinfo.REXECCMD.1 rexeccmd;
  171.  parse var mvsinfo.SDU.1 sdu;
  172.  parse var mvsinfo.SIGYCLST.1 sigyclst;
  173.  parse var mvsinfo.SYSPROC.1 sysproc;
  174.  parse var mvsinfo.SYSTEM.1 system;
  175.  parse var mvsinfo.TEMPDRIVE.1 tempdrive;
  176.  parse var mvsinfo.TEMPDATA.1 tempdata;
  177.  parse var mvsinfo.TESTFILE.1 testfile;
  178.  parse var mvsinfo.TRACE.1 trace tracekeep;
  179.  parse var mvsinfo.TRACECMD.1 tracecmd;
  180.  parse var mvsinfo.TRACEMOD.1 tracemod;
  181.  parse var mvsinfo.UMOUNTCMD.1 umountcmd;
  182.  parse var mvsinfo.USERID.1 userid;
  183.  parse var mvsinfo.WORKSYS.1 worksys;
  184.  parse var mvsinfo.WRITETIMEOUT.1 writetimeout;
  185.  
  186.  parse var mvsinfo.DRIVE numdrive;
  187.  if numdrive = '' then
  188.    numdrive = 0;
  189.  do ii = 1 to numdrive;
  190.    parse var mvsinfo.DRIVE.ii,
  191.              drive.ii highqual.ii trans.ii mapping.ii sidefile.ii;
  192.    end;
  193.  
  194.  parse var mvsinfo.TYPE numtype;
  195.  if numtype = '' then
  196.    numtype = 0;
  197.  do ii = 1 to numtype;
  198.    parse var mvsinfo.TYPE.ii type.ii ext.ii;
  199.    end;
  200.  
  201. return
  202.  
  203. /* */
  204. Traceit:
  205.  parse arg iwz_trc_level iwz_trc_message;
  206.  if iwz_trc_level > trace then
  207.    return;
  208.  if pwd <> '********' & pwd <> '++++++++' & pwd <> '========' then
  209.    do;
  210.    do forever;
  211.      if pos(pwd,iwz_trc_message) = 0 then
  212.        leave;
  213.      parse var iwz_trc_message iwz_trc_message1 (pwd) iwz_trc_message2;
  214.      iwz_trc_message = iwz_trc_message1||'********'||iwz_trc_message2
  215.      end;
  216.    end
  217.  iwz_trc_message = date('O') time('L') whoami':' iwz_trc_message;
  218.  xx = lineout(tempdir'\iwzmTRC.TRC',iwz_trc_message);
  219.  xx = stream(tempdir'\iwzmTRC.TRC','C','CLOSE');
  220.  if tracecmd <> '' then
  221.    interpret tracecmd;
  222. return;
  223.  
  224. /* */
  225. sayit:
  226.  parse arg iwz_sayit_arg;
  227.  if trace > 2 then
  228.    call traceit 3 '--->' iwz_sayit_arg;
  229.  say iwz_sayit_arg;
  230. return;
  231. /*
  232. :runit
  233. @rexx %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
  234. @rem */
  235.