diff toys/which.c @ 25:eb46bb5626cb

New option parsing infrastructure (doesn't use getopt). Hook it up to existing applets. Still a bit buggy, but bits of it work.
author Rob Landley <rob@landley.net>
date Sun, 19 Nov 2006 02:49:22 -0500
parents 3981c96f9285
children 7c77c6ec17ee
line wrap: on
line diff
--- a/toys/which.c	Thu Nov 09 19:19:37 2006 -0500
+++ b/toys/which.c	Sun Nov 19 02:49:22 2006 -0500
@@ -7,7 +7,6 @@
 
 #include "toys.h"
 
-#define OPTIONS "a"
 #define OPT_a   1
 
 // Find an exectuable file either at a path with a slash in it (absolute or
@@ -55,16 +54,12 @@
 
 int which_main(void)
 {
-	char **argv;
 	int rc = 0;
 
-	// get_optflags(OPTIONS);
-	argv = toys.argv+1;
-
-	if (!*argv) rc++;
+	if (!*toys.optargs) rc++;
 	else {
 		int i;
-		for (i=0; argv[i]; i++)	rc |= which_in_path(argv[i]);
+		for (i=0; toys.optargs[i]; i++) rc |= which_in_path(toys.optargs[i]);
 	}
 	// if (CFG_TOYS_FREE) free(argv);