int main(int ac, char **av, char **environ) { t_env env; int fd; int j; j = 0; fd = 0; if (!environ[0]) return (-1); ft_init_env(&env); if (ac == 2) { env.len_y = ft_tab_len(fd, &j, av[1]); if (env.len_y == 0 && j == 0) return (-1); env.grid = ft_mallogrid(env.grid, env.len_y, j); if (!env.grid) return (-1); if ((fd = open(av[1], O_RDONLY)) == -1) return (-1); env.grid = ft_writegrid(env.grid, fd, &env); if (close(fd) == -1) return (-1); ft_fdf(&env); } return (0); }
int main(int argc, char **argv, char **env) { t_dat t_d; char **newenv; t_d.argv = argv; if (ft_init_env(&newenv, env) == 0 && argc > 0) ft_lst_env_new(env, &t_d.t_env, 0); else { ft_lst_env_new(newenv, &t_d.t_env, 0); free(newenv[0]); free(newenv[1]); free(newenv[2]); free(newenv); } ft_update_shlvl(&t_d.t_env); ft_lst_to_env(&t_d.t_env, &newenv, 0); t_d.env = newenv; ft_init_history(&t_d); signal(SIGINT, get_sigint); if (!ft_init_termios(&t_d, 1)) return (-1); while (ft_initshell(&t_d, t_d.init_p) == 1) ; return (0); }
static void test_unexistant_var(t_test *test) { char *tab[] = {"TEST1=content1", "TEST2=content2", NULL}; t_info info; test->debug = 1; ft_init_env(&info, tab); env_add_var(&info, strdup("yolo"), strdup("swag")); env_remove_var(&info, "JHG"); ft_free_env(info.env); }
static void test_env_null(t_test *test) { char **tab = NULL; t_info info; test->debug = 1; ft_init_env(&info, tab); env_remove_var(&info, "yolo"); mt_assert(!info.env); ft_free_env(info.env); }
static void test_simple_test_null(t_test *test) { char *tab[] = {"TEST1=content1", "TEST2=content2", NULL}; t_info info; test->debug = 1; ft_init_env(&info, tab); env_add_var(&info, strdup("yolo"), strdup("swag")); env_remove_var(&info, NULL); mt_assert(!info.env->next->next->next); ft_free_env(info.env); }
static void test_last_var(t_test *test) { char **tab = NULL; t_info info; test->debug = 1; ft_init_env(&info, tab); env_add_var(&info, strdup("yolo"), strdup("swag")); env_remove_var(&info, "yolo"); mt_assert(!info.env); ft_free_env(info.env); }
int main(void) { t_env e; e.mlx = mlx_init(); e.win = mlx_new_window(e.mlx, WIDTH, HEIGHT, TITLE); ft_init_env(&e); mlx_key_hook(e.win, ft_key_hook, &e); mlx_mouse_hook(e.win, ft_mouse_hook, &e); mlx_expose_hook(e.win, ft_expose_hook, &e); mlx_loop(e.mlx); return (0); }
int main(int ac, char **av) { t_env e; t_map *map; if (ac < 2 || ac > 5) ft_usage(); else if ((map = get_map(av[1]))) { ft_init_env(&e, av); ft_putendl("Getting your maps' coordonates..."); if ((e.coord = get_coord(map, &e, NULL))) { ft_free_map(&map); fdf(&e); ft_free_all(&e); } } return (EXIT_FAILURE); }
char *ft_get_inputs(char *str) { static t_env *e = NULL; char inputs[7]; int value; char *test; static int i = 0; if (!e) e = ft_init_env(); test = NULL; e->name = str; e->index = 0; e->max = 0; if (i++ == 0) { dprintf(1, "Tgetent\n"); // if (tgetent(e->buf, test) < 1) // exit(-1); if (!(e->str = (char *)malloc(sizeof(char)))) return (NULL); } ft_bzero(inputs, 7); ft_clean_histo(e); ft_lstr_inputsinit(e); tputs(e->name, 1, ft_putc); start_termcaps(); while ((read(0, inputs, 7)) != EOF) { if ((value = ft_manage_inputs(e, inputs)) >= 0) return (e->str); ft_bzero(inputs, 7); } pause_termcaps(); ft_endline(e); return (e->str); }