home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / 08file / ls_fcomp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  701 b   |  47 lines

  1. /*
  2.  *    ls_fcomp -- file and directory comparison functions
  3.  */
  4.  
  5. #include <string.h>
  6. #include "ls.h"
  7.  
  8. extern int Modtime;
  9. extern int Reverse;
  10.  
  11.  
  12. /*
  13.  *    ls_fcomp -- compare two "file" items
  14.  */
  15.  
  16. int
  17. ls_fcomp(s1, s2)
  18. struct OUTBUF *s1, *s2;
  19. {
  20.     int result;
  21.  
  22.     if (Modtime) {
  23.         if ((result = s1->o_date - s2->o_date) == 0)
  24.             result = s1->o_time - s2->o_time;
  25.     }
  26.     else
  27.         result = strcmp(s1->o_name, s2->o_name);
  28.  
  29.     return (Reverse ? -result : result);
  30. } /* end_fcomp() */
  31.  
  32.  
  33. /*
  34.  *    dcomp -- compare two "directory" items
  35.  */
  36.  
  37. int
  38. ls_dcomp(s1, s2)
  39. char *s1, *s2;
  40. {
  41.     int result;
  42.  
  43.     result = strcmp(s1, s2);
  44.  
  45.     return (Reverse ? -result : result);
  46. } /* end ls_dcomp() */
  47.