/* vi: set sw=4 ts=4: */
/*
 * Which implementation for busybox
 *
 * Copyright (C) 2000 by Lineo, inc.
 * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#include "internal.h"
#include <stdio.h>

extern int which_main(int argc, char **argv)
{
	char *path_list, *path_n;
	struct stat filestat;
	int i, count=1;

	if (argc <= 1 || **(argv + 1) == '-')
		usage(which_usage);
	argc--;

	path_list = getenv("PATH");
	if (!path_list)
		path_list = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin";

	/* Replace colons with zeros in path_parsed and count them */
	for(i=strlen(path_list); i > 0; i--) 
		if (path_list[i]==':') {
			path_list[i]=0;
			count++;
		}

	while(argc-- > 0) { 
		path_n = path_list;
		argv++;
		for (i = 0; i < count; i++) {
			char buf[strlen(path_n)+1+strlen(*argv)];
			strcpy (buf, path_n);
			strcat (buf, "/");
			strcat (buf, *argv);
			if (stat (buf, &filestat) == 0
			    && filestat.st_mode & S_IXUSR)
			{
				printf ("%s\n", buf);
				break;
			}
			path_n += (strlen(path_n) + 1);
		}
	}
	return(TRUE);
}

/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
