Lines Matching refs:pglob
168 glob_t *pglob) in glob() argument
177 pglob->gl_pathc = 0; in glob()
178 pglob->gl_pathv = NULL; in glob()
179 pglob->gl_statv = NULL; in glob()
181 pglob->gl_offs = 0; in glob()
183 pglob->gl_flags = flags & ~GLOB_MAGCHAR; in glob()
184 pglob->gl_errfunc = errfunc; in glob()
185 pglob->gl_matchc = 0; in glob()
187 if (pglob->gl_offs < 0 || pglob->gl_pathc < 0 || in glob()
188 pglob->gl_offs >= INT_MAX || pglob->gl_pathc >= INT_MAX || in glob()
189 pglob->gl_pathc >= INT_MAX - pglob->gl_offs - 1) in glob()
212 return globexp1(patbuf, pglob, &limit); in glob()
214 return glob0(patbuf, pglob, &limit); in glob()
223 globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) in globexp1() argument
229 return glob0(pattern, pglob, limitp); in globexp1()
232 return globexp2(ptr, pattern, pglob, limitp); in globexp1()
234 return glob0(pattern, pglob, limitp); in globexp1()
244 globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, in globexp2() argument
281 return glob0(patbuf, pglob, limitp); in globexp2()
327 rv = globexp1(patbuf, pglob, limitp); in globexp2()
349 globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob) argument
356 if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
458 glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) argument
464 qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
465 oldpathc = pglob->gl_pathc;
496 !(pglob->gl_flags & GLOB_NOCHECK))
509 pglob->gl_flags |= GLOB_MAGCHAR;
513 pglob->gl_flags |= GLOB_MAGCHAR;
517 pglob->gl_flags |= GLOB_MAGCHAR;
534 if ((err = glob1(patbuf, patbuf+MAXPATHLEN-1, pglob, limitp)) != 0)
543 if (pglob->gl_pathc == oldpathc) {
544 if ((pglob->gl_flags & GLOB_NOCHECK) ||
545 ((pglob->gl_flags & GLOB_NOMAGIC) &&
546 !(pglob->gl_flags & GLOB_MAGCHAR)))
547 return(globextend(pattern, pglob, limitp, NULL));
551 if (!(pglob->gl_flags & GLOB_NOSORT))
552 qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
553 pglob->gl_pathc - oldpathc, sizeof(char *), compare);
564 glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) argument
573 pattern, pattern_last, pglob, limitp));
583 Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) argument
596 if (g_lstat(pathbuf, &sb, pglob))
599 if ((pglob->gl_flags & GLOB_LIMIT) &&
607 if (((pglob->gl_flags & GLOB_MARK) &&
610 (g_stat(pathbuf, &sb, pglob) == 0) &&
617 ++pglob->gl_matchc;
618 return(globextend(pathbuf, pglob, limitp, &sb));
644 pglob, limitp));
651 Char *pattern, Char *restpattern, Char *restpattern_last, glob_t *pglob, argument
672 if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
674 if (pglob->gl_errfunc) {
677 if (pglob->gl_errfunc(buf, errno) ||
678 pglob->gl_flags & GLOB_ERR)
687 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
688 readdirfunc = pglob->gl_readdir;
695 if ((pglob->gl_flags & GLOB_LIMIT) &&
721 restpattern, restpattern_last, pglob, limitp);
726 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
727 (*pglob->gl_closedir)(dirp);
749 globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp, argument
759 newn = 2 + pglob->gl_pathc + pglob->gl_offs;
760 if (pglob->gl_offs >= INT_MAX ||
761 pglob->gl_pathc >= INT_MAX ||
766 for (i = pglob->gl_offs; i < (ssize_t)(newn - 2); i++) {
767 if (pglob->gl_pathv && pglob->gl_pathv[i])
768 free(pglob->gl_pathv[i]);
769 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0 &&
770 pglob->gl_pathv && pglob->gl_pathv[i])
771 free(pglob->gl_statv[i]);
773 if (pglob->gl_pathv) {
774 free(pglob->gl_pathv);
775 pglob->gl_pathv = NULL;
777 if (pglob->gl_statv) {
778 free(pglob->gl_statv);
779 pglob->gl_statv = NULL;
784 pathv = realloc(pglob->gl_pathv, newn * sizeof(*pathv));
787 if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
789 pathv += pglob->gl_offs;
790 for (i = pglob->gl_offs; --i >= 0; )
793 pglob->gl_pathv = pathv;
795 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0) {
796 statv = realloc(pglob->gl_statv, newn * sizeof(*statv));
799 if (pglob->gl_statv == NULL && pglob->gl_offs > 0) {
801 statv += pglob->gl_offs;
802 for (i = pglob->gl_offs; --i >= 0; )
805 pglob->gl_statv = statv;
807 statv[pglob->gl_offs + pglob->gl_pathc] = NULL;
810 if ((pglob->gl_flags & GLOB_LIMIT) &&
815 if ((statv[pglob->gl_offs + pglob->gl_pathc] =
818 memcpy(statv[pglob->gl_offs + pglob->gl_pathc], sb,
821 statv[pglob->gl_offs + pglob->gl_pathc + 1] = NULL;
833 pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
835 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
837 if ((pglob->gl_flags & GLOB_LIMIT) &&
908 globfree(glob_t *pglob) argument
913 if (pglob->gl_pathv != NULL) {
914 pp = pglob->gl_pathv + pglob->gl_offs;
915 for (i = pglob->gl_pathc; i--; ++pp)
918 free(pglob->gl_pathv);
919 pglob->gl_pathv = NULL;
921 if (pglob->gl_statv != NULL) {
922 for (i = 0; i < pglob->gl_pathc; i++) {
923 if (pglob->gl_statv[i] != NULL)
924 free(pglob->gl_statv[i]);
926 free(pglob->gl_statv);
927 pglob->gl_statv = NULL;
932 g_opendir(Char *str, glob_t *pglob) argument
943 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
944 return((*pglob->gl_opendir)(buf));
950 g_lstat(Char *fn, struct stat *sb, glob_t *pglob) argument
956 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
957 return((*pglob->gl_lstat)(buf, sb));
962 g_stat(Char *fn, struct stat *sb, glob_t *pglob) argument
968 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
969 return((*pglob->gl_stat)(buf, sb));