/* init - read patterns file */ void init(FILE* fp) { struct lnode head, tail; struct onode *p, **next; next = &opts; while (*next) next = &((*next)->o_next); while (!feof(fp)) { p = (struct onode*)malloc((unsigned)sizeof(struct onode)); if (p == NULL) error("init: out of memory\n"); p->firecount = MAXFIRECOUNT; getlst_1(fp, "=\n", &head, &tail); head.l_next->l_prev = 0; if (tail.l_prev) tail.l_prev->l_next = 0; p->o_old = tail.l_prev; if (p->o_old == NULL) { /* do not create empty rules */ free(p); continue; } getlst(fp, "\n", &head, &tail); tail.l_prev->l_next = 0; if (head.l_next) head.l_next->l_prev = 0; p->o_new = head.l_next; *next = p; next = &p->o_next; } *next = 0; }
t_list *getdir(char *flags, char **argv) { t_list *lst; lst = getlst(argv); lst = ft_lststr_sort(lst); lst = get_lstdir(lst, lst, NULL, NULL, flags); if (lst != NULL) if (ft_strlen(lst->content) > 0 && ft_strchr(flags, 'l') == 0) ft_putendl(""); return (lst); }