int				ft_check_param(char *fmt, int i, t_printf *conv)
{
	int		a;

	if (conv->wc_arg == 0)
	{
		a = i;
		i += is_flag(fmt, i, &conv[0]);
		i += is_mfw(fmt, i, &conv[0]);
		i += is_precision(fmt, i, &conv[0]);
		i += is_length(fmt, i, &conv[0]);
		while (fmt[i] == ' ')
			i++;
		i += is_letter(fmt[i], &conv[0]);
		conv->size_param = i - a;
		if (conv->letter == '*')
		{
			conv->prec_err = 0;
			conv->flag_err = 0;
			conv->size_param = ft_get_param(fmt, a, conv) + 1;
			ft_check_letter(fmt, a + conv->size_param - 1, conv);
			if (conv->display_errors == 1 && conv->count_errors++ >= 0)
				ft_error_msg(1, fmt, a, i - a);
		}
	}
	return ((conv->error_letter != NULL
				&& ft_strcmp(conv->error_letter, "eol") == 0) ? 0 : 1);
}
Exemple #2
0
int			ft_perform_exe(t_p *p, t_env *e)
{
	char	**paths;
	char	*good_path;
	int		i;
	int		value;

	i = 0;
	value = 0;
	while (e->env[i] && ft_strncmp(e->env[i], "PATH=", 5))
		++i;
	if (!e->env[i])
		paths = ft_strsplit(&(e->env_s[0][5]), ':');
	else
		paths = ft_strsplit(&(e->env[i][5]), ':');
	if (!(good_path = ft_find_the_path(p->tok, paths)))
	{
		ft_free_char2(paths);
		return (ft_error_msg(p->tok, ": Command not found"));
	}
	value = ft_exe_the_cmd(p, good_path, e->env);
	gfree(good_path);
	ft_free_char2(paths);
	return (value);
}
Exemple #3
0
static int		ft_print_all(t_printf *conv)
{
	int		i;
	char	*print;
	t_arg	*arg;

	i = 0;
	arg = NULL;
	print = ft_strnew(conv->return_value);
	while (conv->arg_first->next != NULL)
	{
		print = ft_strisub(print, conv->arg_first->value, i);
		i += conv->arg_first->size;
		free(conv->arg_first->value);
		arg = conv->arg_first;
		conv->arg_first = conv->arg_first->next;
		free(arg);
	}
	if (conv->arg_first->value != NULL)
		print = ft_strisub(print, conv->arg_first->value, i);
	free(conv->arg_first->value);
	free(conv->arg_first);
	(conv->count_errors > 0)
		? ft_error_msg(-1, NULL, conv->count_errors, 0) : 0;
	write(1, print, conv->return_value);
	free(print);
	return (conv->return_value - conv->r_v_minus);
}