Beispiel #1
0
t_obj				*parse_object(int fd, int id)
{
	char			**line;
	int				i;
	t_obj			*object;

	object = (t_obj *)malloc(sizeof(t_obj));
	init(object);
	line = malloc_line();
	while (get_next_line(fd, line) > 0 && (*line)[0] != '}' && !(i = 0))
	{
		while ((*line)[i] && ((*line)[i] < 'a' || (*line)[i] > 'z'))
			i++;
		if ((*line)[i] && strncmp(*line + i, "color", 5) == 0)
			object->color = parse_color(fd);
		else if ((*line)[i] && strncmp(*line + i, "text_x", 6) == 0)
			object->text_x = parse_radius(fd);
		else if ((*line)[i] && strncmp(*line + i, "text_y", 6) == 0)
			object->text_y = parse_radius(fd);
		else if ((*line)[i] && strncmp(*line + i, "offset_x", 8) == 0)
			object->offset_x = parse_radius(fd);
		else if ((*line)[i] && strncmp(*line + i, "offset_y", 8) == 0)
			object->offset_y = parse_radius(fd);
		la_norme_a_pas_dit_bonjour(line, object, i, fd);
	}
	object->id = id;
	return (object);
}
Beispiel #2
0
int				get_next_line(int const fd, char **line)
{
	char				*buff;
	int					i;
	char				*inter;
	static char			*save_line;
	int					save;

	inter = ((save_line) ? ft_strdup(save_line) : ft_strnew(BUFF_SIZE));
	while (inter && (!ft_strchr(inter, '\n')))
	{
		if ((buff = ft_strnew(BUFF_SIZE)))
		{
			if ((save = read(fd, buff, BUFF_SIZE)) > 0)
				inter = ft_strjoin(inter, buff);
			else if (save == 0)
				return (end_of_file(line, inter, save_line));
			else
				return (-1);
			free(buff);
		}
	}
	malloc_line(line, inter);
	i = ft_strlen_len(inter);
	save_line = ft_strsub(inter, i + 1, (ft_strlen(inter) - i));
	free(inter);
	return (1);
}
Beispiel #3
0
int	copie_first_line(t_bin **tab, t_list *first_line)
{
	int		nb_var;

	nb_var = ((param(SIZE_X, 0) - 1) / ((8 * sizeof(t_bin)))) + 1;
	tab[0] = malloc_line(nb_var);
	fill_the_char(0, 0, 1);
	while (first_line)
	{
		if (fill_the_char((*(char*)(first_line->data)), tab[0], 0) == -1)
			return (0);
		first_line = first_line->next;
	}
	ft_list_clear(&first_line);
	return (1);
}