Lines Matching defs:pglob

188 	 int (*errfunc)(const char *, int), glob_t * __restrict pglob)
200 pglob->gl_pathc = 0;
201 pglob->gl_pathv = NULL;
203 pglob->gl_offs = 0;
206 limit.l_path_lim = pglob->gl_matchc;
210 pglob->gl_flags = flags & ~GLOB_MAGCHAR;
211 pglob->gl_errfunc = errfunc;
212 pglob->gl_matchc = 0;
222 return (err_nomatch(pglob, &limit, pattern));
244 return (err_nomatch(pglob, &limit, pattern));
254 return (err_nomatch(pglob, &limit, pattern));
258 return (globexp0(patbuf, pglob, &limit, pattern));
260 return (glob0(patbuf, pglob, &limit, pattern));
264 globexp0(const Char *pattern, glob_t *pglob, struct glob_limit *limit,
271 if ((pglob->gl_flags & GLOB_LIMIT) &&
276 return (glob0(pattern, pglob, limit, origpat));
279 oldpathc = pglob->gl_pathc;
281 if ((rv = globexp1(pattern, pglob, limit)) != 0)
284 return (globfinal(pglob, limit, oldpathc, origpat));
293 globexp1(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
298 if ((pglob->gl_flags & GLOB_LIMIT) &&
303 return (globexp2(ptr, pattern, pglob, limit));
306 return (glob0(pattern, pglob, limit, NULL));
316 globexp2(const Char *ptr, const Char *pattern, glob_t *pglob,
354 return (glob0(pattern, pglob, limit, NULL));
399 rv = globexp1(patbuf, pglob, limit);
420 globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
433 if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
532 glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit,
539 qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
544 oldpathc = pglob->gl_pathc;
574 pglob->gl_flags |= GLOB_MAGCHAR;
578 pglob->gl_flags |= GLOB_MAGCHAR;
582 pglob->gl_flags |= GLOB_MAGCHAR;
599 if ((err = glob1(patbuf, pglob, limit)) != 0)
603 return (globfinal(pglob, limit, oldpathc, origpat));
609 globfinal(glob_t *pglob, struct glob_limit *limit, size_t oldpathc,
611 if (pglob->gl_pathc == oldpathc)
612 return (err_nomatch(pglob, limit, origpat));
614 if (!(pglob->gl_flags & GLOB_NOSORT))
615 qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
616 pglob->gl_pathc - oldpathc, sizeof(char *), compare);
628 glob1(Char *pattern, glob_t *pglob, struct glob_limit *limit)
636 pattern, pglob, limit));
646 glob_t *pglob, struct glob_limit *limit)
659 if (g_lstat(pathbuf, &sb, pglob))
662 if ((pglob->gl_flags & GLOB_LIMIT) &&
667 if ((pglob->gl_flags & GLOB_MARK) &&
671 g_stat(pathbuf, &sb, pglob) == 0 &&
680 ++pglob->gl_matchc;
681 return (globextend(pathbuf, pglob, limit, NULL));
709 p, pglob, limit));
717 glob_t *pglob, struct glob_limit *limit)
731 if (pglob->gl_errfunc != NULL &&
739 if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
742 err = err_aborted(pglob, errno, buf);
750 /* pglob->gl_readdir takes a void *, fix this manually */
751 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
752 readdirfunc = (struct dirent *(*)(DIR *))pglob->gl_readdir;
765 if ((pglob->gl_flags & GLOB_LIMIT) &&
795 if (too_long && (err = err_aborted(pglob, ENAMETOOLONG,
808 pglob, limit);
815 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
816 (*pglob->gl_closedir)(dirp);
825 (err = err_aborted(pglob, errno, buf)))
849 globextend(const Char *path, glob_t *pglob, struct glob_limit *limit,
857 if ((pglob->gl_flags & GLOB_LIMIT) &&
858 pglob->gl_matchc > limit->l_path_lim) {
863 newn = 2 + pglob->gl_pathc + pglob->gl_offs;
865 pathv = reallocarray(pglob->gl_pathv, newn, sizeof(*pathv));
869 if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
871 pathv += pglob->gl_offs;
872 for (i = pglob->gl_offs + 1; --i > 0; )
875 pglob->gl_pathv = pathv;
893 if ((pglob->gl_flags & GLOB_LIMIT) &&
899 pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
901 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
965 globfree(glob_t *pglob)
970 if (pglob->gl_pathv != NULL) {
971 pp = pglob->gl_pathv + pglob->gl_offs;
972 for (i = pglob->gl_pathc; i--; ++pp)
975 free(pglob->gl_pathv);
976 pglob->gl_pathv = NULL;
981 g_opendir(Char *str, glob_t *pglob)
994 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
995 return ((*pglob->gl_opendir)(buf));
1001 g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
1009 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1010 return((*pglob->gl_lstat)(buf, sb));
1015 g_stat(Char *fn, struct stat *sb, glob_t *pglob)
1023 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1024 return ((*pglob->gl_stat)(buf, sb));
1064 err_nomatch(glob_t *pglob, struct glob_limit *limit, const char *origpat) {
1071 if ((pglob->gl_flags & GLOB_NOCHECK) ||
1072 ((pglob->gl_flags & GLOB_NOMAGIC) &&
1073 !(pglob->gl_flags & GLOB_MAGCHAR)))
1074 return (globextend(NULL, pglob, limit, origpat));
1079 err_aborted(glob_t *pglob, int err, char *buf) {
1080 if ((pglob->gl_errfunc != NULL && pglob->gl_errfunc(buf, err)) ||
1081 (pglob->gl_flags & GLOB_ERR))