summaryrefslogtreecommitdiff
path: root/usr.bin/find/function.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-11-13 08:30:35 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-11-13 08:30:35 +0000
commitf9f68389af0034cdf15661bc693e77fc1cb925c5 (patch)
tree779d713933ae1328df3afdf85c078d63bd16223f /usr.bin/find/function.c
parent48eccfca3321f7c88e1a2107e3170d2194904baa (diff)
Add the primaries -mmin, -amin, -cmin to find, similar to the GNU find; wosch
Diffstat (limited to 'usr.bin/find/function.c')
-rw-r--r--usr.bin/find/function.c98
1 files changed, 96 insertions, 2 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 92d1a5a1c2a..f1f635c4bee 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: function.c,v 1.10 1997/09/01 02:44:19 millert Exp $ */
+/* $OpenBSD: function.c,v 1.11 1997/11/13 08:30:33 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)function.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: function.c,v 1.10 1997/09/01 02:44:19 millert Exp $";
+static char rcsid[] = "$OpenBSD: function.c,v 1.11 1997/11/13 08:30:33 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -136,6 +136,37 @@ find_parsenum(plan, option, vp, endch)
++((p)->t_data);
/*
+ * -amin n functions --
+ *
+ * True if the difference between the file access time and the
+ * current time is n min periods.
+ */
+int
+f_amin(plan, entry)
+ PLAN *plan;
+ FTSENT *entry;
+{
+ extern time_t now;
+
+ COMPARE((now - entry->fts_statp->st_atime +
+ 60 - 1) / 60, plan->t_data);
+}
+
+PLAN *
+c_amin(arg)
+ char *arg;
+{
+ PLAN *new;
+
+ ftsoptions &= ~FTS_NOSTAT;
+
+ new = palloc(N_AMIN, f_amin);
+ new->t_data = find_parsenum(new, "-amin", arg, NULL);
+ TIME_CORRECT(new, N_AMIN);
+ return (new);
+}
+
+/*
* -atime n functions --
*
* True if the difference between the file access time and the
@@ -164,6 +195,38 @@ c_atime(arg)
TIME_CORRECT(new, N_ATIME);
return (new);
}
+
+/*
+ * -cmin n functions --
+ *
+ * True if the difference between the last change of file
+ * status information and the current time is n min periods.
+ */
+int
+f_cmin(plan, entry)
+ PLAN *plan;
+ FTSENT *entry;
+{
+ extern time_t now;
+
+ COMPARE((now - entry->fts_statp->st_ctime +
+ 60 - 1) / 60, plan->t_data);
+}
+
+PLAN *
+c_cmin(arg)
+ char *arg;
+{
+ PLAN *new;
+
+ ftsoptions &= ~FTS_NOSTAT;
+
+ new = palloc(N_CMIN, f_cmin);
+ new->t_data = find_parsenum(new, "-cmin", arg, NULL);
+ TIME_CORRECT(new, N_CMIN);
+ return (new);
+}
+
/*
* -ctime n functions --
*
@@ -770,6 +833,37 @@ c_mtime(arg)
}
/*
+ * -mmin n functions --
+ *
+ * True if the difference between the file modification time and the
+ * current time is n min periods.
+ */
+int
+f_mmin(plan, entry)
+ PLAN *plan;
+ FTSENT *entry;
+{
+ extern time_t now;
+
+ COMPARE((now - entry->fts_statp->st_mtime + 60 - 1) /
+ 60, plan->t_data);
+}
+
+PLAN *
+c_mmin(arg)
+ char *arg;
+{
+ PLAN *new;
+
+ ftsoptions &= ~FTS_NOSTAT;
+
+ new = palloc(N_MMIN, f_mmin);
+ new->t_data = find_parsenum(new, "-mmin", arg, NULL);
+ TIME_CORRECT(new, N_MMIN);
+ return (new);
+}
+
+/*
* -name functions --
*
* True if the basename of the filename being examined