home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / highver.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-21  |  1.5 KB  |  59 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: highver.c,v 1.4 1995/10/21 18:53:22 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    highver.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    08 Sep 1984 (from 'mv$current', 17-May-1984)
  9.  * Last update:
  10.  *        03 Jun 1995, prototyped
  11.  *        23 Jun 1985, use 'scanver' to decode version number
  12.  *        08 Sep 1984
  13.  *
  14.  * Function:    Given a filename (no wildcards are assumed), return the
  15.  *        highest version number which it has in the directory.
  16.  *
  17.  * Parameters:    name_    => Filename string.  This is returned without a version
  18.  *               on the end.
  19.  *
  20.  * Returns:    the actual version, if the file is found, else 0.
  21.  */
  22.  
  23. #include    <starlet.h>
  24. #include    <rms.h>
  25. #include    <stsdef.h>
  26. #include    <string.h>
  27.  
  28. #include    "rmsinit.h"
  29. #include    "scanver.h"
  30.  
  31. int
  32. highver (char *name_)
  33. {
  34.     struct    FAB    tmpFAB;
  35.     struct    NAM    tmpNAM;
  36.     unsigned status;
  37.     int    len;            /* length to ending ";" */
  38.     char    tmpRSA    [NAM$C_MAXRSS];
  39.     char    tmpESA    [NAM$C_MAXRSS];
  40.  
  41. #define    ok(x)    status = x; if (!$VMS_STATUS_SUCCESS(status))    return (0)
  42.  
  43.     rmsinit_fab (&tmpFAB, &tmpNAM, 0, name_);
  44.     rmsinit_nam (&tmpNAM, tmpRSA, tmpESA);
  45.  
  46.     ok(sys$parse(&tmpFAB));        /* parse the name to find version */
  47.  
  48.     strncpy (name_, tmpESA, len = (tmpNAM.nam$l_ver - tmpNAM.nam$l_node));
  49.     name_[len] = '\0';        /* strip off version code    */
  50.  
  51.     rmsinit_fab (&tmpFAB, &tmpNAM, 0, name_);
  52.     rmsinit_nam (&tmpNAM, tmpRSA, tmpESA);
  53.  
  54.     ok(sys$parse(&tmpFAB));        /* parse the name    */
  55.     ok(sys$search(&tmpFAB));    /* ...find the file    */
  56.  
  57.     return (scanver (tmpNAM.nam$l_ver, tmpNAM.nam$b_ver));
  58. }
  59.