int main(int argc, char **argv) { int i; char **map; t_map *map_info; map = NULL; i = 0; if (argc > 1) { while (++i < argc) if ((map_info = ft_read(argv[i], &map, 1)) == NULL) ft_putstr(2, "map error\n"); else ft_run_bsq(map, map_info); } else { if ((map_info = ft_read(NULL, &map, 0)) == NULL) ft_putstr(2, "map error\n"); else ft_run_bsq(map, map_info); } return (0); }
void ft_execute(int fd) { t_grid *grid; t_point point; grid = init_grid(fd); ft_set_params(grid); if (!g_errno) read_first_line(grid); if (!g_errno) ft_read(grid); if (!g_errno) test_full(grid); if (g_errno) ft_putstr("Map error\n"); else { ft_remap(grid); point = find_max(grid); draw_square(grid, point.x, point.y, point.max); print_index(grid); } if (fd > 0) close(fd); free_grid(grid); }
int get_next_line(int const fd, char **line) { static t_cache *cache; int fin; int bytes; bytes = 0; fin = -1; if (fd < 0 || line == NULL) return (-1); *line = ""; if (cache && ft_set_line(cache, line) == 1) return (1); else { cache = (t_cache *)malloc(sizeof(t_cache)); cache->str = ""; } bytes = ft_read(line, fd, cache, fin); if (bytes == -2 || (bytes == 0 && ft_strlen(*line) > 0 && fin == -1)) return (1); if (bytes == -1) return (-1); return (0); }
int get_next_line(const int fd, char **line) { static char *file; char *endl_index; int ret; if (!file && !(file = (char*)malloc(sizeof(char)))) return (-1); endl_index = ft_strchr(file, '\n'); while (endl_index == NULL) { if ((ret = ft_read(fd, &file)) == 0) { if ((endl_index = ft_strchr(file, '\0')) == file) return (0); } else if (ret < 0) return (-1); else endl_index = ft_strchr(file, '\n'); } if (!(*line = ft_strsub(file, 0, endl_index - file))) return (-1); endl_index = ft_strdup(endl_index + 1); free(file); file = endl_index; return (1); }
int get_next_line(const int fd, char **line) { static char *stock = ""; int ret; char *str; ret = 1; if (!line || fd < 0 || (stock[0] == '\0' && (!(stock = ft_strnew(0))))) return (-1); while (ret > 0) { if ((str = ft_strchr(stock, '\n')) != NULL) { *str = '\0'; if (!(*line = ft_strdup(stock))) return (-1); ft_memmove(stock, str + 1, ft_strlen(str + 1) + 1); return (1); } if (!(stock = ft_read(fd, stock, &ret))) return (-1); } ft_strdel(&str); if (ret == 0 && ft_strlen(stock)) ret = ft_end_line(&(*line), &stock); return (ret); }
int get_next_line(int const fd, char **line) { static char *full[256]; char *buff_rd; char *temp_rd; int read_ret; buff_rd = ft_strnew(BUFFER); if (fd < 0 || line == NULL || buff_rd == NULL) return (-1); if (full[fd] == NULL) full[fd] = ft_strnew(1); read_ret = ft_read(fd, buff_rd, full); if (read_ret == -1) return (-1); if (read_ret == 0) { *line = full[fd]; full[fd] = NULL; return (0); } *line = ft_strsub(full[fd], 0, (ft_strchr(full[fd], '\n')) - full[fd]); temp_rd = full[fd]; full[fd] = ft_strdup(ft_strchr(full[fd], '\n') + 1); ft_strdel(&temp_rd); return (1); }
int get_next_line(int const fd, char **line) { static t_rest st = {.sfree = NULL, .s = NULL, .tmp = NULL, .ret = 0}; st.i = 0; if (fd < 0 || line == NULL) return (-1); *line = NULL; if (st.s) if ((ft_static_exist(&st.s, line, st.ret, &st.sfree)) != 2) return (st.ret == 0 ? 0 : 1); st.tmp = (st.tmp == NULL ? ft_memalloc(BUFF_SIZE + 1) : st.tmp); while ((st.ret = read(fd, st.tmp, BUFF_SIZE)) != 0) { if (st.ret == -1) return (-1); st.tmp[st.ret] = '\0'; if ((ft_read(line, &st.tmp, &st.s, &st.sfree)) == 1) return (1); st.tmp = (st.tmp == NULL ? ft_memalloc(BUFF_SIZE + 1) : st.tmp); } if (st.ret == 0) ft_strdel(&st.sfree); return (st.ret == 0 && (*line == NULL || *line[0] == '\0') ? 0 : 1); }
int main(int argc, char **argv) { t_piece *tetriminos; int s; char **tab; int i; i = 0; tab = (char **)malloc(sizeof(char **) * 24); if (!tab) ft_error(); while (i < 24) { tab[i] = (char *)malloc(sizeof(char *) * 24); if (!tab[i++]) ft_error(); } if (argc != 2) ft_error(); tetriminos = ft_read(argv[1], &s, 0); ft_dim(tetriminos, s); i = ft_resolve(tetriminos, tab, s, 0); ft_aff_tab(tab, i); return (0); }
int get_next_line(int const fd, char **line) { int ret; static char buf[BUFF_SIZE + 1]; int i; int j; if (!(*line = ft_strnew(BUFF_SIZE + 1))) return (-1); ret = 1; j = 1; while (ret > 0) { if (buf[0] == '\0') { if (!(ret = ft_read(buf, fd, ret)) && *line[0] != '\0') return (1); } i = 0; while (buf[i] && buf[i] != '\n' && ret > 0) i++; if (buf[i] == '\n' && ret > 0) return (ft_is_new_line(line, buf, i)); else if (ret > 0 && (j = ft_no_new_line(line, buf, j)) == -1) return (-1); } return (ret); }
int ft_island(char *file) { int fd; int len_str; int len_tab; char *buff; char **tab; len_tab = 1; len_str = 0; tab = NULL; buff = NULL; if ((fd = open(file, O_RDONLY)) == -1) return (-1); if ((buff = ft_read(buff, fd, &len_tab, &len_str)) == NULL) return (-1); tab = ft_malloc(tab, len_str, len_tab); tab = ft_strsplit(tab, buff, '\n'); free(buff); if ((tab = ft_count_island(tab, len_str, len_tab)) == NULL) return (-1); ft_put_tab(tab, len_tab); free(tab); return (0); }
int get_next_line(int const fd, char **line) { t_get *get; static char **rest = NULL; if (fd < 0 || fd >= FD_MAX || BUFF_SIZE <= 0 || !line) return (-1); if (!(get = (t_get *)malloc(sizeof(t_get)))) return (-1); get->fd = fd; if (rest == NULL) if (!(rest = (char **)malloc(sizeof(char *) * FD_MAX))) return (-1); *line = NEW(0); if (rest[fd] == NULL || !check_rest(get, &rest[fd], line)) ft_read(get, &rest[fd], line); if (get->ret == -1) return (-1); if (get->ret == 0 && rest[fd] == NULL && *line && LEN(*line) == 0) { REMOVE(line); /* peut poser probleme selon le cas */ ft_memdel((void *)&get); return (0); } ft_memdel((void *)&get); return (1); }
void ft_loop_bsq(int ac, char **av) { unsigned long long ret2; char *buf; t_bsq_data data; char **bsq; int i; i = 1; while (i < ac) { ret2 = ft_get_swap(i, av); buf = ft_read(ret2); data = ft_get_infos(buf, ret2); bsq = ft_get_bsq(data, buf); if ((ft_check_map(bsq, data) == FALSE)) write(2, "map error\n", 10); else { bsq = ft_fill_square(bsq, data, ft_check_tab(bsq, data)); ft_print_bsq(bsq, data); } ft_free_bsq(bsq, data); i++; } }
char *ft_term(t_shell *shell, int j, int f) { char buf[5]; t_line *tmp; char *str; tmp = shell->hist; str = NULL; ft_putstr(tgetstr("sc", NULL)); f = 0; while (42) { ft_read(buf); if (buf[0] == '\n') return (exit_mode(shell, str, j)); else if (K_UP(buf)) f *= history(&tmp, 'A', &str); else if (K_DOWN(buf)) f *= history(&tmp, 'B', &str); else if (K_END(buf)) f = 0; else if (K_HOME(buf)) f = ft_strlen(str); else term_center(shell, &str, buf, &f); } return (str); }
int main(int argc, char **argv, char **env) { t_env *environ; int debug; t_data envi; manage_signal(); ft_save_some_env_values(&envi, env); debug = 0; (void)argv; if (argc > 1) return (0); if (ft_termios(&environ, envi.env) == -1) { ft_putstr_fd("laucnhing a shell whitout an env is dangerous\n", 2); return (-5); } debug = ft_read(&environ, &envi); if (debug == -1) return (-1); else if (debug == -2) return (-2); else if (debug == -3) return (-3); return (0); }
int get_next_line(const int fd, char **line) { int i[2]; char *buff; static char *stce = NULL; i[0] = 0; i[1] = 0; if (fd < 0 || !line || !*line || BUFF_SIZE < 1) return (-1); while (i[1] < BUFF_SIZE) { if (!stce) stce = ft_strnew(2); buff = ft_strnew(2); if ((i[0] = ft_read(fd, buff, BUFF_SIZE)) < 0) return (-1); if (*buff != '\n' && i[0] != 0) stce = ft_strjoin(stce, buff); if (*buff == '\n' || i[0] == 0) return (cleanthis(line, &stce, &buff, i)); i[1]++; } if (i[1] == BUFF_SIZE) return (get_next_line(fd, line)); return (-1); }
int get_next_line(int const fd, char **line) { static char *buff; int rd; char *ret; *line = NULL; rd = 0; if (BUFF_SIZE <= 0 || fd < 0) return (-1); if (!buff) { buff = (char *)malloc(sizeof(char) * BUFF_SIZE + 1); buff[0] = 0; } if (ft_strchr((buff), '\n') || buff[0]) { ret = ft_putline(&buff, &(*line)); if (ret) rd = 1; } if (rd == 0) rd = ft_read(fd, &buff, &(*line)); if (*line) rd = 1; return (rd); }
int get_next_line(int const fd, char **line) { static char *str; int i; char *ptr; if (BUFF_SIZE < 1 || !line) return (-1); if (str == 0) str = ""; i = BUFF_SIZE; while (1) { ptr = str; while (*ptr || i < BUFF_SIZE) { if (*ptr == '\n' || *ptr == 0 || *ptr == -1) return (ft_to_fill(line, &str, ptr)); ptr++; } i = ft_read(&str, fd); if (i == -1) return (-1); } }
int get_next_line(int const fd, char **line) { char buf[BUFF_SIZE + 1]; if (!line || BUFF_SIZE <= 0) return (-1); return (ft_read(fd, buf, line)); }
int main(int argc, char **argv) { if (argc > 1) ft_read(argv[1]); else write(1, "\n", 1); return (0); }
int main(void) { int solution[5]; assignment(solution); ft_read(solution); return (0); }
int main(void) { t_node *tab[TAB_SIZE]; ft_tab_init(tab); ft_read(tab); ft_search(tab); ft_tab_destroy(tab); return (0); }
int main(int argc, char **argv) { if (argc < 2) ft_putstr("File name missing.\n"); else if (argc > 2) ft_putstr("Too many arguments.\n"); else ft_read(argv); return (0); }
static int after_while(t_env **ev, t_data *en, t_edit **lst, t_hist **hst) { if (ft_sigleton(0) == 3) { ft_sigleton(-1); ft_putchar('\n'); ft_read(ev, en); } else { if (*lst) ft_jumprint(lst); ft_putchar('\n'); if ((ft_write_on_file(lst, en->env)) == 0) ft_lexer(ft_creat_string(*lst), en); clean_all(lst, hst); ft_read(ev, en); return (1); } return (0); }
int ft_printf(const char *format, ...) { va_list ap; t_env env; if (format == NULL) return (-1); va_start(ap, format); env.str = format; ft_read(format, 0, &env, ap); return (env.nb_char); }
static void treatment(t_ant **ants, t_room **rooms) { int num_ants; int num_rooms; num_ants = 0; num_rooms = 0; ft_read(&rooms, &ants, &num_rooms, &num_ants); if (!num_rooms) ft_block("There is no room, where do you want the ants to go?\n"); write(1, "\n", 1); ft_core(rooms, ants, num_ants); }
int get_next_line(int const fd, char **line) { static char *str[256]; int i; i = 0; if (fd < 0 || line == NULL || BUFF_SIZE < 1 || fd > 256) return (-1); if (!(str[fd])) if ((str[fd] = ft_read(fd, str[fd])) == NULL) return (-1); if (str[fd][i] == '\0') return (0); *line = ft_line(str[fd]); str[fd] = ft_subline(str[fd]); return (1); }
void ft_get_input(char **line) { int position; static int autocomp; autocomp = 0; signal(SIGTSTP, ft_suspend); position = 0; if (*line) { free(*line); *line = NULL; } *line = ft_strdup("\0"); ft_read(line, &position, &autocomp); while (position < (int)ft_strlen(*line)) ft_move_right(&position, *line); ft_putchar('\n'); }
int get_next_line(int const fd, char **line) { static t_list *fds = NULL; t_fd *actual; int read; if (!line || fd < 0) return (-1); actual = actual_fd(fd, &fds); if (actual->rest && ft_rest(actual, line)) return (1); if ((read = ft_read(fd, actual, line)) != 0) return (read); if (actual->rest == NULL || actual->rest[0] == '\0') return (0); *line = actual->rest; actual->rest = NULL; return (1); }
int ft_get_next_line(int const fd, char **line) { static char *str[MAX_FD_NBR] = {0}; static int len[MAX_FD_NBR] = {0}; static int tabidfd[MAX_FD_NBR] = {0}; int pos; int fdid; if ((fdid = ft_getfdid(fd, tabidfd)) == -1) return (-1); pos = ft_read(&str[fdid], fd, &len[fdid]); if (pos == -1) return (-1); else if (pos == -2 || pos == 0) return (0); if (!((*line = ft_strsub(str[fdid], 0, pos)))) return (-1); if (!ft_delline(&str[fdid], &len[fdid], pos)) return (-1); return (1); }
int get_next_line(const int fd, char **line) { static t_data *data[10]; int i; i = 0; if (fd < 0 || !line || BUFF_SIZE < 1) return (-1); while (data[i] && data[i]->cur_fd != fd) i++; if (!data[i]) { data[i] = (t_data*)malloc(sizeof(t_data)); if (!data[i]) return (-1); data[i]->str = NULL; data[i]->rest = NULL; data[i]->ret = 0; data[i]->cur_fd = fd; } return (ft_read(data[i], fd, line)); }