Lines Matching defs:buf
35 static int do_glob(char *buf, size_t pos, int type, char *pat, int flags, int (*errfunc)(const char *path, int err), struct match **tail)
43 while (pos+1 < PATH_MAX && *pat=='/') buf[pos++] = *pat++;
81 buf[pos+j++] = pat[i];
91 buf[pos] = 0;
103 if ((flags & GLOB_MARK) && (!type||type==DT_LNK) && !stat(buf, &st)) {
107 if (!type && lstat(buf, &st)) {
108 if (errno!=ENOENT && (errfunc(buf, errno) || (flags & GLOB_ERR)))
112 if (append(tail, buf, pos, (flags & GLOB_MARK) && type==DT_DIR))
127 DIR *dir = opendir(pos ? buf : ".");
129 if (errfunc(buf, errno) || (flags & GLOB_ERR))
158 memcpy(buf+pos, de->d_name, l+1);
160 int r = do_glob(buf, pos+l, de->d_type, p2 ? p2 : "", flags, errfunc, tail);
169 if (readerr && (errfunc(buf, errno) || (flags & GLOB_ERR)))
194 static int expand_tilde(char **pat, char *buf, size_t *pos)
206 switch (*p ? getpwnam_r(p, &pw, buf, PATH_MAX, &res)
207 : getpwuid_r(getuid(), &pw, buf, PATH_MAX, &res)) {
218 buf[i++] = *home++;
221 if ((buf[i] = delim))
222 buf[++i] = 0;
233 char buf[PATH_MAX];
246 buf[0] = 0;
250 error = expand_tilde(&s, buf, &pos);
252 error = do_glob(buf, pos, 0, s, flags, errfunc, &tail);