void ft_loop_server(t_env *env, int client_socket) { int r; int flag; char buf[1000024]; ft_putstr_color_fd("\033[0;32m", "\n[ serveur ] : ", 1); while ((r = read(client_socket, buf, 1000023)) > 0) { buf[r] = '\0'; flag = 0; if (ft_strncmp(buf, "quit", 4) == 0) { close(client_socket); exit (0); } if (r < 0) return ; if (ft_check_putfile(buf) == 1 && ft_putfile(buf) == 0) flag = 1; if (flag == 0) ft_pre_fork(env, client_socket, buf); ft_bzero(buf, ft_strlen(buf)); ft_putstr_color_fd("\033[0;32m", "\n[ serveur ] : ", 1); } }
void ft_error(char *line, t_env *env) { char **tmp; if (ft_isprint(line[0])) { tmp = ft_strsplit(line, ' '); ft_putstr_color_fd("\033[0;35m", "ft_minishell1 : command not found: " , env->client_socket); ft_putstr_color_fd("\033[0;36m", tmp[0], env->client_socket); ft_putstr_fd("\n", env->client_socket); free(tmp); } }
static int check_size(INF *infos) { if (infos->col_size > infos->width || infos->width < 65 || infos->height < 4) { ft_tputs("ho", 1); ft_tputs("cd", 1); ft_putstr_times(" ", (infos->width / 2) - 10, BLINK_MODE, 2); ft_putstr_color_fd("Windows too small :/", RED, 2, 1); ft_putstr_color_fd(" ", RESET_MODE, 2, 1); infos->valid_size = -1; return (0); } infos->valid_size = 1; return (1); }
void ft_error_cd_bis(char *line, int n) { char **tmp; if (n == 2) { if (ft_isprint(line[0])) { tmp = ft_strsplit(line, ' '); ft_putstr_color_fd("\033[0;42m", "cd: not a directory: ", 2); ft_putstr_color_fd("\033[0;43m", tmp[0], 2); ft_putchar_fd('\n', 2); free(tmp); } } }
void ft_error_cd_ter(char *line, int n) { char **tmp; if (n == 3) { if (ft_isprint(line[0])) { tmp = ft_strsplit(line, ' '); ft_putstr_color_fd("\033[0;47m", "cd: permission denied: ", 2); ft_putstr_color_fd("\033[0;46m", tmp[0], 2); ft_putchar_fd('\n', 2); free(tmp); } } }
void *ft_err_p(t_error *err, void *ret_value, int fd) { if (ERROR_PRINTING_MODE == DEBUG_MODE) { ft_putstr_color_fd("ERROR", COL_RED, fd); ft_putstr_color_fd(" - ", COL_WHITE, fd); ft_putstr_color_fd("Func: ", COL_LIGHT_RED, fd); ft_putstr_fd(err->func, fd); ft_putchar_fd(',', fd); ft_putstr_color_fd(" File: ", COL_LIGHT_RED, fd); ft_putstr_fd(err->file, fd); ft_putstr_fd(" - l.", fd); ft_putnbr_fd(err->line, fd); ft_putchar_fd(',', fd); ft_putstr_color_fd(" Status: ", COL_LIGHT_RED, fd); ft_putnbr_fd(err->status, fd); ft_putchar_fd('\n', fd); } if (err && err->msg1 && err->status >= ERROR_PRINTING_MODE) { ft_putstr_color_fd(err->msg1, COL_YELLOW, fd); if (err->msg2) ft_putstr_color_fd(err->msg2, COL_YELLOW, fd); ft_putstr_fd("\n", fd); } free(err); return (ret_value); }
int ft_env(t_env *env, char **cmd) { int i; i = 0; if (cmd[0] && cmd[1]) { ft_error(cmd[1]); return (0); } while (env->bkp[i]) { ft_putstr_color_fd("\033[0;30m", "MY ENV = ", 1); ft_putstr_color_fd("\033[0;33m", env->bkp[i], 1); ft_putchar('\n'); i++; } return (0); }
void ft_error_cd(char *line, int n) { char **tmp; if (n == 1) { if (ft_isprint(line[0])) { tmp = ft_strsplit(line, ' '); ft_putstr_color_fd("\033[0;44m", "cd: no such file or directory: " , 2); ft_putstr_color_fd("\033[0;45m", tmp[0], 2); ft_putchar_fd('\n', 2); free(tmp); } } else if (n == 2) ft_error_cd_bis(line, n); else ft_error_cd_ter(line, n); }
void handle_signal(int signo) { signo++; ft_putstr_color_fd("\033[0;34m", "\n$> ", 1); }