34 struct dirent ***namelist;
35 int (*select) (const struct dirent *);
36 int (*cmp) (const
void *, const
void *);
38 DIR *dp = opendir (dir);
39 struct dirent **v = NULL;
51 while ((d = readdir (dp)) != NULL)
52 if (select == NULL || (*select) (d))
67 new = (
struct dirent **) realloc (v, vsize *
sizeof (*v));
73 dsize = &d->d_name[strlen(d->d_name)+1] - (
char *) d;
74 vnew = (
struct dirent *) malloc (dsize);
78 v[i++] = (
struct dirent *) memcpy (vnew, d, dsize);
97 qsort (v, i,
sizeof (*v), cmp);
int scandir(char *dir, struct dirent ***namelist, int(*)(const struct dirent *) select, int *cmp) const