void my_builtins(t_mysh *mysh) { my_exit(mysh); my_cd(mysh); my_set_env(mysh); my_unset_env(mysh); }
int test_builtins(char **buffer, t_list *list) { if (buffer[0] == NULL) return (0); if (my_strcmp(buffer[0], "cd")) { my_move_dir(list, buffer); return (1); } if (my_strcmp(buffer[0], "env")) { my_print_env(list); return (1); } if (my_strcmp(buffer[0], "setenv")) { if (buffer[1]) my_set_env(list, buffer); return (1); } if (my_strcmp(buffer[0], "unsetenv")) { if (buffer[1]) my_unset_env(list, buffer); return (1); } return (0); }
void set_it(t_vars *p, char *str) { int i; int nbr_quote; nbr_quote = 0; i = -1; while (str && str[++i]) if (str[i] == 39) ++nbr_quote; i = 0; while (str && str[i] != '=') ++i; if ((str[i] == '=') && (str[i + 1] != 39)) fprintf(stderr, "error while reading .cfg file, check it.\n"); else if ((nbr_quote == 2) && (str[strlen(str) - 1] == 39)) { str = rem_char(str, 39); my_set_env(p, str); } else fprintf(stderr, "error while reading .cfg file, check it.\n"); free(str); }