#define _GNU_SOURCE #include "shared.h" #include "scanner.h" #include #include #include #include #include // dlinkedlist * scandirlist(const char * const dir, int (*selector)(const struct dirent *), int (*cmp)(const struct dirent **, const struct dirent **)) { // if(!dir || selector == NULL || cmp == NULL) ERRRET(EINVAL, NULL); // struct dirent **namelist = NULL; // dlinkedlist *list = NULL; // int numentries = -1; // if((numentries = scandir(dir, &namelist, selector, cmp)) < 0) // ERRRET(errno, NULL); // list = dlinkedlist_init(); // for(int i = 0; i < numentries; i++) // if(dlinkedlist_append(list, (void *)(namelist[i]), free) < 0) { // dlinkedlist_free(list); // for(int j = i; j < numentries; j++) // free(namelist[j]); // free(namelist); // ERRRET(errno, NULL); // } // free(namelist); // return list; // } // TODO: Rewrite this to use the threadpool. Each newly scanned file should be pushed onto the threadpool as an encryption task