xref: /original-bsd/usr.bin/find/main.c (revision ba762ddc)
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.7 (Berkeley) 04/27/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:rsXx")) != 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 			isxargs = 1;
47 			break;
48 		case 'x':
49 			ftsoptions &= ~FTS_NOSTAT;
50 			ftsoptions |= FTS_XDEV;
51 			break;
52 		case '?':
53 		default:
54 			usage();
55 		}
56 
57 	*argvp += optind;
58 	if (cur == argv) {
59 		if (!**argvp)
60 			usage();
61 		*cur++ = **argvp;
62 		++*argvp;
63 	}
64 	*cur = NULL;
65 }
66