Lines Matching defs:pglob

179     glob_t *pglob)
191 pglob->gl_pathc = 0;
192 pglob->gl_pathv = NULL;
193 pglob->gl_statv = NULL;
195 pglob->gl_offs = 0;
197 pglob->gl_flags = flags & ~GLOB_MAGCHAR;
198 pglob->gl_errfunc = errfunc;
199 pglob->gl_matchc = 0;
201 if (pglob->gl_offs < 0 || pglob->gl_pathc < 0 ||
202 pglob->gl_offs >= INT_MAX || pglob->gl_pathc >= INT_MAX ||
203 pglob->gl_pathc >= INT_MAX - pglob->gl_offs - 1)
226 return globexp1(patbuf, pglob, &limit);
228 return glob0(patbuf, pglob, &limit);
237 globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
243 return glob0(pattern, pglob, limitp);
246 return globexp2(ptr, pattern, pglob, limitp);
248 return glob0(pattern, pglob, limitp);
258 globexp2(const Char *ptr, const Char *pattern, glob_t *pglob,
295 return glob0(patbuf, pglob, limitp);
341 rv = globexp1(patbuf, pglob, limitp);
363 globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
370 if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
472 glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
478 qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
479 oldpathc = pglob->gl_pathc;
510 !(pglob->gl_flags & GLOB_NOCHECK))
523 pglob->gl_flags |= GLOB_MAGCHAR;
527 pglob->gl_flags |= GLOB_MAGCHAR;
531 pglob->gl_flags |= GLOB_MAGCHAR;
548 if ((err = glob1(patbuf, patbuf+MAXPATHLEN-1, pglob, limitp)) != 0)
557 if (pglob->gl_pathc == oldpathc) {
558 if ((pglob->gl_flags & GLOB_NOCHECK) ||
559 ((pglob->gl_flags & GLOB_NOMAGIC) &&
560 !(pglob->gl_flags & GLOB_MAGCHAR)))
561 return(globextend(pattern, pglob, limitp, NULL));
565 if (!(pglob->gl_flags & GLOB_NOSORT)) {
566 if ((pglob->gl_flags & GLOB_KEEPSTAT)) {
570 int n = pglob->gl_pathc - oldpathc;
571 int o = pglob->gl_offs + oldpathc;
576 path_stat[i].gps_path = pglob->gl_pathv[o + i];
577 path_stat[i].gps_stat = pglob->gl_statv[o + i];
581 pglob->gl_pathv[o + i] = path_stat[i].gps_path;
582 pglob->gl_statv[o + i] = path_stat[i].gps_stat;
586 qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
587 pglob->gl_pathc - oldpathc, sizeof(char *),
610 glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp)
619 pattern, pattern_last, pglob, limitp));
629 Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp)
642 if (g_lstat(pathbuf, &sb, pglob))
645 if ((pglob->gl_flags & GLOB_LIMIT) &&
653 if (((pglob->gl_flags & GLOB_MARK) &&
656 (g_stat(pathbuf, &sb, pglob) == 0) &&
663 ++pglob->gl_matchc;
664 return(globextend(pathbuf, pglob, limitp, &sb));
690 pglob, limitp));
697 Char *pattern, Char *restpattern, Char *restpattern_last, glob_t *pglob,
718 if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
720 if (pglob->gl_errfunc) {
723 if (pglob->gl_errfunc(buf, errno) ||
724 pglob->gl_flags & GLOB_ERR)
733 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
734 readdirfunc = pglob->gl_readdir;
741 if ((pglob->gl_flags & GLOB_LIMIT) &&
768 restpattern, restpattern_last, pglob, limitp);
773 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
774 (*pglob->gl_closedir)(dirp);
796 globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp,
806 newn = 2 + pglob->gl_pathc + pglob->gl_offs;
807 if (pglob->gl_offs >= INT_MAX ||
808 pglob->gl_pathc >= INT_MAX ||
813 for (i = pglob->gl_offs; i < (ssize_t)(newn - 2); i++) {
814 if (pglob->gl_pathv && pglob->gl_pathv[i])
815 free(pglob->gl_pathv[i]);
816 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0 &&
817 pglob->gl_pathv && pglob->gl_pathv[i])
818 free(pglob->gl_statv[i]);
820 if (pglob->gl_pathv) {
821 free(pglob->gl_pathv);
822 pglob->gl_pathv = NULL;
824 if (pglob->gl_statv) {
825 free(pglob->gl_statv);
826 pglob->gl_statv = NULL;
831 pathv = realloc(pglob->gl_pathv, newn * sizeof(*pathv));
834 if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
836 pathv += pglob->gl_offs;
837 for (i = pglob->gl_offs; --i >= 0; )
840 pglob->gl_pathv = pathv;
842 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0) {
843 statv = realloc(pglob->gl_statv, newn * sizeof(*statv));
846 if (pglob->gl_statv == NULL && pglob->gl_offs > 0) {
848 statv += pglob->gl_offs;
849 for (i = pglob->gl_offs; --i >= 0; )
852 pglob->gl_statv = statv;
854 statv[pglob->gl_offs + pglob->gl_pathc] = NULL;
857 if ((pglob->gl_flags & GLOB_LIMIT) &&
862 if ((statv[pglob->gl_offs + pglob->gl_pathc] =
865 memcpy(statv[pglob->gl_offs + pglob->gl_pathc], sb,
868 statv[pglob->gl_offs + pglob->gl_pathc + 1] = NULL;
880 pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
882 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
884 if ((pglob->gl_flags & GLOB_LIMIT) &&
960 globfree(glob_t *pglob)
965 if (pglob->gl_pathv != NULL) {
966 pp = pglob->gl_pathv + pglob->gl_offs;
967 for (i = pglob->gl_pathc; i--; ++pp)
970 free(pglob->gl_pathv);
971 pglob->gl_pathv = NULL;
973 if (pglob->gl_statv != NULL) {
974 for (i = 0; i < pglob->gl_pathc; i++) {
975 if (pglob->gl_statv[i] != NULL)
976 free(pglob->gl_statv[i]);
978 free(pglob->gl_statv);
979 pglob->gl_statv = NULL;
984 g_opendir(Char *str, glob_t *pglob)
995 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
996 return((*pglob->gl_opendir)(buf));
1002 g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
1008 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1009 return((*pglob->gl_lstat)(buf, sb));
1014 g_stat(Char *fn, struct stat *sb, glob_t *pglob)
1020 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1021 return((*pglob->gl_stat)(buf, sb));