コード例 #1
0
ファイル: parse_file.c プロジェクト: randrini/BSQ
void	ft_check_file(char *buf)
{
	int		i;
	char	*str;
	t_param *tmp_param;

	i = 0;
	str = first_line(buf);
	tmp_param = ft_get_parameters(buf);
	if (str[0] >= 48 && str[0] <= 57)
	{
		str[ft_strlen_mod(buf) - 3] = '\0';
		if (ft_atoi(str) != size_col(buf))
			ft_error();
		i = ft_intlen(ft_atoi(str));
		str = first_line(buf);
		if (str[i] == tmp_param->empty)
			i++;
		if (str[i] == tmp_param->obst)
			i++;
		if (str[i] == tmp_param->full)
			i++;
		else
			ft_error();
	}
	else
		ft_error();
}
コード例 #2
0
ファイル: ft_check_instructions.c プロジェクト: Tolo789/BSQ
t_instr		*ft_first_line(char *str)
{
	t_instr	*ptr;
	int		i;
	char	*str2;
	int		a;

	ptr = NULL;
	a = ft_strlen_mod(str);
	if (check_v(str, a) == 1)
	{
		str2 = (char *)malloc(sizeof(*str2) * 1000);
		ptr = (t_instr *)malloc(sizeof(t_instr) * 1000);
		i = 0;
		str2 = cut_str(str, a - 5);
		ptr->height = ft_atoi(str2);
		ptr->length = a;
		ptr->empty = str[a - 4];
		ptr->obst = str[a - 3];
		ptr->full = str[a - 2];
	}
	return (ptr);
}