Esempio n. 1
0
void			ft_resize_image(int keycode, t_env *e)
{
	char		*data;

	e->ecart_x += (keycode == PLUS) ? ECART_RATE : 0;
	e->ecart_x -= (keycode == MINUS) ? ECART_RATE : 0;
	mlx_clear_window(e->mlx, e->win);
	mlx_destroy_image(e->mlx, e->img.ptr);
	e->img.ptr = NULL;
	e->img.w = ECART_X * (e->map_w + e->map_h + 2);
	e->img.h = (e->map_h > e->map_w) ? e->map_h + 2 : e->map_w + 2;
	e->img.h *= ECART_X;
	if (!(e->img.ptr = mlx_new_image(e->mlx, e->img.w, e->img.h)))
		ft_end("fdf: Failed to create a new_image.", e);
	data = mlx_get_data_addr(e->img.ptr, &e->bpp, &e->sizeline, &e->endian);
	if (data == NULL)
		ft_end("fdf: Failed to get_data_addr.", e);
	e->img.data = data;
	ft_putstr("New image created is ");
	ft_putnbr(e->img.w);
	ft_putstr(" width and ");
	ft_putnbr(e->img.h);
	ft_putendl(" height.");
	draw(e);
}
Esempio n. 2
0
int				main(int ac, char **av)
{
	int		i;
	t_flag	flg;
	t_swap	*a;
	t_swap	*b;

	a = NULL;
	b = NULL;
	i = ac - 1;
	if (ac < 2)
		ft_usage(av[0]);
	else
	{
		ft_extract_stack(av, i, &a, &flg);
		i == flg.total_mod ? ft_error() : 0;
		ft_check_duplicates(a);
		ft_init_b(i - flg.total_mod, &b);
		ft_end(a);
		ft_end(b);
		flg.infos ? ft_print_infos(a) : 0;
		a->next == NULL ? ft_exit_one_nb(a, flg) : 0;
		ft_is_sorted(a) && ft_is_null(b) ? ft_exit_already_ordered(a, flg) : 0;
		ft_launcher(a, b, &flg);
	}
	return (0);
}
Esempio n. 3
0
void					ft_sig_child(int sig)
{
	t_opt				*opts;

	(void)sig;
	opts = ft_get_opts();
	if (!opts->q)
		write(1, "\n", 1);
	if (opts->zombi)
		ft_end(opts->zombi);
	else
		ft_end(0);
}
Esempio n. 4
0
t_sq		*ft_back_co(t_tet *t, t_sq *sq, t_sq *fin, int nr)
{
	t_sq	*f;
	int		i;

	f = NULL;
	f = (t_sq*)malloc(sizeof(t_sq));
	if (f)
		ft_clone(f, sq, 13);
	i = 0;
	while (t[i].x != -1)
	{
		if (ft_is_taken(f, t[i]) == 0)
		{
			ft_add(f, t[i]);
			if (ft_back_co(t, f, fin, nr) == NULL)
				return (NULL);
			ft_clone(f, sq, 13);
		}
		i++;
	}
	if (nr == f->tot)
		fin = ft_min(fin, f);
	if (ft_end(fin->d, nr))
		return (NULL);
	return (f);
}
Esempio n. 5
0
void		ft_special(t_env *e, int kind)
{
	if (kind == 70)
		ft_end(e);
	else if (kind == 72)
		ft_home(e);
}
Esempio n. 6
0
char			*ft_strtrim(char const *s)
{
	int		i;
	int		j;
	int		n;
	char	*tmp;

	if (s)
	{
		i = ft_start(s);
		j = ft_strlen((char *)s);
		if (!(tmp = (char *)malloc(sizeof(*tmp) * (j - i + 1))))
			return (NULL);
		j = ft_end(s);
		n = 0;
		while (i <= j)
		{
			tmp[n] = s[i];
			i++;
			n++;
		}
		tmp[n] = '\0';
		return (tmp);
	}
	return (NULL);
}
Esempio n. 7
0
char		*ft_strtrim(char const *s)
{
	size_t		i;
	size_t		start;
	size_t		end;
	char		*dest;

	if (s == NULL)
		return (NULL);
	i = 0;
	while (ft_iswhite(s[i]) && s[i])
		i++;
	start = i;
	end = ft_end((char *)s, start);
	dest = (char *)malloc(sizeof(char));
	if (start != end || (start == end && start != (size_t)ft_strlen(s)))
	{
		if (!(dest == (char *)malloc((end - start + 2) * sizeof(char))))
			return (NULL);
		ft_strncpy(dest, s + start, end - start + 1);
		dest[end - start + 1] = 0;
	}
	else if (start == end && start == (size_t)ft_strlen(s))
		*dest = '\0';
	return (dest);
}
Esempio n. 8
0
void	ft_print_comb(void)
{
	int x;
	int y;
	int z;

	x = '0';
	while (x <= '7')
	{
		y = x + 1;
		while (y <= '8')
		{
			z = y + 1;
			while (z <= '9')
			{
				ft_end(x, y, z);
				if (x != '7')
					ft_putchar(',');
				if (x != '7')
					ft_putchar(' ');
				z++;
			}
			y++;
		}
		x++;
	}
}
Esempio n. 9
0
int					get_next_line(int fd, char **line)
{
	static char		*save = NULL;
	char			buff[BUFF_SIZE + 1];
	char			*tmp;
	int				ret;

	ret = 0;
	if (fd == -1 || BUFF_SIZE <= 0)
		return (ft_err(&save));
	if (save == NULL)
		save = ft_strnew(BUFF_SIZE + 1);
	while (save != NULL
			&& ft_strchr(save, '\n') == NULL
			&& ((ret = read(fd, buff, BUFF_SIZE)) > 0))
	{
		buff[ret] = '\0';
		tmp = save;
		save = ft_strjoin(tmp, buff);
		free(tmp);
	}
	if (ret == -1)
		return (-1);
	if (ret == 0 && ft_strchr(save, '\n') == NULL)
		return ((ft_end(line, &save)));
	ft_ret(line, &(save));
	return (1);
}
Esempio n. 10
0
static char	*clean_return(t_line *l)
{
	g_inheredoc = 0;
	ft_strdel(&l->strcpy);
	ft_end(l);
	ft_putchar('\n');
	return (l->str);
}
Esempio n. 11
0
int		is_it_ptr(t_list_rb *prev, t_list_rb *lst, void *ptr)
{
    debug_stdout("INIT", __FILE__, __LINE__, __func__);
    debug_ptr("ptr", (const void **)&ptr);
    debug_lst("prev", prev, __FILE__, __LINE__);
    debug_lst("lst", lst, __FILE__, __LINE__);
    if (lst->content == ptr)
        return (ft_end(NULL, EXIT_SUCCESS, "lst to be freed\n"));
    return (EXIT_FAILURE);
}
Esempio n. 12
0
static int					ft_find_line(int ret, char **str, char **line)
{
	if (ret == -1)
		return (-1);
	if (ft_strchr(*str, '\n') || ret > 0)
		return (ft_find(str, line));
	else if (ft_strlen(*str) > 0)
		return (ft_end(str, line));
	*line = NULL;
	return (0);
}
Esempio n. 13
0
void			ft_rm_end_sc(char **a)
{
	int			i;

	i = 0;
	while (a[i])
	{
		if (ft_end(a, i) == 0)
			a[i] = '\0';
		i++;
	}
}
Esempio n. 14
0
File: main.c Progetto: NegMozzie/42
int				main(int ac, char **av)
{
    GLFWwindow*	window;

	(void)av;
	if (ac == 1)
	{
		if (ft_init() == -1)
			return(ERROR);
	    window = glfwCreateWindow(SCREEN_X, SCREEN_Y, "Arkabroid", NULL, NULL);
		if (ft_check_window(window) == -1)
			return (ERROR);
		ft_config(window);
	    while ((!glfwWindowShouldClose(window)))
	    	ft_dothetrick(window);
	    ft_end(window);
	}
	return (EXIT_SUCCESS);
}
Esempio n. 15
0
char			*ft_strtrim(char const *s)
{
	int		deb;
	int		end;
	int		i;
	char	*str;

	if (!s)
		return (NULL);
	deb = ft_deb((char *)s);
	end = ft_end((char *)s);
	if (deb > end)
		return (NULL);
	str = ft_strnew((end - deb) + 1);
	if (!str)
		return (NULL);
	if (end == 0)
		return (str);
	i = 0;
	while (deb <= end)
		str[i++] = s[deb++];
	return (str);
}
Esempio n. 16
0
File: read.c Progetto: jaybi42/21sh
static int	get_stdin(t_line *l)
{
	while (42)
	{
		ft_bzero(l->buffer, 6);
		if (read(0, l->buffer, 6) == -1)
		{
			l->str = NULL;
			return (1);
		}
		if (l->buffer[0] != 10)
			actions(l);
		if (l->buffer[0] != 10 && ft_isprint(l->buffer[0]) == 1 &&
				l->size < MAXSIZE)
			ft_print_key(l);
		if (l->buffer[0] == 10)
		{
			ft_end(l);
			ft_putchar('\n');
			return (0);
		}
	}
}
Esempio n. 17
0
void			*ft_end_ptr(t_env *env, int ret, const char *s, void *ptr)
{
	ft_end(env, ret, s);
	return (ptr);
}
Esempio n. 18
0
void			ft_end_void(t_env *env, int ret, const char *s)
{
	ft_end(env, ret, s);
	return ;
}