/* $Id: bldlevel.cmd,v 1.1.1.1 2003/10/04 08:19:08 prokushev Exp $ */

Say 'Build Level Display Facility Version 1.0'
Say '(C) Copyright 2003 by Yuri Prokushev'

if (arg(1)='')|(pos('/?', arg(1))=1) then
do
  Say ''
  Say '     Use the BLDLEVEL command to search for a version string in a file.'
  Say ''
  Say '     SYNTAX:  bldlevel [drive:][path]filename'
  Say '         or   bldlevel /?'
  Say '         or   bldlevel'
  Say ''
  Say '     Where:'
  Say '       drive           Specifies a drive letter for the path or filename,'
  Say '                       for example: C:'
  Say '       path            Specifies a path,'
  Say '                       for example: \os2\dll\'
  Say '       filename        Specifies the name for the file.'
  Say ''
  Say '     /?              Displays this information.'
  Say '     no parameter    Displays this information.'
  return
end

BuildDate=''
HostName=''
Package=''
ASDFeatureID=''
LanguageCode=''
CountryCode=''
FixPackVer=''
Build=''

filename=arg(1)
rc=stream(filename, 'c', 'QUERY EXIST');
if rc='' then
do
  Say 'File not found'
  return
end

f=charin(filename,1, chars(filename))

as:
interpret "parse var f with Skip '@#' Vendor ':' Revision '#@' Description '"||d2c(0)||"' Skip"
if length(Vendor)>31 then
do
  f=Vendor||':'||Revision||'#@'||Description||d2c(0)||Skip
  signal as
end

Signature='@#'Vendor||':'||Revision||'#@'||Description

/* This modification to original is to allow use not only asciiz strings */
Parse var Description Description '#@'

/* Following is extensions to original bldlevel. */
/* Used, for example, by TCP/IP tools */
Parse var Description Description '##' BuildInfo '@@' Description2

If Description='' then
do
  Description=Description2

  /* Another type extensions (Odin, Innotek)*/
  Parse var BuildInfo BuildInfo '1##' BuildInfo2

  If BuildInfo<>'' then
  do
    Parse var BuildInfo 'built ' BuildDate ' -- On ' HostName ';' Unknown
    Parse var Description Package ':' Description
  end

  /* Following is another type extensions (found in Odin) */

  If BuildInfo='' then
  do
    BuildDate=SubStr(BuildInfo2, 1, 26);
    BuildInfo2=DelStr(BuildInfo2, 1, 25);
    parse var BuildInfo2 HostName ':' ASDFeatureID ':' LanguageCode ':' CountryCode ':' Build ':' Unknown ':' FixPackVer
  end

end

/* And show time! */

Say 'Signature:       'Signature
Say 'Vendor:          'Vendor
Say 'Revision:        'Revision
If BuildDate<>'' then Say 'Date/Time:       'Space(BuildDate)
If HostName<>'' then Say 'Build Machine:   'Space(HostName)
If Build<>'' then Say 'File Version:    'Revision'.'Build
else Say 'File Version:    'Revision
If Package<>'' then Say 'Package:         'Space(Package)
Say 'Description:     'Space(Description)
If ASDFeatureID<>'' then Say 'ASD Feature ID:  'ASDFeatureID
If LanguageCode<>'' then Say 'Language Code:   'LanguageCode
If CountryCode<>'' then Say 'Country Code:    'CountryCode
If FixPackVer<>'' then Say 'FixPack version: 'FixPackVer

/*

$Log: bldlevel.cmd,v $
Revision 1.1.1.1  2003/10/04 08:19:08  prokushev
Import


*/

