2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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 * 4. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 static char sccsid[] = "@(#)cmp.c 8.1 (Berkeley) 5/31/93";
38 #include <sys/cdefs.h>
39 __FBSDID("$FreeBSD$");
42 #include <sys/types.h>
52 namecmp(const FTSENT *a, const FTSENT *b)
55 return (strcoll(a->fts_name, b->fts_name));
59 revnamecmp(const FTSENT *a, const FTSENT *b)
62 return (strcoll(b->fts_name, a->fts_name));
66 modcmp(const FTSENT *a, const FTSENT *b)
69 if (b->fts_statp->st_mtimespec.tv_sec >
70 a->fts_statp->st_mtimespec.tv_sec)
72 if (b->fts_statp->st_mtimespec.tv_sec <
73 a->fts_statp->st_mtimespec.tv_sec)
75 if (b->fts_statp->st_mtimespec.tv_nsec >
76 a->fts_statp->st_mtimespec.tv_nsec)
78 if (b->fts_statp->st_mtimespec.tv_nsec <
79 a->fts_statp->st_mtimespec.tv_nsec)
81 return (strcoll(a->fts_name, b->fts_name));
85 revmodcmp(const FTSENT *a, const FTSENT *b)
88 return (modcmp(b, a));
92 acccmp(const FTSENT *a, const FTSENT *b)
95 if (b->fts_statp->st_atimespec.tv_sec >
96 a->fts_statp->st_atimespec.tv_sec)
98 if (b->fts_statp->st_atimespec.tv_sec <
99 a->fts_statp->st_atimespec.tv_sec)
101 if (b->fts_statp->st_atimespec.tv_nsec >
102 a->fts_statp->st_atimespec.tv_nsec)
104 if (b->fts_statp->st_atimespec.tv_nsec <
105 a->fts_statp->st_atimespec.tv_nsec)
107 return (strcoll(a->fts_name, b->fts_name));
111 revacccmp(const FTSENT *a, const FTSENT *b)
114 return (acccmp(b, a));
118 birthcmp(const FTSENT *a, const FTSENT *b)
121 if (b->fts_statp->st_birthtimespec.tv_sec >
122 a->fts_statp->st_birthtimespec.tv_sec)
124 if (b->fts_statp->st_birthtimespec.tv_sec <
125 a->fts_statp->st_birthtimespec.tv_sec)
127 if (b->fts_statp->st_birthtimespec.tv_nsec >
128 a->fts_statp->st_birthtimespec.tv_nsec)
130 if (b->fts_statp->st_birthtimespec.tv_nsec <
131 a->fts_statp->st_birthtimespec.tv_nsec)
133 return (strcoll(a->fts_name, b->fts_name));
137 revbirthcmp(const FTSENT *a, const FTSENT *b)
140 return (birthcmp(b, a));
144 statcmp(const FTSENT *a, const FTSENT *b)
147 if (b->fts_statp->st_ctimespec.tv_sec >
148 a->fts_statp->st_ctimespec.tv_sec)
150 if (b->fts_statp->st_ctimespec.tv_sec <
151 a->fts_statp->st_ctimespec.tv_sec)
153 if (b->fts_statp->st_ctimespec.tv_nsec >
154 a->fts_statp->st_ctimespec.tv_nsec)
156 if (b->fts_statp->st_ctimespec.tv_nsec <
157 a->fts_statp->st_ctimespec.tv_nsec)
159 return (strcoll(a->fts_name, b->fts_name));
163 revstatcmp(const FTSENT *a, const FTSENT *b)
166 return (statcmp(b, a));
170 sizecmp(const FTSENT *a, const FTSENT *b)
173 if (b->fts_statp->st_size > a->fts_statp->st_size)
175 if (b->fts_statp->st_size < a->fts_statp->st_size)
177 return (strcoll(a->fts_name, b->fts_name));
181 revsizecmp(const FTSENT *a, const FTSENT *b)
184 return (sizecmp(b, a));