xref: /original-bsd/usr.bin/find/main.c (revision 331bfa8d)
1 /*-
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)main.c	5.5 (Berkeley) 11/15/90";
10 #endif /* not lint */
11 
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <stdio.h>
15 #include <fts.h>
16 #include "find.h"
17 
18 void
19 newsyntax(argc, argvp)
20 	int argc;
21 	char ***argvp;
22 {
23 	extern int optind;
24 	extern char *optarg;
25 	int ch;
26 	char **argv, **cur;
27 
28 	cur = argv = *argvp;
29 	while ((ch = getopt(argc, argv, "df:rsx")) != EOF)
30 		switch(ch) {
31 		case 'd':
32 			isdepth = 1;
33 			break;
34 		case 'f':
35 			*cur++ = optarg;
36 			break;
37 		case 'r':
38 			isrelative = 1;
39 			break;
40 		case 's':
41 			ftsoptions &= ~FTS_PHYSICAL;
42 			ftsoptions |= FTS_LOGICAL;
43 			break;
44 		case 'x':
45 			ftsoptions &= ~FTS_NOSTAT;
46 			ftsoptions |= FTS_XDEV;
47 			break;
48 		case '?':
49 		default:
50 			usage();
51 		}
52 
53 	*argvp += optind;
54 	if (cur == argv) {
55 		if (!**argvp)
56 			usage();
57 		*cur++ = **argvp;
58 		++*argvp;
59 	}
60 	*cur = NULL;
61 }
62