int main(int argc, char *argv[], char *envp[]) { t_tree *tree; t_env *env; char buf[SIZE]; int ret; env = (t_env *)x_malloc(sizeof(t_env)); env->env = get_env(envp); get_path(env); while (argv || argc) { ft_bzero(buf, SIZE); print_prompt(); ft_printf(" $>"); if ((ret = read(0, buf, SIZE)) < 2) continue ; buf[ret - 1] = '\0'; env->fst_cmd = ft_strdup(buf); if (!(tree = init_tree(env->fst_cmd))) continue ; ft_cmd_path(tree, env); ft_process(tree, env); free_tree(tree); free(env->fst_cmd); } return (0); }
void ft_processing(t_data *d, char *str) { t_lexer *lex; t_parser *parser; parser = NULL; lex = NULL; d->pipe = 0; if (!str) return ; ft_backup_termcap(d); ft_lexer(&lex, str); if (lex) { ft_parser(&parser, lex, 1); ft_free_lex(&lex); ft_process_tree(parser, d); ft_free_pars(&parser); } else ft_process(d, str); ft_reset_termcap(d); if (d->first) ft_free_list(d->first); }
int ft_checkpath(char *s, t_list **begin, t_param *param) { char *path; char **tmp; int i; i = 0; ft_check_builtin(s, begin); if ((path = get_env(g_env, "PATH")) == NULL) return (0); tmp = ft_strsplit(path, ':'); ft_process(tmp, s, i, begin); ft_clear(tmp); if (*begin != NULL) del_word(s, param, &STR); return (0); }