static int in_while(char **key, t_data **data, t_hist **hst, t_edit **lst) { int value; value = 0; ft_bzero(*key, 7); if ((value = ft_sigleton(0)) > 0) { ft_signal_2(data, lst); return (-1); } else { if (read(0, *key, 6) == -1) return (-1); if (ft_sigleton(0) == 0) ft_check_key(*key, lst, hst, (*data)->env_tr); if ((value = ft_sigleton(0)) == 3) { ft_signal_2(data, lst); return (-1); } } return (0); }
static void ft_read(char **line, int *position, int *autocomp) { int ret; char *buf; ret = 1; buf = ft_memalloc(42); g_env.saved_line = line; while (!ft_strchr(buf, '\n') && ret > 0) { ft_bzero(buf, 42); ret = read(0, buf, 1024); buf[ret] = '\0'; if (ft_isprint(*buf)) { *autocomp = 0; ft_putchar(*buf); ft_add_char(line, *position, *buf); (*position)++; if ((*position + g_prompt_len + 1) % g_ws.ws_col == 1) tputs(tgetstr("sf", NULL), 1, ft_put); } else if (*buf != '\n') ft_check_key(buf, line, position, autocomp); } free(buf); }
static int in_while(char **key, t_env **env, t_hist **hst, t_edit **lst) { int value; value = 0; ft_bzero(*key, 7); if ((value = ft_sigleton(0)) > 0) ft_signal(env, lst, value, hst); else { if (read(0, *key, 6) == -1) return (-1); if (*key[0] == 4 && *key[1] == 0 && *key[2] == 1 && *key[3] == -64) ft_exit_eof(env); if (ft_sigleton(0) == 0) ft_check_key(*key, lst, hst, env); if ((value = ft_sigleton(0)) == 3) ft_signal(env, lst, value, hst); } return (0); }