2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Cimarron D. Taylor of the University of California, Berkeley.
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 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 static const char sccsid[] = "@(#)function.c 8.10 (Berkeley) 5/4/95";
41 static const char rcsid[] =
46 #include <sys/param.h>
47 #include <sys/ucred.h>
50 #include <sys/mount.h>
65 #define COMPARE(a, b) { \
66 switch (plan->flags) { \
78 static PLAN *palloc __P((enum ntype, int (*) __P((PLAN *, FTSENT *))));
82 * Parse a string of the form [+-]# and return the value.
85 find_parsenum(plan, option, vp, endch)
87 char *option, *vp, *endch;
90 char *endchar, *str; /* Pointer to character ending conversion. */
92 /* Determine comparison from leading + or -. */
97 plan->flags = F_GREATER;
101 plan->flags = F_LESSTHAN;
104 plan->flags = F_EQUAL;
109 * Convert the string with strtoq(). Note, if strtoq() returns zero
110 * and endchar points to the beginning of the string we know we have
113 value = strtoq(str, &endchar, 10);
114 if (value == 0 && endchar == str)
115 errx(1, "%s: %s: illegal numeric value", option, vp);
116 if (endchar[0] && (endch == NULL || endchar[0] != *endch))
117 errx(1, "%s: %s: illegal trailing character", option, vp);
124 * The value of n for the inode times (atime, ctime, and mtime) is a range,
125 * i.e. n matches from (n - 1) to n 24 hour periods. This interacts with
126 * -n, such that "-mtime -1" would be less than 0 days, which isn't what the
127 * user wanted. Correct so that -1 is "less than 1".
129 #define TIME_CORRECT(p, ttype) \
130 if ((p)->type == ttype && (p)->flags == F_LESSTHAN) \
134 * -amin n functions --
136 * True if the difference between the file access time and the
137 * current time is n min periods.
146 COMPARE((now - entry->fts_statp->st_atime +
147 60 - 1) / 60, plan->t_data);
156 ftsoptions &= ~FTS_NOSTAT;
158 new = palloc(N_AMIN, f_amin);
159 new->t_data = find_parsenum(new, "-amin", arg, NULL);
160 TIME_CORRECT(new, N_AMIN);
166 * -atime n functions --
168 * True if the difference between the file access time and the
169 * current time is n 24 hour periods.
178 COMPARE((now - entry->fts_statp->st_atime +
179 86400 - 1) / 86400, plan->t_data);
188 ftsoptions &= ~FTS_NOSTAT;
190 new = palloc(N_ATIME, f_atime);
191 new->t_data = find_parsenum(new, "-atime", arg, NULL);
192 TIME_CORRECT(new, N_ATIME);
198 * -cmin n functions --
200 * True if the difference between the last change of file
201 * status information and the current time is n min periods.
210 COMPARE((now - entry->fts_statp->st_ctime +
211 60 - 1) / 60, plan->t_data);
220 ftsoptions &= ~FTS_NOSTAT;
222 new = palloc(N_CMIN, f_cmin);
223 new->t_data = find_parsenum(new, "-cmin", arg, NULL);
224 TIME_CORRECT(new, N_CMIN);
229 * -ctime n functions --
231 * True if the difference between the last change of file
232 * status information and the current time is n 24 hour periods.
241 COMPARE((now - entry->fts_statp->st_ctime +
242 86400 - 1) / 86400, plan->t_data);
251 ftsoptions &= ~FTS_NOSTAT;
253 new = palloc(N_CTIME, f_ctime);
254 new->t_data = find_parsenum(new, "-ctime", arg, NULL);
255 TIME_CORRECT(new, N_CTIME);
261 * -depth functions --
263 * Always true, causes descent of the directory hierarchy to be done
264 * so that all entries in a directory are acted on before the directory
268 f_always_true(plan, entry)
280 return (palloc(N_DEPTH, f_always_true));
284 * [-exec | -ok] utility [arg ... ] ; functions --
286 * True if the executed utility returns a zero value as exit status.
287 * The end of the primary expression is delimited by a semicolon. If
288 * "{}" occurs anywhere, it gets replaced by the current pathname.
289 * The current directory for the execution of utility is the same as
290 * the current directory when the find utility was started.
292 * The primary -ok is different in that it requests affirmation of the
293 * user before executing the utility.
305 for (cnt = 0; plan->e_argv[cnt]; ++cnt)
306 if (plan->e_len[cnt])
307 brace_subst(plan->e_orig[cnt], &plan->e_argv[cnt],
308 entry->fts_path, plan->e_len[cnt]);
310 if (plan->flags == F_NEEDOK && !queryuser(plan->e_argv))
313 /* make sure find output is interspersed correctly with subprocesses */
316 switch (pid = fork()) {
325 execvp(plan->e_argv[0], plan->e_argv);
326 warn("%s", plan->e_argv[0]);
329 pid = waitpid(pid, &status, 0);
330 return (pid != -1 && WIFEXITED(status) && !WEXITSTATUS(status));
335 * build three parallel arrays, one with pointers to the strings passed
336 * on the command line, one with (possibly duplicated) pointers to the
337 * argv array, and one with integer values that are lengths of the
338 * strings, but also flags meaning that the string has to be massaged.
345 PLAN *new; /* node returned */
347 register char **argv, **ap, *p;
351 new = palloc(N_EXEC, f_exec);
353 new->flags = F_NEEDOK;
355 for (ap = argv = *argvp;; ++ap) {
358 "%s: no terminating \";\"", isok ? "-ok" : "-exec");
363 cnt = ap - *argvp + 1;
364 new->e_argv = (char **)emalloc((u_int)cnt * sizeof(char *));
365 new->e_orig = (char **)emalloc((u_int)cnt * sizeof(char *));
366 new->e_len = (int *)emalloc((u_int)cnt * sizeof(int));
368 for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) {
369 new->e_orig[cnt] = *argv;
370 for (p = *argv; *p; ++p)
371 if (p[0] == '{' && p[1] == '}') {
372 new->e_argv[cnt] = emalloc((u_int)MAXPATHLEN);
373 new->e_len[cnt] = MAXPATHLEN;
377 new->e_argv[cnt] = *argv;
381 new->e_argv[cnt] = new->e_orig[cnt] = NULL;
388 * -execdir utility [arg ... ] ; functions --
390 * True if the executed utility returns a zero value as exit status.
391 * The end of the primary expression is delimited by a semicolon. If
392 * "{}" occurs anywhere, it gets replaced by the unqualified pathname.
393 * The current directory for the execution of utility is the same as
394 * the directory where the file lives.
397 f_execdir(plan, entry)
406 /* XXX - if file/dir ends in '/' this will not work -- can it? */
407 if ((file = strrchr(entry->fts_path, '/')))
410 file = entry->fts_path;
412 for (cnt = 0; plan->e_argv[cnt]; ++cnt)
413 if (plan->e_len[cnt])
414 brace_subst(plan->e_orig[cnt], &plan->e_argv[cnt],
415 file, plan->e_len[cnt]);
417 /* don't mix output of command with find output */
421 switch (pid = fork()) {
426 execvp(plan->e_argv[0], plan->e_argv);
427 warn("%s", plan->e_argv[0]);
430 pid = waitpid(pid, &status, 0);
431 return (pid != -1 && WIFEXITED(status) && !WEXITSTATUS(status));
436 * build three parallel arrays, one with pointers to the strings passed
437 * on the command line, one with (possibly duplicated) pointers to the
438 * argv array, and one with integer values that are lengths of the
439 * strings, but also flags meaning that the string has to be massaged.
445 PLAN *new; /* node returned */
447 register char **argv, **ap, *p;
449 ftsoptions &= ~FTS_NOSTAT;
452 new = palloc(N_EXECDIR, f_execdir);
454 for (ap = argv = *argvp;; ++ap) {
457 "-execdir: no terminating \";\"");
462 cnt = ap - *argvp + 1;
463 new->e_argv = (char **)emalloc((u_int)cnt * sizeof(char *));
464 new->e_orig = (char **)emalloc((u_int)cnt * sizeof(char *));
465 new->e_len = (int *)emalloc((u_int)cnt * sizeof(int));
467 for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) {
468 new->e_orig[cnt] = *argv;
469 for (p = *argv; *p; ++p)
470 if (p[0] == '{' && p[1] == '}') {
471 new->e_argv[cnt] = emalloc((u_int)MAXPATHLEN);
472 new->e_len[cnt] = MAXPATHLEN;
476 new->e_argv[cnt] = *argv;
480 new->e_argv[cnt] = new->e_orig[cnt] = NULL;
487 * -follow functions --
489 * Always true, causes symbolic links to be followed on a global
495 ftsoptions &= ~FTS_PHYSICAL;
496 ftsoptions |= FTS_LOGICAL;
498 return (palloc(N_FOLLOW, f_always_true));
502 * -fstype functions --
504 * True if the file is of a certain type.
507 f_fstype(plan, entry)
511 static dev_t curdev; /* need a guaranteed illegal dev value */
512 static int first = 1;
514 static int val_type, val_flags;
517 /* Only check when we cross mount point. */
518 if (first || curdev != entry->fts_statp->st_dev) {
519 curdev = entry->fts_statp->st_dev;
522 * Statfs follows symlinks; find wants the link's file system,
523 * not where it points.
525 if (entry->fts_info == FTS_SL ||
526 entry->fts_info == FTS_SLNONE) {
527 if ((p = strrchr(entry->fts_accpath, '/')) != NULL)
530 p = entry->fts_accpath;
539 if (statfs(entry->fts_accpath, &sb))
540 err(1, "%s", entry->fts_accpath);
550 * Further tests may need both of these values, so
551 * always copy both of them.
553 val_flags = sb.f_flags;
554 val_type = sb.f_type;
556 switch (plan->flags) {
558 return (val_flags & plan->mt_data) != 0;
560 return (val_type == plan->mt_data);
566 #if !defined(__NetBSD__)
568 f_always_false(plan, entry)
582 ftsoptions &= ~FTS_NOSTAT;
584 new = palloc(N_FSTYPE, f_fstype);
587 * Check first for a filesystem name.
589 if (getvfsbyname(arg, &vfc) == 0) {
590 new->flags = F_MTTYPE;
591 new->mt_data = vfc.vfc_typenum;
597 if (!strcmp(arg, "local")) {
598 new->flags = F_MTFLAG;
599 new->mt_data = MNT_LOCAL;
604 if (!strcmp(arg, "rdonly")) {
605 new->flags = F_MTFLAG;
606 new->mt_data = MNT_RDONLY;
612 * We need to make filesystem checks for filesystems
613 * that exists but aren't in the kernel work.
615 fprintf(stderr, "Warning: Unknown filesystem type %s\n", arg);
618 return (palloc(N_FSTYPE, f_always_false));
623 * -group gname functions --
625 * True if the file belongs to the group gname. If gname is numeric and
626 * an equivalent of the getgrnam() function does not return a valid group
627 * name, gname is taken as a group ID.
634 return (entry->fts_statp->st_gid == plan->g_data);
645 ftsoptions &= ~FTS_NOSTAT;
650 if (gid == 0 && gname[0] != '0')
651 errx(1, "-group: %s: no such group", gname);
655 new = palloc(N_GROUP, f_group);
661 * -inum n functions --
663 * True if the file has inode # n.
670 COMPARE(entry->fts_statp->st_ino, plan->i_data);
679 ftsoptions &= ~FTS_NOSTAT;
681 new = palloc(N_INUM, f_inum);
682 new->i_data = find_parsenum(new, "-inum", arg, NULL);
687 * -links n functions --
689 * True if the file has n links.
696 COMPARE(entry->fts_statp->st_nlink, plan->l_data);
705 ftsoptions &= ~FTS_NOSTAT;
707 new = palloc(N_LINKS, f_links);
708 new->l_data = (nlink_t)find_parsenum(new, "-links", arg, NULL);
715 * Always true - prints the current entry to stdout in "ls" format.
722 printlong(entry->fts_path, entry->fts_accpath, entry->fts_statp);
729 ftsoptions &= ~FTS_NOSTAT;
732 return (palloc(N_LS, f_ls));
736 * -maxdepth n functions --
738 * Does the same as -prune if the level of the current file is greater
739 * than the specified maximum depth.
741 * Note that -maxdepth and -mindepth are handled specially in
742 * find_execute() so their f_* functions here do nothing.
745 f_maxdepth(plan, entry)
759 /* all other errors handled by find_parsenum() */
760 errx(1, "-maxdepth: %s: value must be positive", arg);
762 new = palloc(N_MAXDEPTH, f_maxdepth);
763 maxdepth = find_parsenum(new, "-maxdepth", arg, NULL);
768 * -mindepth n functions --
770 * True if the current file is at or deeper than the specified minimum
774 f_mindepth(plan, entry)
788 /* all other errors handled by find_parsenum() */
789 errx(1, "-maxdepth: %s: value must be positive", arg);
791 new = palloc(N_MINDEPTH, f_mindepth);
792 mindepth = find_parsenum(new, "-mindepth", arg, NULL);
797 * -mtime n functions --
799 * True if the difference between the file modification time and the
800 * current time is n 24 hour periods.
809 COMPARE((now - entry->fts_statp->st_mtime + 86400 - 1) /
810 86400, plan->t_data);
819 ftsoptions &= ~FTS_NOSTAT;
821 new = palloc(N_MTIME, f_mtime);
822 new->t_data = find_parsenum(new, "-mtime", arg, NULL);
823 TIME_CORRECT(new, N_MTIME);
828 * -mmin n functions --
830 * True if the difference between the file modification time and the
831 * current time is n min periods.
840 COMPARE((now - entry->fts_statp->st_mtime + 60 - 1) /
850 ftsoptions &= ~FTS_NOSTAT;
852 new = palloc(N_MMIN, f_mmin);
853 new->t_data = find_parsenum(new, "-mmin", arg, NULL);
854 TIME_CORRECT(new, N_MMIN);
862 * True if the basename of the filename being examined
863 * matches pattern using Pattern Matching Notation S3.14
870 return (!fnmatch(plan->c_data, entry->fts_name, 0));
879 new = palloc(N_NAME, f_name);
880 new->c_data = pattern;
885 * -newer file functions --
887 * True if the current file has been modified more recently
888 * then the modification time of the file named by the pathname
896 return (entry->fts_statp->st_mtime > plan->t_data);
906 ftsoptions &= ~FTS_NOSTAT;
908 if (stat(filename, &sb))
909 err(1, "%s", filename);
910 new = palloc(N_NEWER, f_newer);
911 new->t_data = sb.st_mtime;
916 * -nogroup functions --
918 * True if file belongs to a user ID for which the equivalent
919 * of the getgrnam() 9.2.1 [POSIX.1] function returns NULL.
922 f_nogroup(plan, entry)
926 return (group_from_gid(entry->fts_statp->st_gid, 1) ? 0 : 1);
932 ftsoptions &= ~FTS_NOSTAT;
934 return (palloc(N_NOGROUP, f_nogroup));
938 * -nouser functions --
940 * True if file belongs to a user ID for which the equivalent
941 * of the getpwuid() 9.2.2 [POSIX.1] function returns NULL.
944 f_nouser(plan, entry)
948 return (user_from_uid(entry->fts_statp->st_uid, 1) ? 0 : 1);
954 ftsoptions &= ~FTS_NOSTAT;
956 return (palloc(N_NOUSER, f_nouser));
962 * True if the path of the filename being examined
963 * matches pattern using Pattern Matching Notation S3.14
970 return (!fnmatch(plan->c_data, entry->fts_path, 0));
979 new = palloc(N_NAME, f_path);
980 new->c_data = pattern;
987 * The mode argument is used to represent file mode bits. If it starts
988 * with a leading digit, it's treated as an octal mode, otherwise as a
998 mode = entry->fts_statp->st_mode &
999 (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO);
1000 if (plan->flags == F_ATLEAST)
1001 return ((plan->m_data | mode) == mode);
1002 else if (plan->flags == F_ANY )
1003 return (plan->m_data & mode);
1005 return (mode == plan->m_data);
1016 ftsoptions &= ~FTS_NOSTAT;
1018 new = palloc(N_PERM, f_perm);
1021 new->flags = F_ATLEAST;
1023 } else if (*perm == '+') {
1028 if ((set = setmode(perm)) == NULL)
1029 errx(1, "-perm: %s: illegal mode string", perm);
1031 new->m_data = getmode(set, 0);
1037 * -flags functions --
1039 * The flags argument is used to represent file flags bits.
1042 f_flags(plan, entry)
1048 flags = entry->fts_statp->st_flags &
1049 (UF_NODUMP | UF_IMMUTABLE | UF_APPEND | UF_OPAQUE |
1050 SF_ARCHIVED | SF_IMMUTABLE | SF_APPEND);
1051 if (plan->flags == F_ATLEAST)
1052 /* note that plan->fl_flags always is a subset of
1054 return (flags & plan->fl_mask) == plan->fl_flags;
1056 return flags == plan->fl_flags;
1065 u_long flags, notflags;
1067 ftsoptions &= ~FTS_NOSTAT;
1069 new = palloc(N_FLAGS, f_flags);
1071 if (*flags_str == '-') {
1072 new->flags = F_ATLEAST;
1075 if (strtofflags(&flags_str, &flags, ¬flags) == 1)
1076 errx(1, "-flags: %s: illegal flags string", flags_str);
1078 new->fl_flags = flags;
1079 new->fl_mask = flags | notflags;
1081 printf("flags = %08x, mask = %08x (%08x, %08x)\n",
1082 new->fl_flags, new->fl_mask, flags, notflags);
1088 * -print functions --
1090 * Always true, causes the current pathame to be written to
1094 f_print(plan, entry)
1098 (void)puts(entry->fts_path);
1107 return (palloc(N_PRINT, f_print));
1111 * -print0 functions --
1113 * Always true, causes the current pathame to be written to
1114 * standard output followed by a NUL character
1117 f_print0(plan, entry)
1121 fputs(entry->fts_path, stdout);
1122 fputc('\0', stdout);
1131 return (palloc(N_PRINT0, f_print0));
1135 * -prune functions --
1137 * Prune a portion of the hierarchy.
1140 f_prune(plan, entry)
1146 if (fts_set(tree, entry, FTS_SKIP))
1147 err(1, "%s", entry->fts_path);
1154 return (palloc(N_PRUNE, f_prune));
1158 * -size n[c] functions --
1160 * True if the file size in bytes, divided by an implementation defined
1161 * value and rounded up to the next integer, is n. If n is followed by
1162 * a c, the size is in bytes.
1164 #define FIND_SIZE 512
1165 static int divsize = 1;
1174 size = divsize ? (entry->fts_statp->st_size + FIND_SIZE - 1) /
1175 FIND_SIZE : entry->fts_statp->st_size;
1176 COMPARE(size, plan->o_data);
1186 ftsoptions &= ~FTS_NOSTAT;
1188 new = palloc(N_SIZE, f_size);
1190 new->o_data = find_parsenum(new, "-size", arg, &endch);
1197 * -type c functions --
1199 * True if the type of the file is c, where c is b, c, d, p, f or w
1200 * for block special file, character special file, directory, FIFO,
1201 * regular file or whiteout respectively.
1208 return ((entry->fts_statp->st_mode & S_IFMT) == plan->m_data);
1218 ftsoptions &= ~FTS_NOSTAT;
1220 switch (typestring[0]) {
1245 ftsoptions |= FTS_WHITEOUT;
1247 #endif /* FTS_WHITEOUT */
1249 errx(1, "-type: %s: unknown type", typestring);
1252 new = palloc(N_TYPE, f_type);
1258 * -delete functions --
1260 * True always. Makes it's best shot and continues on regardless.
1263 f_delete(plan, entry)
1267 /* ignore these from fts */
1268 if (strcmp(entry->fts_accpath, ".") == 0 ||
1269 strcmp(entry->fts_accpath, "..") == 0)
1273 if (isdepth == 0 || /* depth off */
1274 (ftsoptions & FTS_NOSTAT) || /* not stat()ing */
1275 !(ftsoptions & FTS_PHYSICAL) || /* physical off */
1276 (ftsoptions & FTS_LOGICAL)) /* or finally, logical on */
1277 errx(1, "-delete: insecure options got turned on");
1279 /* Potentially unsafe - do not accept relative paths whatsoever */
1280 if (strchr(entry->fts_accpath, '/') != NULL)
1281 errx(1, "-delete: %s: relative path potentially not safe",
1282 entry->fts_accpath);
1284 /* Turn off user immutable bits if running as root */
1285 if ((entry->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
1286 !(entry->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)) &&
1288 chflags(entry->fts_accpath,
1289 entry->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE));
1291 /* rmdir directories, unlink everything else */
1292 if (S_ISDIR(entry->fts_statp->st_mode)) {
1293 if (rmdir(entry->fts_accpath) < 0 && errno != ENOTEMPTY)
1294 warn("-delete: rmdir(%s)", entry->fts_path);
1296 if (unlink(entry->fts_accpath) < 0)
1297 warn("-delete: unlink(%s)", entry->fts_path);
1308 ftsoptions &= ~FTS_NOSTAT; /* no optimise */
1309 ftsoptions |= FTS_PHYSICAL; /* disable -follow */
1310 ftsoptions &= ~FTS_LOGICAL; /* disable -follow */
1311 isoutput = 1; /* possible output */
1312 isdepth = 1; /* -depth implied */
1314 return (palloc(N_DELETE, f_delete));
1318 * -user uname functions --
1320 * True if the file belongs to the user uname. If uname is numeric and
1321 * an equivalent of the getpwnam() S9.2.2 [POSIX.1] function does not
1322 * return a valid user name, uname is taken as a user ID.
1329 return (entry->fts_statp->st_uid == plan->u_data);
1340 ftsoptions &= ~FTS_NOSTAT;
1342 p = getpwnam(username);
1344 uid = atoi(username);
1345 if (uid == 0 && username[0] != '0')
1346 errx(1, "-user: %s: no such user", username);
1350 new = palloc(N_USER, f_user);
1356 * -xdev functions --
1358 * Always true, causes find not to decend past directories that have a
1359 * different device ID (st_dev, see stat() S5.6.2 [POSIX.1])
1364 ftsoptions |= FTS_XDEV;
1366 return (palloc(N_XDEV, f_always_true));
1370 * ( expression ) functions --
1372 * True if expression is true.
1383 for (p = plan->p_data[0];
1384 p && (state = (p->eval)(p, entry)); p = p->next);
1389 * N_OPENPAREN and N_CLOSEPAREN nodes are temporary place markers. They are
1390 * eliminated during phase 2 of find_formplan() --- the '(' node is converted
1391 * to a N_EXPR node containing the expression and the ')' node is discarded.
1396 return (palloc(N_OPENPAREN, (int (*)())-1));
1402 return (palloc(N_CLOSEPAREN, (int (*)())-1));
1406 * ! expression functions --
1408 * Negation of a primary; the unary NOT operator.
1419 for (p = plan->p_data[0];
1420 p && (state = (p->eval)(p, entry)); p = p->next);
1427 return (palloc(N_NOT, f_not));
1431 * expression -o expression functions --
1433 * Alternation of primaries; the OR operator. The second expression is
1434 * not evaluated if the first expression is true.
1445 for (p = plan->p_data[0];
1446 p && (state = (p->eval)(p, entry)); p = p->next);
1451 for (p = plan->p_data[1];
1452 p && (state = (p->eval)(p, entry)); p = p->next);
1459 return (palloc(N_OR, f_or));
1465 int (*f) __P((PLAN *, FTSENT *));
1469 if ((new = malloc(sizeof(PLAN))) == NULL)