int execute_member(t_pars *pars, char *token, t_glob *glob, int side) { if (token && (!my_match(token, PIPE))) pars->status = exec_gnral(pars->arg, glob, pars->redir , pars->redir_fich); if (side == 0 && my_match(token, AND) && pars && pars->status != 0) return (0); if (side == 0 && my_match(token, OR) && pars && pars->status == 0) return (0); gere_status(pars->status); return (1); }
void execution(t_pars *pars, t_glob *glob) { if (pars && pars->token && my_match(pars->token, PIPE)) do_fork_pipe(pars->left, glob); else { if (pars->left && pars->left->token) execution(pars->left, glob); else if (pars->left && pars->token && (!my_match(pars->token, PIPE))) if (!execute_member(pars->left, pars->token, glob, 0)) return ; if (pars->right && pars->right->token) execution(pars->right, glob); else if (pars->right && pars->token && (!my_match(pars->token, PIPE))) if (!execute_member(pars->right, pars->token, glob, 1)) return ; } }
char *my_getenv(char *name, t_env *envp) { t_env *tmp; tmp = envp; while (tmp) { if (my_match(name, tmp->name)) return (tmp->data); tmp = tmp->next; } return (NULL); }
int is_type(char *str, t_pars *pars) { int i; i = 0; while (pars->types && pars->types[i]) { if (my_match(str, pars->types[i])) return (i); i++; } return (-1); }
static int check_n(t_program *prgm, int i, int argc, const char **argv) { if (my_match(argv[i], "-n")) { if (prgm->player_id != -1) return (error_int(RET_FAILURE, ERR_N_REPEAT)); if (i + 1 < argc) { if (!my_str_isnum(argv[i + 1]) || (prgm->player_id = my_getnbr(argv[i + 1])) < 0) return (error_int(RET_ERROR, ERR_N_INVALID_VAL)); } else return (error_int(RET_FAILURE, ERR_N_NO_VAL)); } return (RET_SUCCESS); }