Show portable version informations embedded in binary files under windows, linux and macintosh, on the command line or in batch files.

Embed a simple string version info in your programs without the need for non portable manifest files.
sfk version filename
sfk ver -own

print version of a binary file, or of sfk itself.
the provided file is searched for a string with format:

   $version:name=sfk,type=base,os=windows,vernum=1.5.1,fix=0,
   title=Swiss File Knife,date=Aug  2 2008,info=major rework$\0

version string fields:
 [2] *name    short name, usually similar to the executable name
 [3]  type    the type of edition, e.g. base or extended
 [4] *os      operating system, e.g. windows, linux-lib6, linux-lib5
 [5] *vernum  version number, any number of values separated by dots
 [6]  fix     fix level, e.g. a revision or service pack number
 [7] *title   long, descriptive name, as printed in a help text
 [8] *date    release or compile date
 [9]  info    additional infos or remarks, free text string

fields marked with "*" are mandatory for a valid version string.
the other fields can be left out, or be empty like ",fix=,".
if found, contents are printed TAB-separated, after the filename,
therefore the [] numbers given above are output column numbers,
not the location in the input string (which is random anyway).

options
   -num[ber]  just print the full version number, combining
              vernum and fix to a dotted string.
              cannot be used with -own.
   -verbose   tells a warning if file(s) contain no version.

see also
   sfk require - check if a required version is used.

web reference
   http://stahlworks.com/sfk-version

examples
   sfk ver dview.exe
      print the version of a Depeche View executable.
   sfk ver -own
      print sfk's version.
   sfk ver.
      print sfk's version (quickest).
   sfk ver -nosub . .exe +filt -ssep "\t" -sform "$-20.20col1\t$col5"
      search all .exe files of the current dir for versions,
      reformatting the output, with a 20 chars filename limit.

 
version embedding example for C/C++ programs

   Add to your source code:

      #define SOFTWARE_VERSION 101  // meaning 1.01
   
      #define OS_SHORT_NAME "linux" // or "windows", "mac"
   
      #define STRINGIFY(x) #x
      #define TOSTRING(x)  STRINGIFY(x)
      #define SOFTWARE_VERTEXT TOSTRING(SOFTWARE_VERSION)
      
      static const char *pGlblVersionText =
         " $version:name=footool,vernum=" SOFTWARE_VERTEXT ","
         "title=The Foo Bar Tool,"
         "os=" OS_SHORT_NAME ","
         "date=" __DATE__ " " __TIME__ "$\0";
   
      void printHelpText()
      {
         // NOTE: this dummy operation is required with some compilers
         //       to keep pGlblVersionText from being stripped by the linker,
         //       as it isn't used anywhere within the code.
         printf("%c", *pGlblVersionText);
   
         // ... (print actual help text)
      }

   After compile, extract version like:

      sfk version footool.exe

   Example output:

      footool.exe  footool  linux  101  The Foo Bar Tool  Apr 20 2013 08:58:40