Sync zoneinfo database with tzdata2018b from ftp://ftp.iana.org/tz/releases
[dragonfly.git] / bin / ls / cmp.c
blob93a07c3cede9212b1af030cdddab042598e0702b
1 /*-
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
6 * Michael Fischbein.
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. 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
30 * SUCH DAMAGE.
32 * @(#)cmp.c 8.1 (Berkeley) 5/31/93
33 * $FreeBSD: src/bin/ls/cmp.c,v 1.16 2005/01/10 08:39:23 imp Exp $
36 #include <sys/types.h>
37 #include <sys/stat.h>
39 #include <fts.h>
40 #include <string.h>
42 #include "ls.h"
43 #include "extern.h"
45 int
46 namecmp(const FTSENT *a, const FTSENT *b)
48 return (strcoll(a->fts_name, b->fts_name));
51 int
52 revnamecmp(const FTSENT *a, const FTSENT *b)
54 return (strcoll(b->fts_name, a->fts_name));
57 int
58 modcmp(const FTSENT *a, const FTSENT *b)
60 if (b->fts_statp->st_mtimespec.tv_sec >
61 a->fts_statp->st_mtimespec.tv_sec)
62 return (1);
63 if (b->fts_statp->st_mtimespec.tv_sec <
64 a->fts_statp->st_mtimespec.tv_sec)
65 return (-1);
66 if (b->fts_statp->st_mtimespec.tv_nsec >
67 a->fts_statp->st_mtimespec.tv_nsec)
68 return (1);
69 if (b->fts_statp->st_mtimespec.tv_nsec <
70 a->fts_statp->st_mtimespec.tv_nsec)
71 return (-1);
72 return (strcoll(a->fts_name, b->fts_name));
75 int
76 revmodcmp(const FTSENT *a, const FTSENT *b)
78 return (modcmp(b, a));
81 int
82 acccmp(const FTSENT *a, const FTSENT *b)
84 if (b->fts_statp->st_atimespec.tv_sec >
85 a->fts_statp->st_atimespec.tv_sec)
86 return (1);
87 if (b->fts_statp->st_atimespec.tv_sec <
88 a->fts_statp->st_atimespec.tv_sec)
89 return (-1);
90 if (b->fts_statp->st_atimespec.tv_nsec >
91 a->fts_statp->st_atimespec.tv_nsec)
92 return (1);
93 if (b->fts_statp->st_atimespec.tv_nsec <
94 a->fts_statp->st_atimespec.tv_nsec)
95 return (-1);
96 return (strcoll(a->fts_name, b->fts_name));
99 int
100 revacccmp(const FTSENT *a, const FTSENT *b)
102 return (acccmp(b, a));
106 sizecmp(const FTSENT *a, const FTSENT *b)
108 if (b->fts_statp->st_size >
109 a->fts_statp->st_size)
110 return (1);
111 if (b->fts_statp->st_size <
112 a->fts_statp->st_size)
113 return (-1);
114 return (strcoll(a->fts_name, b->fts_name));
118 revsizecmp(const FTSENT *a, const FTSENT *b)
120 return (sizecmp(b, a));
124 statcmp(const FTSENT *a, const FTSENT *b)
126 if (b->fts_statp->st_ctimespec.tv_sec >
127 a->fts_statp->st_ctimespec.tv_sec)
128 return (1);
129 if (b->fts_statp->st_ctimespec.tv_sec <
130 a->fts_statp->st_ctimespec.tv_sec)
131 return (-1);
132 if (b->fts_statp->st_ctimespec.tv_nsec >
133 a->fts_statp->st_ctimespec.tv_nsec)
134 return (1);
135 if (b->fts_statp->st_ctimespec.tv_nsec <
136 a->fts_statp->st_ctimespec.tv_nsec)
137 return (-1);
138 return (strcoll(a->fts_name, b->fts_name));
142 revstatcmp(const FTSENT *a, const FTSENT *b)
144 return (statcmp(b, a));