home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / cern_os2.zip / emxrev.cmd < prev    next >
OS/2 REXX Batch file  |  1995-02-18  |  4KB  |  130 lines

  1. /* emxrev.cmd -- Display revision numbers of emx DLLs
  2.    Copyright (c) 1993-1995 Eberhard Mattes
  3.  
  4. This file is part of emx.
  5.  
  6. emx is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. emx is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with emx; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21.   call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  22.   call SysLoadFuncs
  23.  
  24.   parse arg arg1 rest
  25.   select
  26.   when arg1 = '' then do
  27.     say revision( 'emx')
  28.     say revision( 'emxio')
  29.     say revision( 'emxlibc')
  30.     say revision( 'emxlibcm')
  31.     say revision( 'emxlibcs')
  32.     say revision( 'emxwrap')
  33.   end
  34.   when arg1 = '-a' then do
  35.     if rest \= '' then
  36.       call usage
  37.     call find_all
  38.   end
  39.   when arg1 = '-c' then do
  40.     if (rest = '') | (words( rest) > 1) then
  41.       call usage
  42.     parse var rest drive':'rest
  43.     if (length( drive) \= 1) | (rest \= '') then
  44.       call usage
  45.     call find_tree( drive':')
  46.   end
  47.   when arg1 = '-d' then do
  48.     if (rest = '') | (words( rest) > 1) then
  49.       call usage
  50.     call find_dir rest, 'S'
  51.   end
  52.   when arg1 = '-f' then do
  53.     if (rest = '') | (words( rest) > 1) then
  54.       call usage
  55.     say revision( rest)
  56.   end
  57.   when arg1 = '-p' then do
  58.     if (rest = '') | (words( rest) > 1) then
  59.       call usage
  60.     call find_config rest
  61.   end
  62.   otherwise
  63.     call usage
  64.   end
  65.   exit 0
  66.  
  67. usage:
  68.   say 'Usage:'
  69.   say '  emxrev           Display revision number of default emx DLLs'
  70.   say '  emxrev -a        Scan all disks for emx DLLs'
  71.   say '  emxrev -c d:     Scan complete drive D: for emx DLLs'
  72.   say '  emxrev -d dir    Scan directory DIR for emx DLLs'
  73.   say '  emxrev -f file   Display revision number of FILE'
  74.   say '  emxrev -p file   Scan directories in LIBPATH statement of FILE'
  75.   say ''
  76.   say 'emx DLLs are emx.dll, emxio.dll, emxlibc.dll, emxlibcm.dll,'
  77.   say '             emxlibcs.dll, and emxwrap.dll.'
  78. exit 1
  79.  
  80. find_all: procedure
  81.   drives = SysDriveMap()
  82.   do i = 1 to words( drives)
  83.     call find_tree( word( drives, i))
  84.   end
  85.   return
  86.  
  87. find_tree: procedure
  88.   arg drive
  89.   call find_dir drive'\', 'S'
  90.   return
  91.  
  92. find_dir: procedure
  93.   arg dir, opt
  94.   last = right( dir, 1)
  95.   if (last \= '/') & (last \= '\') & (last \= ':') then
  96.     dir = dir'\'
  97.   call SysFileTree dir'emx*.dll', files, 'FO'||opt
  98.   do i = 1 to files.0
  99.     name = translate( filespec( 'name', files.i))
  100.     if (name = 'EMX.DLL') | (name = 'EMXIO.DLL') | (name = 'EMXLIBC.DLL'),
  101.        | (name = 'EMXLIBCM.DLL') | (name = 'EMXLIBCS.DLL'),
  102.        | (name = 'EMXWRAP.DLL') then
  103.       say revision( files.i)
  104.   end
  105.   return
  106.   
  107. find_config: procedure
  108.   arg config
  109.   call SysFileSearch 'LIBPATH=', config, lines
  110.   do i = 1 to lines.0
  111.     parse var lines.i 'LIBPATH='rest
  112.     list = translate( rest, ' ', ';')
  113.     do j = 1 to words( list)
  114.       call find_dir word( list, j), ''
  115.     end
  116.   end
  117.   return
  118.  
  119. revision: procedure
  120.   arg pathname
  121.   call RxFuncAdd emx_revision, pathname, emx_revision
  122.   signal on syntax name error
  123.   tmp = emx_revision()
  124.   signal off syntax
  125.   call RxFuncDrop emx_revision
  126.   return pathname ': revision =' tmp
  127.  
  128. error:
  129.   return pathname ': revision number not available'
  130.