Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/gen/scandir-compat11.c
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
* function freebsd11_scandir_b(). | * function freebsd11_scandir_b(). | ||||
*/ | */ | ||||
#define SELECT(x) select(x) | #define SELECT(x) select(x) | ||||
static int freebsd11_alphasort_thunk(void *thunk, const void *p1, | static int freebsd11_alphasort_thunk(void *thunk, const void *p1, | ||||
const void *p2); | const void *p2); | ||||
int | static int | ||||
freebsd11_scandir(const char *dirname, struct freebsd11_dirent ***namelist, | freebsd11_scandir(const char *dirname, struct freebsd11_dirent ***namelist, | ||||
int (*select)(const struct freebsd11_dirent *), | int (*select)(const struct freebsd11_dirent *), | ||||
int (*dcomp)(const struct freebsd11_dirent **, | int (*dcomp)(const struct freebsd11_dirent **, | ||||
const struct freebsd11_dirent **)) | const struct freebsd11_dirent **)) | ||||
{ | { | ||||
struct freebsd11_dirent *d, *p, **names = NULL; | struct freebsd11_dirent *d, *p, **names = NULL; | ||||
size_t arraysz, numitems; | size_t arraysz, numitems; | ||||
DIR *dirp; | DIR *dirp; | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | fail: | ||||
closedir(dirp); | closedir(dirp); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
/* | /* | ||||
* Alphabetic order comparison routine for those who want it. | * Alphabetic order comparison routine for those who want it. | ||||
* POSIX 2008 requires that alphasort() uses strcoll(). | * POSIX 2008 requires that alphasort() uses strcoll(). | ||||
*/ | */ | ||||
int | static int | ||||
freebsd11_alphasort(const struct freebsd11_dirent **d1, | freebsd11_alphasort(const struct freebsd11_dirent **d1, | ||||
const struct freebsd11_dirent **d2) | const struct freebsd11_dirent **d2) | ||||
{ | { | ||||
return (strcoll((*d1)->d_name, (*d2)->d_name)); | return (strcoll((*d1)->d_name, (*d2)->d_name)); | ||||
} | } | ||||
static int | static int | ||||
Show All 13 Lines |