/* GetDriverVersion
 *
 * Description
 *   GetDriverVersion returns a version string taken from the driver file supplied.
 *
 * Returns
 *   if no file is provided, returns "usage"
 *   if file is not found, returns driverName "not found"
 *   if file has no build information, returns "none"
 *   otherwise returns the revision field of the build string
 *
 * Copyright (C) 2021 Blonde Guy
 * All Rights Reserved
 */

driverName = arg(1)
if driverName = '' then do
   say "usage: GetDriverVersion <driverFile>"
   say "returns version string or 'none' if no version string found."
   return 'usage'
end

call SysFileTree drivername, 'driv.', 'FO'
if driv.0 = 0 then do
   say driverName "not found"
   return driverName "not found"
end
address cmd '@ bldlevel' driverName '| rxqueue'

revNo = 'none'
do while queued() > 0
   parse pull bldLine
   if abbrev(bldLine, 'Revision:') then do
      parse var bldLine 'Revision:' revNo
      revNo = strip(revNo)
   end
end

/* say "Found revision:" revNo */
return revNo
