xref: /original-bsd/usr.bin/find/main.c (revision f91c1509)
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.6 (Berkeley) 03/09/91";
10 #endif /* not lint */
11 
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <fts.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include "find.h"
18 
19 void
20 newsyntax(argc, argvp)
21 	int argc;
22 	char ***argvp;
23 {
24 	extern int optind;
25 	extern char *optarg;
26 	int ch;
27 	char **argv, **cur;
28 
29 	cur = argv = *argvp;
30 	while ((ch = getopt(argc, argv, "df:rsx")) != EOF)
31 		switch(ch) {
32 		case 'd':
33 			isdepth = 1;
34 			break;
35 		case 'f':
36 			*cur++ = optarg;
37 			break;
38 		case 'r':
39 			isrelative = 1;
40 			break;
41 		case 's':
42 			ftsoptions &= ~FTS_PHYSICAL;
43 			ftsoptions |= FTS_LOGICAL;
44 			break;
45 		case 'x':
46 			ftsoptions &= ~FTS_NOSTAT;
47 			ftsoptions |= FTS_XDEV;
48 			break;
49 		case '?':
50 		default:
51 			usage();
52 		}
53 
54 	*argvp += optind;
55 	if (cur == argv) {
56 		if (!**argvp)
57 			usage();
58 		*cur++ = **argvp;
59 		++*argvp;
60 	}
61 	*cur = NULL;
62 }
63