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

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: dirhigh.c,v 1.6 1995/06/04 22:42:18 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    dirhigh.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    18 Jul 1984
  9.  * Last update:
  10.  *        18 Mar 1995, prototypes
  11.  *        24 Aug 1985, use 'dds_add2' instead of 'dirdata_one'
  12.  *        20 Jul 1985, use 'dirent_nul' to make dummy entry in 'filelink'.
  13.  *        16 Jul 1985, use 'filelist' as pointers to 'filelink'.
  14.  *        03 Jul 1985, cleanup of 'filelist' definition
  15.  *        14 Dec 1984, added nam-argument to 'dirent_chop'
  16.  *        25 Aug 1984, cleanup buffer sizes
  17.  *
  18.  * Function:    This module is called from FLIST when a file-modification
  19.  *        operation is used with the (FLIST option) /NOVERSION.  The
  20.  *        intent of NOVERSION is to show on the display only the highest
  21.  *        version of any particular file.  This module determines the
  22.  *        highest version of the particular file, locates in 'filelist[]'
  23.  *        (or adds) the entry to be updated, and displays the updated
  24.  *        line.
  25.  *
  26.  * Parameters:    filespec[] = file specification to use.
  27.  *
  28.  * Returns:    TRUE if any version of the given filename is found; otherwise
  29.  *        assume that the file does not exist.
  30.  */
  31.  
  32. #include    <rms.h>
  33.  
  34. #include    "flist.h"
  35. #include    "dirent.h"
  36. #include    "dds.h"
  37.  
  38. import(filelist); import(numfiles); import(numdlets);
  39.  
  40. int    dirhigh (char *filespec)
  41. {
  42.     FILENT    zold, znew;
  43.     char    highspec[MAX_PATH];
  44.     int    j,
  45.         lower    = -1,        /* Set if version to "delete"    */
  46.         same    = -1;        /* Set if version to update    */
  47.  
  48.     dirent_chop (&zold, filespec, 0);
  49.     znew       = zold;
  50.     znew.fvers = 0;            /* Force current-version    */
  51.     dirent_glue (highspec, &znew);
  52.  
  53.     if (dirent_chk (&znew, highspec))
  54.     {
  55.         /*
  56.          * Find any occurrence of this PATH+NAME+TYPE in 'filelist[]'.
  57.          */
  58.         for (j = 0; j < numfiles; j++)
  59.         {
  60. #define    SAMEP(p) (znew.p == FK(j).p)
  61.             if (! DELETED(j)
  62.             &&  SAMEP(fpath_) && SAMEP(fname) && SAMEP(ftype))
  63.             {
  64.                 if (znew.fvers > FK(j).fvers)
  65.                     lower    = j;
  66.                 else if (znew.fvers <= FK(j).fvers)
  67.                     same    = j;
  68.             }
  69.         }
  70.  
  71.         if (same >= 0)
  72.         {
  73.             if (lower >= 0)        /* RENAME to lower version ? */
  74.             {
  75.                 dirent_nul (lower);
  76.                 dds_line(same);
  77.             }
  78.             if (znew.fvers == FK(same).fvers)
  79.                 dds_add2 (&znew, same);
  80.         }
  81.         else if (lower >= 0)
  82.             dds_add2 (&znew, lower);
  83.         else
  84.             dds_add (&znew);
  85.         return (TRUE);
  86.     }
  87.     else
  88.         return (FALSE);    /* file not found */
  89. }
  90.