xref: /original-bsd/bin/ls/cmp.c (revision 95a66346)
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 %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 static char sccsid[] = "@(#)cmp.c	5.4 (Berkeley) 03/08/91";
13 #endif /* not lint */
14 
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include "ls.h"
18 
19 namecmp(a, b)
20 	LS *a, *b;
21 {
22 	return(strcmp(a->name, b->name));
23 }
24 
25 revnamecmp(a, b)
26 	LS *a, *b;
27 {
28 	return(strcmp(b->name, a->name));
29 }
30 
31 modcmp(a, b)
32 	LS *a, *b;
33 {
34 	return(b->lstat.st_mtime - a->lstat.st_mtime);
35 }
36 
37 revmodcmp(a, b)
38 	LS *a, *b;
39 {
40 	return(a->lstat.st_mtime - b->lstat.st_mtime);
41 }
42 
43 acccmp(a, b)
44 	LS *a, *b;
45 {
46 	return(b->lstat.st_atime - a->lstat.st_atime);
47 }
48 
49 revacccmp(a, b)
50 	LS *a, *b;
51 {
52 	return(a->lstat.st_atime - b->lstat.st_atime);
53 }
54 
55 statcmp(a, b)
56 	LS *a, *b;
57 {
58 	return(b->lstat.st_ctime - a->lstat.st_ctime);
59 }
60 
61 revstatcmp(a, b)
62 	LS *a, *b;
63 {
64 	return(a->lstat.st_ctime - b->lstat.st_ctime);
65 }
66