Lines Matching refs:pglob

183     glob_t *pglob)  in glob()  argument
192 pglob->gl_pathc = 0; in glob()
193 pglob->gl_pathv = NULL; in glob()
194 pglob->gl_statv = NULL; in glob()
196 pglob->gl_offs = 0; in glob()
198 pglob->gl_flags = flags & ~GLOB_MAGCHAR; in glob()
199 pglob->gl_errfunc = errfunc; in glob()
200 pglob->gl_matchc = 0; in glob()
205 if (pglob->gl_offs >= SSIZE_MAX || pglob->gl_pathc >= SSIZE_MAX || in glob()
206 pglob->gl_pathc >= SSIZE_MAX - pglob->gl_offs - 1) in glob()
229 return globexp1(patbuf, pglob, &limit); in glob()
231 return glob0(patbuf, pglob, &limit); in glob()
240 globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) in globexp1() argument
246 return glob0(pattern, pglob, limitp); in globexp1()
249 return globexp2(ptr, pattern, pglob, limitp); in globexp1()
251 return glob0(pattern, pglob, limitp); in globexp1()
261 globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, in globexp2() argument
298 return glob0(patbuf, pglob, limitp); in globexp2()
344 rv = globexp1(patbuf, pglob, limitp); in globexp2()
366 globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob) argument
373 if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
475 glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) argument
482 qpatnext = globtilde(pattern, patbuf, PATH_MAX, pglob);
483 oldpathc = pglob->gl_pathc;
514 !(pglob->gl_flags & GLOB_NOCHECK))
527 pglob->gl_flags |= GLOB_MAGCHAR;
531 pglob->gl_flags |= GLOB_MAGCHAR;
535 pglob->gl_flags |= GLOB_MAGCHAR;
552 if ((err = glob1(patbuf, patbuf+PATH_MAX-1, pglob, limitp)) != 0)
561 if (pglob->gl_pathc == oldpathc) {
562 if ((pglob->gl_flags & GLOB_NOCHECK) ||
563 ((pglob->gl_flags & GLOB_NOMAGIC) &&
564 !(pglob->gl_flags & GLOB_MAGCHAR)))
565 return(globextend(pattern, pglob, limitp, NULL));
569 if (!(pglob->gl_flags & GLOB_NOSORT)) {
570 if ((pglob->gl_flags & GLOB_KEEPSTAT)) {
574 size_t n = pglob->gl_pathc - oldpathc;
575 size_t o = pglob->gl_offs + oldpathc;
580 path_stat[i].gps_path = pglob->gl_pathv[o + i];
581 path_stat[i].gps_stat = pglob->gl_statv[o + i];
585 pglob->gl_pathv[o + i] = path_stat[i].gps_path;
586 pglob->gl_statv[o + i] = path_stat[i].gps_stat;
590 qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
591 pglob->gl_pathc - oldpathc, sizeof(char *),
614 glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) argument
623 pattern, pattern_last, pglob, limitp));
633 Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) argument
647 if ((pglob->gl_flags & GLOB_LIMIT) &&
654 if (g_lstat(pathbuf, &sb, pglob))
657 if (((pglob->gl_flags & GLOB_MARK) &&
660 (g_stat(pathbuf, &sb, pglob) == 0) &&
667 ++pglob->gl_matchc;
668 return(globextend(pathbuf, pglob, limitp, &sb));
694 pglob, limitp));
701 Char *pattern, Char *restpattern, Char *restpattern_last, glob_t *pglob, argument
722 if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
724 if (pglob->gl_errfunc) {
727 if (pglob->gl_errfunc(buf, errno) ||
728 pglob->gl_flags & GLOB_ERR)
737 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
738 readdirfunc = pglob->gl_readdir;
745 if ((pglob->gl_flags & GLOB_LIMIT) &&
772 restpattern, restpattern_last, pglob, limitp);
777 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
778 (*pglob->gl_closedir)(dirp);
800 globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp, argument
809 newn = 2 + pglob->gl_pathc + pglob->gl_offs;
810 if (pglob->gl_offs >= SSIZE_MAX ||
811 pglob->gl_pathc >= SSIZE_MAX ||
816 for (i = pglob->gl_offs; i < newn - 2; i++) {
817 if (pglob->gl_pathv && pglob->gl_pathv[i])
818 free(pglob->gl_pathv[i]);
819 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0 &&
820 pglob->gl_pathv && pglob->gl_pathv[i])
821 free(pglob->gl_statv[i]);
823 free(pglob->gl_pathv);
824 pglob->gl_pathv = NULL;
825 free(pglob->gl_statv);
826 pglob->gl_statv = NULL;
830 pathv = reallocarray(pglob->gl_pathv, newn, sizeof(*pathv));
833 if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
835 pathv += pglob->gl_offs;
836 for (i = pglob->gl_offs; i > 0; i--)
839 pglob->gl_pathv = pathv;
841 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0) {
842 statv = reallocarray(pglob->gl_statv, newn, sizeof(*statv));
845 if (pglob->gl_statv == NULL && pglob->gl_offs > 0) {
847 statv += pglob->gl_offs;
848 for (i = pglob->gl_offs; i > 0; i--)
851 pglob->gl_statv = statv;
853 statv[pglob->gl_offs + pglob->gl_pathc] = NULL;
856 if ((pglob->gl_flags & GLOB_LIMIT) &&
861 if ((statv[pglob->gl_offs + pglob->gl_pathc] =
864 memcpy(statv[pglob->gl_offs + pglob->gl_pathc], sb,
867 statv[pglob->gl_offs + pglob->gl_pathc + 1] = NULL;
879 pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
881 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
883 if ((pglob->gl_flags & GLOB_LIMIT) &&
975 globfree(glob_t *pglob) argument
980 if (pglob->gl_pathv != NULL) {
981 pp = pglob->gl_pathv + pglob->gl_offs;
982 for (i = pglob->gl_pathc; i--; ++pp)
984 free(pglob->gl_pathv);
985 pglob->gl_pathv = NULL;
987 if (pglob->gl_statv != NULL) {
988 for (i = 0; i < pglob->gl_pathc; i++) {
989 free(pglob->gl_statv[i]);
991 free(pglob->gl_statv);
992 pglob->gl_statv = NULL;
997 g_opendir(Char *str, glob_t *pglob) argument
1008 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1009 return((*pglob->gl_opendir)(buf));
1015 g_lstat(Char *fn, struct stat *sb, glob_t *pglob) argument
1021 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1022 return((*pglob->gl_lstat)(buf, sb));
1027 g_stat(Char *fn, struct stat *sb, glob_t *pglob) argument
1033 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1034 return((*pglob->gl_stat)(buf, sb));