X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=mm.c;h=92856ec3ef903eb905b0379c6eaff605bf6f8d06;hp=6f2c088e9e653d375e4ab76157f58582f0d04797;hb=becfb4be64a123630775b6517279ed20e4b498f8;hpb=d1e6b28f66e243516d01916f9125baee75dd98d6 diff --git a/mm.c b/mm.c index 6f2c088e..92856ec3 100644 --- a/mm.c +++ b/mm.c @@ -1,12 +1,11 @@ /* - * Copyright (C) 2007-2014 Andre Noll + * Copyright (C) 2007 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ /** \file mm.c Paraslash's mood methods. */ -#include #include #include #include @@ -18,6 +17,7 @@ #include "afs.h" #include "mm.h" +/** The comparators for numeric mood methods (year, bitrate, ...). */ #define MOOD_COMPARATORS \ MC(LESS, <) \ MC(LESS_OR_EQUAL, <=) \ @@ -28,10 +28,14 @@ MC(GREATER, >) \ MC(GREATER_OR_EQUAL, >=) \ +/** Prefix mood comparator name with "_MC", example: MC_LESS. */ #define MC(a, b) MC_ ## a, +/** Each mood comparator is identified by an integer of this type. */ enum mood_comparator_id {MOOD_COMPARATORS NUM_MOOD_COMPARATORS}; #undef MC +/** Stringfied mood comparator, example: "<". */ #define MC(a, b) # b, +/** Array of mood comparators represented as C strings ("<", "<=", ...). */ static const char *mood_comparators[] = {MOOD_COMPARATORS}; #undef MC @@ -187,6 +191,22 @@ static int mm_channels_score_function(__a_unused const char *path, return mm_compare_num_score_function(afhi->channels, private); } +static int mm_image_id_score_function(__a_unused const char *path, + const struct afs_info *afsi, + __a_unused const struct afh_info *afhi, + const void *private) +{ + return mm_compare_num_score_function(afsi->image_id, private); +} + +static int mm_lyrics_id_score_function(__a_unused const char *path, + const struct afs_info *afsi, + __a_unused const struct afh_info *afhi, + const void *private) +{ + return mm_compare_num_score_function(afsi->lyrics_id, private); +} + static int mm_num_played_score_function(__a_unused const char *path, const struct afs_info *afsi, __a_unused const struct afh_info *afhi, @@ -204,7 +224,7 @@ struct mm_year_data { static int mm_year_parser(int argc, char **argv, void **private) { - int ret = -E_MOOD_SYNTAX; + int ret; struct mm_year_data *mmyd = para_malloc(sizeof(*mmyd)); time_t current_time; struct tm *gmt; @@ -352,5 +372,7 @@ const struct mood_method mood_methods[] = { {DEFINE_COMPARE_NUM_MOOD_METHOD(frequency)}, {DEFINE_COMPARE_NUM_MOOD_METHOD(channels)}, {DEFINE_COMPARE_NUM_MOOD_METHOD(num_played)}, + {DEFINE_COMPARE_NUM_MOOD_METHOD(image_id)}, + {DEFINE_COMPARE_NUM_MOOD_METHOD(lyrics_id)}, {.parser = NULL} };