]> git.ipfire.org Git - people/ms/network.git/commitdiff
util: Drop nw_ftw
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Jun 2023 13:11:11 +0000 (13:11 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Jun 2023 13:11:11 +0000 (13:11 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/util.c
src/networkd/util.h

index 0381ea866f62655d0b8cd0e926fe417a95da0e7c..e2f5cf1608b767b9c16d2b4e9916955f1000b014 100644 (file)
 #                                                                             #
 #############################################################################*/
 
-#include <errno.h>
-#include <fnmatch.h>
-#include <ftw.h>
-#include <stddef.h>
-#include <stdio.h>
-
 #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);
-}
index 950afdacc8d060bc14b62d8d95592277915c3ca6..11317ff1655da3be24d786b8a83655d483cf805f 100644 (file)
@@ -21,9 +21,4 @@
 #ifndef NETWORKD_UTIL_H
 #define NETWORKD_UTIL_H
 
-#include <sys/stat.h>
-
-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 */