struct audio_format_handler: use proper pointer type for the init function
[paraslash.git] / db.c
diff --git a/db.c b/db.c
index d97a6e0e917ffd8b3662ba96d13bbcd37aadefd3..cb6f692a74cd136a712f961294b3b9fbc735729c 100644 (file)
--- a/db.c
+++ b/db.c
@@ -17,7 +17,7 @@
  */
 
 
-/** \file db.c functions common to all database tools. */
+/** \file db.c functions common to all audio file selectors */
 
 #include "server.cmdline.h"
 #include "server.h"
  */
 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;
 }
@@ -123,6 +124,6 @@ out:
                ret = -E_CHDIR;
        close(cwd_fd);
        if (ret < 0)
-               PARA_ERROR_LOG("ret = %x\n", -ret);
+               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
        return ret;
 }