From: Michael Tremer Date: Sun, 11 Jun 2023 13:11:11 +0000 (+0000) Subject: util: Drop nw_ftw X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=10edad249159db9d6ef1e2b6e7a8fac78f183fce;p=network.git util: Drop nw_ftw Signed-off-by: Michael Tremer --- diff --git a/src/networkd/util.c b/src/networkd/util.c index 0381ea86..e2f5cf16 100644 --- a/src/networkd/util.c +++ b/src/networkd/util.c @@ -18,44 +18,4 @@ # # #############################################################################*/ -#include -#include -#include -#include -#include - #include "util.h" - -int nw_ftw(const char* path, const char* filter, - int (*callback)(const char* path, const struct stat* s, void* data), void* data) { - /* - This is a nested function which allows us to pass some custom pointer to - the callback function as that isn't possible with nftw(). - */ - int __callback(const char* p, const struct stat* s, int type, struct FTW* ftw) { - int r; - - // Filter out anything we don't want - if (filter) { - r = fnmatch(filter, p, FNM_PATHNAME); - - switch (r) { - // Pattern didn't match - case FNM_NOMATCH: - return 0; - - // Pattern matched - case 0: - break; - - // Error - default: - return 1; - } - } - - return callback(p, s, data); - } - - return nftw(path, __callback, 0, 0); -} diff --git a/src/networkd/util.h b/src/networkd/util.h index 950afdac..11317ff1 100644 --- a/src/networkd/util.h +++ b/src/networkd/util.h @@ -21,9 +21,4 @@ #ifndef NETWORKD_UTIL_H #define NETWORKD_UTIL_H -#include - -int nw_ftw(const char* path, const char* filter, - int (*callback)(const char* path, const struct stat* s, void* data), void* data); - #endif /* NETWORKD_UTIL_H */