Exemplo n.º 1
0
static void		ft_fill_cone(t_rtv1 *rtv1, char **tab, char **tri, int i)
{
	char	*hexa;

	rtv1->obj.cone[i].posx = ft_atoid(tri[0]);
	rtv1->obj.cone[i].posy = ft_atoid(tri[1]);
	rtv1->obj.cone[i].posz = ft_atoid(tri[2]);
	rtv1->obj.cone[i].base_size = ft_atoid(tab[1]);
	rtv1->obj.cone[i].height = ft_atoid(tab[2]);
	if ((hexa = ft_strstr(tab[3], "0x")))
		rtv1->obj.cone[i].color = ft_abs(ft_atoi_base(&hexa[2], 16));
	else
		rtv1->obj.cone[i].color = ft_abs(ft_atoi_base(tab[3], 16));

}
Exemplo n.º 2
0
char	*ft_convert_base(char *nbr, char *base_from, char *base_to)
{
	int		nb;
	int		j;
	char	*res;
	int		i;

	j = 1;
	i = 0;
	nb = ft_atoi_base(nbr, base_from);
	ft_bis(&j, &i, base_to, nb);
	res = (char*)malloc(sizeof(char) * (i + ((nb < 0) ? 1 : 0)));
	i = (nb < 0) ? 1 : 0;
	res[0] = '-';
	j = (nb < 0) ? j * ft_strlen(base_to) : j;
	nb = (nb < 0) ? -nb : nb;
	while (j >= 1)
	{
		res[i] = base_to[(nb / j) % ft_strlen(base_to)];
		j /= ft_strlen(base_to);
		i++;
	}
	res[i] = '\0';
	return (res);
}
Exemplo n.º 3
0
int main(void)
{
	char str[19];
	char base[19];

	ft_strcpy(str, "-eeeq");
	ft_strcpy(base, "qwerty");
	printf("%d\n", ft_atoi_base(str, base));
	return (0);
	
}
Exemplo n.º 4
0
int	main (void)
{
	char str[] = "-eqweq";
	char base[] = "qwerty";

	printf("%d", ft_check_str(str, base));
	printf("\n");
	printf("%d", ft_check_base(base));
	printf("\n");
	printf("%d\n", ft_atoi_base(str, base));
	return (0);
}
Exemplo n.º 5
0
void		ft_init_color(t_param *p)
{
    char	*file;
    char	*line;
    int		fd;
    int		i;

    if (p->color == 3 || p->color == 4)
    {
        file = (p->color >= 4) ? "includes/game.ini" : "includes/carto.ini";
        if ((fd = open(file, O_RDONLY)) <= -1)
            exit(ft_error("[Color]: open() failed"));
        get_next_line(fd, &line);
        if (!(p->col = (int *)malloc(sizeof(int) * ft_atoi_base(line, 10))))
            exit(ft_error("[Color]: malloc failed"));
        p->nb_color = ft_atoi_base(line, 10);
        i = 0;
        while (get_next_line(fd, &line) > 0)
            p->col[i++] = ft_atoi_base(line, 16);
        p->col[i++] = ft_atoi_base(line, 16);
        if (close(fd) == -1)
            exit(ft_error("[Color]: close() failed"));
    }
}
Exemplo n.º 6
0
int				color(char *str)
{
	char	*color;
	int		col;

	col = 0;
	while (*str && *str != ',')
		str++;
	if (*str == ',')
	{
		str++;
		color = ft_strdup(str);
		col = ft_atoi_base(color, "0123456789abcdef");
		free(color);
		if (col != 0)
			return (col);
	}
	return (RED);
}
static void	put_values_into_int_tabs(t_fdf_env *env, int *i, int *j, int *k)
{
	while (LINE[*k])
	{
		while (LINE[*k] == ' ')
			*k += 1;
		if (LINE[*k] && LINE[*k] >= '0' && LINE[*k] <= '9')
			VAL[*i][*j] = ft_atoi(&LINE[*k]);
		while (LINE[*k] && LINE[*k] != ',' && LINE[*k] != ' ')
			*k += 1;
		if (LINE[*k] && LINE[*k] == ',')
			CLR[*i][*j] = ft_atoi_base(&LINE[*k + 3], 16);
		else
			CLR[*i][*j] = 16777215; //11111111 11111111 11111111 0xFFFFFF
		while (LINE[*k] && LINE[*k] != ' ')
			*k += 1;
		*j += 1;
	}
}
Exemplo n.º 8
0
char		*ft_convert_base(char *nbr, int bf, int bt)
{
	int		i;
	char	*res;
	int		convert;
	char	*base_to;

	i = 0;
	res = ft_strnew(64);
	base_to = ft_get_base(bt);
	convert = ft_atoi_base(nbr, bf);
	while (convert > 0)
	{
		*(res + i++) = base_to[convert % ft_strlen(base_to)];
		convert /= ft_strlen(base_to);
	}
	*(res + i++) = '\0';
	free(base_to);
	return (ft_strrev(res));
}