home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / softinst / epflevel.cm_ / EPFLEVEL.CMD
Encoding:
Text File  |  1993-02-10  |  11.7 KB  |  343 lines

  1. /*
  2. SOFTWARE INSTALLER EPFLEVEL.CMD 5621-434 (C) COPYRIGHT IBM CORP 1992, 1993.  ALL RIGHTS RESERVED. LICENSED MATERIALS - PROPERTY OF IBM.
  3. */
  4.  
  5. /******************************************************************************/
  6. /* epflevel - display file version statistics for Software Installer files... */
  7. /******************************************************************************/
  8.  
  9. '@echo off'
  10.  
  11. parse upper arg fidMask '/' options
  12.  
  13. /* Check parameters and set defaults...                                      */
  14. if fidMask = '?' then do
  15.   say ' '
  16.   say 'Display the service level information of Software Installer files.'
  17.   say ' '
  18.   say 'EPFLEVEL file_mask [ /FC ]'
  19.   say ' '
  20.   say 'Where:'
  21.   say '       file_mask is a path and file specification of the file or '
  22.   say '       files for which service information is to be displayed.   '
  23.   say ' '
  24.   say '       /FC displays the full copyright statement information.'
  25.   exit
  26. end
  27. else
  28.   nop
  29. copyright = 0
  30. do while options <> ''
  31.   parse var options option '/' options
  32.   select
  33.     when option = 'FC' then    /* Full copyright statements displayed */
  34.       copyright = 1
  35.     otherwise
  36.       do
  37.         say 'Invalid option '''option'''.'
  38.         exit 1
  39.       end
  40.   end
  41. end
  42.  
  43. fidMask = strip(fidMask)
  44. if fidmask = '' | right(fidMask,1) = '\' then do
  45.     saveMask = fidMask
  46.     fidMask = saveMask || 'EPF*'
  47.     call do_prefix 'NO-MESSAGE'
  48.     fidMask = saveMask || 'EHO*'
  49.     call do_prefix 'NO-MESSAGE'
  50.     fidMask = saveMask || 'EWY*'
  51.     call do_prefix 'NO-MESSAGE'
  52.     exit
  53.   end
  54.  
  55. do_prefix:
  56. parse arg MessageParm .
  57. /* Clean out queue...                                                        */
  58. do while queued() <> 0
  59.   parse pull .
  60. end
  61.  
  62. /* Put filename(s) into queue...                                             */
  63. 'dir /f' fidMask '2>nul |rxqueue'
  64.  
  65. /* Process file(s)...                                                        */
  66. f = 0
  67. szHeadLast = ''
  68. do while queued() <> 0
  69.   parse pull fidFull .
  70.  
  71.   /* Non-blank line...                                                       */
  72.   if fidFull <> '' then
  73.     do
  74.       /* Query file size...                                                  */
  75.       fidSize = stream( fidFull, 'c', 'query size' )
  76.  
  77.       /* Non-directory file...                                               */
  78.       if fidSize <> '' then
  79.         do
  80.           /* Update header if it has changed...                              */
  81.           szHead = filespec( 'drive', fidFull ) ||,
  82.                    translate( filespec( 'path', fidFull ) ) || '..'
  83.           if szHead <> szHeadLast then
  84.             do
  85.               say szHead
  86.               szHeadLast = szHead
  87.             end
  88.           else
  89.             nop
  90.  
  91.           /* Write out data...                                               */
  92.           say '..' || left( translate( filespec( 'name', fidFull ) ), 36 ) ||,
  93.               '  ' || stream( fidFull, 'c', 'query datetime' ) ||,
  94.               '  ' || right( fidSize, 7 )
  95.           if copyright then
  96.             szVer = os2ver( fidFull )
  97.           else
  98.             parse value os2ver( fidFull ) with szVer '(C)' .
  99.           if szVer <> '' then
  100.             say '    ' || szVer
  101.           else
  102.             nop
  103.  
  104.           /* Update found flag...                                            */
  105.           f = 1
  106.         end
  107.  
  108.       /* Directory found (no file size)...                                   */
  109.       else
  110.         nop
  111.     end
  112.  
  113.   /* Blank line...                                                           */
  114.   else
  115.     nop
  116. end
  117.  
  118. /* Check if any files found...                                               */
  119. if f = 0 then
  120.   do
  121.     if MessageParm <> 'NO-MESSAGE' then say 'File '''fidMask''' not found.'
  122.   end
  123. else
  124.   nop
  125.  
  126. return 0
  127.  
  128. /*****************************************************************************/
  129. /* os2ver - return version information from OS/2 files...                    */
  130. /*****************************************************************************/
  131. os2ver:  procedure
  132.  
  133. parse arg fidFull .
  134.  
  135. /* Extract file extension...                                                 */
  136. parse value translate( filespec( 'name', fidFull ) ) with . '.' fidExt
  137. do while pos( '.', fidExt ) <> 0
  138.   parse var fidExt . '.' fidExt
  139. end
  140.  
  141. sz = ''
  142.  
  143. /* Process according to file extension...                                    */
  144. select
  145.   /* .DLL or .EXE file...                                                    */
  146.   when wordpos( fidExt, 'DLL EXE EML' ) <> 0 then
  147.     do
  148.       /* EXE header...                                                       */
  149.       if charin( fidFull, 1 , 2 ) = 'MZ' then
  150.         do
  151.           /* Offset of OS/2 EXE header...                                    */
  152.           oExe = c2d( reverse( charin( fidFull, 61, 4 ) ) ) + 1
  153.  
  154.           select
  155.             /*┌─────────────────────────────────────────────────────────────┐*/
  156.             /*│ 32-bit OS/2 EXE header...                                   │*/
  157.             /*└─────────────────────────────────────────────────────────────┘*/
  158.             when charin( fidFull, oExe, 2 ) = 'LX' then
  159.               do
  160.                 /*┌─────────────────────────────────────────────────────────┐*/
  161.                 /*│ Offset/length of DESCRIPTION...                         │*/
  162.                 /*└─────────────────────────────────────────────────────────┘*/
  163.                 oDesc = c2d( reverse( charin( fidFull, oExe + 136, 4 ) ) ) + 1
  164.                 lDesc = c2d( charin( fidFull, oDesc, 1 ) )
  165.  
  166.                 sz = charin( fidFull, oDesc + 1, lDesc )
  167.  
  168.                 /*┌─────────────────────────────────────────────────────────┐*/
  169.                 /*│ Stop at first line feed...                              │*/
  170.                 /*└─────────────────────────────────────────────────────────┘*/
  171.                 i = pos( '0A'x, sz )
  172.                 if i <> 0 then
  173.                   sz = strip( left( sz, i - 1 ), 'T' )
  174.               end
  175.  
  176.             /*┌─────────────────────────────────────────────────────────────┐*/
  177.             /*│ 16-bit OS/2 EXE header...                                   │*/
  178.             /*└─────────────────────────────────────────────────────────────┘*/
  179.             when charin( fidFull, oExe, 2 ) = 'NE' then
  180.               do
  181.                 /*┌─────────────────────────────────────────────────────────┐*/
  182.                 /*│ Offset/length of ENTTAB...                              │*/
  183.                 /*└─────────────────────────────────────────────────────────┘*/
  184.                 oEnt = oExe + c2d( reverse( charin( fidFull, oExe + 4, 2 ) ) )
  185.                 lEnt = c2d( reverse( charin( fidFull, oExe + 6, 2 ) ) )
  186.  
  187.                 /*┌─────────────────────────────────────────────────────────┐*/
  188.                 /*│ Offset/length of DESCRIPTION...                         │*/
  189.                 /*└─────────────────────────────────────────────────────────┘*/
  190.                 oDesc = oEnt + lEnt
  191.                 lDesc = c2d( charin( fidFull, oDesc, 1 ) )
  192.  
  193.                 sz = charin( fidFull, oDesc + 1, lDesc )
  194.  
  195.                 /*┌─────────────────────────────────────────────────────────┐*/
  196.                 /*│ Stop at first line feed...                              │*/
  197.                 /*└─────────────────────────────────────────────────────────┘*/
  198.                 i = pos( '0A'x, sz )
  199.                 if i <> 0 then
  200.                   sz = strip( left( sz, i - 1 ), 'T' )
  201.               end
  202.  
  203.             /*┌─────────────────────────────────────────────────────────────┐*/
  204.             /*│ Unrecognized EXE header...                                  │*/
  205.             /*└─────────────────────────────────────────────────────────────┘*/
  206.             otherwise
  207.               sz = ''
  208.           end
  209.         end
  210.  
  211.       /* Non-EXE header...                                                   */
  212.       else
  213.         sz = '';
  214.     end
  215.  
  216.   /* .CMD file...                                                            */
  217.   when fidExt = 'CMD' | fidExt = 'C' | fidExt = 'H' | fidExt = 'RC' then
  218.     do
  219.       /* Rexx header...                                                      */
  220.       if charin( fidFull, 1, 2 ) = '/*' then
  221.         do
  222.           call linein( fidFull )
  223.           sz = linein( fidFull )
  224.         end
  225.  
  226.       /* Non-Rexx header...                                                  */
  227.       else
  228.         sz = ''
  229.     end
  230.  
  231.   /* .MAK file...                                                            */
  232.   when fidExt = 'MAK' then
  233.     do
  234.       /* MAK Comment...                                                      */
  235.       if charin( fidFull, 1, 2 ) = '# ' then
  236.         sz = linein( fidFull )
  237.  
  238.     end
  239.  
  240.   /* .DEF file...                                                            */
  241.   when fidExt = 'DEF' then
  242.     do
  243.       /* DEF Comment...                                                      */
  244.       if charin( fidFull, 1, 2 ) = '; ' then
  245.         sz = linein( fidFull )
  246.  
  247.     end
  248.  
  249.   /* .HLP file...                                                            */
  250.   when fidExt = 'HLP' then
  251.     do
  252.       /* IPF header...                                                       */
  253.       if charin( fidFull, 1, 2 ) = 'HS' then
  254.         do
  255.           sz = ''
  256.           c = charin( fidFull, 108, 1 )
  257.           do while c <> '00'x
  258.             sz = sz || c
  259.             c = charin( fidFull )
  260.           end
  261.         end
  262.  
  263.       /* Non-IPF header...                                                   */
  264.       else
  265.         sz = ''
  266.     end
  267.  
  268.   /* .MSG file...                                                            */
  269.   when fidExt = 'MSG' then
  270.     do
  271.       if charin( fidFull, 1 ) = 'FF'x then
  272.         do
  273.           oMsg = c2d( reverse( charin( fidFull, 32, 2 ) ) )
  274.           sz = ''
  275. /*        c = charin( fidFull, oMsg + 11, 1 )   With message number */
  276.           c = charin( fidFull, oMsg + 2, 1 )
  277.           do while c <> '0D'x
  278.             sz = sz || c
  279.             c = charin( fidFull )
  280.           end
  281.         end
  282.       else
  283.         sz = ''
  284.     end
  285.  
  286.   /* .NLS file or .PKG file...                                               */
  287.   when wordpos( fidExt, 'DAT ICF NLS PKG' ) <> 0 then
  288.     do
  289.       /* Comment header...                                                   */
  290.       if charin( fidFull, 1, 2 ) = '* ' then
  291.         sz = linein( fidFull )
  292.  
  293.       /* Non-comment header...                                               */
  294.       else
  295.         sz = ''
  296.     end
  297.  
  298.   /* .SYM file...                                                            */
  299.   when fidExt = 'SYM' then
  300.     do
  301.       sz = ''
  302.       c = charin( fidFull, 19, 1 )
  303.       do while c <> '00'x
  304.         sz = sz || c
  305.         c = charin( fidFull )
  306.       end
  307.     end
  308.  
  309.   /* Unknown file extension...                                               */
  310.   otherwise
  311.     do
  312.       'eautil' fidFull 'ezerlvl.ea /p /r /s 2>nul'
  313.  
  314.       /* Extended attributes found...                                        */
  315.       if rc = 0 & stream( 'ezerlvl.ea', 'c', 'query exists') <> '' then
  316.         do
  317.           /* .VERSION attribute found...                                     */
  318.           if charin( 'ezerlvl.ea', 9, 8 ) = '.VERSION' then
  319.             do
  320.               lVer = c2d( reverse( charin( 'ezerlvl.ea', 20, 2 ) ) )
  321.               sz = charin( 'ezerlvl.ea', 22, lVer )
  322.             end
  323.  
  324.           /* No .VERSION attribute found...                                  */
  325.           else
  326.             sz = ''
  327.  
  328.           call stream 'ezerlvl.ea', 'c', 'close'
  329.           'erase ezerlvl.ea'
  330.         end
  331.  
  332.       /* No extended attributes found...                                     */
  333.       else
  334.         sz = ''
  335.     end
  336.  
  337. end
  338.  
  339. /* Close file...                                                             */
  340. call stream fidFull, 'c', 'close'
  341.  
  342. return sz
  343.