diff options
Diffstat (limited to 'usr.bin/find/function.c')
-rw-r--r-- | usr.bin/find/function.c | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 52e0f43..72a4e74 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -84,7 +84,7 @@ find_parsenum(plan, option, vp, endch) { long value; char *endchar, *str; /* Pointer to character ending conversion. */ - + /* Determine comparison from leading + or -. */ str = vp; switch (*str) { @@ -100,7 +100,7 @@ find_parsenum(plan, option, vp, endch) plan->flags = F_EQUAL; break; } - + /* * Convert the string with strtol(). Note, if strtol() returns zero * and endchar points to the beginning of the string we know we have @@ -142,7 +142,7 @@ f_atime(plan, entry) COMPARE((now - entry->fts_statp->st_atime + SECSPERDAY - 1) / SECSPERDAY, plan->t_data); } - + PLAN * c_atime(arg) char *arg; @@ -172,7 +172,7 @@ f_ctime(plan, entry) COMPARE((now - entry->fts_statp->st_ctime + SECSPERDAY - 1) / SECSPERDAY, plan->t_data); } - + PLAN * c_ctime(arg) char *arg; @@ -201,7 +201,7 @@ f_always_true(plan, entry) { return (1); } - + PLAN * c_depth() { @@ -209,7 +209,7 @@ c_depth() return (palloc(N_DEPTH, f_always_true)); } - + /* * [-exec | -ok] utility [arg ... ] ; functions -- * @@ -256,7 +256,7 @@ f_exec(plan, entry) pid = waitpid(pid, &status, 0); return (pid != -1 && WIFEXITED(status) && !WEXITSTATUS(status)); } - + /* * c_exec -- * build three parallel arrays, one with pointers to the strings passed @@ -274,7 +274,7 @@ c_exec(argvp, isok) register char **argv, **ap, *p; isoutput = 1; - + new = palloc(N_EXEC, f_exec); if (isok) new->flags = F_NEEDOK; @@ -310,7 +310,7 @@ c_exec(argvp, isok) *argvp = argv + 1; return (new); } - + /* * -follow functions -- * @@ -325,7 +325,7 @@ c_follow() return (palloc(N_FOLLOW, f_always_true)); } - + /* * -fstype functions -- * @@ -360,8 +360,8 @@ f_fstype(plan, entry) p[0] = '.'; save[1] = p[1]; p[1] = '\0'; - - } else + + } else p = NULL; if (statfs(entry->fts_accpath, &sb)) @@ -386,22 +386,22 @@ f_fstype(plan, entry) } switch(plan->flags) { case F_MTFLAG: - return (val & plan->mt_data); + return (val & plan->mt_data); case F_MTTYPE: return (val == plan->mt_data); default: abort(); } } - + PLAN * c_fstype(arg) char *arg; { register PLAN *new; - + ftsoptions &= ~FTS_NOSTAT; - + new = palloc(N_FSTYPE, f_fstype); switch (*arg) { case 'l': @@ -450,7 +450,7 @@ c_fstype(arg) errx(1, "%s: unknown file type", arg); /* NOTREACHED */ } - + /* * -group gname functions -- * @@ -465,7 +465,7 @@ f_group(plan, entry) { return (entry->fts_statp->st_gid == plan->g_data); } - + PLAN * c_group(gname) char *gname; @@ -473,7 +473,7 @@ c_group(gname) PLAN *new; struct group *g; gid_t gid; - + ftsoptions &= ~FTS_NOSTAT; g = getgrnam(gname); @@ -483,7 +483,7 @@ c_group(gname) errx(1, "-group: %s: no such group", gname); } else gid = g->gr_gid; - + new = palloc(N_GROUP, f_group); new->g_data = gid; return (new); @@ -501,20 +501,20 @@ f_inum(plan, entry) { COMPARE(entry->fts_statp->st_ino, plan->i_data); } - + PLAN * c_inum(arg) char *arg; { PLAN *new; - + ftsoptions &= ~FTS_NOSTAT; - + new = palloc(N_INUM, f_inum); new->i_data = find_parsenum(new, "-inum", arg, NULL); return (new); } - + /* * -links n functions -- * @@ -527,20 +527,20 @@ f_links(plan, entry) { COMPARE(entry->fts_statp->st_nlink, plan->l_data); } - + PLAN * c_links(arg) char *arg; { PLAN *new; - + ftsoptions &= ~FTS_NOSTAT; - + new = palloc(N_LINKS, f_links); new->l_data = (nlink_t)find_parsenum(new, "-links", arg, NULL); return (new); } - + /* * -ls functions -- * @@ -554,13 +554,13 @@ f_ls(plan, entry) printlong(entry->fts_path, entry->fts_accpath, entry->fts_statp); return (1); } - + PLAN * c_ls() { ftsoptions &= ~FTS_NOSTAT; isoutput = 1; - + return (palloc(N_LS, f_ls)); } @@ -580,7 +580,7 @@ f_mtime(plan, entry) COMPARE((now - entry->fts_statp->st_mtime + SECSPERDAY - 1) / SECSPERDAY, plan->t_data); } - + PLAN * c_mtime(arg) char *arg; @@ -608,7 +608,7 @@ f_name(plan, entry) { return (!fnmatch(plan->c_data, entry->fts_name, 0)); } - + PLAN * c_name(pattern) char *pattern; @@ -619,7 +619,7 @@ c_name(pattern) new->c_data = pattern; return (new); } - + /* * -newer file functions -- * @@ -634,14 +634,14 @@ f_newer(plan, entry) { return (entry->fts_statp->st_mtime > plan->t_data); } - + PLAN * c_newer(filename) char *filename; { PLAN *new; struct stat sb; - + ftsoptions &= ~FTS_NOSTAT; if (stat(filename, &sb)) @@ -650,7 +650,7 @@ c_newer(filename) new->t_data = sb.st_mtime; return (new); } - + /* * -nogroup functions -- * @@ -666,7 +666,7 @@ f_nogroup(plan, entry) return (group_from_gid(entry->fts_statp->st_gid, 1) ? 0 : 1); } - + PLAN * c_nogroup() { @@ -674,7 +674,7 @@ c_nogroup() return (palloc(N_NOGROUP, f_nogroup)); } - + /* * -nouser functions -- * @@ -690,7 +690,7 @@ f_nouser(plan, entry) return (user_from_uid(entry->fts_statp->st_uid, 1) ? 0 : 1); } - + PLAN * c_nouser() { @@ -698,7 +698,7 @@ c_nouser() return (palloc(N_NOUSER, f_nouser)); } - + /* * -path functions -- * @@ -712,7 +712,7 @@ f_path(plan, entry) { return (!fnmatch(plan->c_data, entry->fts_path, 0)); } - + PLAN * c_path(pattern) char *pattern; @@ -723,7 +723,7 @@ c_path(pattern) new->c_data = pattern; return (new); } - + /* * -perm functions -- * @@ -746,7 +746,7 @@ f_perm(plan, entry) return (mode == plan->m_data); /* NOTREACHED */ } - + PLAN * c_perm(perm) char *perm; @@ -769,7 +769,7 @@ c_perm(perm) new->m_data = getmode(set, 0); return (new); } - + /* * -print functions -- * @@ -784,7 +784,7 @@ f_print(plan, entry) (void)printf("%s\n", entry->fts_path); return (1); } - + PLAN * c_print() { @@ -792,7 +792,7 @@ c_print() return (palloc(N_PRINT, f_print)); } - + /* * -print0 functions -- * @@ -808,7 +808,7 @@ f_print0(plan, entry) fputc('\0', stdout); return (1); } - + PLAN * c_print0() { @@ -816,7 +816,7 @@ c_print0() return (palloc(N_PRINT0, f_print0)); } - + /* * -prune functions -- * @@ -833,13 +833,13 @@ f_prune(plan, entry) err(1, "%s", entry->fts_path); return (1); } - + PLAN * c_prune() { return (palloc(N_PRUNE, f_prune)); } - + /* * -size n[c] functions -- * @@ -861,14 +861,14 @@ f_size(plan, entry) FIND_SIZE : entry->fts_statp->st_size; COMPARE(size, plan->o_data); } - + PLAN * c_size(arg) char *arg; { PLAN *new; char endch; - + ftsoptions &= ~FTS_NOSTAT; new = palloc(N_SIZE, f_size); @@ -878,7 +878,7 @@ c_size(arg) divsize = 0; return (new); } - + /* * -type c functions -- * @@ -893,14 +893,14 @@ f_type(plan, entry) { return ((entry->fts_statp->st_mode & S_IFMT) == plan->m_data); } - + PLAN * c_type(typestring) char *typestring; { PLAN *new; mode_t mask; - + ftsoptions &= ~FTS_NOSTAT; switch (typestring[0]) { @@ -928,12 +928,12 @@ c_type(typestring) default: errx(1, "-type: %s: unknown type", typestring); } - + new = palloc(N_TYPE, f_type); new->m_data = mask; return (new); } - + /* * -user uname functions -- * @@ -948,7 +948,7 @@ f_user(plan, entry) { return (entry->fts_statp->st_uid == plan->u_data); } - + PLAN * c_user(username) char *username; @@ -956,7 +956,7 @@ c_user(username) PLAN *new; struct passwd *p; uid_t uid; - + ftsoptions &= ~FTS_NOSTAT; p = getpwnam(username); @@ -971,7 +971,7 @@ c_user(username) new->u_data = uid; return (new); } - + /* * -xdev functions -- * @@ -1003,7 +1003,7 @@ f_expr(plan, entry) p && (state = (p->eval)(p, entry)); p = p->next); return (state); } - + /* * N_OPENPAREN and N_CLOSEPAREN nodes are temporary place markers. They are * eliminated during phase 2 of find_formplan() --- the '(' node is converted @@ -1014,13 +1014,13 @@ c_openparen() { return (palloc(N_OPENPAREN, (int (*)())-1)); } - + PLAN * c_closeparen() { return (palloc(N_CLOSEPAREN, (int (*)())-1)); } - + /* * ! expression functions -- * @@ -1038,13 +1038,13 @@ f_not(plan, entry) p && (state = (p->eval)(p, entry)); p = p->next); return (!state); } - + PLAN * c_not() { return (palloc(N_NOT, f_not)); } - + /* * expression -o expression functions -- * |