865
d_name_len = strlen(dirst->d_name);
867
865
/* Ignore dotfiles, backup files and other junk */
869
867
bool bad_name = false;
871
const char * const bad_prefixes[] = { ".", "#", NULL };
873
const char * const bad_suffixes[] = { "~", "#", ".dpkg-new",
876
".dpkg-divert", NULL };
878
#pragma GCC diagnostic push
879
#pragma GCC diagnostic ignored "-Wcast-qual"
881
for(const char **pre = (const char **)bad_prefixes;
882
*pre != NULL; pre++){
884
#pragma GCC diagnostic pop
886
size_t pre_len = strlen(*pre);
887
if((d_name_len >= pre_len)
888
and strncmp((dirst->d_name), *pre, pre_len) == 0){
890
fprintf(stderr, "Ignoring plugin dir entry \"%s\""
891
" with bad prefix %s\n", dirst->d_name, *pre);
901
#pragma GCC diagnostic push
902
#pragma GCC diagnostic ignored "-Wcast-qual"
904
for(const char **suf = (const char **)bad_suffixes;
905
*suf != NULL; suf++){
907
#pragma GCC diagnostic pop
909
size_t suf_len = strlen(*suf);
910
if((d_name_len >= suf_len)
911
and (strcmp((dirst->d_name) + d_name_len-suf_len, *suf)
914
fprintf(stderr, "Ignoring plugin dir entry \"%s\""
915
" with bad suffix %s\n", dirst->d_name, *suf);
868
const char * const patterns[] = { ".*", "#*#", "*~",
869
"*.dpkg-new", "*.dpkg-old",
870
"*.dpkg-bak", "*.dpkg-divert",
873
#pragma GCC diagnostic push
874
#pragma GCC diagnostic ignored "-Wcast-qual"
876
for(const char **pat = (const char **)patterns;
877
*pat != NULL; pat++){
879
#pragma GCC diagnostic pop
881
if(fnmatch(*pat, dirst->d_name,
882
FNM_FILE_NAME | FNM_PERIOD) != FNM_NOMATCH){
884
fprintf(stderr, "Ignoring plugin dir entry \"%s\""
885
" matching pattern %s\n", dirst->d_name, *pat);