summaryrefslogtreecommitdiff
path: root/usr.bin/find/function.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/find/function.c')
-rw-r--r--usr.bin/find/function.c252
1 files changed, 62 insertions, 190 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 31e1a651767b..3ba755517fdb 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -39,6 +39,7 @@
static const char sccsid[] = "@(#)function.c 8.10 (Berkeley) 5/4/95";
#endif
#endif /* not lint */
+
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -86,8 +87,7 @@ extern char **environ;
} while(0)
static PLAN *
-palloc(option)
- OPTION *option;
+palloc(OPTION *option)
{
PLAN *new;
@@ -104,10 +104,7 @@ palloc(option)
* Parse a string of the form [+-]# and return the value.
*/
static long long
-find_parsenum(plan, option, vp, endch)
- PLAN *plan;
- const char *option;
- char *vp, *endch;
+find_parsenum(PLAN *plan, const char *option, char *vp, char *endch)
{
long long value;
char *endchar, *str; /* Pointer to character ending conversion. */
@@ -148,10 +145,7 @@ find_parsenum(plan, option, vp, endch)
* Parse a string of the form [+-]([0-9]+[smhdw]?)+ and return the value.
*/
static long long
-find_parsetime(plan, option, vp)
- PLAN *plan;
- const char *option;
- char *vp;
+find_parsetime(PLAN *plan, const char *option, char *vp)
{
long long secs, value;
char *str, *unit; /* Pointer to character ending conversion. */
@@ -226,9 +220,7 @@ find_parsetime(plan, option, vp)
* and increment the argument vector pointer.
*/
static char *
-nextarg(option, argvp)
- OPTION *option;
- char ***argvp;
+nextarg(OPTION *option, char ***argvp)
{
char *arg;
@@ -258,12 +250,8 @@ nextarg(option, argvp)
* and the current time is n min periods.
*/
int
-f_Xmin(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_Xmin(PLAN *plan, FTSENT *entry)
{
- extern time_t now;
-
if (plan->flags & F_TIME_C) {
COMPARE((now - entry->fts_statp->st_ctime +
60 - 1) / 60, plan->t_data);
@@ -277,9 +265,7 @@ f_Xmin(plan, entry)
}
PLAN *
-c_Xmin(option, argvp)
- OPTION *option;
- char ***argvp;
+c_Xmin(OPTION *option, char ***argvp)
{
char *nmins;
PLAN *new;
@@ -304,11 +290,8 @@ c_Xmin(option, argvp)
*/
int
-f_Xtime(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_Xtime(PLAN *plan, FTSENT *entry)
{
- extern time_t now;
time_t xtime;
if (plan->flags & F_TIME_A)
@@ -325,9 +308,7 @@ f_Xtime(plan, entry)
}
PLAN *
-c_Xtime(option, argvp)
- OPTION *option;
- char ***argvp;
+c_Xtime(OPTION *option, char ***argvp)
{
char *value;
PLAN *new;
@@ -352,9 +333,7 @@ c_Xtime(option, argvp)
* find_execute() so their f_* functions are set to f_always_true().
*/
PLAN *
-c_mXXdepth(option, argvp)
- OPTION *option;
- char ***argvp;
+c_mXXdepth(OPTION *option, char ***argvp)
{
char *dstr;
PLAN *new;
@@ -378,9 +357,7 @@ c_mXXdepth(option, argvp)
* True always. Makes its best shot and continues on regardless.
*/
int
-f_delete(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry;
+f_delete(PLAN *plan __unused, FTSENT *entry)
{
/* ignore these from fts */
if (strcmp(entry->fts_accpath, ".") == 0 ||
@@ -420,9 +397,7 @@ f_delete(plan, entry)
}
PLAN *
-c_delete(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_delete(OPTION *option, char ***argvp __unused)
{
ftsoptions &= ~FTS_NOSTAT; /* no optimise */
@@ -443,17 +418,13 @@ c_delete(option, argvp)
* itself.
*/
int
-f_always_true(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry __unused;
+f_always_true(PLAN *plan __unused, FTSENT *entry __unused)
{
return 1;
}
PLAN *
-c_depth(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_depth(OPTION *option, char ***argvp __unused)
{
isdepth = 1;
@@ -466,9 +437,7 @@ c_depth(option, argvp)
* True if the file or directory is empty
*/
int
-f_empty(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry;
+f_empty(PLAN *plan __unused, FTSENT *entry)
{
if (S_ISREG(entry->fts_statp->st_mode) &&
entry->fts_statp->st_size == 0)
@@ -496,9 +465,7 @@ f_empty(plan, entry)
}
PLAN *
-c_empty(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_empty(OPTION *option, char ***argvp __unused)
{
ftsoptions &= ~FTS_NOSTAT;
@@ -521,11 +488,8 @@ c_empty(option, argvp)
* of the user before executing the utility.
*/
int
-f_exec(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_exec(PLAN *plan, FTSENT *entry)
{
- extern int dotfd;
int cnt;
pid_t pid;
int status;
@@ -601,9 +565,7 @@ doexec: if ((plan->flags & F_NEEDOK) && !queryuser(plan->e_argv))
* strings, but also flags meaning that the string has to be massaged.
*/
PLAN *
-c_exec(option, argvp)
- OPTION *option;
- char ***argvp;
+c_exec(OPTION *option, char ***argvp)
{
PLAN *new; /* node returned */
long argmax;
@@ -695,9 +657,7 @@ done: *argvp = argv + 1;
}
int
-f_flags(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_flags(PLAN *plan, FTSENT *entry)
{
u_long flags;
@@ -714,9 +674,7 @@ f_flags(plan, entry)
}
PLAN *
-c_flags(option, argvp)
- OPTION *option;
- char ***argvp;
+c_flags(OPTION *option, char ***argvp)
{
char *flags_str;
PLAN *new;
@@ -749,9 +707,7 @@ c_flags(option, argvp)
* basis.
*/
PLAN *
-c_follow(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_follow(OPTION *option, char ***argvp __unused)
{
ftsoptions &= ~FTS_PHYSICAL;
ftsoptions |= FTS_LOGICAL;
@@ -765,9 +721,7 @@ c_follow(option, argvp)
* True if the file is of a certain type.
*/
int
-f_fstype(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_fstype(PLAN *plan, FTSENT *entry)
{
static dev_t curdev; /* need a guaranteed illegal dev value */
static int first = 1;
@@ -828,9 +782,7 @@ f_fstype(plan, entry)
#if !defined(__NetBSD__)
PLAN *
-c_fstype(option, argvp)
- OPTION *option;
- char ***argvp;
+c_fstype(OPTION *option, char ***argvp)
{
char *fsname;
PLAN *new;
@@ -885,17 +837,13 @@ c_fstype(option, argvp)
* name, gname is taken as a group ID.
*/
int
-f_group(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_group(PLAN *plan, FTSENT *entry)
{
return entry->fts_statp->st_gid == plan->g_data;
}
PLAN *
-c_group(option, argvp)
- OPTION *option;
- char ***argvp;
+c_group(OPTION *option, char ***argvp)
{
char *gname;
PLAN *new;
@@ -924,17 +872,13 @@ c_group(option, argvp)
* True if the file has inode # n.
*/
int
-f_inum(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_inum(PLAN *plan, FTSENT *entry)
{
COMPARE(entry->fts_statp->st_ino, plan->i_data);
}
PLAN *
-c_inum(option, argvp)
- OPTION *option;
- char ***argvp;
+c_inum(OPTION *option, char ***argvp)
{
char *inum_str;
PLAN *new;
@@ -953,17 +897,13 @@ c_inum(option, argvp)
* True if the file has n links.
*/
int
-f_links(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_links(PLAN *plan, FTSENT *entry)
{
COMPARE(entry->fts_statp->st_nlink, plan->l_data);
}
PLAN *
-c_links(option, argvp)
- OPTION *option;
- char ***argvp;
+c_links(OPTION *option, char ***argvp)
{
char *nlinks;
PLAN *new;
@@ -982,18 +922,14 @@ c_links(option, argvp)
* Always true - prints the current entry to stdout in "ls" format.
*/
int
-f_ls(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry;
+f_ls(PLAN *plan __unused, FTSENT *entry)
{
printlong(entry->fts_path, entry->fts_accpath, entry->fts_statp);
return 1;
}
PLAN *
-c_ls(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_ls(OPTION *option, char ***argvp __unused)
{
ftsoptions &= ~FTS_NOSTAT;
isoutput = 1;
@@ -1008,18 +944,14 @@ c_ls(option, argvp)
* matches pattern using Pattern Matching Notation S3.14
*/
int
-f_name(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_name(PLAN *plan, FTSENT *entry)
{
return !fnmatch(plan->c_data, entry->fts_name,
plan->flags & F_IGNCASE ? FNM_CASEFOLD : 0);
}
PLAN *
-c_name(option, argvp)
- OPTION *option;
- char ***argvp;
+c_name(OPTION *option, char ***argvp)
{
char *pattern;
PLAN *new;
@@ -1038,9 +970,7 @@ c_name(option, argvp)
* file.
*/
int
-f_newer(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_newer(PLAN *plan, FTSENT *entry)
{
if (plan->flags & F_TIME_C)
return entry->fts_statp->st_ctime > plan->t_data;
@@ -1051,9 +981,7 @@ f_newer(plan, entry)
}
PLAN *
-c_newer(option, argvp)
- OPTION *option;
- char ***argvp;
+c_newer(OPTION *option, char ***argvp)
{
char *fn_or_tspec;
PLAN *new;
@@ -1088,17 +1016,13 @@ c_newer(option, argvp)
* of the getgrnam() 9.2.1 [POSIX.1] function returns NULL.
*/
int
-f_nogroup(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry;
+f_nogroup(PLAN *plan __unused, FTSENT *entry)
{
return group_from_gid(entry->fts_statp->st_gid, 1) == NULL;
}
PLAN *
-c_nogroup(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_nogroup(OPTION *option, char ***argvp __unused)
{
ftsoptions &= ~FTS_NOSTAT;
@@ -1112,17 +1036,13 @@ c_nogroup(option, argvp)
* of the getpwuid() 9.2.2 [POSIX.1] function returns NULL.
*/
int
-f_nouser(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry;
+f_nouser(PLAN *plan __unused, FTSENT *entry)
{
return user_from_uid(entry->fts_statp->st_uid, 1) == NULL;
}
PLAN *
-c_nouser(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_nouser(OPTION *option, char ***argvp __unused)
{
ftsoptions &= ~FTS_NOSTAT;
@@ -1136,9 +1056,7 @@ c_nouser(option, argvp)
* matches pattern using Pattern Matching Notation S3.14
*/
int
-f_path(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_path(PLAN *plan, FTSENT *entry)
{
return !fnmatch(plan->c_data, entry->fts_path,
plan->flags & F_IGNCASE ? FNM_CASEFOLD : 0);
@@ -1154,9 +1072,7 @@ f_path(plan, entry)
* symbolic mode.
*/
int
-f_perm(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_perm(PLAN *plan, FTSENT *entry)
{
mode_t mode;
@@ -1172,9 +1088,7 @@ f_perm(plan, entry)
}
PLAN *
-c_perm(option, argvp)
- OPTION *option;
- char ***argvp;
+c_perm(OPTION *option, char ***argvp)
{
char *perm;
PLAN *new;
@@ -1208,18 +1122,14 @@ c_perm(option, argvp)
* standard output.
*/
int
-f_print(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry;
+f_print(PLAN *plan __unused, FTSENT *entry)
{
(void)puts(entry->fts_path);
return 1;
}
PLAN *
-c_print(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_print(OPTION *option, char ***argvp __unused)
{
isoutput = 1;
@@ -1233,9 +1143,7 @@ c_print(option, argvp)
* standard output followed by a NUL character
*/
int
-f_print0(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry;
+f_print0(PLAN *plan __unused, FTSENT *entry)
{
fputs(entry->fts_path, stdout);
fputc('\0', stdout);
@@ -1250,12 +1158,8 @@ f_print0(plan, entry)
* Prune a portion of the hierarchy.
*/
int
-f_prune(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry;
+f_prune(PLAN *plan __unused, FTSENT *entry)
{
- extern FTS *tree;
-
if (fts_set(tree, entry, FTS_SKIP))
err(1, "%s", entry->fts_path);
return 1;
@@ -1270,9 +1174,7 @@ f_prune(plan, entry)
* regular expression.
*/
int
-f_regex(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_regex(PLAN *plan, FTSENT *entry)
{
char *str;
int len;
@@ -1305,9 +1207,7 @@ f_regex(plan, entry)
}
PLAN *
-c_regex(option, argvp)
- OPTION *option;
- char ***argvp;
+c_regex(OPTION *option, char ***argvp)
{
PLAN *new;
char *pattern;
@@ -1337,9 +1237,7 @@ c_regex(option, argvp)
/* c_simple covers c_prune, c_openparen, c_closeparen, c_not, c_or */
PLAN *
-c_simple(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_simple(OPTION *option, char ***argvp __unused)
{
return palloc(option);
}
@@ -1355,9 +1253,7 @@ c_simple(option, argvp)
static int divsize = 1;
int
-f_size(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_size(PLAN *plan, FTSENT *entry)
{
off_t size;
@@ -1367,9 +1263,7 @@ f_size(plan, entry)
}
PLAN *
-c_size(option, argvp)
- OPTION *option;
- char ***argvp;
+c_size(OPTION *option, char ***argvp)
{
char *size_str;
PLAN *new;
@@ -1394,17 +1288,13 @@ c_size(option, argvp)
* regular file or whiteout respectively.
*/
int
-f_type(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_type(PLAN *plan, FTSENT *entry)
{
return (entry->fts_statp->st_mode & S_IFMT) == plan->m_data;
}
PLAN *
-c_type(option, argvp)
- OPTION *option;
- char ***argvp;
+c_type(OPTION *option, char ***argvp)
{
char *typestring;
PLAN *new;
@@ -1458,17 +1348,13 @@ c_type(option, argvp)
* return a valid user name, uname is taken as a user ID.
*/
int
-f_user(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_user(PLAN *plan, FTSENT *entry)
{
return entry->fts_statp->st_uid == plan->u_data;
}
PLAN *
-c_user(option, argvp)
- OPTION *option;
- char ***argvp;
+c_user(OPTION *option, char ***argvp)
{
char *username;
PLAN *new;
@@ -1498,9 +1384,7 @@ c_user(option, argvp)
* different device ID (st_dev, see stat() S5.6.2 [POSIX.1])
*/
PLAN *
-c_xdev(option, argvp)
- OPTION *option;
- char ***argvp __unused;
+c_xdev(OPTION *option, char ***argvp __unused)
{
ftsoptions |= FTS_XDEV;
@@ -1513,9 +1397,7 @@ c_xdev(option, argvp)
* True if expression is true.
*/
int
-f_expr(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_expr(PLAN *plan, FTSENT *entry)
{
PLAN *p;
int state = 0;
@@ -1533,17 +1415,13 @@ f_expr(plan, entry)
*/
int
-f_openparen(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry __unused;
+f_openparen(PLAN *plan __unused, FTSENT *entry __unused)
{
abort();
}
int
-f_closeparen(plan, entry)
- PLAN *plan __unused;
- FTSENT *entry __unused;
+f_closeparen(PLAN *plan __unused, FTSENT *entry __unused)
{
abort();
}
@@ -1555,9 +1433,7 @@ f_closeparen(plan, entry)
* AND operator. Since AND is implicit, no node is allocated.
*/
PLAN *
-c_and(option, argvp)
- OPTION *option __unused;
- char ***argvp __unused;
+c_and(OPTION *option __unused, char ***argvp __unused)
{
return NULL;
}
@@ -1568,9 +1444,7 @@ c_and(option, argvp)
* Negation of a primary; the unary NOT operator.
*/
int
-f_not(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_not(PLAN *plan, FTSENT *entry)
{
PLAN *p;
int state = 0;
@@ -1589,9 +1463,7 @@ f_not(plan, entry)
* not evaluated if the first expression is true.
*/
int
-f_or(plan, entry)
- PLAN *plan;
- FTSENT *entry;
+f_or(PLAN *plan, FTSENT *entry)
{
PLAN *p;
int state = 0;