t_env *ft_init(char **env) { char *shlvl; t_env *e; if (!(e = (t_env *)malloc(sizeof(t_env)))) return (ERROR); if (!*env) { creat_env(&e->env); e->list = ft_create_list(e->env); } else { e->list = ft_create_list(env); shlvl = ft_itoa(ft_atoi(ft_check_var(e->list, "SHLVL")) + 1); ft_set(e->list, "SHLVL", shlvl); free(shlvl); e->env = conv_lst(e->list); } ft_init_line(&e); e->prompt = ft_strjoin(ft_check_var(e->list, "USER"), "$>"); e->shell = ft_strdup("MISHELL"); ft_putstr(e->prompt); return (e); }
void ft_push_list(t_list **first, char c) { t_list *list; list = *first; if (!list) { *first = ft_create_list(c); return ; } while (list->next) list = list->next; list->next = ft_create_list(c); }
int fillit(char *argv) { char **tetros; int nb_tetros; t_tetros *begin; int i; i = 0; nb_tetros = 0; tetros = ft_read_argv(argv, &nb_tetros); if (!tetros) return (0); if (!ft_valid_tetros(tetros, nb_tetros)) return (0); begin = ft_create_list(tetros, nb_tetros); ft_free_tetros(tetros, nb_tetros); ft_solve(begin, nb_tetros); return (1); }
void ft_search_list(t_magic *magic, int tmp2, float tmp, int signe) { t_pol *cursor; cursor = magic->begin; while (cursor) { if (tmp2 == cursor->pow) { cursor->coef += tmp * signe; return ; } cursor = cursor->next; } if (magic->begin == NULL) ft_create_list(magic, tmp2, tmp, signe); else if (cursor == NULL) ft_add_list(magic, tmp2, tmp, signe); }