Esempio n. 1
0
int	main(int argc, char **argv)
{
	char BUF[547];
	char **map;
	char save[16][16];
	char tab[27];
	char end;
	int	 taille;
	int cpt;

	
	if (argc != 2)
		ft_ragequit();
	ft_bzero(tab, 27);
	ft_file(argv[1], BUF);
	ft_erreur(BUF);
	ft_search(BUF, tab);
	taille = ft_sqrt(8 * tab[0]);
	map = ft_init(taille);
	ft_clean(save, 15);
	cpt = 1;
	end = 0;
	while (end == 0 && taille >= ft_sqrt(4 * tab[0]))
	{
		end = ft_treatment(map, save, tab, cpt);
		if (taille > ft_sqrt(4 * tab[0]))
		{
			taille--;
			map = ft_init(taille);
			cpt = ft_try_copy(map, save, taille);
		}
	}
	ft_exit(save, ft_len_save(save));
	return (0);
}
Esempio n. 2
0
static void		test_lstDel(t_test *test)
{
    t_info	*info;
    int		i;
    int		result;
    char 	str[] = " mamie mange de la compote";

    test->debug = 1;
    i = 0;
    result = 0;


    int		j;

    j = 0;
    info = (t_info *)malloc(sizeof(t_info));
    info->term = NULL;
    info = ft_init(info);
    while (str[j] != '\0')
        info->term = lstAdd(info->term, str[j++]);


    while (info->term)
    {
        if (info->term->c != str[i++])
            result = 1;
        info->term = info->term->next;
    }
    mt_assert((result == 0 ? 1 : 0));
    free_list(info);
}
Esempio n. 3
0
void bamboo_init(void)
{
	platform_ops.fixups = bamboo_fixups;
	platform_ops.exit = ibm44x_dbcr_reset;
	ft_init(_dtb_start, 0, 32);
	serial_console_init();
}
Esempio n. 4
0
File: main.c Progetto: kperreau/2048
int				main(void)
{
	int			key;
	t_win		win;

	if ((WIN_VALUE & (~WIN_VALUE + 1)) == WIN_VALUE && WIN_VALUE > 1)
	{
		ft_init(&win);
		key = 0;
		key = ft_menu(&win);
		while (key != ESCAPE)
		{
			if (ft_boucle(&win) != -1)
			{
				key = getch();
				if (ft_key_event(&win, key) == -1)
					break ;
			}
			ft_del_win(&win);
		}
		endwin();
	}
	else
		ft_putendl_fd("Bad number for win", 2);
	return (0);
}
Esempio n. 5
0
char		*ft_strnstr(const char *s1, const char *s2, size_t n)
{
	size_t	i;
	int		j;
	int		retry;
	char	*str;

	str = NULL;
	ft_init(&i, &j, &retry);
	if (s2[0] == '\0')
		return (ft_check_s2(str, s1, s2, &i));
	while (s1[i] != '\0' && i < n)
	{
		str = ft_mark_letter(s1, s2, &i, &j);
		while (s1[i] == s2[j] && i < n)
		{
			ft_increment(&i, &j);
			if (s2[j] == '\0')
				return (str);
		}
		j = 0;
		i = retry++;
	}
	return (NULL);
}
Esempio n. 6
0
File: main.c Progetto: vdaviot/Fdf
int		main(int ac, char **av)
{
	t_env	env;
	List	*list;
	t_coord	*ptr;

	list = NULL;
	if (av[1])
	{
		if (!(env.fd = open(av[1], O_RDONLY)))
			return (-1);
		while (get_next_line(env.fd, &env.data))
		{
			env.val = ft_strsplit(env.data, ' ');
			list = ft_get_params_to_lst(env.val, list);
			free (env.val);
		}
		ft_init(&env);
		ft_add_param_to_struct(&env, &ptr, list);
		env.ptr2 = ptr;
		mlx_key_hook(env.win, ft_key_hook, &env);
		mlx_expose_hook(env.win, ft_expose_hook, &env);
		mlx_loop_hook(env.win, ft_key_hook, &env);
		mlx_loop(env.mlx);
	}
	return (0);
}
Esempio n. 7
0
void				loop(t_list **list, t_token **cur_tok, char *input)
{
	int			index;
	char		cur;
	char		prev;

	ft_init(&index, &cur, &prev, input);
	while (cur)
	{
		if ((*cur_tok)->token && is_operator(prev) && !is_newline(cur))
			rule_1(*cur_tok, list, input, &index);
		else if (is_quoting(cur))
			handle_quoting(*cur_tok, list, input, &index);
		else if (is_start_of_expansion(cur) || is_operator(cur))
			rule_34(*cur_tok, list, input, &index);
		else if (is_newline(cur) || is_whitespace(cur))
			rule_56(*cur_tok, list, input, &index);
		else if ((*cur_tok)->token && is_word(prev))
			build_token(*cur_tok, cur);
		else if (cur == '#')
			discard_comment(input, &index);
		else
			build_token(*cur_tok, cur);
		prev = cur;
		cur = input[++index];
	}
}
Esempio n. 8
0
int				main(int argc, char **argv)
{
	t_data	d;
	t_file	*file;
	t_file	*tmp;

	file = NULL;
	if (argc != 2)
		ft_putendl_fd("Usage: ./rt scene", 2);
	else
	{
		tmp = ft_init(&file, &d, argv[1]);
		ft_parsing(file, &d);
		ft_get_light(file, &d);
		if ((d.mlx = mlx_init()) == NULL)
			return (-1);
		d.win = mlx_new_window(d.mlx, d.width, d.height, "RT");
		d.img = mlx_new_image(d.mlx, d.width, d.height);
		ft_get_data(&d);
		ft_free_file(tmp);
		ft_raytracing(&d);
		mlx_key_hook(d.win, &ft_key_hook, &d);
		mlx_expose_hook(d.win, &ft_expose_hook, &d);
		mlx_loop(d.mlx);
	}
	return (0);
}
Esempio n. 9
0
char					*get_line(t_shell *shell)
{
	struct termios		term;
	t_line				*tmp;

	new_line(shell, &tmp);
	if (shell && shell->env && !ft_init(&term))
	{
		if (!ft_config(&term))
		{
			ft_term(&tmp->str, shell, 0);
			if (!tmp->str || !tmp->str[0])
			{
				shell->hist = shell->hist->next;
				if (shell->hist)
					shell->hist->prev = NULL;
			}
			if (ft_defconfig(&term))
				exit (0);
			return (ft_strdup(tmp->str));
		}
	}
	get_next_line(1, &tmp->str);
	return (ft_strdup(tmp->str));
}
Esempio n. 10
0
File: main.c Progetto: Geronymo/42
int		main(int argc, char **argv)
{
	char	buffer[547];
	char	**map;
	char	save[16][16];
	char	tab[27];
	int		cpt[4];

	if (argc != 2)
		ft_ragequit();
	ft_file(argv[1], buffer, tab);
	map = ft_debut(cpt, save, tab);
	while (cpt[0] == 1 && cpt[1] >= cpt[2])
	{
		cpt[0] = ft_treatment(map, save, tab, 1);
		cpt[3] = 0;
		while (cpt[1] > cpt[2] && !cpt[3] && cpt[0] == 2)
		{
			cpt[1]--;
			map = ft_init(cpt[1]);
			cpt[3] = ft_test_point(map);
			cpt[0] = 1;
		}
	}
	ft_exit(save, ft_len_save(save));
	return (0);
}
Esempio n. 11
0
int		main(int argc, char **argv)
{
	t_ints	a;
	t_tab	pn;

	a.i = 0;
	if (ft_strcmp(argv[1], "-C") == 0)
		a.i = 1;
	a.c16 = 0;
	a.ctt = 0;
	a.star = 0;
	pn = ft_init(pn);
	while (++a.i < argc)
	{
		a.fd = open(argv[a.i], O_RDONLY);
		if (a.fd >= 0)
			a.ctt = ft_mainbis(a, pn, argv[1]);
		else
			a.ctt = ft_error(argc, argv, a.i);
	}
	if (a.ctt != -10)
	{
		ft_printnbchar(a.ctt, ft_strcmp(argv[1], "-C"));
		ft_putchar('\n');
	}
	close(a.fd);
	return (0);
}
Esempio n. 12
0
int		main( void )
{
	char			buf[BUFF_SIZE];
	extern char 	**environ;
	t_sh1			sh1;
	int				call;
	// void			*sign_f;

	// sign_f = ft_kill_them_all;
	ft_init(&sh1, environ);
	write(1, "> ", 2);
	// signal(SIGINT, sign_f);
	while (42)
	{
		buf[read(0, buf, (BUFF_SIZE + 1))] = '\0';
		call = ft_parser(&sh1, buf);
		if (call == 1)
		{
			// printf("\n");
			// debug_array(sh1.params);
			// printf("\n");
			// printf("%s\n", sh1.command);
			// printf("\n");
			// sleep(50);
			ft_execve(&sh1);
		}
		else
			write(1, "> ", 2);
	}
	return (0);
}
Esempio n. 13
0
t_way			*ft_choose(t_way *way, t_tree *tree)
{
	t_way *w;
	
	ft_sizeway(&way);
	return (ft_init(way, ft_nb(ft_getTreeEnd(tree))));	
}
Esempio n. 14
0
int		main(void)
{
	t_glob		*gl;
	t_bitmap	*bmp;

	gl = (t_glob *)malloc(sizeof(t_glob));
	if (!gl)
		return (0);
	bmp = (t_bitmap *)malloc(sizeof(t_bitmap));
	if (!bmp)
		return (0);
	ft_init(gl);
	texture_grey(gl, bmp);
	texture_wood(gl, bmp);
	texture_me(gl, bmp);
	ft_skybox(gl, bmp);
	gl->mlx = mlx_init();
	gl->win = mlx_new_window(gl->mlx, gl->s_x, gl->s_y, "Wolf 3D");
	ft_wolf3d(gl);
	mlx_loop_hook(gl->mlx, ft_wolf3d, gl);
	mlx_hook(gl->win, 2, (1L << 0), ft_key_press, gl);
	mlx_hook(gl->win, 3, (1L << 1), ft_key_release, gl);
	mlx_hook(gl->win, 17, 0, ft_close, gl);
	mlx_loop(gl->mlx);
	return (0);
}
Esempio n. 15
0
int ft_loop (
  const int port
) {
	int unused __attribute__((unused));
  const int sock = ft_init(port);
  struct sockaddr address;
  unsigned int address_len;
  int fd;
  int id;

  if (sock < 0) {
    return (sock);
  }
  else {
    id = 0;
    while (42) {
      fd = accept(sock, &address, &address_len);
      (void)ft_putnbr(++id);
      unused = write(1, SERVER_MSG_CONNECTED, SERVER_LMSG_CONNECTED);
      if (ft_com(&fd, id) < 0) {
        (void)ft_putnbr_fd(id, 2);
        unused = write(2, SERVER_MSG_INCIDENT, SERVER_LMSG_INCIDENT);
      }
      unused = close(fd);
    }
    unused = close(sock);
    return (0);
  }
}
Esempio n. 16
0
File: main.c Progetto: kelu27/42
int		main(int argc, char *argv[])
{
	t_serv				e;

	if (argc != 2)
		usage(argv[0]);
	ft_init(&e, argv[1]);
	while (42)
	{
		e.cs = accept(e.sock, (struct sockaddr *)&e.csin, &e.cslen);
		if ((e.pid = fork()) == -1)
		{
			close(e.cs);
			continue ;
		}
		else if (e.pid > 0)
		{
			close(e.cs);
			e.counter++;
			continue ;
		}
		else if (e.pid == 0)
			e.counter++;
		ft_read_server(&e);
	}
	return (0);
}
Esempio n. 17
0
int					get_next_line(int fd, char **line)
{
	static char		**memory = NULL;
	register char	*tmp;
	register char	*ptr;
	register int	value;

	if (fd == 0)
		return (-1);
	if ((value = ft_init(&memory, fd, &line)) <= 0)
		return (value);
	ptr = ft_strchr((memory[fd]), '\n');
	if (ptr + 1 == '\0')
		*ptr = '\0';
	if (!ptr || ptr + 1 == '\0')
	{
		*line = (memory[fd]);
		(memory[fd]) = NULL;
		return ((*(*line)) ? 1 : 0);
	}
	if (!(*line = ft_strcdup((memory[fd]), '\n')) ||
		!(tmp = ft_strdup(ptr + 1)))
		return (-1);
	free((memory[fd]));
	(memory[fd]) = tmp;
	return (1);
}
Esempio n. 18
0
void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
                   unsigned long r6, unsigned long r7)
{
	CUBOOT_INIT();
	ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
	serial_console_init();
	platform_ops.fixups = platform_fixups;
}
Esempio n. 19
0
File: main.c Progetto: sbenning42/42
int				main(int ac, char *av[])
{
	t_sh		sh;

	ft_init(av[0]);
	sh_init(&sh, ac, av);
	sh_loop(&sh);
	return (0);
}
Esempio n. 20
0
void ebony_init(void *mac0, void *mac1)
{
	platform_ops.fixups = ebony_fixups;
	platform_ops.exit = ibm44x_dbcr_reset;
	ebony_mac0 = mac0;
	ebony_mac1 = mac1;
	ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
	serial_console_init();
}
Esempio n. 21
0
void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
                   unsigned long r6, unsigned long r7)
{
    CUBOOT_INIT();
    platform_ops.fixups = sequoia_fixups;
    platform_ops.exit = ibm44x_dbcr_reset;
    ft_init(_dtb_start, 0, 32);
    serial_console_init();
}
Esempio n. 22
0
void		handle_sigcont(int sig)
{
	if (sig == SIGCONT)
		ft_init();
	else
	{
		set_term(ft_glob(NULL)->sauv);
		signal(SIGTSTP, SIG_DFL);
	}
}
Esempio n. 23
0
int main(int argc, char* argv[]) {
  int* ft = ft_init(MAX_P+1);
  for (int i = MAX_P; i > 6; i--) {
    int phi = phi_int(i);
    int nb_seq = 1 + sum_between(phi+1, i-1, ft);
    add(phi, nb_seq, ft, MAX_P+1);
  }
  printf("%d\n", 1+sum_between(phi_int(6) + 1, 5, ft));
  return 0;
}
Esempio n. 24
0
File: ft_way.c Progetto: aoll/lemin
static void		print(t_way **way, t_che *che, char *s)
{
	while (che)
	{
		if (che->fin == 1)
		{
			ft_init(way, che);
		}
		che = che->next;
	}
}
Esempio n. 25
0
t_color		*draw_suite(t_ray *ray, t_tool *t)
{
	t_draw_suite *val;

	val = malloc(sizeof(t_draw_suite));
	ft_init(val);
	if ((val->curobject = intersection(t->l_objects, ray)))
	{
		ft_impact(val, ray, t);
	}
	return (val->final_color);
}
Esempio n. 26
0
int	main(int argc, char **argv, char **env)
{
	t_env	e;

	if (!*env)
		return (ft_perror("Environnement indisponible."));
	else if (!(argc - 1))
		return (ft_perror("Usage: ./wolf3d [map]"));
	ft_parser(argv[1], &e);
	ft_init(&e);
	mlx_loop(e.mlx);
	return (0);
}
Esempio n. 27
0
static void	test_lstLast_null(t_test *test)
{
	char	*tab_c = "";
	t_info	*info;
	int		i = 0;

	info = (t_info *)malloc(sizeof(t_info));
	info->term = NULL;
	info = ft_init(info);
	while (tab_c[i])
		info->term = lstAdd(info->term, tab_c[i++]);
	mt_assert((!lstLast(info->term) ? 1 : 0));
	free_list(info);	
}
Esempio n. 28
0
t_info	*create_list(void)
{
    t_info	*info;
    int		i;
    char 	str[] = " mamie mange de la compote";

    i = 0;
    info = (t_info *)malloc(sizeof(t_info));
    info->term = NULL;
    info = ft_init(info);
    while (str[i] != '\0')
        info->term = lstAdd(info->term, str[i++]);
    return (info);
}
Esempio n. 29
0
File: main.c Progetto: sbenning42/42
int				main(int ac, char *av[])
{
	t_sh		sh;

	ft_init(av[0]);															//Init program name in libft (for error reporting purpose)
	sh_init(&sh, ac, av);														//Init 42sh options, binary collection, past history, prompt name and ft_readline settings
	sh.ac = ac;
	sh.av = av;
	sh_loop(&sh);																//MAIN LOOP
/*	hist_save(&sh.hist);														//Write the new command history in '.42sh_history'
	ft_printf("sh.ac = %d, sh.av = %p\n");
	sh_clear(&sh);																//Cleaning memory
*/	return (0);	
}
Esempio n. 30
0
static void	test_lstLast_simple(t_test *test)
{
	char	*tab_c = "abcdefghijklmnopqrstuvwxyz";
	t_info	*info;
	int		i = 0;

	info = (t_info *)malloc(sizeof(t_info));
	info->term = NULL;
	info = ft_init(info);
	while (tab_c[i])
		info->term = lstAdd(info->term, tab_c[i++]);
	mt_assert((lstLast(info->term)->c == 'z' ? 1 : 0));
	free_list(info);	
}