xref: /original-bsd/bin/ls/cmp.c (revision 7eb91141)
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.7 (Berkeley) 03/01/92";
13 #endif /* not lint */
14 
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <fts.h>
18 #include <string.h>
19 #include "ls.h"
20 #include "extern.h"
21 
22 int
23 namecmp(a, b)
24 	const FTSENT *a, *b;
25 {
26 	return (strcmp(a->fts_name, b->fts_name));
27 }
28 
29 int
30 revnamecmp(a, b)
31 	const FTSENT *a, *b;
32 {
33 	return (strcmp(b->fts_name, a->fts_name));
34 }
35 
36 int
37 modcmp(a, b)
38 	const FTSENT *a, *b;
39 {
40 	return (b->fts_statp->st_mtime - a->fts_statp->st_mtime);
41 }
42 
43 int
44 revmodcmp(a, b)
45 	const FTSENT *a, *b;
46 {
47 	return (a->fts_statp->st_mtime - b->fts_statp->st_mtime);
48 }
49 
50 int
51 acccmp(a, b)
52 	const FTSENT *a, *b;
53 {
54 	return (b->fts_statp->st_atime - a->fts_statp->st_atime);
55 }
56 
57 int
58 revacccmp(a, b)
59 	const FTSENT *a, *b;
60 {
61 	return (a->fts_statp->st_atime - b->fts_statp->st_atime);
62 }
63 
64 int
65 statcmp(a, b)
66 	const FTSENT *a, *b;
67 {
68 	return (b->fts_statp->st_ctime - a->fts_statp->st_ctime);
69 }
70 
71 int
72 revstatcmp(a, b)
73 	const FTSENT *a, *b;
74 {
75 	return (a->fts_statp->st_ctime - b->fts_statp->st_ctime);
76 }
77