コード例 #1
0
ファイル: ft_parse_argv.c プロジェクト: Fantasim/Langage-C
void	ft_parse_input(t_shun **shell)
{
	if (*(*shell)->input)
	{
		(*shell)->argv = ft_parse_get_args((*shell)->input);
		(*shell)->argc = ft_tablen((*shell)->argv);
		if ((*shell)->argc != 0)
		{
			if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "exit") == 0)
				ft_exit(&(*shell));
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "env") == 0)
				ft_print_environ(*shell);
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "setenv") == 0)
				ft_setenv(&(*shell));
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]),
							"unsetenv") == 0)
				ft_unsetenv(&(*shell));
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "cd") == 0)
				ft_cd(&(*shell));
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "prompt") == 0)
				ft_chg_prompt(&(*shell));
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "pwd") == 0)
				ft_putendl(ft_get_pwd());
			else
				ft_exec_bin(&(*shell));
		}
	}
}
コード例 #2
0
void	ft_parse_input(t_shell **shell)
{
	if (*(*shell)->input)
	{
		(*shell)->argv = ft_parse_get_args((*shell)->input);
		(*shell)->argc = ft_count_arg((*shell)->argv);
		if ((*shell)->argc != 0)
		{
			if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "env") == 0)
				ft_print_environ(*shell);
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "setenv") == 0)
				ft_setenv(&(*shell));
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]),
								"unsetenv") == 0)
				ft_unsetenv(&(*shell));
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "exit") == 0)
				ft_exit(&(*shell));
			else if (ft_strcmp(ft_strtolower((*shell)->argv[0]), "cd") == 0)
				ft_cd(&(*shell));
			else
				ft_exec_bin(&(*shell));
		}
	}
}