t_getopt ft_getopt(int ac, char **av, const char *opt_str) { static t_getopt opt = {0, 1, 0, 0, NULL}; static char *opt_ptr = NULL; static int *elem_ind = NULL; if (elem_ind == NULL) { if ((elem_ind = (int *)malloc(ac * sizeof(int))) == NULL) exit(1); ft_memset(elem_ind, 0, ac * sizeof(int)); } opt.arg = NULL; opt.is_arg = 0; while (opt.ind < ac && !is_options(&opt, &opt_ptr, av, opt_str)) { elem_ind[opt.ind++] = 1; opt_ptr = NULL; } if (opt.ind >= ac) { opt.ret = -1; sort_opt(ac, av, elem_ind, &opt); return (opt); } get_opt(&opt, &opt_ptr, ac, av); return (opt); }
void display_l_file(t_list *file, t_opt *opt) { struct stat buf; t_list *tmp; tmp = NULL; tmp = sort_opt(file, opt); while (tmp) { stat(tmp->data, &buf); display_fold(tmp->data, opt); ft_putstr(tmp->data); ft_putstr("\n"); tmp = tmp->next; } }