home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / win3 / nt / source.exe / POSIX / LS / CMP.C < prev    next >
C/C++ Source or Header  |  1992-10-29  |  3KB  |  133 lines

  1. /*
  2.  * Copyright (c) 1989 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * This code is derived from software contributed to Berkeley by
  6.  * Michael Fischbein.
  7.  *
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  * 2. Redistributions in binary form must reproduce the above copyright
  14.  *    notice, this list of conditions and the following disclaimer in the
  15.  *    documentation and/or other materials provided with the distribution.
  16.  * 3. All advertising materials mentioning features or use of this software
  17.  *    must display the following acknowledgement:
  18.  *    This product includes software developed by the University of
  19.  *    California, Berkeley and its contributors.
  20.  * 4. Neither the name of the University nor the names of its contributors
  21.  *    may be used to endorse or promote products derived from this software
  22.  *    without specific prior written permission.
  23.  *
  24.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  25.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  28.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34.  * SUCH DAMAGE.
  35.  */
  36.  
  37. #ifndef lint
  38. static char sccsid[] = "@(#)cmp.c    5.4 (Berkeley) 3/8/91";
  39. #endif /* not lint */
  40.  
  41. #include <string.h>
  42. #include <sys/types.h>
  43. #include <sys/stat.h>
  44. #include "ls.h"
  45.  
  46. int
  47. #if __STDC__
  48. namecmp (LS *a, LS *b)
  49. #else
  50. namecmp(a, b)
  51.     LS *a, *b;
  52. #endif
  53. {
  54.     return(strcmp(a->name, b->name));
  55. }
  56.  
  57. int
  58. #if __STDC__
  59. revnamecmp (LS *a, LS *b)
  60. #else
  61. revnamecmp(a, b)
  62.     LS *a, *b;
  63. #endif
  64. {
  65.     return(strcmp(b->name, a->name));
  66. }
  67.  
  68. int
  69. #if __STDC__
  70. modcmp (LS *a, LS *b)
  71. #else
  72. modcmp(a, b)
  73.     LS *a, *b;
  74. #endif
  75. {
  76.     return((int)(b->lstat.st_mtime - a->lstat.st_mtime));
  77. }
  78.  
  79. int
  80. #if __STDC__
  81. revmodcmp (LS *a, LS *b)
  82. #else
  83. revmodcmp(a, b)
  84.     LS *a, *b;
  85. #endif
  86. {
  87.     return((int)(a->lstat.st_mtime - b->lstat.st_mtime));
  88. }
  89.  
  90. int
  91. #if __STDC__
  92. acccmp (LS *a, LS *b)
  93. #else
  94. acccmp(a, b)
  95.     LS *a, *b;
  96. #endif
  97. {
  98.     return((int)(b->lstat.st_atime - a->lstat.st_atime));
  99. }
  100.  
  101. int
  102. #if __STDC__
  103. revacccmp (LS *a, LS *b)
  104. #else
  105. revacccmp(a, b)
  106.     LS *a, *b;
  107. #endif
  108. {
  109.     return((int)(a->lstat.st_atime - b->lstat.st_atime));
  110. }
  111.  
  112. int
  113. #if __STDC__
  114. statcmp (LS *a, LS *b)
  115. #else
  116. statcmp(a, b)
  117.     LS *a, *b;
  118. #endif
  119. {
  120.     return((int)(b->lstat.st_ctime - a->lstat.st_ctime));
  121. }
  122.  
  123. int
  124. #if __STDC__
  125. revstatcmp (LS *a, LS *b)
  126. #else
  127. revstatcmp(a, b)
  128.     LS *a, *b;
  129. #endif
  130. {
  131.     return((int)(a->lstat.st_ctime - b->lstat.st_ctime));
  132. }
  133.