home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / archie-1.4.1 / vl_comp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-18  |  2.1 KB  |  73 lines

  1. /*
  2.  * Copyright (c) 1989, 1990, 1991 by the University of Washington
  3.  *
  4.  * For copying and distribution information, please see the file
  5.  * <copyright.h>.
  6.  */
  7.  
  8. #include <pfs.h>
  9.  
  10. /*
  11.  * vl_comp - compare the names of two virtual links
  12.  *
  13.  *           VL_COMP compares the names of two links.  It returns
  14.  *           0 if they are equal, negative if vl1 < vl2, and positive if
  15.  *           vl1 > vl2.
  16.  *
  17.  *    ARGS:  vl1,vl2 - Virtual links to be compared
  18.  * 
  19.  * RETURNS:  0 if equal, + is vl1 > vl2, - if vl1 < vl2
  20.  *
  21.  *   NOTES:  Order of significance is as follows.  Existence,
  22.  *           name.  If names do not exist, then hosttype, host,
  23.  *           native filenametype, native filename.  The only time
  24.  *           the name will not exist if if the link is a union link.
  25.  */
  26. int
  27. vl_comp(vl1,vl2)
  28.     VLINK    vl1;
  29.     VLINK    vl2;
  30.     {
  31.     int    retval;
  32.  
  33.     if(vl1->name && !vl2->name) return(1);
  34.     if(!vl1->name && vl2->name) return(-1);
  35.     if(vl1->name && vl2->name && (*(vl1->name) || *(vl2->name)))
  36.         return(strcmp(vl1->name,vl2->name));
  37.  
  38.     retval = strcmp(vl1->hosttype,vl2->hosttype);
  39.     if(!retval) retval = strcmp(vl1->host,vl2->host);
  40.     if(!retval) retval = strcmp(vl1->nametype,vl2->nametype);
  41.     if(!retval) retval = strcmp(vl1->filename,vl2->filename);
  42.     return(retval);
  43.     }
  44.  
  45. /*
  46.  * vl_equal - compare the values of two virtual links
  47.  *
  48.  *           VL_EQUAL compares the values of two links.  It returns
  49.  *           1 if all important fields are the same, and 0 otherwise.
  50.  *
  51.  *    ARGS:  vl1,vl2 - Virtual links to be compared
  52.  * 
  53.  * RETURNS:  1 if equal, 0 if not equal
  54.  *
  55.  */
  56. int
  57. vl_equal(vl1,vl2)
  58.     VLINK    vl1;
  59.     VLINK    vl2;
  60.     {
  61.       return strcmp(vl1->name, vl2->name) == 0         &&
  62.          vl1->linktype == vl2->linktype            &&
  63.          strcmp(vl1->type, vl2->type) == 0         &&
  64.          strcmp(vl1->hosttype, vl2->hosttype) == 0 &&
  65.          strcmp(vl1->host, vl2->host) == 0         &&
  66.          strcmp(vl1->nametype, vl2->nametype) == 0 &&
  67.          strcmp(vl1->filename, vl2->filename) == 0 &&
  68.          vl1->version == vl2->version              &&
  69.          vl1->f_magic_no == vl2->f_magic_no        ;
  70.  
  71.     }
  72.  
  73.