Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/gen/scandir.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
#define SELECT(x) CALL_BLOCK(select, x) | #define SELECT(x) CALL_BLOCK(select, x) | ||||
#ifndef __BLOCKS__ | #ifndef __BLOCKS__ | ||||
void qsort_b(void *, size_t, size_t, void *); | void qsort_b(void *, size_t, size_t, void *); | ||||
#endif | #endif | ||||
#else | #else | ||||
#define SELECT(x) select(x) | #define SELECT(x) select(x) | ||||
#endif | #endif | ||||
#ifndef I_AM_SCANDIR_B | #ifdef I_AM_SCANDIR_B | ||||
typedef DECLARE_BLOCK(int, select_block, const struct dirent *); | |||||
typedef DECLARE_BLOCK(int, dcomp_block, const struct dirent **, | |||||
const struct dirent **); | |||||
#else | |||||
static int alphasort_thunk(void *thunk, const void *p1, const void *p2); | static int alphasort_thunk(void *thunk, const void *p1, const void *p2); | ||||
#endif | #endif | ||||
int | int | ||||
#ifdef I_AM_SCANDIR_B | #ifdef I_AM_SCANDIR_B | ||||
scandir_b(const char *dirname, struct dirent ***namelist, | scandir_b(const char *dirname, struct dirent ***namelist, select_block select, | ||||
DECLARE_BLOCK(int, select, const struct dirent *), | dcomp_block dcomp) | ||||
DECLARE_BLOCK(int, dcomp, const struct dirent **, const struct dirent **)) | |||||
#else | #else | ||||
scandir(const char *dirname, struct dirent ***namelist, | scandir(const char *dirname, struct dirent ***namelist, | ||||
int (*select)(const struct dirent *), int (*dcomp)(const struct dirent **, | int (*select)(const struct dirent *), int (*dcomp)(const struct dirent **, | ||||
const struct dirent **)) | const struct dirent **)) | ||||
#endif | #endif | ||||
{ | { | ||||
struct dirent *d, *p, **names = NULL; | struct dirent *d, *p, **names = NULL; | ||||
size_t arraysz, numitems; | size_t arraysz, numitems; | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |