home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / scanver.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-04  |  1.0 KB  |  46 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: scanver.c,v 1.3 1995/06/04 22:23:22 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    scanver.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    23 Jun 1985
  9.  * Last update:    23 Jun 1985
  10.  *
  11.  * Function:    Scan an input string for a VMS file-version number.  This code
  12.  *        was in-line in several places, but with CC2.0, stopped working.
  13.  *        (Could not determine the nature of the bug, save that it seems
  14.  *        to be something wrong with 'sscanf'.)
  15.  *
  16.  * Arguments:    vers_    => string to decode
  17.  *        len    = length (string may not be null-terminated)
  18.  *
  19.  * Returns:    The version number.  If an '*' is found, we return the most-
  20.  *        negative (16-bit) value.
  21.  */
  22.  
  23. #define    WILD_VER    -32768
  24.  
  25. int    scanver (char *vers_, int len)
  26. {
  27.     register int    value    = 0;
  28.     register int    sflg    = 0;
  29.  
  30.     if (*vers_ == ';')    vers_++, len--;
  31.  
  32.     if (*vers_ == '*')
  33.         value = WILD_VER;
  34.     else while (len-- > 0)
  35.     {
  36.         if (*vers_ == '-')
  37.             sflg++;
  38.         else if (*vers_ == '+')
  39.             len = value = 0;
  40.         else
  41.             value = (value * 10) + (*vers_ - '0');
  42.         vers_++;
  43.     }
  44.     return (sflg ? -value : value);
  45. }
  46.