/* Gitignore-style patterns for skill discovery, as Pi's skills.ts feeds them * to the `ignore` library: .gitignore, .ignore and .fdignore found while * walking a skills folder, each pattern prefixed by its folder's path from * the walk's root. Globs (* ? [a-z]), **, a trailing / (folders only), ! * negation, # comments and \ escapes; the last matching rule wins, and * nothing under an ignored folder is reachable. */ #ifndef PIC_IGNORE_H #define PIC_IGNORE_H #include typedef struct { char *pat; int negated, dir_only, anchored; } pic_ignore_rule; typedef struct { pic_ignore_rule *v; size_t n, cap; } pic_ignore; /* Adds the lines of TEXT, each prefixed by PREFIX ("" or "sub/dir/"). * 0, or -1 when out of memory. */ int pic_ignore_add(pic_ignore *ig, const char *text, size_t len, const char *prefix); /* Forgets the rules added after the first N (leaving a folder). */ void pic_ignore_truncate(pic_ignore *ig, size_t n); void pic_ignore_free(pic_ignore *ig); /* 1 when REL (slash separated, relative to the walk's root) is ignored. */ int pic_ignore_ignored(const pic_ignore *ig, const char *rel, int isdir); #endif