int get_next_line(int const fd, char **line) { static char *save; if (!save) { save = ft_strnew(BUFF_SIZE); if (ft_loop(fd, line, &save) == 1) return (1); else if (ft_loop(fd, line, &save) == -1) return (-1); else return (0); } if (save && ft_return_next_line(line, &save) == 1) return (1); else if (ft_loop(fd, line, &save) == 1) return (1); else if (ft_loop(fd, line, &save) == -1) return (-1); else { ft_strclr(*line); *line = ft_strncat(*line, save, ft_cut_line(save)); } return (0); }
int main(int ac, char **av, char **env) { t_env *e; char *line; char **cmd; char **tab_e; e = NULL; line = NULL; tab_e = NULL; if (ac >= 1 && av && *env) e = init_env(e, env); while (42) { ft_putstr("$> "); get_next_line(0, &line); line = final_line(line, e); cmd = final_cmd(line); free(line); if (!cmd || cmd[0] == '\0') continue ; ft_loop(cmd, &e, tab_e); } return (0); }
int ft_atoi(const char *str) { t_data r; int sign; size_t i; i = 0; r.result = 0; r.resultl = 0; r.resultll = 0; r.resulti = 0; while ((str[i] == ' ' || (str[i] >= 9 && str[i] <= 13)) && str[i]) i++; if (str[i] == '-') sign = -1; else sign = 1; ft_loop(&r, str, i); if (ft_invalid(r, sign)) { if (sign < 0) return (0); return (-sign); } return (r.resulti * sign); }
int main(int ac, char **av, char **env) { t_ctx *ctx; ctx = CTX; (void)ac; (void)av; ctx = CTX; ft_term_init(); setup_signal(); ft_copy_tab(&ctx->env, env); ft_load_history(ctx, 0, NULL, NULL); ft_aff_prompt(); ft_loop(); ft_reset_term(); return (0); }
int main(int argc, char **argv) { int fd; t_mlx *mlx; if (argc != 2) return (ft_err(001, NULL)); fd = 0; mlx = NULL; fd = open(argv[1], O_RDONLY); if (fd < 0) return (ft_err(002, argv[1])); mlx = ft_init(mlx, fd); mlx = ft_loop(mlx); close(fd); ft_free_bundle(mlx); return (0); }
void ft_select(t_dlist *arg, struct termios term) { char read_char[4]; t_dlist_node *node; signal(SIGWINCH, ft_resize); signal(SIGTSTP, ft_select_control_z); signal(SIGCONT, ft_select_fg); signal(SIGINT, ft_exit_signal); signal(SIGQUIT, ft_exit_signal); ((t_sing *)ft_get_instance())->arg = arg; ((t_sing *)ft_get_instance())->term = term; node = arg->head; ft_write_list(arg, node, term, node); node = arg->head; ft_underline(arg, node); ft_loop(arg, node, read_char, term); }
void init_client(int s, t_env *e, t_client client) { int father; t_play player; father = fork(); if (father > 0) return ; if (father == 0) { if ((s = client_init(client.port, client.host)) < 0) { ft_putendl_fd("Client init error\n", 2); exit(0); } printf("SON\n"); player = init_play(s, client); ft_loop(s, e, player); } }
int main(int ac, char **av) { t_truc c; (void)ac; (void)av; if (ac == 1) { ft_putstr("Usage : ./ft_select [argv1] [argv2] ... OR ./ft_select *\n"); return (0); } c.lst = NULL; ft_signal(); if (ft_init_termios(&c)) return (0); tputs(tgetstr("cl", NULL), 1, ft_putchar_auto); if (ac >= 2) ft_loop(av, &c); ft_end_termios(&c); return (0); }
int get_next_line(int const fd, char **line) { static char *keep; char *fullline; int result; fullline = ft_strnew(0); if (keep != NULL) { if (ft_joinsave(&fullline, &keep)) { *line = fullline; return (1); } } result = ft_loop(fd, line, &fullline, &keep); if (result > 0) return (1); else if (result < 0) return (-1); else return (0); }
int main(int argc, char **argv) { char *str; t_data *ptr; int fd; int ret; if (argc == 2) { fd = open(argv[1], O_RDONLY); while ((ret = get_next_line(fd, &str))) { if (ret == -1) return (0); ptr = ft_read(str); if (ptr == NULL) return (0); } if (ptr->index == 1 && ptr->width == 1) return (0); ft_loop(ptr); } return (0); }
int expose_hook(t_mlx *mx) { ft_loop(mx); return (0); }