void ft_fetch_lst(DIR *dirp, char *filename, t_dlst *headfile, t_dlst *headdir) { t_node *nodefile; t_node *nodedir; t_dlst headerror; struct dirent *tmp; dlst_init(&headerror); while ((tmp = readdir(dirp))) { if (tmp->d_name[0] == '.' && !GET(C_NODE(t_info, headfile)->opt, OPT_A)) continue ; if (!(nodefile = (t_node *)malloc(sizeof(t_node)))) ft_error_malloc(); nodefile->namtyp = *tmp; ft_save(filename, nodefile, headfile, &headerror); if (S_ISDIR(nodefile->statfile.st_mode) && ft_strcmp(".", nodefile->namtyp.d_name) && ft_strcmp("..", nodefile->namtyp.d_name)) { if (!(nodedir = (t_node *)malloc(sizeof(t_node)))) ft_error_malloc(); nodedir->namtyp = *tmp; ft_save(filename, nodedir, headdir, &headerror); } } flush_headerror(&headerror); }
int get_next_line(int const fd, char **line) { char buf[BUFF_SIZE + 1]; int ret; static t_save *s; t_save *lst; if (!line) return (-1); lst = ft_get_list(&s, fd); if (lst && lst->rest && ft_strchr(lst->rest, '\n') && ft_save(&lst, lst->rest, line)) return (1); while ((ret = read(fd, buf, BUFF_SIZE)) > 0) { buf[ret] = '\0'; if (ft_save(&lst, buf, line)) return (1); } if (ret == 0 && lst->rest && (*line = ft_strdup(lst->rest)) != NULL) { ft_strdel(&lst->rest); return (1); } if (ret == -1) return (-1); return (0); }
int ft_treatment(char **ptr_map, char ptr_map_saved[16][16], char order_figure[27], int i) { int pos[3]; int end; end = 0; pos[0] = 0; pos[1] = 0; pos[2] = ft_len(ptr_map); if (ft_place(ptr_map, order_figure[i], ((char)i + 64), pos)) { if (i == order_figure[0]) { end = ft_save(ptr_map, ptr_map_saved, pos[2], order_figure[0]); } else { while (!end) { end = ft_treatment(ptr_map, ptr_map_saved, order_figure, (i + 1)); if (end < 26 && end >= 0) { if (!ft_deplace(ptr_map, order_figure[i], (i + 64), pos)) { ft_del(ptr_map, (i + 64), pos[2]); end = 1; } } } } } else return (0); return (end - 1); }
void ft_fillit(t_map *map) { int y; int x; t_piece *tmp; tmp = map->lst; while (tmp->used == 1 && tmp->next) tmp = tmp->next; if (tmp->used == 1 && tmp->next == NULL) { if (map->actualsize < map->bestsize) ft_save(map); return ; } y = -1; while (++y < map->bestsize) { x = -1; while (++x < map->bestsize) ft_try_put_piece(map, tmp, y, x); } if (tmp->letter == 'A') ft_print_best_map(map); }
double ft_put_cu(t_ba *ba, t_obj *obj) { double det[12]; double ray[3]; double cam[3]; int tmp[6]; ft_save(ba, obj, tmp, det); rotate(ba, obj, ray, cam); ft_ini_cub(ba, obj, cam, ray); ft_put_cu2(ba, obj); return (ft_replace(ba, obj, det, tmp)); }
int ft_joinsave(char **fullline, char **keep) { if (ft_strchr(*keep, '\n')) { *fullline = ft_strjoin(*fullline, ft_save(*keep, keep)); return (1); } else { *fullline = ft_strjoin(*fullline, *keep); ft_strdel(keep); return (0); } }
int ft_loop(int const fd, char **line, char **fullline, char **keep) { char *characters; int ret; ret = 1; while (ret > 0) { characters = ft_strnew(BUFF_SIZE_GNL + 1); ret = read(fd, characters, BUFF_SIZE_GNL); if (ft_strchr(characters, '\n')) { *fullline = ft_strjoin(*fullline, ft_save(characters, keep)); *line = *fullline; return (ret); } else *fullline = ft_strjoin(*fullline, characters); } return (ret); }
static void save_options(void) { XFILE *file; long n; int error = 0, h; graf_mouse(HOURGLASS, NULL); if ((file = x_fopen(optname, O_DENYRW | O_WRONLY, &error)) != NULL) { if ((n = x_fwrite(file, &options, sizeof(Options))) == sizeof(Options)) { if (options.cprefs & SAVE_COLORS) error = save_colors(file); if (error == 0) if ((error = dsk_save(file)) == 0) if ((error = ft_save(file)) == 0) if ((error = icnt_save(file)) == 0) if ((error = app_save(file)) == 0) if ((error = prg_save(file)) == 0) error = wd_save(file); } else error = (int) n; if (((h = x_fclose(file)) < 0) && (error == 0)) error = h; } graf_mouse(ARROW, NULL); if (error != 0) hndl_error(MSAVECFG, error); wd_set_update(WD_UPD_COPIED, optname, NULL); wd_do_update(); }