]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mood.c: Add no_attributes_set mood method.
authorAndre Noll <maan@systemlinux.org>
Sat, 29 Sep 2007 11:39:34 +0000 (13:39 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 29 Sep 2007 11:39:34 +0000 (13:39 +0200)
Also fix a bug in mm_played_rarely_parser(): If no arg was
specified in the mood definition, a NULL pointer is passed to that
function, so it must not blindly dereference that pointer.

mood.c

diff --git a/mood.c b/mood.c
index e685fd91c982fd82cd9afa69c3a06932328907a5..b7ee99eb73799b03fdd0fff63b7ff77e940a1a82 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -164,6 +164,25 @@ static uint64_t int_sqrt(uint64_t x)
        return res;
 }
 
        return res;
 }
 
+static int mm_no_attributes_set_parser(const char *arg, __a_unused void **ignored)
+{
+       if (arg && *arg)
+               PARA_WARNING_LOG("ignored junk at eol: %s\n", arg);
+       return 1;
+}
+
+static int mm_no_attributes_set_score_function(__a_unused const char *path,
+               const struct afs_info *afsi,
+               __a_unused const struct audio_format_info *afhi,
+               __a_unused const void *data)
+{
+       if (!strcmp(path, "/home/mp3/checked/dvd_08/cd_52/Sade__Paradise.mp3"))
+               PARA_NOTICE_LOG("%s: %llu\n", path, afsi->attributes);
+       if (!afsi->attributes)
+               return 100;
+       return -100;
+}
+
 static int mm_played_rarely_score_function(__a_unused const char *path,
                const struct afs_info *afsi,
                __a_unused const struct audio_format_info *afhi,
 static int mm_played_rarely_score_function(__a_unused const char *path,
                const struct afs_info *afsi,
                __a_unused const struct audio_format_info *afhi,
@@ -182,7 +201,7 @@ static int mm_played_rarely_score_function(__a_unused const char *path,
 
 static int mm_played_rarely_parser(const char *arg, __a_unused void **ignored)
 {
 
 static int mm_played_rarely_parser(const char *arg, __a_unused void **ignored)
 {
-       if (*arg)
+       if (arg && *arg)
                PARA_WARNING_LOG("ignored junk at eol: %s\n", arg);
        return 1;
 }
                PARA_WARNING_LOG("ignored junk at eol: %s\n", arg);
        return 1;
 }
@@ -292,6 +311,11 @@ static int compute_mood_score(const struct osl_row *aft_row, struct mood *m,
 }
 
 static const struct mood_method mood_methods[] = {
 }
 
 static const struct mood_method mood_methods[] = {
+{
+       .parser = mm_no_attributes_set_parser,
+       .score_function = mm_no_attributes_set_score_function,
+       .name = "no_attributes_set"
+},
 {
        .parser = mm_played_rarely_parser,
        .score_function = mm_played_rarely_score_function,
 {
        .parser = mm_played_rarely_parser,
        .score_function = mm_played_rarely_score_function,