random/mysql selector: make it find m4a files
[paraslash.git] / db.c
diff --git a/db.c b/db.c
index 26f82d4..cb6f692 100644 (file)
--- a/db.c
+++ b/db.c
  */
 static int match_audio_file_name(char *name)
 {
-       int i, len = strlen(name);
-       const char *pattern[] = {SUPPORTED_AUDIO_FORMATS_ARRAY};
+       int i,j, len = strlen(name);
 
-       for (i = 0; pattern[i]; i++) {
-               const char *p = pattern[i];
-               int plen = strlen(p);
-               if (len < plen + 1)
-                       continue;
-               if (name[len - plen - 1] != '.')
-                       continue;
-               if (strcasecmp(name + len - plen, p))
-                       continue;
-               return 1;
+       FOR_EACH_AUDIO_FORMAT(i) {
+               for (j = 0; afl[i].suffixes[j]; j++) {
+                       const char *p = afl[i].suffixes[j];
+                       int plen = strlen(p);
+                       if (len < plen + 1)
+                               continue;
+                       if (name[len - plen - 1] != '.')
+                               continue;
+                       if (strcasecmp(name + len - plen, p))
+                               continue;
+                       return 1;
+               }
        }
        return 0;
 }