vl_comp.c
上传用户:sddyfurun
上传日期:2007-01-04
资源大小:525k
文件大小:3k
源码类别:

代理服务器

开发平台:

Unix_Linux

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