int main(int ac, char **av, char **env) { t_all all; char *str; char **mav; int check; int l; all.hist = NULL; check = (init_main(ac, av, &all.lenv, &str)); all.cd.previous = NULL; environ_copy(&all.lenv, env); init_caps(&all.caps, env); while (check != -1) { manwhile(&str, &l, &all.lenv, &check); str = (char *)get_commandline(&all.caps, l, end_hist(all.hist)); my_history(&all.hist, str); write(1, "\n", 1); if (str[my_strlen(str)] == '\0') if (before_manif(&str, &mav) != 0) if (mav[0]) check = big_manif(mav, &all.path, &all.lenv, &all.cd); } finish_main(&all.lenv); free_list_history(all.hist); return (1); }
int check_next(char *cmd, char **arg, char **env) { int ret; ret = 0; if (my_strcmp("echo", arg[0]) == 0) { if (arg[1] == NULL) printf("Usage : echo [-neE] [VALUE] \n"); else my_echo(&arg[1], 0, 0); ++ret; } if (my_strcmp("cd", arg[0]) == 0) { change_directory(arg[1], env); ++ret; } if (my_strcmp("history", cmd) == 0) { my_history(); ++ret; } ret += check_again(cmd, arg, env); return (ret); }
/* Fonction: internal_command * Entrees: un entier représentant la position de la commande * a effectuer dans le tableau commande[] * * Sortie: aucune * * Execute une commande externe */ int internal_command(int pos) { if( strcmp(commande[pos], "exit") == 0) {stockCommande(); my_exit(commande); return 1;} else if(strcmp(commande[pos], "cd") == 0) {stockCommande(); chdir(commande[pos+1]); return 1;} else if(strcmp(commande[pos], "cat") == 0) {stockCommande(); my_cat(commande[pos+1], commande[pos+2]); return 1;} else if(strcmp(commande[pos], "history") == 0) {stockCommande(); my_history(); return 1;} else if(strcmp(commande[pos], "cp") == 0) {stockCommande(); my_copy(commande[pos+1], commande[pos+2]); return 1;} else if(strcmp(commande[pos], "find") == 0) {stockCommande(); my_find(0); return 1;} else return 0; }