diff options
author | Leah Neukirchen <leah@vuxu.org> | 2020-03-08 17:16:50 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2020-03-08 17:16:50 +0100 |
commit | 6dd0799aab88c1e923141b249f90fd728324e1f3 (patch) | |
tree | 339631aa83e6934da303aaf29883e2dea1cd9fd6 | |
parent | 582256618a102cb3b6597ed63124c48ae16f8efb (diff) | |
download | mblaze-6dd0799aab88c1e923141b249f90fd728324e1f3.tar.gz mblaze-6dd0799aab88c1e923141b249f90fd728324e1f3.tar.xz mblaze-6dd0799aab88c1e923141b249f90fd728324e1f3.zip |
mdirs: extract DT_* handling
-rw-r--r-- | blaze822_priv.h | 9 | ||||
-rw-r--r-- | mdirs.c | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/blaze822_priv.h b/blaze822_priv.h index f1fe880..a84c963 100644 --- a/blaze822_priv.h +++ b/blaze822_priv.h @@ -16,4 +16,13 @@ struct message { #define lc(c) ((c) | 0x20) #define uc(c) ((c) & 0xdf) +// dirent type that can be a mail/dir (following symlinks) +#if defined(DT_REG) && defined(DT_LNK) && defined(DT_UNKNOWN) +#define MAIL_DT(t) (t == DT_REG || t == DT_LNK || t == DT_UNKNOWN) +#define DIR_DT(t) (t == DT_DIR || t == DT_UNKNOWN) +#else +#define MAIL_DT(t) (1) +#define DIR_DT(t) (1) +#endif + void *mymemmem(const void *h0, size_t k, const void *n0, size_t l); diff --git a/mdirs.c b/mdirs.c index 68b7e3f..46b2426 100644 --- a/mdirs.c +++ b/mdirs.c @@ -8,6 +8,7 @@ #include <unistd.h> #include "blaze822.h" +#include "blaze822_priv.h" static char sep = '\n'; int aflag; @@ -47,10 +48,9 @@ mdirs(char *fpath) } while ((d = readdir(dir))) { -#if defined(DT_DIR) && defined(DT_UNKNOWN) - if (d->d_type != DT_DIR && d->d_type != DT_UNKNOWN) + if (!DIR_DT(d->d_type)) continue; -#endif + if (d->d_name[0] == '.' && d->d_name[1] == 0) continue; |